use of com.ibm.streamsx.topology.spl.SPLStream in project streamsx.topology by IBMStreams.
the class SPLJavaPrimitiveTest method testIsolatedVmArgs2.
@Test
public void testIsolatedVmArgs2() throws Exception {
// isolation only works in DISTRIBUTED
assumeTrue(getTesterType() == StreamsContext.Type.DISTRIBUTED_TESTER);
assumeTrue(SC_OK);
Topology t = new Topology("testIsolatedVmArgs1");
SPL.addToolkit(t, new File(getTestRoot(), "spl/testtk"));
// getConfig().put(ContextProperties.KEEP_ARTIFACTS, true);
SPLStream spl = SPLStreams.stringToSPLStream(t.strings("hello"));
// isolate the JavaPrimitive to avoid the restriction/failure
// demonstrated in testIncompatVmArgs
spl = spl.isolate();
Map<String, Object> params = new HashMap<>();
params.put("vmArg", new String[] { "-DXYZZY", "-DFOOBAR" });
SPLStream splResult = JavaPrimitive.invokeJavaPrimitive(testjava.NoOpJavaPrimitive.class, spl, SPLSchemas.STRING, params);
splResult = splResult.isolate();
TStream<String> result = splResult.toStringStream();
completeAndValidate(result, 10, "hello");
}
use of com.ibm.streamsx.topology.spl.SPLStream in project streamsx.topology by IBMStreams.
the class SPLJavaPrimitiveTest method testSimpleInvoke.
@Test
public void testSimpleInvoke() throws Exception {
Topology t = new Topology("testSimpleInvoke");
SPL.addToolkit(t, new File(getTestRoot(), "spl/testtk"));
SPLStream spl = SPLStreams.stringToSPLStream(t.strings("hello"));
SPLStream splResult = JavaPrimitive.invokeJavaPrimitive(testjava.NoOpJavaPrimitive.class, spl, SPLSchemas.STRING, null);
TStream<String> result = splResult.toStringStream();
completeAndValidate(result, 10, "hello");
}
use of com.ibm.streamsx.topology.spl.SPLStream in project streamsx.topology by IBMStreams.
the class SPLOperatorsTest method testSPLOperatorMultipleOuptuts.
/**
* Test we can invoke an SPL operator.
*/
@Test
public void testSPLOperatorMultipleOuptuts() throws Exception {
Topology topology = new Topology();
SPLStream tuples = SPLStreamsTest.testTupleStream(topology);
// Filter on the vi attribute, passing the value 321.
Map<String, Object> params = new HashMap<>();
params.put("attr", tuples.getSchema().getAttribute("vi"));
params.put("value", 321);
SPL.addToolkit(tuples, new File(getTestRoot(), "spl/testtk"));
List<SPLStream> outputs = SPL.invokeOperator(topology, "testSPLOperatorMultipleOuptuts", "testspl::Int32FilterPF", Collections.singletonList(tuples), Collections.nCopies(2, tuples.getSchema()), params);
SPLStream int32Filtered = outputs.get(0);
SPLStream int32Dropped = outputs.get(1);
Tester tester = topology.getTester();
Condition<Long> expectedCount = tester.tupleCount(int32Dropped, 2);
Condition<List<Tuple>> expectedTuples = tester.tupleContents(int32Filtered, SPLStreamsTest.TEST_TUPLES[0], SPLStreamsTest.TEST_TUPLES[2]);
Condition<List<Tuple>> droppedTuples = tester.tupleContents(int32Dropped, SPLStreamsTest.TEST_TUPLES[1], SPLStreamsTest.TEST_TUPLES[3]);
complete(tester, expectedCount, 10, TimeUnit.SECONDS);
assertTrue(expectedCount.toString(), expectedCount.valid());
assertTrue(expectedTuples.toString(), expectedTuples.valid());
assertTrue(droppedTuples.toString(), droppedTuples.valid());
}
use of com.ibm.streamsx.topology.spl.SPLStream in project streamsx.topology by IBMStreams.
the class PythonFunctionalOperatorsKwargsTest method testFilterOptionalOutput.
@Test
public void testFilterOptionalOutput() throws Exception {
Topology topology = new Topology("testFilterOptionalOutput");
SPLStream tuples = sampleFilterStream(topology);
PythonFunctionalOperatorsTest.addTestToolkit(tuples);
List<SPLStream> filtered = SPL.invokeOperator(topology, "CFOpt", "com.ibm.streamsx.topology.pysamples.kwargs::ContainsFilter", Collections.singletonList(tuples), Collections.nCopies(2, tuples.getSchema()), Collections.singletonMap("term", "23"));
SPLStream pass = filtered.get(0);
SPLStream failed = filtered.get(1);
Tester tester = topology.getTester();
Condition<Long> expectedPassCount = tester.tupleCount(pass, 2);
Condition<Long> expectedFailedCount = tester.tupleCount(failed, 2);
Condition<List<Tuple>> passResult = tester.tupleContents(pass);
Condition<List<Tuple>> failedResult = tester.tupleContents(failed);
getConfig().put(ContextProperties.KEEP_ARTIFACTS, true);
complete(tester, expectedPassCount.and(expectedFailedCount), 10, TimeUnit.SECONDS);
assertEquals(TEST_TUPLES[1], passResult.getResult().get(0));
assertEquals(TEST_TUPLES[3], passResult.getResult().get(1));
assertEquals(TEST_TUPLES[0], failedResult.getResult().get(0));
assertEquals(TEST_TUPLES[2], failedResult.getResult().get(1));
}
use of com.ibm.streamsx.topology.spl.SPLStream in project streamsx.topology by IBMStreams.
the class PythonFunctionalOperatorsKwargsTest method testMap.
@Test
public void testMap() throws Exception {
Topology topology = new Topology("testMap");
SPLStream tuples = sampleFilterStream(topology);
PythonFunctionalOperatorsTest.addTestToolkit(tuples);
SPLStream mapped = SPL.invokeOperator("Mp", "com.ibm.streamsx.topology.pytest.pymap::OffByOne", tuples, tuples.getSchema(), null);
Tester tester = topology.getTester();
Condition<Long> expectedCount = tester.tupleCount(mapped, 3);
Condition<List<Tuple>> result = tester.tupleContents(mapped, TEST_TUPLES[0], TEST_TUPLES[1], TEST_TUPLES[2]);
getConfig().put(ContextProperties.KEEP_ARTIFACTS, true);
complete(tester, expectedCount, 10, TimeUnit.SECONDS);
assertTrue(result.getResult().toString(), result.valid());
}
Aggregations