当前位置: 首页>>代码示例>>Java>>正文


Java SiddhiManager.createSiddhiAppRuntime方法代码示例

本文整理汇总了Java中org.wso2.siddhi.core.SiddhiManager.createSiddhiAppRuntime方法的典型用法代码示例。如果您正苦于以下问题:Java SiddhiManager.createSiddhiAppRuntime方法的具体用法?Java SiddhiManager.createSiddhiAppRuntime怎么用?Java SiddhiManager.createSiddhiAppRuntime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.wso2.siddhi.core.SiddhiManager的用法示例。


在下文中一共展示了SiddhiManager.createSiddhiAppRuntime方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testUpdateUpdateRegressionLearningStreamProcessorExtension3

import org.wso2.siddhi.core.SiddhiManager; //导入方法依赖的package包/类
@Test
public void testUpdateUpdateRegressionLearningStreamProcessorExtension3() throws InterruptedException {
    logger.info("UpdateUpdateRegressionLearningStreamProcessorExtension TestCase "
            + "- Target value is not of type double");
    SiddhiManager siddhiManager = new SiddhiManager();

    String inStreamDefinition = "define stream StreamA (attribute_0 double, attribute_1 double, attribute_2 "
            + "double, attribute_3 double, attribute_4 String );";

    String query = ("@info(name = 'query1') from StreamA#streamingml:updateAMRulesRegressor('model1',  "
            + "attribute_0, attribute_1 , attribute_2 ,attribute_3,attribute_4) select attribute_0, "
            + "attribute_1, attribute_2, attribute_3, accuracy insert into"
            + " outputStream;");
    try {
        SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(inStreamDefinition + query);
    } catch (Exception e) {
        logger.error(e.getCause().getMessage());
        AssertJUnit.assertTrue(e instanceof SiddhiAppCreationException);
        AssertJUnit.assertTrue(e.getCause().getMessage().contains("model.features in 6th parameter is not a " +
                "numerical type attribute. Found STRING. Check the input stream definition."));
    }
}
 
开发者ID:wso2-extensions,项目名称:siddhi-gpl-execution-streamingml,代码行数:23,代码来源:AdaptiveModelRulesRegressorUpdaterStreamProcessorExtensionTestcase.java

示例2: testClusTree2D_23

import org.wso2.siddhi.core.SiddhiManager; //导入方法依赖的package包/类
@Test
public void testClusTree2D_23() throws Exception {
    logger.info("ClusTreeStreamProcessorExtension Test - Test case with non existing stream");
    SiddhiManager siddhiManager = new SiddhiManager();
    //String inputStream = "define stream InputStream (x double, y double);";

    String query = (
            "@info(name = 'query1') " +
                    "from InputStream#streamingml:clusTree(2, 10, 20, 2, -50, x, y) " +
                    "select closestCentroidCoordinate1, closestCentroidCoordinate2, x, y " +
                    "insert into OutputStream;");
    try {
        SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(query);
    } catch (Exception e) {
        logger.info("Error caught");
        AssertJUnit.assertTrue(e instanceof SiddhiParserException);
        AssertJUnit.assertTrue(e.getMessage().contains("Syntax error in SiddhiQL, no viable alternative at input "
                + "'@info(name = query1)"));
    }
}
 
开发者ID:wso2-extensions,项目名称:siddhi-gpl-execution-streamingml,代码行数:21,代码来源:ClusTreeStreamProcessorExtensionTest.java

示例3: testClusTree2D_24

import org.wso2.siddhi.core.SiddhiManager; //导入方法依赖的package包/类
@Test
public void testClusTree2D_24() throws Exception {
    logger.info("ClusTreeStreamProcessorExtension Test - Test case with non-numeric event data");
    SiddhiManager siddhiManager = new SiddhiManager();
    String inputStream = "define stream InputStream (x double, y double);";

    String query = (
            "@info(name = 'query1') " +
                    "from InputStream#streamingml:clusTree(2, x, y) " +
                    "select closestCentroidCoordinate1, closestCentroidCoordinate2, x, y " +
                    "insert into OutputStream;");
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(inputStream + query);

    siddhiAppRuntime.addCallback("query1", new QueryCallback() {
        @Override
        public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
            EventPrinter.print(inEvents);
        }
    });


    siddhiAppRuntime.start();
    InputHandler inputHandler = siddhiAppRuntime.getInputHandler("InputStream");
    inputHandler.send(new Object[]{5.7905, "hi"});
}
 
