当前位置: 首页>>代码示例>>Java>>正文


Java ActivityInvoker类代码示例

本文整理汇总了Java中org.apache.taverna.activities.testutils.ActivityInvoker的典型用法代码示例。如果您正苦于以下问题:Java ActivityInvoker类的具体用法?Java ActivityInvoker怎么用?Java ActivityInvoker使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ActivityInvoker类属于org.apache.taverna.activities.testutils包,在下文中一共展示了ActivityInvoker类的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"));

}
 
开发者ID:apache,项目名称:incubator-taverna-plugin-gis,代码行数:21,代码来源:GisActivityTest.java

示例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"));
}
 
开发者ID:apache,项目名称:incubator-taverna-engine,代码行数:27,代码来源:DataflowActivityTest.java

示例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"));
}
 
开发者ID:apache,项目名称:incubator-taverna-common-activities,代码行数:30,代码来源:BeanshellActivityTest.java

示例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>"));
}
 
开发者ID:apache,项目名称:incubator-taverna-common-activities,代码行数:26,代码来源:WSDLActivityTest.java

示例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


注:本文中的org.apache.taverna.activities.testutils.ActivityInvoker类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。