Search in sources :

Example 6 with BeaconTuple

use of com.ibm.streamsx.topology.tuple.BeaconTuple in project streamsx.topology by IBMStreams.

the class BeaconTest method testBeaconTupleToString.

@Test
public void testBeaconTupleToString() throws Exception {
    assumeTrue(isMainRun());
    BeaconTuple bt1 = new BeaconTuple(0, 1);
    BeaconTuple bt2 = new BeaconTuple(0, 2);
    String s = bt1.toString();
    assertNotNull(s);
    assertFalse(s.isEmpty());
    assertFalse(s.equals(bt2.toString()));
}
Also used : BeaconTuple(com.ibm.streamsx.topology.tuple.BeaconTuple) Test(org.junit.Test)

Example 7 with BeaconTuple

use of com.ibm.streamsx.topology.tuple.BeaconTuple in project streamsx.topology by IBMStreams.

the class BeaconTest method testForeverBeacon.

@Test
public void testForeverBeacon() throws Exception {
    Topology topology = new Topology("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 8 with BeaconTuple

use of com.ibm.streamsx.topology.tuple.BeaconTuple in project streamsx.topology by IBMStreams.

the class BeaconTest method testBeaconTupleEquals.

@Test
public void testBeaconTupleEquals() throws Exception {
    assumeTrue(isMainRun());
    BeaconTuple bt1 = new BeaconTuple(0, 1);
    BeaconTuple bt2 = new BeaconTuple(0, 2);
    BeaconTuple bt3 = new BeaconTuple(0, 2);
    BeaconTuple bt4 = new BeaconTuple(1, 2);
    assertTrue(!bt1.equals("foo"));
    assertTrue(!bt1.equals(null));
    assertTrue(bt1.equals(bt1));
    assertTrue(!bt1.equals(bt2));
    assertTrue(bt2.equals(bt3));
    assertTrue(!bt3.equals(bt4));
}
Also used : BeaconTuple(com.ibm.streamsx.topology.tuple.BeaconTuple) Test(org.junit.Test)

Example 9 with BeaconTuple

use of com.ibm.streamsx.topology.tuple.BeaconTuple in project streamsx.topology by IBMStreams.

the class BeaconTest method testFixedCount.

@Test
public void testFixedCount() throws Exception {
    Topology topology = new Topology("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 10 with BeaconTuple

use of com.ibm.streamsx.topology.tuple.BeaconTuple in project streamsx.topology by IBMStreams.

the class BeaconTest method testBeaconTupleHashCode.

@Test
public void testBeaconTupleHashCode() throws Exception {
    assumeTrue(isMainRun());
    BeaconTuple bt1 = new BeaconTuple(0, 1);
    BeaconTuple bt2 = new BeaconTuple(0, 2);
    BeaconTuple bt3 = new BeaconTuple(0, 2);
    assertTrue(bt1.hashCode() != 0);
    assertTrue(bt1.hashCode() != bt2.hashCode());
    assertTrue(bt2.hashCode() == bt3.hashCode());
}
Also used : BeaconTuple(com.ibm.streamsx.topology.tuple.BeaconTuple) Test(org.junit.Test)

Aggregations

BeaconTuple (com.ibm.streamsx.topology.tuple.BeaconTuple)14 Test (org.junit.Test)12 Topology (com.ibm.streamsx.topology.Topology)11 TestTopology (com.ibm.streamsx.topology.test.TestTopology)10 Tester (com.ibm.streamsx.topology.tester.Tester)9 Random (java.util.Random)9 ArrayList (java.util.ArrayList)6 List (java.util.List)6 HashMap (java.util.HashMap)2 JSONObject (com.ibm.json.java.JSONObject)1 StreamSchema (com.ibm.streams.operator.StreamSchema)1 Factory.getStreamSchema (com.ibm.streams.operator.Type.Factory.getStreamSchema)1 SPLStream (com.ibm.streamsx.topology.spl.SPLStream)1 File (java.io.File)1 IOException (java.io.IOException)1