开发者ID:wso2-extensions,项目名称:siddhi-gpl-execution-streamingml,代码行数:26,代码来源:ClusTreeStreamProcessorExtensionTest.java

示例4: testHoeffdingClassifierLearningExtension19

import org.wso2.siddhi.core.SiddhiManager; //导入方法依赖的package包/类
@Test
public void testHoeffdingClassifierLearningExtension19() throws InterruptedException {
    logger.info("HoeffdingClassifierUpdaterStreamProcessorExtension TestCase " +
            "- Configure a model with tie threshold value <0");
    SiddhiManager siddhiManager = new SiddhiManager();

    String inStreamDefinition = " define stream StreamA (attribute_0 double, attribute_1 double, attribute_2 "
            + "double,attribute_3 double, attribute_4 string );";

    String query = ("@info(name = 'query1') "
            + "from StreamA#streamingml:updateHoeffdingTree('model1', 3, 5, 300, 1e-7, -2, false, false, 2, "
            + "attribute_0, attribute_1 , attribute_2 ,attribute_3,attribute_4) select attribute_0, "
            + "attribute_1, attribute_2, attribute_3, accuracy insert into outputStream;");
    try {
        SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(inStreamDefinition + query);
    } catch (Exception e) {
        logger.error(e.getCause().getMessage());
        AssertJUnit.assertTrue(e instanceof SiddhiAppCreationException);
        AssertJUnit.assertTrue(e.getCause().getMessage().contains("Option tieThreshold cannot be less than 0.0,"
                + " out of range: -2.0"));
    }
}
 
开发者ID:wso2-extensions,项目名称:siddhi-gpl-execution-streamingml,代码行数:23,代码来源:HoeffdingClassifierUpdaterStreamProcessorExtensionTestCase.java

示例5: jsonSourceMapperTest21

import org.wso2.siddhi.core.SiddhiManager; //导入方法依赖的package包/类
@Test
public void jsonSourceMapperTest21() throws InterruptedException {
    log.info("test JsonSourceMapper with test json object type");
    log = Logger.getLogger(JsonSourceMapper.class);
    UnitTestAppender appender = new UnitTestAppender();
    log.addAppender(appender);
    String streams = "" +
            "@App:name('TestSiddhiApp')" +
            "@source(type='inMemory', topic='stock', @map(type='json')) " +
            "define stream FooStream (symbol Bool, price double, volume int); " +
            "define stream BarStream (symbol Bool, price double, volume int); ";
    String query = "" +
            "from FooStream " +
            "select * " +
            "insert into BarStream; ";
    SiddhiManager siddhiManager = new SiddhiManager();
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query);

    siddhiAppRuntime.start();
    InMemoryBroker.publish("stock", 12);
    AssertJUnit.assertTrue(appender.getMessages().contains("Invalid JSON object received. Expected String"));
    siddhiAppRuntime.shutdown();
}
 
开发者ID:wso2-extensions,项目名称:siddhi-map-json,代码行数:24,代码来源:JsonSourceMapperTestCase.java

示例6: testClassificationStreamProcessorExtension5

import org.wso2.siddhi.core.SiddhiManager; //导入方法依赖的package包/类
@Test
public void testClassificationStreamProcessorExtension5() throws InterruptedException {
    logger.info("HoeffdingClassifierStreamProcessorExtension TestCase - incorrect initialization");
    SiddhiManager siddhiManager = new SiddhiManager();

    String inStreamDefinition = "define stream StreamA (attribute_0 double, attribute_1 double, attribute_2 " +
            "double, attribute_3 double, attribute_4 string );";
    String query = ("@info(name = 'query1') from StreamA#streamingml:hoeffdingTreeClassifier() \n"
            + "select attribute_0, attribute_1, attribute_2, attribute_3, prediction, confidenceLevel " +
            "insert into outputStream;");

    try {
        SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(inStreamDefinition + query);
        AssertJUnit.fail();
    } catch (Exception e) {
        logger.error(e.getCause().getMessage());
        AssertJUnit.assertTrue(e instanceof SiddhiAppCreationException);
        AssertJUnit.assertTrue(e.getCause().getMessage().contains("Invalid number of parameters " +
                "for streamingml:hoeffdingTreeClassifier. This Stream Processor requires at least 3 parameters," +
                " namely, model.name and at least 2 feature_attributes, but found 0 parameters"));
    }
}
 
