Search in sources :

Example 96 with Topology

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

the class BeaconTest method testForeverBeacon.

@Test
public void testForeverBeacon() throws Exception {
    Topology topology = newTopology("testForeverBeacon");
    final int count = new Random().nextInt(1000) + 37;
    TStream<BeaconTuple> fb = BeaconStreams.beacon(topology, count);
    Tester tester = topology.getTester();
    Condition<Long> endCondition = tester.atLeastTupleCount(fb, count);
    assertTrue(complete(tester, endCondition, 20, TimeUnit.SECONDS));
}
Also used : Tester(com.ibm.streamsx.topology.tester.Tester) Random(java.util.Random) BeaconTuple(com.ibm.streamsx.topology.tuple.BeaconTuple) Topology(com.ibm.streamsx.topology.Topology) TestTopology(com.ibm.streamsx.topology.test.TestTopology) Test(org.junit.Test)

Example 97 with Topology

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

the class BeaconTest method testFixedCount.

@Test
public void testFixedCount() throws Exception {
    Topology topology = newTopology("testFixedCount");
    final int count = new Random().nextInt(1000) + 37;
    TStream<BeaconTuple> fb = BeaconStreams.beacon(topology, count);
    Tester tester = topology.getTester();
    Condition<Long> expectedCount = tester.tupleCount(fb, count);
    complete(tester, expectedCount, 20, TimeUnit.SECONDS);
    assertTrue(expectedCount.valid());
}
Also used : Tester(com.ibm.streamsx.topology.tester.Tester) Random(java.util.Random) BeaconTuple(com.ibm.streamsx.topology.tuple.BeaconTuple) Topology(com.ibm.streamsx.topology.Topology) TestTopology(com.ibm.streamsx.topology.test.TestTopology) Test(org.junit.Test)

Example 98 with Topology

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

the class BeaconTest method testBeaconTypes.

@Test
public void testBeaconTypes() {
    assumeTrue(isMainRun());
    Topology t = newTopology();
    assertEquals(BeaconTuple.class, BeaconStreams.beacon(t).getTupleClass());
    assertEquals(BeaconTuple.class, BeaconStreams.beacon(t, 77).getTupleClass());
    assertEquals(Long.class, BeaconStreams.longBeacon(t).getTupleClass());
    assertEquals(Long.class, BeaconStreams.longBeacon(t, 23).getTupleClass());
    assertEquals(Long.class, BeaconStreams.single(t).getTupleClass());
}
Also used : Topology(com.ibm.streamsx.topology.Topology) TestTopology(com.ibm.streamsx.topology.test.TestTopology) Test(org.junit.Test)

Example 99 with Topology

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

the class ConditionTest method testExactCountBad2.

@Test
public void testExactCountBad2() throws Exception {
    final Topology topology = new Topology();
    TStream<String> source = topology.strings("hello", "goodbye");
    Condition<Long> tupleCount = topology.getTester().tupleCount(source, 3);
    boolean passed = complete(topology.getTester(), tupleCount, 10, TimeUnit.SECONDS);
    assertFalse(tupleCount.toString(), tupleCount.valid());
    assertFalse(tupleCount.failed());
    assertFalse(passed);
}
Also used : Topology(com.ibm.streamsx.topology.Topology) TestTopology(com.ibm.streamsx.topology.test.TestTopology) RString(com.ibm.streams.operator.types.RString) Test(org.junit.Test)

Example 100 with Topology

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

the class ConditionTest method testStringContentsBad3.

@Test
public void testStringContentsBad3() throws Exception {
    final Topology topology = new Topology();
    TStream<String> source = topology.strings("A", "B", "C", "D");
    Condition<List<String>> contents = topology.getTester().stringContents(source, "A", "B", "C");
    boolean passed = complete(topology.getTester(), contents, 10, TimeUnit.SECONDS);
    assertFalse(contents.toString(), contents.valid());
    assertFalse(passed);
}
Also used : List(java.util.List) Topology(com.ibm.streamsx.topology.Topology) TestTopology(com.ibm.streamsx.topology.test.TestTopology) RString(com.ibm.streams.operator.types.RString) Test(org.junit.Test)

Aggregations

Topology (com.ibm.streamsx.topology.Topology)372 TestTopology (com.ibm.streamsx.topology.test.TestTopology)315 Test (org.junit.Test)301 List (java.util.List)116 Tester (com.ibm.streamsx.topology.tester.Tester)115 ArrayList (java.util.ArrayList)70 SPLStream (com.ibm.streamsx.topology.spl.SPLStream)68 HashMap (java.util.HashMap)49 TStream (com.ibm.streamsx.topology.TStream)42 Condition (com.ibm.streamsx.topology.tester.Condition)28 File (java.io.File)27 TimeUnit (java.util.concurrent.TimeUnit)27 StreamSchema (com.ibm.streams.operator.StreamSchema)26 Random (java.util.Random)26 JSONObject (com.ibm.json.java.JSONObject)23 HashSet (java.util.HashSet)23 RString (com.ibm.streams.operator.types.RString)21 StreamsContext (com.ibm.streamsx.topology.context.StreamsContext)21 Message (com.ibm.streamsx.topology.tuple.Message)20 SimpleMessage (com.ibm.streamsx.topology.tuple.SimpleMessage)20