Search in sources :

Example 51 with TStream

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());
}
Also used : Tester(com.ibm.streamsx.topology.tester.Tester) JsonObject(com.google.gson.JsonObject) Topology(com.ibm.streamsx.topology.Topology) TestTopology(com.ibm.streamsx.topology.test.TestTopology) TStream(com.ibm.streamsx.topology.TStream) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File) Test(org.junit.Test)

Example 52 with TStream

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());
}
Also used : Tester(com.ibm.streamsx.topology.tester.Tester) JsonObject(com.google.gson.JsonObject) Topology(com.ibm.streamsx.topology.Topology) TestTopology(com.ibm.streamsx.topology.test.TestTopology) TStream(com.ibm.streamsx.topology.TStream) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File) Test(org.junit.Test)

Aggregations

TStream (com.ibm.streamsx.topology.TStream)52 Topology (com.ibm.streamsx.topology.Topology)44 Test (org.junit.Test)44 Tester (com.ibm.streamsx.topology.tester.Tester)41 List (java.util.List)36 TestTopology (com.ibm.streamsx.topology.test.TestTopology)30 Condition (com.ibm.streamsx.topology.tester.Condition)28 TimeUnit (java.util.concurrent.TimeUnit)27 HashSet (java.util.HashSet)25 HashMap (java.util.HashMap)23 SPLStream (com.ibm.streamsx.topology.spl.SPLStream)19 StreamsContext (com.ibm.streamsx.topology.context.StreamsContext)17 ArrayList (java.util.ArrayList)17 SPLStreams (com.ibm.streamsx.topology.spl.SPLStreams)16 Map (java.util.Map)16 StreamsContextFactory (com.ibm.streamsx.topology.context.StreamsContextFactory)15 SPL (com.ibm.streamsx.topology.spl.SPL)15 Type (com.ibm.streamsx.topology.context.StreamsContext.Type)14 Assert.assertTrue (org.junit.Assert.assertTrue)14 Assume.assumeTrue (org.junit.Assume.assumeTrue)14