Search in sources :

Example 26 with Topology

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

the class JoinTest method testEmptyJoin.

@Test
public void testEmptyJoin() throws Exception {
    final Topology t = newTopology();
    TStream<String> strings = t.strings();
    TWindow<String, ?> window = strings.last(3);
    TStream<Number> main = t.numbers(0, 134, 76);
    main = main.throttle(1, TimeUnit.SECONDS);
    TStream<List<String>> joined = _jointest(main, window);
    TStream<String> asString = StringStreams.toString(joined);
    completeAndValidate(asString, 12, "[empty-134]", "[empty-76]");
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) Topology(com.ibm.streamsx.topology.Topology) TestTopology(com.ibm.streamsx.topology.test.TestTopology) Test(org.junit.Test)

Example 27 with Topology

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

the class JoinTest method testEmptyJoinLast.

@Test
public void testEmptyJoinLast() throws Exception {
    final Topology t = newTopology();
    TStream<String> strings = t.strings();
    TStream<Number> main = t.numbers(0, 134, 76);
    main = main.throttle(1, TimeUnit.SECONDS);
    TStream<List<String>> joined = _joinLasttest(main, strings);
    TStream<String> asString = StringStreams.toString(joined);
    completeAndValidate(asString, 12, "[empty-134]", "[empty-76]");
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) Topology(com.ibm.streamsx.topology.Topology) TestTopology(com.ibm.streamsx.topology.test.TestTopology) Test(org.junit.Test)

Example 28 with Topology

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

the class XMLTupleTest method testConstant.

@Test
public void testConstant() throws Exception {
    final Topology topology = newTopology();
    String sdata = "<book><title>Dracula</title><author>Bram Stoker</author></book>";
    byte[] data = sdata.getBytes(StandardCharsets.UTF_8);
    XML xml = ValueFactory.newXML(new ByteArrayInputStream(data));
    TStream<XML> source = topology.constants(Collections.singletonList(xml)).asType(XML.class);
    assertNotNull(source);
    assertEquals(XML.class, source.getTupleClass());
    TStream<String> out = convertXMLToString(source);
    completeAndValidate(out, 10, sdata);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) XML(com.ibm.streams.operator.types.XML) Topology(com.ibm.streamsx.topology.Topology) TestTopology(com.ibm.streamsx.topology.test.TestTopology) Test(org.junit.Test)

Example 29 with Topology

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

the class JobConfigOverlaysFileTest method testJobConfigOther.

@Test
public void testJobConfigOther() throws Exception {
    // Just a simple graph, which won't be executed.
    Topology topology = newTopology("testJobConfigOther");
    topology.constants(Collections.emptyList());
    Map<String, Object> cfg = new HashMap<>();
    {
        JobConfig jc = new JobConfig();
        jc.addToConfig(cfg);
        jc.setDataDirectory("/tmp/abc");
        jc.setPreloadApplicationBundles(true);
        jc.setTracing(Level.INFO);
        assertEquals("info", jc.getStreamsTracing());
    }
    sab = bundler().submit(topology, cfg).get();
    JsonObject jcos = assertSabGetJcos(topology);
    assertDefaultDeployment(jcos);
    JsonObject jco = jobConfigOverlay(jcos);
    assertMissing(jco, "operatorConfigs");
    assertMissing(jco, "configInstructions");
    assertTrue(jco.has("jobConfig"));
    assertTrue(jco.get("jobConfig").isJsonObject());
    JsonObject jc = jco.get("jobConfig").getAsJsonObject();
    assertMissing(jc, "jobName");
    assertMissing(jc, "jobGroup");
    assertJsonString(jc, "dataDirectory", "/tmp/abc");
    assertJsonBoolean(jc, "preloadApplicationBundles", true);
    assertJsonString(jc, "tracing", "info");
    assertEquals(3, jc.entrySet().size());
}
Also used : HashMap(java.util.HashMap) JsonObject(com.google.gson.JsonObject) JsonObject(com.google.gson.JsonObject) Topology(com.ibm.streamsx.topology.Topology) TestTopology(com.ibm.streamsx.topology.test.TestTopology) JobConfig(com.ibm.streamsx.topology.jobconfig.JobConfig) Test(org.junit.Test)

Example 30 with Topology

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

the class JobConfigOverlaysFileTest method testStandalone.

@Test
public void testStandalone() throws Exception {
    // Just a simple graph, which won't be executed.
    Topology topology = newTopology("testNoConfig");
    topology.constants(Collections.emptyList());
    @SuppressWarnings("unchecked") StreamsContext<File> sb = (StreamsContext<File>) StreamsContextFactory.getStreamsContext(Type.STANDALONE_BUNDLE);
    sab = sb.submit(topology).get();
    String jconame = sab.getName().replace(".sab", "_JobConfig.json");
    jcos = new File(sab.getParentFile(), jconame);
    assertFalse(jcos.exists());
}
Also used : StreamsContext(com.ibm.streamsx.topology.context.StreamsContext) Topology(com.ibm.streamsx.topology.Topology) TestTopology(com.ibm.streamsx.topology.test.TestTopology) File(java.io.File) Test(org.junit.Test)

Aggregations

Topology (com.ibm.streamsx.topology.Topology)282 TestTopology (com.ibm.streamsx.topology.test.TestTopology)235 Test (org.junit.Test)227 List (java.util.List)80 Tester (com.ibm.streamsx.topology.tester.Tester)75 SPLStream (com.ibm.streamsx.topology.spl.SPLStream)53 ArrayList (java.util.ArrayList)50 HashMap (java.util.HashMap)33 JSONObject (com.ibm.json.java.JSONObject)25 TStream (com.ibm.streamsx.topology.TStream)23 Message (com.ibm.streamsx.topology.tuple.Message)20 SimpleMessage (com.ibm.streamsx.topology.tuple.SimpleMessage)20 Random (java.util.Random)19 StreamsContext (com.ibm.streamsx.topology.context.StreamsContext)16 File (java.io.File)16 Map (java.util.Map)16 OutputTuple (com.ibm.streams.operator.OutputTuple)14 StreamSchema (com.ibm.streams.operator.StreamSchema)14 Value (com.ibm.streamsx.topology.logic.Value)14 Condition (com.ibm.streamsx.topology.tester.Condition)14