use of com.ibm.streamsx.topology.TStream in project streamsx.topology by IBMStreams.
the class InvokerTest method testSource2PipeSerializers.
@Test
public void testSource2PipeSerializers() throws Exception {
assumeSPLOk();
Topology topology = newTopology();
SPL.addToolkit(topology, new File(getTestRoot(), "spl/testtk"));
JsonObject sname = new JsonObject();
sname.addProperty("name", "S");
TStream<Byte> s = Invoker.invokeSource(topology, JavaFunctionalOps.SOURCE_KIND, sname, new ByteData(), Byte.class, new ByteSerializer(), null);
s = s.isolate();
JsonObject pname = new JsonObject();
pname.addProperty("name", "P");
@SuppressWarnings("unchecked") TStream<Byte> sp = (TStream<Byte>) Invoker.invokePipe("testjava::MyPipe", s, pname, new ByteAdder(72), Byte.class, new ByteSerializer(), null, null);
sp = sp.isolate();
TStream<String> ss = StringStreams.toString(sp);
Tester tester = topology.getTester();
Condition<List<String>> contents = tester.stringContents(ss, "73", "89", "-91", "29");
Condition<Long> count = tester.tupleCount(ss, 4);
complete(topology.getTester(), count, 10, TimeUnit.SECONDS);
assertTrue(count.valid());
assertTrue(contents.valid());
}
use of com.ibm.streamsx.topology.TStream in project streamsx.topology by IBMStreams.
the class InvokerTest method testParallelHashSerializersWithAdjcentUDP.
@Test
public void testParallelHashSerializersWithAdjcentUDP() throws Exception {
checkUdpSupported();
Topology topology = newTopology();
SPL.addToolkit(topology, new File(getTestRoot(), "spl/testtk"));
JsonObject sname = new JsonObject();
sname.addProperty("name", "S");
TStream<Byte> s = Invoker.invokeSource(topology, JavaFunctionalOps.SOURCE_KIND, sname, new ByteData(), Byte.class, new ByteSerializer(), null);
s = s.setParallel(() -> 2);
s = s.endParallel();
s = s.parallel(() -> 3, Routing.HASH_PARTITIONED);
JsonObject pname = new JsonObject();
pname.addProperty("name", "P");
@SuppressWarnings("unchecked") TStream<Byte> sp = (TStream<Byte>) Invoker.invokePipe("testjava::MyPipe", s, pname, new ByteAdder(32), Byte.class, new ByteSerializer(), new ByteSerializer(), null);
sp = sp.endParallel();
JsonObject fname = new JsonObject();
fname.addProperty("name", "F");
@SuppressWarnings("unchecked") TStream<Byte> fsp = (TStream<Byte>) Invoker.invokePipe("testjava::MyPipe", sp, pname, new ByteAdder(0), Byte.class, new ByteSerializer(), null, null);
TStream<String> ss = StringStreams.toString(fsp);
Tester tester = topology.getTester();
// Note the source is in a parallel region of width 2 wo we get twice as many tuples.
Condition<List<String>> contents = tester.stringContentsUnordered(ss, "33", "49", "125", "-11", "33", "49", "125", "-11");
Condition<Long> count = tester.tupleCount(ss, 8);
complete(topology.getTester(), count, 10, TimeUnit.SECONDS);
assertTrue(count.valid());
assertTrue(contents.valid());
}
Aggregations