开发者ID:wso2-extensions,项目名称:siddhi-gpl-execution-streamingml,代码行数:23,代码来源:HoeffdingClassifierStreamProcessorExtensionTestCase.java

示例7: testHoeffdingClassifierLearningExtension13

import org.wso2.siddhi.core.SiddhiManager; //导入方法依赖的package包/类
@Test
public void testHoeffdingClassifierLearningExtension13() throws InterruptedException {
    logger.info("HoeffdingClassifierUpdaterStreamProcessorExtension TestCase - no label is passed");
    SiddhiManager siddhiManager = new SiddhiManager();

    String inStreamDefinition = "define stream StreamA (attribute_0 double, attribute_1 double, attribute_2 " +
            "double, attribute_3 double);";

    String query = ("@info(name = 'query1') from StreamA#streamingml:updateHoeffdingTree('model1', 3, " +
            "attribute_0, attribute_1 , attribute_2 , attribute_3) select attribute_0, "
            + "attribute_1, attribute_2, attribute_3, accuracy insert into"
            + " outputStream;");

    try {
        SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(inStreamDefinition + query);
    } catch (Exception e) {
        logger.error(e.getCause().getMessage());
        AssertJUnit.assertTrue(e instanceof SiddhiAppCreationException);
        AssertJUnit.assertTrue(e.getCause().getMessage().contains("[label attribute] in 5 th index of "
                + "classifierUpdate should be either a BOOL or a STRING but found DOUBLE"));
    }
}
 
开发者ID:wso2-extensions,项目名称:siddhi-gpl-execution-streamingml,代码行数:23,代码来源:HoeffdingClassifierUpdaterStreamProcessorExtensionTestCase.java

示例8: testClusTree2D_18

import org.wso2.siddhi.core.SiddhiManager; //导入方法依赖的package包/类
@Test
public void testClusTree2D_18() throws Exception {
    logger.info("ClusTreeStreamProcessorExtension Test - Test case to validate noOfClusters to be positive");
    SiddhiManager siddhiManager = new SiddhiManager();
    String inputStream = "define stream InputStream (x double, y double);";

    String query = (
            "@info(name = 'query1') " +
                    "from InputStream#streamingml:clusTree(-2, 10, 20, 2, 50, x, y) " +
                    "select closestCentroidCoordinate1, closestCentroidCoordinate2, x, y " +
                    "insert into OutputStream;");
    try {
        SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(inputStream + query);
    } catch (Exception e) {
        logger.info("Error caught");
        AssertJUnit.assertTrue(e instanceof SiddhiAppCreationException);
        AssertJUnit.assertTrue(e.getCause().getMessage().contains("noOfClusters should be a positive integer " +
                "but found -2"));
    }
}
 
开发者ID:wso2-extensions,项目名称:siddhi-gpl-execution-streamingml,代码行数:21,代码来源:ClusTreeStreamProcessorExtensionTest.java

示例9: testClusTree2D_19

import org.wso2.siddhi.core.SiddhiManager; //导入方法依赖的package包/类
@Test
public void testClusTree2D_19() throws Exception {
    logger.info("ClusTreeStreamProcessorExtension Test - Test case to validate maxIterations to be positive");
    SiddhiManager siddhiManager = new SiddhiManager();
    String inputStream = "define stream InputStream (x double, y double);";

    String query = (
            "@info(name = 'query1') " +
                    "from InputStream#streamingml:clusTree(2, -10, 20, 2, 50, x, y) " +
                    "select closestCentroidCoordinate1, closestCentroidCoordinate2, x, y " +
                    "insert into OutputStream;");
    try {
        SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(inputStream + query);
    } catch (Exception e) {
        logger.info("Error caught");
        AssertJUnit.assertTrue(e instanceof SiddhiAppCreationException);
        AssertJUnit.assertTrue(e.getCause().getMessage().contains("maxIterations should be a positive integer " +
                "but found -10"));
    }
}
 
