Search in sources :

Example 46 with TStream

use of com.ibm.streamsx.topology.TStream in project streamsx.topology by IBMStreams.

the class CompGenerationTest method nestedUDPWithBroadcast.

@Test
public void nestedUDPWithBroadcast() throws Exception {
    assumeTrue(SC_OK);
    assumeTrue(!isMainRun());
    Topology topo = new Topology();
    TStream<String> nums = topo.strings("1", "2");
    nums.setParallel(() -> 2);
    nums = nums.parallel(() -> 4, Routing.BROADCAST);
    nums = nums.filter(tup -> true);
    nums = nums.endParallel().endParallel();
    Tester tester = topo.getTester();
    Condition<List<String>> validCount = tester.stringContentsUnordered(nums, "1", "1", "1", "1", "1", "1", "1", "1", "2", "2", "2", "2", "2", "2", "2", "2");
    complete(tester, allConditions(validCount), 10, TimeUnit.SECONDS);
    assertTrue(validCount.valid());
}
Also used : TStream(com.ibm.streamsx.topology.TStream) Tester(com.ibm.streamsx.topology.tester.Tester) Assert.assertTrue(org.junit.Assert.assertTrue) Set(java.util.Set) Test(org.junit.Test) HashSet(java.util.HashSet) TimeUnit(java.util.concurrent.TimeUnit) Routing(com.ibm.streamsx.topology.TStream.Routing) List(java.util.List) Topology(com.ibm.streamsx.topology.Topology) Condition(com.ibm.streamsx.topology.tester.Condition) Assume.assumeTrue(org.junit.Assume.assumeTrue) TestTopology(com.ibm.streamsx.topology.test.TestTopology) Tester(com.ibm.streamsx.topology.tester.Tester) List(java.util.List) Topology(com.ibm.streamsx.topology.Topology) TestTopology(com.ibm.streamsx.topology.test.TestTopology) Test(org.junit.Test)

Example 47 with TStream

use of com.ibm.streamsx.topology.TStream in project streamsx.topology by IBMStreams.

the class CompGenerationTest method multipleInputPortsDifferentRoutingSchemesMultipleOutputs.

@Test
public void multipleInputPortsDifferentRoutingSchemesMultipleOutputs() throws Exception {
    assumeTrue(SC_OK);
    assumeTrue(!isMainRun());
    Topology topo = new Topology();
    TStream<String> nums = topo.strings("1");
    TStream<String> nums2 = topo.strings("2");
    TStream<String> nums3 = topo.strings("3");
    nums = nums.parallel(() -> 3, tup -> 1);
    nums2 = nums2.parallel(() -> 3, Routing.BROADCAST);
    nums3 = nums3.parallel(3);
    Set<TStream<String>> streams = new HashSet<>();
    streams.add(nums2);
    streams.add(nums3);
    nums = nums.union(streams);
    TStream<String> nums_1_2 = nums.filter(tup -> tup.equals("1") || tup.equals("2"));
    TStream<String> nums_3 = nums.filter(tup -> tup.equals("3"));
    nums_1_2 = nums_1_2.endParallel();
    nums_3 = nums_3.endParallel();
    Tester tester = topo.getTester();
    Condition<List<String>> validCount_1_2 = tester.stringContentsUnordered(nums_1_2, "1", "2", "2", "2");
    Condition<List<String>> validCount_3 = tester.stringContentsUnordered(nums_3, "3");
    complete(tester, allConditions(validCount_1_2, validCount_3), 10, TimeUnit.SECONDS);
    assertTrue(validCount_1_2.valid());
    assertTrue(validCount_3.valid());
}
Also used : TStream(com.ibm.streamsx.topology.TStream) Tester(com.ibm.streamsx.topology.tester.Tester) Assert.assertTrue(org.junit.Assert.assertTrue) Set(java.util.Set) Test(org.junit.Test) HashSet(java.util.HashSet) TimeUnit(java.util.concurrent.TimeUnit) Routing(com.ibm.streamsx.topology.TStream.Routing) List(java.util.List) Topology(com.ibm.streamsx.topology.Topology) Condition(com.ibm.streamsx.topology.tester.Condition) Assume.assumeTrue(org.junit.Assume.assumeTrue) TestTopology(com.ibm.streamsx.topology.test.TestTopology) TStream(com.ibm.streamsx.topology.TStream) Tester(com.ibm.streamsx.topology.tester.Tester) List(java.util.List) Topology(com.ibm.streamsx.topology.Topology) TestTopology(com.ibm.streamsx.topology.test.TestTopology) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 48 with TStream

