use of com.ibm.streamsx.topology.Topology in project streamsx.topology by IBMStreams.
the class PublishSubscribeTest method testFilterOnBlob.
@Test(expected = IllegalArgumentException.class)
public void testFilterOnBlob() throws Exception {
final Topology t = new Topology();
TStream<Blob> blobs = t.constants(Collections.<Blob>emptyList()).asType(Blob.class);
blobs.publish("sometopic", true);
}
use of com.ibm.streamsx.topology.Topology in project streamsx.topology by IBMStreams.
the class PublishSubscribeUDPTest method testObjectPublishBothSubscribeNonUDP.
@Test
public void testObjectPublishBothSubscribeNonUDP() throws Exception {
String topic = uniqueTopic("testObjectPublishBothSubscribeNonUDP");
Random r = new Random();
List<BigDecimal> data = new ArrayList<>(20);
for (int i = 0; i < 20; i++) data.add(new BigDecimal(r.nextDouble() * 100.0));
final Topology t = new Topology();
TStream<BigDecimal> source = t.constants(data);
source = addStartupDelay(source).asType(BigDecimal.class);
source = source.parallel(4);
source.publish(topic);
List<BigDecimal> data2 = new ArrayList<>(10);
for (int i = 0; i < 10; i++) data2.add(new BigDecimal(r.nextDouble() * 100.0));
TStream<BigDecimal> source2 = t.constants(data2);
source2 = addStartupDelay(source2);
source2.asType(BigDecimal.class).publish(topic);
TStream<BigDecimal> subscribe = t.subscribe(topic, BigDecimal.class);
TStream<String> strings = StringStreams.toString(subscribe);
List<String> expected = new ArrayList<>();
for (BigDecimal d : data) expected.add(d.toString());
for (BigDecimal d : data2) expected.add(d.toString());
completeAndValidateUnordered(strings, 40, expected.toArray(new String[0]));
}
use of com.ibm.streamsx.topology.Topology in project streamsx.topology by IBMStreams.
the class PublishSubscribeUDPTest method testPublishUDPSubscribeUDP.
private void testPublishUDPSubscribeUDP(int pwidth, int swidth) throws Exception {
String topic = uniqueTopic("testPublishUDPSubscribeUDP/" + pwidth);
String[] data = new String[100];
for (int i = 0; i < data.length; i++) {
data[i] = "SubUDP" + i;
}
final Topology t = new Topology();
SPL.addToolkit(t, new File(getTestRoot(), "spl/testtk"));
TStream<String> source = t.strings(data);
source = addStartupDelay(source);
if (pwidth > 0)
source = source.parallel(pwidth);
source.publish(topic);
Map<String, Object> params = new HashMap<>();
params.put("width", swidth);
params.put("topic", topic);
SPLStream subscribe = SPL.invokeSource(t, "testspl::UDPStringSub", params, SPLSchemas.STRING);
completeAndValidateUnordered(subscribe.toStringStream(), 30, data);
}
use of com.ibm.streamsx.topology.Topology in project streamsx.topology by IBMStreams.
the class PublishSubscribeUDPTest method testPublishUDPSubscribeNonUDP.
private void testPublishUDPSubscribeNonUDP(int width) throws Exception {
String topic = uniqueTopic("testPublishUDPSubscribeNonUDP/" + width);
final Topology t = new Topology();
TStream<String> source = t.strings("325", "457", "9325", "hello", "udp");
source = addStartupDelay(source);
if (width > 0)
source = source.parallel(width);
source.publish(topic);
TStream<String> subscribe = t.subscribe(topic, String.class);
completeAndValidateUnordered(subscribe, 20, "325", "457", "9325", "hello", "udp");
}
use of com.ibm.streamsx.topology.Topology in project streamsx.topology by IBMStreams.
the class VwapTest method testVwap.
@Test
public void testVwap() throws Exception {
// Invokes an SPL operator so cannot run in embedded.
assumeSPLOk();
TStream<Bargain> bargains = Vwap.createVwapTopology();
bargains = Vwap.realBargains(bargains);
Topology topology = bargains.topology();
Tester tester = topology.getTester();
Condition<Long> expectedCount = tester.atLeastTupleCount(bargains, 2200);
complete(tester, expectedCount, 120, TimeUnit.SECONDS);
assertTrue(expectedCount.toString(), expectedCount.valid());
}
Aggregations