开发者ID:wso2-extensions,项目名称:siddhi-gpl-execution-streamingml,代码行数:21,代码来源:ClusTreeStreamProcessorExtensionTest.java

示例10: testRegressionStreamProcessorExtension5

import org.wso2.siddhi.core.SiddhiManager; //导入方法依赖的package包/类
@Test
public void testRegressionStreamProcessorExtension5() throws InterruptedException {
    logger.info("RegressionLearningStreamProcessorExtension TestCase - incorrect initialization");
    SiddhiManager siddhiManager = new SiddhiManager();

    String inStreamDefinition = "define stream StreamA (attribute_0 double, attribute_1 double, attribute_2 "
            + "double, attribute_3 double, attribute_4 double );";
    String query = ("@info(name = 'query1') from StreamA#streamingml:AMRulesRegressor() \n"
            + "select attribute_0, attribute_1, attribute_2, attribute_3, prediction, meanSquaredError "
            + "insert into outputStream;");
    try {
        SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(inStreamDefinition + query);
        AssertJUnit.fail();
    } catch (Exception e) {
        logger.error(e.getCause().getMessage());
        AssertJUnit.assertTrue(e instanceof SiddhiAppCreationException);
        AssertJUnit.assertTrue(e.getCause().getMessage().contains("streamingML:AMRulesRegressor needs exactly"
                + " model.name and 5 feature atttributes, but found 0."));
    }
}
 
开发者ID:wso2-extensions,项目名称:siddhi-gpl-execution-streamingml,代码行数:21,代码来源:AdaptiveModelRulesRegressorStreamProcessorExtensionTestcase.java

示例11: testHTTPTestPutMethod

import org.wso2.siddhi.core.SiddhiManager; //导入方法依赖的package包/类
/**
 * Creating test for publishing events from PUT method.
 * @throws Exception Interrupted exception
 */
@Test (dependsOnMethods = "testHTTPTestGetMethod")
public void testHTTPTestPutMethod() throws Exception {
    log.info("Creating test for publishing events from PUT method.");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setExtension("xml-output-mapper", XMLSinkMapper.class);
    String inStreamDefinition = "Define stream FooStream (message String,method String,headers String);"
            + "@sink(type='http',publisher.url='http://localhost:8005/abc',method='{{method}}',"
            + "headers='{{headers}}',"
            + "@map(type='xml', "
            + "@payload('{{message}}'))) "
            + "Define stream BarStream (message String,method String,headers String);";
    String query = ("@info(name = 'query') " +
            "from FooStream "
            + "select message,method,headers "
            + "insert into BarStream;"
            );
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(inStreamDefinition +
            query);
    InputHandler fooStream = siddhiAppRuntime.getInputHandler("FooStream");
    siddhiAppRuntime.start();
    HttpServerListenerHandler lst = new HttpServerListenerHandler(8005);
    lst.run();
    fooStream.send(new Object[]{payload, "PUT", "Name:John,Age:23"});
    while (!lst.getServerListener().isMessageArrive()) {
        Thread.sleep(10);
    }
    String eventData = lst.getServerListener().getData();
    Assert.assertEquals(expected, eventData);
    siddhiAppRuntime.shutdown();
    lst.shutdown();
}
 
开发者ID:wso2-extensions,项目名称:siddhi-io-http,代码行数:36,代码来源:HttpSinkMethodTypeTestCase.java

示例12: testHTTPTestDeleteMethod

import org.wso2.siddhi.core.SiddhiManager; //导入方法依赖的package包/类
/**
 * Creating test for publishing events from DELETE method.
 * @throws Exception Interrupted exception
 */
@Test (dependsOnMethods = "testHTTPTestPutMethod")
public void testHTTPTestDeleteMethod() throws Exception {
    log.info("Creating test for publishing events from DELETE method.");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setExtension("xml-output-mapper", XMLSinkMapper.class);

    String inStreamDefinition = "Define stream FooStream (message String,method String,headers String);"
            + "@sink(type='http',publisher.url='http://localhost:8005/abc',method='{{method}}',"
            + "headers='{{headers}}',"
            + "@map(type='xml', "
            + "@payload('{{message}}'))) "
            + "Define stream BarStream (message String,method String,headers String);";
    String query = ("@info(name = 'query') " +
            "from FooStream "
            + "select message,method,headers "
            + "insert into BarStream;"
            );
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(inStreamDefinition +
            query);
    InputHandler fooStream = siddhiAppRuntime.getInputHandler("FooStream");
    siddhiAppRuntime.start();
    HttpServerListenerHandler lst = new HttpServerListenerHandler(8005);
    lst.run();
    fooStream.send(new Object[]{payload, "DELETE", "'Name:John','Age:23'"});
    while (!lst.getServerListener().isMessageArrive()) {
    Thread.sleep(10);
    }
    String eventData = lst.getServerListener().getData();
    Assert.assertEquals("", eventData);
    siddhiAppRuntime.shutdown();
    lst.shutdown();
}
 