use of com.ibm.streamsx.topology.TStream in project streamsx.topology by IBMStreams.

the class CompGenerationTest method multipleInputPortsDifferentWidths.

@Test(expected = IllegalStateException.class)
public void multipleInputPortsDifferentWidths() throws Exception {
    assumeTrue(SC_OK);
    assumeTrue(!isMainRun());
    Topology topo = new Topology();
    TStream<String> nums = topo.strings("1");
    TStream<String> nums2 = topo.strings("2");
    TStream<String> nums3 = topo.strings("3");
    nums = nums.parallel(() -> 3, tup -> 1);
    nums2 = nums2.parallel(() -> 1, Routing.BROADCAST);
    nums3 = nums3.parallel(2);
    Set<TStream<String>> streams = new HashSet<>();
    streams.add(nums2);
    streams.add(nums3);
    nums = nums.union(streams);
    nums = nums.filter(tup -> true);
    nums = nums.endParallel();
    Tester tester = topo.getTester();
    complete(tester);
}
Also used : TStream(com.ibm.streamsx.topology.TStream) Tester(com.ibm.streamsx.topology.tester.Tester) Assert.assertTrue(org.junit.Assert.assertTrue) Set(java.util.Set) Test(org.junit.Test) HashSet(java.util.HashSet) TimeUnit(java.util.concurrent.TimeUnit) Routing(com.ibm.streamsx.topology.TStream.Routing) List(java.util.List) Topology(com.ibm.streamsx.topology.Topology) Condition(com.ibm.streamsx.topology.tester.Condition) Assume.assumeTrue(org.junit.Assume.assumeTrue) TestTopology(com.ibm.streamsx.topology.test.TestTopology) TStream(com.ibm.streamsx.topology.TStream) Tester(com.ibm.streamsx.topology.tester.Tester) Topology(com.ibm.streamsx.topology.Topology) TestTopology(com.ibm.streamsx.topology.test.TestTopology) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 49 with TStream

use of com.ibm.streamsx.topology.TStream in project streamsx.topology by IBMStreams.

the class CompGenerationTest method multipleInputPorts.

@Test
public void multipleInputPorts() throws Exception {
    assumeTrue(SC_OK);
    assumeTrue(!isMainRun());
    Topology topo = new Topology();
    TStream<String> nums = topo.strings("1");
    TStream<String> nums2 = topo.strings("2");
    TStream<String> nums3 = topo.strings("3");
    nums = nums.parallel(3);
    nums2 = nums2.parallel(3);
    nums3 = nums3.parallel(3);
    Set<TStream<String>> streams = new HashSet<>();
    streams.add(nums2);
    streams.add(nums3);
    nums = nums.union(streams);
    nums = nums.filter(tup -> true);
    nums = nums.endParallel();
    Tester tester = topo.getTester();
    Condition<List<String>> validCount = tester.stringContentsUnordered(nums, "1", "2", "3");
    complete(tester, allConditions(validCount), 10, TimeUnit.SECONDS);
    assertTrue(validCount.valid());
}
Also used : TStream(com.ibm.streamsx.topology.TStream) Tester(com.ibm.streamsx.topology.tester.Tester) Assert.assertTrue(org.junit.Assert.assertTrue) Set(java.util.Set) Test(org.junit.Test) HashSet(java.util.HashSet) TimeUnit(java.util.concurrent.TimeUnit) Routing(com.ibm.streamsx.topology.TStream.Routing) List(java.util.List) Topology(com.ibm.streamsx.topology.Topology) Condition(com.ibm.streamsx.topology.tester.Condition) Assume.assumeTrue(org.junit.Assume.assumeTrue) TestTopology(com.ibm.streamsx.topology.test.TestTopology) TStream(com.ibm.streamsx.topology.TStream) Tester(com.ibm.streamsx.topology.tester.Tester) List(java.util.List) Topology(com.ibm.streamsx.topology.Topology) TestTopology(com.ibm.streamsx.topology.test.TestTopology) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 50 with TStream

use of com.ibm.streamsx.topology.TStream in project streamsx.topology by IBMStreams.

the class InvokerTest method testParallelHashSerializers.

@Test
public void testParallelHashSerializers() 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.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();
    Condition<List<String>> contents = tester.stringContentsUnordered(ss, "33", "49", "125", "-11");
    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)

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