use of com.ibm.streamsx.topology.tester.Tester in project streamsx.topology by IBMStreams.
the class WindowTest method testPeriodicAggregateLastMicroseconds.
/**
* Test a periodic aggregation with microsecond aggregation.
* Basically a test that the application runs, hard to test
* for specific results for such a short window.
*/
@Test
@Ignore("Java SPL not supporting small window sizes")
public void testPeriodicAggregateLastMicroseconds() throws Exception {
// Embedded doesn't support window sizes < 1ms (see issue #211)
assumeTrue(!isEmbedded());
final Topology t = newTopology();
TStream<String> source = t.periodicSource(new PeriodicStrings(), 10, TimeUnit.MILLISECONDS);
TStream<JSONObject> aggregate = source.last(3, TimeUnit.MICROSECONDS).aggregate(new AggregateStrings(), 10, TimeUnit.MICROSECONDS);
TStream<String> strings = JSONStreams.serialize(aggregate);
Tester tester = t.getTester();
// Aggregate 10 microseconds, so 2 seconds is around 200,000 tuples.
Condition<Long> ending = tester.atLeastTupleCount(strings, 200_000);
complete(tester, ending, 30, TimeUnit.SECONDS);
}
use of com.ibm.streamsx.topology.tester.Tester in project streamsx.topology by IBMStreams.
the class SimpleEmbeddedTest method testSimple.
@Test
public void testSimple() throws Exception {
Topology topology = new Topology("testSimple");
TStream<String> hw = topology.strings("Hello", "World!", "Test!!");
SPLStream hws = SPLStreams.stringToSPLStream(hw);
Tester tester = topology.getTester();
StreamCounter<Tuple> counter = tester.splHandler(hws, new StreamCounter<Tuple>());
StreamCollector<LinkedList<Tuple>, Tuple> collector = tester.splHandler(hws, StreamCollector.newLinkedListCollector());
StreamsContextFactory.getStreamsContext(StreamsContext.Type.EMBEDDED_TESTER).submit(topology).get();
assertEquals(3, counter.getTupleCount());
assertEquals("Hello", collector.getTuples().get(0).getString(0));
assertEquals("World!", collector.getTuples().get(1).getString(0));
assertEquals("Test!!", collector.getTuples().get(2).getString(0));
}
use of com.ibm.streamsx.topology.tester.Tester in project streamsx.topology by IBMStreams.
the class PublishSubscribeUDPTest method completeAndValidateUnordered.
public void completeAndValidateUnordered(TStream<String> output, int seconds, String... contents) throws Exception {
Tester tester = output.topology().getTester();
Condition<List<String>> expectedContents = tester.stringContentsUnordered(output, contents);
tester.complete(getTesterContext(), getConfig(), expectedContents, seconds + getStartupDelay(), TimeUnit.SECONDS);
assertTrue(expectedContents.toString(), expectedContents.valid());
}
use of com.ibm.streamsx.topology.tester.Tester in project streamsx.topology by IBMStreams.
the class BeaconTest method testLongFixedCount.
@Test
public void testLongFixedCount() throws Exception {
Topology topology = new Topology("testLongFixedCount");
final int count = 7;
TStream<Long> fb = BeaconStreams.longBeacon(topology, count);
TStream<String> fs = StringStreams.toString(fb);
Tester tester = topology.getTester();
Condition<Long> expectedCount = tester.tupleCount(fs, count);
Condition<List<String>> expectedContents = tester.stringContents(fs, "0", "1", "2", "3", "4", "5", "6");
complete(tester, expectedCount, 20, TimeUnit.SECONDS);
assertTrue(expectedCount.valid());
assertTrue(expectedContents.valid());
}
use of com.ibm.streamsx.topology.tester.Tester in project streamsx.topology by IBMStreams.
the class PythonFunctionalOperatorsTest method testPositionalSampleNoop.
@Test
public void testPositionalSampleNoop() throws Exception {
Topology topology = new Topology("testPositionalSampleNoop");
addTestToolkit(topology);
SPLStream tuples = testTupleStream(topology);
SPLStream viaSPL = SPL.invokeOperator("spl.relational::Functor", tuples, tuples.getSchema(), null);
SPLStream viaPython = SPL.invokeOperator("com.ibm.streamsx.topology.pysamples.positional::Noop", tuples, tuples.getSchema(), null);
// Only supported for Python 3.5 and Streams 4.2 and later
if ((getVersion().getVersion() > 4) || (getVersion().getVersion() == 4 && getVersion().getRelease() >= 2)) {
viaPython = SPL.invokeOperator("com.ibm.streamsx.topology.pytest.pyec::TestOperatorContext", viaPython, viaPython.getSchema(), null);
viaPython = SPL.invokeOperator("com.ibm.streamsx.topology.pytest.pyec::PyTestMetrics", viaPython, viaPython.getSchema(), null);
}
Tester tester = topology.getTester();
Condition<Long> expectedCount = tester.tupleCount(viaPython, TUPLE_COUNT);
Condition<List<Tuple>> viaSPLResult = tester.tupleContents(viaSPL);
Condition<List<Tuple>> viaPythonResult = tester.tupleContents(viaPython);
complete(tester, expectedCount, 60, TimeUnit.SECONDS);
assertTrue(expectedCount.getResult().toString(), expectedCount.valid());
assertEquals(viaSPLResult.getResult(), viaPythonResult.getResult());
}
Aggregations