开发者ID:wso2-extensions,项目名称:siddhi-io-http,代码行数:37,代码来源:HttpSinkMethodTypeTestCase.java

示例13: jsonSourceMapper20

import org.wso2.siddhi.core.SiddhiManager; //导入方法依赖的package包/类
@Test
public void jsonSourceMapper20() throws InterruptedException {
    log.info("test JsonSourceMapper with test Test values type boolean");
    log = Logger.getLogger(JsonSourceMapper.class);
    UnitTestAppender appender = new UnitTestAppender();
    log.addAppender(appender);
    String streams = "" +
            "@App:name('TestSiddhiApp')" +
            "@source(type='inMemory', topic='stock', @map(type='json')) " +
            "define stream FooStream (symbol Bool, price double, volume int); " +
            "define stream BarStream (symbol Bool, price double, volume int); ";
    String query = "" +
            "from FooStream " +
            "select * " +
            "insert into BarStream; ";
    SiddhiManager siddhiManager = new SiddhiManager();
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query);

    siddhiAppRuntime.start();
    InMemoryBroker.publish("stock", " {\n" +
            "      \"event\":{\n" +
            "         \"symbol\":\"true\",\n" +
            "         \"price\":55,\n" +
            "         \"volume\":100.0\n" +
            "      }\n" +
            " }");
    AssertJUnit.assertTrue(appender.getMessages().contains("contains incompatible attribute types and values"));
    siddhiAppRuntime.shutdown();
}
 
开发者ID:wso2-extensions,项目名称:siddhi-map-json,代码行数:30,代码来源:JsonSourceMapperTestCase.java

示例14: testHTTPInputTransportWithoutURL

import org.wso2.siddhi.core.SiddhiManager; //导入方法依赖的package包/类
/**
 * Creating test for publishing events without URL.
 * @throws Exception Interrupted exception
 */
@Test
public void testHTTPInputTransportWithoutURL() throws Exception {
    logger.info(" Creating test for publishing events without URL.");
    URI baseURI = URI.create(String.format("http://%s:%d", "0.0.0.0", 8280));
    List<String> receivedEventNameList = new ArrayList<>(2);
    PersistenceStore persistenceStore = new InMemoryPersistenceStore();
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setPersistenceStore(persistenceStore);
    siddhiManager.setExtension("xml-input-mapper", XmlSourceMapper.class);
    String inStreamDefinition =  "@App:name('TestSiddhiApp')"  +
            "@source(type='http', @map(type='xml') )" +
                    "define stream inputStream (name string, age int, country string);";
    String query = ("@info(name = 'query') "
            + "from inputStream "
            + "select *  "
            + "insert into outputStream;"
                    );
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager
            .createSiddhiAppRuntime(inStreamDefinition + query);

    siddhiAppRuntime.addCallback("query", new QueryCallback() {
        @Override
        public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
            EventPrinter.print(timeStamp, inEvents, removeEvents);
            for (Event event : inEvents) {
                eventCount.incrementAndGet();
                receivedEventNameList.add(event.getData(0).toString());
            }
        }
    });
    siddhiAppRuntime.start();
    // publishing events
    List<String> expected = new ArrayList<>(2);
    expected.add("John");
    expected.add("Mike");
    String event1 = "<events>"
                        + "<event>"
                            + "<name>John</name>"
                            + "<age>100</age>"
                            + "<country>AUS</country>"
                        + "</event>"
                    + "</events>";
    String event2 = "<events>"
                        + "<event>"
                            + "<name>Mike</name>"
                            + "<age>20</age>"
                            + "<country>USA</country>"
                        + "</event>"
                    + "</events>";
    HttpTestUtil.httpPublishEventDefault(event1, baseURI);
    HttpTestUtil.httpPublishEventDefault(event2, baseURI);
    SiddhiTestHelper.waitForEvents(waitTime, 2, eventCount, timeout);
    Assert.assertEquals(receivedEventNameList.toString(), expected.toString());
    siddhiAppRuntime.shutdown();
}
 
