use of com.ibm.streamsx.topology.Topology in project streamsx.topology by IBMStreams.
the class EndParallelTest method testInvalidEndParallel.
@Test
public void testInvalidEndParallel() throws Exception {
Topology topology = newTopology("endParallel");
TStream<String> stream = topology.constants(Arrays.asList("Boom!"));
// endParallel() on a stream that's not parallel
stream.endParallel();
// should not generate invalid SPL
this.getConfig().put(com.ibm.streamsx.topology.context.ContextProperties.KEEP_ARTIFACTS, Boolean.TRUE);
StreamsContextFactory.getStreamsContext(StreamsContext.Type.STANDALONE_TESTER).submit(topology).get();
}
use of com.ibm.streamsx.topology.Topology in project streamsx.topology by IBMStreams.
the class SPLOperatorsTest method _testSCoptions.
private void _testSCoptions(Object options, String e1, String e2) throws Exception {
Topology topology = new Topology("testSCoptions");
SPLStream single = SPLStreams.stringToSPLStream(topology.constants(Collections.singletonList("A")));
SPL.addToolkit(topology, new File(getTestRoot(), "spl/testtk"));
TStream<String> output = SPL.invokeOperator("SCO", "testspl::ScOptionTester", single, single.getSchema(), Collections.emptyMap()).toStringStream();
if (options != null)
this.getConfig().put(ContextProperties.SC_OPTIONS, options);
Tester tester = topology.getTester();
Condition<Long> optC = tester.tupleCount(output, 2);
Condition<List<String>> optV = tester.stringContents(output, e1, e2);
complete(tester, optC, 10, TimeUnit.SECONDS);
assertTrue(optC.toString(), optC.valid());
assertTrue(optV.toString(), optV.valid());
}
use of com.ibm.streamsx.topology.Topology 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"));
SPL.addToolkitDependency(tuples, "com.ibm.streamsx.topology.testing.testtk", "0.9.9");
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.Topology in project streamsx.topology by IBMStreams.
the class SPLStreamsTest method testConversionToSPLWithSkip.
@Test
public void testConversionToSPLWithSkip() throws Exception {
final Topology topology = new Topology("ConvertSPLStream");
SPLStream splStream = createSPLFlowFromStream(topology, true);
TStream<String> tupleString = splStream.toTupleString();
completeAndValidate(tupleString, 10, "{ii=418,ss=\"325\"}", "{ii=9418,ss=\"9325\"}");
}
use of com.ibm.streamsx.topology.Topology in project streamsx.topology by IBMStreams.
the class SPLStreamsTest method testParameterizedConversionToSPL.
@Test
public void testParameterizedConversionToSPL() throws Exception {
final Topology topology = new Topology();
List<List<String>> data = new ArrayList<>();
data.add(Collections.singletonList("fix"));
data.add(Arrays.asList(new String[] { "bug", "164" }));
TStream<List<String>> s = topology.constants(data);
TStream<String> tupleString = convertListToSPL(s).toTupleString();
completeAndValidate(tupleString, 10, "{lrs=[\"fix\"]}", "{lrs=[\"bug\",\"164\"]}");
}
Aggregations