use of com.ibm.streamsx.topology.Topology in project streamsx.topology by IBMStreams.
the class AutoTypeTest method _testAutoMultiTransform.
private static void _testAutoMultiTransform() {
Topology t = newTopology();
TStream<Integer> ints = t.strings("3").multiTransform(new Function<String, Iterable<Integer>>() {
@Override
public Iterable<Integer> apply(String v) {
return null;
}
});
assertEquals(Integer.class, ints.getTupleClass());
}
use of com.ibm.streamsx.topology.Topology in project streamsx.topology by IBMStreams.
the class AutoTypeTest method _testAutoLimitedSourceClass.
private static void _testAutoLimitedSourceClass() {
Topology t = newTopology();
TStream<BeaconTuple> stream = t.limitedSource(new Supplier<BeaconTuple>() {
@Override
public BeaconTuple get() {
return new BeaconTuple(0);
}
}, 8);
assertEquals(BeaconTuple.class, stream.getTupleClass());
}
use of com.ibm.streamsx.topology.Topology in project streamsx.topology by IBMStreams.
the class AutoTypeTest method testStringListUnTyped.
@Test
public void testStringListUnTyped() throws Exception {
Topology t = newTopology();
TStream<String> strings = t.constants(Collections.nCopies(10, "hello"));
assertNull(strings.getTupleClass());
assertNotNull(strings.getTupleType());
}
use of com.ibm.streamsx.topology.Topology in project streamsx.topology by IBMStreams.
the class LowLatencyTest method testSameThread.
/**
* Test the same thread executes the low latency section.
*/
@Test
public void testSameThread() throws Exception {
final int tc = 2000;
final Topology topology = newTopology("testSameThread");
final Tester tester = topology.getTester();
TStream<Long> s1 = topology.limitedSource(new Rnd(), tc);
TStream<Long> s2 = topology.limitedSource(new Rnd(), tc);
TStream<Long> s3 = topology.limitedSource(new Rnd(), tc);
TStream<Long> s4 = topology.limitedSource(new Rnd(), tc);
TStream<Long> s = s1.union(new HashSet<>(Arrays.asList(s2, s3, s4)));
s = s.lowLatency();
s = s.transform(new SetThread());
for (int i = 0; i < 20; i++) s = s.transform(new CheckThread());
s = s.transform(new ClearThread());
s = s.endLowLatency();
s = s.filter(t -> true);
this.getConfig().put(com.ibm.streamsx.topology.context.ContextProperties.KEEP_ARTIFACTS, Boolean.TRUE);
Condition<Long> endCondition = tester.tupleCount(s, 4 * tc);
this.complete(tester, endCondition, 30, TimeUnit.SECONDS);
}
use of com.ibm.streamsx.topology.Topology in project streamsx.topology by IBMStreams.
the class ParallelTest method testParallelIsolate.
@Test
public void testParallelIsolate() throws Exception {
assumeTrue(getTesterType() == StreamsContext.Type.DISTRIBUTED_TESTER);
skipVersion("udp-fusing", 4, 2);
Topology topology = newTopology();
TStream<String> strings = topology.strings("A", "B", "C", "D", "E", "F", "G", "H", "I");
TStream<String> stringsP = strings.parallel(3);
TStream<Map<Integer, String>> channelPe = stringsP.transform(new ChannelAndPEid());
channelPe = channelPe.endParallel();
TStream<String> result = channelPe.transform(new CheckSeparatePE());
Tester tester = topology.getTester();
Condition<Long> singleResult = tester.tupleCount(result, 1);
Condition<List<String>> contents = tester.stringContents(result, "true");
complete(tester, allConditions(singleResult, contents), 10, TimeUnit.SECONDS);
assertTrue("contents: " + contents, contents.valid());
}
Aggregations