开发者ID:wso2-extensions,项目名称:siddhi-io-http,代码行数:60,代码来源:HttpBasicTestCase.java

示例15: jsonSinkMapperTestCase1

import org.wso2.siddhi.core.SiddhiManager; //导入方法依赖的package包/类
@Test
public void jsonSinkMapperTestCase1() throws InterruptedException {
    log.info("JsonSinkMapperTestCase 1");
    InMemoryBroker.Subscriber subscriberWSO2 = new InMemoryBroker.Subscriber() {
        @Override
        public void onMessage(Object msg) {
            String jsonString;
            switch (wso2Count.incrementAndGet()) {
                case 1:
                    jsonString = "{\"event\":{\"symbol\":\"WSO2\",\"price\":55.6,\"volume\":100}}";
                    AssertJUnit.assertEquals(jsonString , msg);
                    break;
                case 2:
                    jsonString = "{\"event\":{\"symbol\":\"WSO2\",\"price\":57.678,\"volume\":100}}";
                    AssertJUnit.assertEquals(jsonString, msg);
                    break;
                case 3:
                    jsonString = "{\"event\":{\"symbol\":\"WSO2\",\"price\":50.0,\"volume\":100}}";
                    AssertJUnit.assertEquals(jsonString , msg);
                    break;
                case 4:
                    jsonString = "{\"event\":{\"symbol\":\"WSO2#$%\",\"price\":50.0,\"volume\":100}}";
                    AssertJUnit.assertEquals(jsonString , msg);
                    break;
                case 5:
                    jsonString = "[{\"event\":{\"symbol\":\"WSO2\",\"price\":55.6,\"volume\":100}}," +
                            "{\"event\":{\"symbol\":\"IBM\",\"price\":32.6,\"volume\":160}}]";
                    AssertJUnit.assertEquals(jsonString , msg);
                    break;
                default:
                    AssertJUnit.fail();
            }
        }
        @Override
        public String getTopic() {
            return "WSO2";
        }
    };
    //subscribe to "inMemory" broker per topic
    InMemoryBroker.subscribe(subscriberWSO2);
    String streams = "" +
            "@App:name('TestSiddhiApp')" +
            "define stream FooStream (symbol string, price float, volume long); " +
            "@sink(type='inMemory', topic='WSO2', @map(type='json')) " +
            "define stream BarStream (symbol string, price float, volume long); ";
    String query = "" +
            "from FooStream " +
            "select * " +
            "insert into BarStream; ";
    SiddhiManager siddhiManager = new SiddhiManager();
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query);
    InputHandler stockStream = siddhiAppRuntime.getInputHandler("FooStream");
    siddhiAppRuntime.start();
    Event wso2Event = new Event();
    Event ibmEvent = new Event();
    Object[] wso2Data = {"WSO2", 55.6f, 100L};
    Object[] ibmData = {"IBM", 32.6f, 160L};
    wso2Event.setData(wso2Data);
    ibmEvent.setData(ibmData);
    stockStream.send(new Object[]{"WSO2", 55.6f, 100L});
    stockStream.send(new Object[]{"WSO2", 57.678f, 100L});
    stockStream.send(new Object[]{"WSO2", 50f, 100L});
    stockStream.send(new Object[]{"WSO2#$%", 50f, 100L});
    stockStream.send(new Event[]{wso2Event, ibmEvent});
    SiddhiTestHelper.waitForEvents(waitTime, 5, wso2Count, timeout);
    //assert event count
    AssertJUnit.assertEquals(5, wso2Count.get());
    siddhiAppRuntime.shutdown();
    //unsubscribe from "inMemory" broker per topic
    InMemoryBroker.unsubscribe(subscriberWSO2);
}
 
开发者ID:wso2-extensions,项目名称:siddhi-map-json,代码行数:72,代码来源:JsonSinkMapperTestCase.java


注:本文中的org.wso2.siddhi.core.SiddhiManager.createSiddhiAppRuntime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。