本文整理汇总了Java中org.apache.taverna.activities.testutils.ActivityInvoker.invokeAsyncActivity方法的典型用法代码示例。如果您正苦于以下问题:Java ActivityInvoker.invokeAsyncActivity方法的具体用法?Java ActivityInvoker.invokeAsyncActivity怎么用?Java ActivityInvoker.invokeAsyncActivity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.taverna.activities.testutils.ActivityInvoker
的用法示例。
在下文中一共展示了ActivityInvoker.invokeAsyncActivity方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: executeAsynch
import org.apache.taverna.activities.testutils.ActivityInvoker; //导入方法依赖的package包/类
@Test
public void executeAsynch() throws Exception {
activity.configure(configuration);
Map<String, Object> inputs = new HashMap<String, Object>();
inputs.put("firstInput", "hello");
Map<String, Class<?>> expectedOutputTypes = new HashMap<String, Class<?>>();
expectedOutputTypes.put("simpleOutput", String.class);
expectedOutputTypes.put("moreOutputs", String.class);
Map<String, Object> outputs = ActivityInvoker.invokeAsyncActivity(
activity, inputs, expectedOutputTypes);
assertEquals("Unexpected outputs", 2, outputs.size());
assertEquals("simple", outputs.get("simpleOutput"));
assertEquals(Arrays.asList("Value 1", "Value 2"), outputs
.get("moreOutputs"));
}
示例2: testConfigureDataflowActivityConfigurationBean
import org.apache.taverna.activities.testutils.ActivityInvoker; //导入方法依赖的package包/类
@Test
public void testConfigureDataflowActivityConfigurationBean() throws Exception {
activity.setNestedDataflow(dataflow);
assertEquals(dataflow, activity.getNestedDataflow());
Edits edits = new EditsImpl();
dataflow = edits.createDataflow();
edits.getAddActivityInputPortEdit(activity, new ActivityInputPortImpl("input", 0)).doEdit();
edits.getAddActivityOutputPortEdit(activity, new ActivityOutputPortImpl("output", 0, 0))
.doEdit();
assertEquals(1, activity.getInputPorts().size());
assertEquals("input", activity.getInputPorts().iterator().next().getName());
assertEquals(1, activity.getOutputPorts().size());
assertEquals("output", activity.getOutputPorts().iterator().next().getName());
Map<String, Object> inputs = new HashMap<String, Object>();
inputs.put("input", "aString");
Map<String, Class<?>> expectedOutputs = new HashMap<String, Class<?>>();
expectedOutputs.put("output", String.class);
Map<String, Object> outputs = ActivityInvoker.invokeAsyncActivity(activity, inputs,
expectedOutputs);
assertTrue("there should be an output named output", outputs.containsKey("output"));
assertEquals("output should have the value aString", "aString", outputs.get("output"));
}
示例3: simpleScript
import org.apache.taverna.activities.testutils.ActivityInvoker; //导入方法依赖的package包/类
/**
* Tests a simple script (String output = input + "_returned") to ensure the script is invoked correctly.
* @throws Exception
*/
@Test
public void simpleScript() throws Exception {
BeanshellActivity activity = new BeanshellActivity(null);
Edits edits = new EditsImpl();
edits.getAddActivityInputPortEdit(activity, new ActivityInputPortImpl("input", 0, false, null, String.class)).doEdit();
edits.getAddActivityOutputPortEdit(activity, new ActivityOutputPortImpl("output", 0, 0)).doEdit();
configuration.put("script", "String output = input + \"_returned\";");
activity.configure(configuration);
assertEquals("There should be 1 input port",1,activity.getInputPorts().size());
assertEquals("There should be 1 output port",1,activity.getOutputPorts().size());
assertEquals("The input should be called input", "input",((AbstractPort)activity.getInputPorts().toArray()[0]).getName());
assertEquals("The output should be called output", "output",((AbstractPort)activity.getOutputPorts().toArray()[0]).getName());
Map<String,Object> inputs = new HashMap<String, Object>();
inputs.put("input", "aString");
Map<String, Class<?>> expectedOutputs = new HashMap<String, Class<?>>();
expectedOutputs.put("output", String.class);
Map<String,Object> outputs = ActivityInvoker.invokeAsyncActivity(activity, inputs, expectedOutputs);
assertTrue("there should be an output named output",outputs.containsKey("output"));
assertEquals("output should have the value aString_returned","aString_returned",outputs.get("output"));
}
示例4: oneLinerNoSemicolon
import org.apache.taverna.activities.testutils.ActivityInvoker; //导入方法依赖的package包/类
@Test
public void oneLinerNoSemicolon() throws Exception {
BeanshellActivity activity = new BeanshellActivity(null);
configuration.put("script", "a = 5+3");
// Notice lack of ;
activity.configure(configuration);
Map<String,Object> inputs = new HashMap<String, Object>();
Map<String, Class<?>> expectedOutputs = new HashMap<String, Class<?>>();
ActivityInvoker.invokeAsyncActivity(activity, inputs, expectedOutputs);
BeanshellActivityHealthChecker healthChecker = new BeanshellActivityHealthChecker();
assertTrue(healthChecker.canVisit(activity));
ArrayList<Object> ancestors = new ArrayList<Object>();
ancestors.add(edits.createProcessor("beanie"));
VisitReport visit = healthChecker.visit(activity, ancestors);
assertEquals(Status.OK, visit.getStatus());
}
开发者ID:apache,项目名称:incubator-taverna-common-activities,代码行数:20,代码来源:BeanshellActivityHealthCheckerTest.java
示例5: oneLiner
import org.apache.taverna.activities.testutils.ActivityInvoker; //导入方法依赖的package包/类
@Test
public void oneLiner() throws Exception {
BeanshellActivity activity = new BeanshellActivity(null);
configuration.put("script", "System.out.println(\"Hello\");");
activity.configure(configuration);
Map<String,Object> inputs = new HashMap<String, Object>();
Map<String, Class<?>> expectedOutputs = new HashMap<String, Class<?>>();
ActivityInvoker.invokeAsyncActivity(activity, inputs, expectedOutputs);
BeanshellActivityHealthChecker healthChecker = new BeanshellActivityHealthChecker();
assertTrue(healthChecker.canVisit(activity));
ArrayList<Object> ancestors = new ArrayList<Object>();
ancestors.add(edits.createProcessor("beanie"));
VisitReport visit = healthChecker.visit(activity, ancestors);
assertEquals(Status.OK, visit.getStatus());
}
开发者ID:apache,项目名称:incubator-taverna-common-activities,代码行数:19,代码来源:BeanshellActivityHealthCheckerTest.java
示例6: threeLines
import org.apache.taverna.activities.testutils.ActivityInvoker; //导入方法依赖的package包/类
@Test
public void threeLines() throws Exception {
BeanshellActivity activity = new BeanshellActivity(null);
configuration.put("script", "if (2>1) {\n" +
" new Integer(4);\n" +
"}");
activity.configure(configuration);
Map<String,Object> inputs = new HashMap<String, Object>();
Map<String, Class<?>> expectedOutputs = new HashMap<String, Class<?>>();
ActivityInvoker.invokeAsyncActivity(activity, inputs, expectedOutputs);
BeanshellActivityHealthChecker healthChecker = new BeanshellActivityHealthChecker();
assertTrue(healthChecker.canVisit(activity));
ArrayList<Object> ancestors = new ArrayList<Object>();
ancestors.add(edits.createProcessor("beanie"));
VisitReport visit = healthChecker.visit(activity, ancestors);
assertEquals(Status.OK, visit.getStatus());
}
开发者ID:apache,项目名称:incubator-taverna-common-activities,代码行数:24,代码来源:BeanshellActivityHealthCheckerTest.java
示例7: invalidScript
import org.apache.taverna.activities.testutils.ActivityInvoker; //导入方法依赖的package包/类
@Test
public void invalidScript() throws Exception {
BeanshellActivity activity = new BeanshellActivity(null);
configuration.put("script", "invalid script 5 +");
activity.configure(configuration);
Map<String,Object> inputs = new HashMap<String, Object>();
Map<String, Class<?>> expectedOutputs = new HashMap<String, Class<?>>();
try {
ActivityInvoker.invokeAsyncActivity(activity, inputs, expectedOutputs);
fail("Script should not be valid");
} catch (RuntimeException ex) {
// expected to fail
}
BeanshellActivityHealthChecker healthChecker = new BeanshellActivityHealthChecker();
assertTrue(healthChecker.canVisit(activity));
ArrayList<Object> ancestors = new ArrayList<Object>();
ancestors.add(edits.createProcessor("beanie"));
VisitReport visit = healthChecker.visit(activity, ancestors);
assertEquals(Status.SEVERE, visit.getStatus());
}
开发者ID:apache,项目名称:incubator-taverna-common-activities,代码行数:25,代码来源:BeanshellActivityHealthCheckerTest.java
示例8: strangeWhitespace
import org.apache.taverna.activities.testutils.ActivityInvoker; //导入方法依赖的package包/类
@Test
public void strangeWhitespace() throws Exception {
BeanshellActivity activity = new BeanshellActivity(null);
configuration.put("script", "b = \"fish\";\n" +
"a = 2+3\n" +
"\n" +
"\n" +
" +5 ");
// Notice lots of whitespace, but still valid
activity.configure(configuration);
Map<String,Object> inputs = new HashMap<String, Object>();
Map<String, Class<?>> expectedOutputs = new HashMap<String, Class<?>>();
ActivityInvoker.invokeAsyncActivity(activity, inputs, expectedOutputs);
BeanshellActivityHealthChecker healthChecker = new BeanshellActivityHealthChecker();
assertTrue(healthChecker.canVisit(activity));
ArrayList<Object> ancestors = new ArrayList<Object>();
ancestors.add(edits.createProcessor("beanie"));
VisitReport visit = healthChecker.visit(activity, ancestors);
System.out.println(visit);
assertEquals(Status.OK, visit.getStatus());
}
开发者ID:apache,项目名称:incubator-taverna-common-activities,代码行数:25,代码来源:BeanshellActivityHealthCheckerTest.java
示例9: testExecuteAsynchMapOfStringEntityIdentifierAsynchronousActivityCallback
import org.apache.taverna.activities.testutils.ActivityInvoker; //导入方法依赖的package包/类
@Test
@Ignore("Service is broken")
public void testExecuteAsynchMapOfStringEntityIdentifierAsynchronousActivityCallback()
throws Exception {
Map<String, Object> inputMap = new HashMap<String, Object>();
inputMap.put("parameters", "<parameters><db>pubmed</db></parameters>");
Map<String, Class<?>> expectedOutputs = new HashMap<String, Class<?>>();
expectedOutputs.put("parameters", String.class);
Map<String, Object> outputMap = ActivityInvoker.invokeAsyncActivity(
activity, inputMap, expectedOutputs);
assertNotNull("there should be an output named parameters", outputMap
.get("parameters"));
String xml;
if (outputMap.get("parameters") instanceof String) {
xml = (String) outputMap.get("parameters");
} else {
byte[] bytes = (byte[]) outputMap.get("parameters");
xml = new String(bytes);
}
assertTrue("the xml is not what was expected", xml
.contains("<DbName>pubmed</DbName>"));
}
示例10: testExecuteAsynchMapOfStringT2ReferenceAsynchronousActivityCallback
import org.apache.taverna.activities.testutils.ActivityInvoker; //导入方法依赖的package包/类
@Test
public void testExecuteAsynchMapOfStringT2ReferenceAsynchronousActivityCallback() throws Exception {
configuration.put("columnRange", configuration.objectNode().put("start", 0).put("end", 3));
activity.configure(configuration);
for (ActivityInputPort activityInputPort : activityFactory.getInputPorts(configuration)) {
edits.getAddActivityInputPortEdit(activity, activityInputPort).doEdit();
}
for (ActivityOutputPort activityOutputPort : activityFactory.getOutputPorts(configuration)) {
edits.getAddActivityOutputPortEdit(activity, activityOutputPort).doEdit();
}
Map<String, Class<?>> outputs = new HashMap<String, Class<?>>();
outputs.put("A", String.class);
outputs.put("B", String.class);
outputs.put("C", String.class);
outputs.put("D", String.class);
Map<String, Object> results = ActivityInvoker.invokeAsyncActivity(activity, Collections.singletonMap("fileurl",
(Object) "src/test/resources/test-spreadsheet.xls"), outputs);
assertEquals(4, results.size());
assertTrue(results.get("A") instanceof List<?>);
assertEquals(15, ((List<?>) results.get("A")).size());
results = ActivityInvoker.invokeAsyncActivity(activity, Collections.singletonMap("fileurl",
(Object) "src/test/resources/test-spreadsheet.ods"), outputs);
assertEquals(4, results.size());
assertTrue(results.get("A") instanceof List<?>);
assertEquals(15, ((List<?>) results.get("A")).size());
results = ActivityInvoker.invokeAsyncActivity(activity, Collections.singletonMap("fileurl",
(Object) "src/test/resources/test-spreadsheet.csv"), outputs);
assertEquals(4, results.size());
assertTrue(results.get("A") instanceof List<?>);
assertEquals(15, ((List<?>) results.get("A")).size());
// CSV output
configuration.put("outputFormat", SpreadsheetOutputFormat.SINGLE_PORT.name());
activity.configure(configuration);
outputs = new HashMap<String, Class<?>>();
outputs.put("output", String.class);
results = ActivityInvoker.invokeAsyncActivity(activity, Collections.singletonMap("fileurl",
(Object) "src/test/resources/test-spreadsheet.xls"), outputs);
assertEquals(1, results.size());
assertTrue(results.get("output") instanceof String);
assertEquals(15, ((String) results.get("output")).split(System.getProperty("line.separator")).length);
// TSV output
configuration.put("csvDelimiter", "\t");
activity.configure(configuration);
results = ActivityInvoker.invokeAsyncActivity(activity, Collections.singletonMap("fileurl",
(Object) "src/test/resources/test-spreadsheet.csv"), outputs);
assertEquals(1, results.size());
assertTrue(results.get("output") instanceof String);
assertEquals(15, ((String) results.get("output")).split(System.getProperty("line.separator")).length);
}
开发者ID:apache,项目名称:incubator-taverna-common-activities,代码行数:52,代码来源:SpreadsheetImportActivityTest.java