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


Java SiddhiManager.setPersistenceStore方法代码示例

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


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

示例1: testBasicAuthTrueWrongConf

import org.wso2.siddhi.core.SiddhiManager; //导入方法依赖的package包/类
@Test
public void testBasicAuthTrueWrongConf() throws Exception {
    URI baseURI = URI.create(String.format("http://%s:%d", "localhost", 8009));
    receivedEventNameList = new ArrayList<>(2);
    PersistenceStore persistenceStore = new InMemoryPersistenceStore();
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setPersistenceStore(persistenceStore);
    siddhiManager.setExtension("text", TextSourceMapper.class);
    String inStreamDefinition = "" + "@source(type='http', @map(type='text'), "
            + "receiver.url='http://localhost:8009/endpoints/RecPro', " + "basic.auth.enabled='true'" + ")"
            + "define stream inputStream (name string, age int, country string);";
    String query = ("@info(name = 'query1') " + "from inputStream " + "select *  " + "insert into outputStream;");
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager
            .createSiddhiAppRuntime(inStreamDefinition + query);
    siddhiAppRuntime.addCallback("query1", 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<>();
    String event1 = "name:\"John\",\n" +
            "age:100,\n" +
            "country:\"USA\"";
    String event2 = "name:\"Mike\",\n" +
            "age:100,\n" +
            "country:\"USA\"";
    new TestUtil().httpPublishEventAuthIncorrect(event1, baseURI, true, "plain/text");
    new TestUtil().httpPublishEventAuthIncorrect(event2, baseURI, true, "plain/text");
    SiddhiTestHelper.waitForEvents(waitTime, 0, eventCount, timeout);
    Assert.assertEquals(receivedEventNameList, expected);
    siddhiAppRuntime.shutdown();
}
 
开发者ID:wso2-extensions,项目名称:siddhi-io-http,代码行数:40,代码来源:HttpSourceTestCase.java

示例2: testHTTPInputTransportBasicAuthFalse

import org.wso2.siddhi.core.SiddhiManager; //导入方法依赖的package包/类
@Test
public void testHTTPInputTransportBasicAuthFalse() throws Exception {
    URI baseURI = URI.create(String.format("http://%s:%d", "localhost", 8009));
    receivedEventNameList = new ArrayList<>(2);
    PersistenceStore persistenceStore = new InMemoryPersistenceStore();
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setPersistenceStore(persistenceStore);
    siddhiManager.setExtension("text", TextSourceMapper.class);
    String inStreamDefinition = "" + "@source(type='http', @map(type='text'), "
            + "receiver.url='http://localhost:8009/endpoints/RecPro' " + ")"
            + "define stream inputStream (name string, age int, country string);";
    String query = ("@info(name = 'query1') " + "from inputStream " + "select *  " + "insert into outputStream;");
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager
            .createSiddhiAppRuntime(inStreamDefinition + query);
    siddhiAppRuntime.addCallback("query1", 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 = "name:\"John\",\n" +
            "age:100,\n" +
            "country:\"USA\"";
    String event2 = "name:\"Mike\",\n" +
            "age:100,\n" +
            "country:\"USA\"";
    new TestUtil().httpPublishEvent(event1, baseURI, "/endpoints/RecPro", false, "plain/text",
            "POST");
    new TestUtil().httpPublishEvent(event2, baseURI, "/endpoints/RecPro", false, "plain/text",
            "POST");
    SiddhiTestHelper.waitForEvents(waitTime, 2, eventCount, timeout);
    logger.info(receivedEventNameList);
    Assert.assertEquals(receivedEventNameList, expected);
    siddhiAppRuntime.shutdown();
}
 
开发者ID:wso2-extensions,项目名称:siddhi-io-http,代码行数:45,代码来源:HttpSourceTestCase.java

示例3: testHTTPInputTransportBasicAuthTrue

import org.wso2.siddhi.core.SiddhiManager; //导入方法依赖的package包/类
@Test
public void testHTTPInputTransportBasicAuthTrue() throws Exception {
    URI baseURI = URI.create(String.format("http://%s:%d", "localhost", 8009));
    receivedEventNameList = new ArrayList<>(2);
    PersistenceStore persistenceStore = new InMemoryPersistenceStore();
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setPersistenceStore(persistenceStore);
    siddhiManager.setExtension("text", TextSourceMapper.class);
    String inStreamDefinition = "" + "@source(type='http', @map(type='text'), "
            + "receiver.url='http://localhost:8009/endpoints/RecPro', " + "basic.auth.enabled='true'" + ")"
            + "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 = "name:\"John\",\n" +
            "age:100,\n" +
            "country:\"USA\"";
    String event2 = "name:\"Mike\",\n" +
            "age:100,\n" +
            "country:\"USA\"";
    new TestUtil().httpPublishEvent(event1, baseURI, "/endpoints/RecPro", true, "plain/text",
            "POST");
    new TestUtil().httpPublishEvent(event2, baseURI, "/endpoints/RecPro", true, "plain/text",
            "POST");
    SiddhiTestHelper.waitForEvents(waitTime, 2, eventCount, timeout);
    logger.info(receivedEventNameList);
    Assert.assertEquals(receivedEventNameList, expected);
    siddhiAppRuntime.shutdown();
}
 
开发者ID:wso2-extensions,项目名称:siddhi-io-http,代码行数:45,代码来源:HttpSourceTestCase.java

示例4: 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

示例5: testCustomPoolConfig

import org.wso2.siddhi.core.SiddhiManager; //导入方法依赖的package包/类
/**
 * Creating test for publishing events with XML mapping.
 * @throws Exception Interrupted exception
 */
@Test
public void testCustomPoolConfig() throws Exception {
    logger.info("Creating test for publishing events with XML mapping.");
    URI baseURI = URI.create(String.format("http://%s:%d", "localhost", 8005));
    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 = "@source(type='http', @map(type='xml'), "
            + "receiver.url='http://localhost:8005/endpoints/RecPro', basic.auth.enabled='false',worker" +
            ".count='8')"
            + "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.httpPublishEvent(event1, baseURI, "/endpoints/RecPro",
            "POST");
    HttpTestUtil.httpPublishEvent(event2, baseURI, "/endpoints/RecPro",
            "POST");
    int waitTime = 50;
    int timeout = 30000;
    SiddhiTestHelper.waitForEvents(waitTime, 2, eventCount, timeout);
    Assert.assertEquals(receivedEventNameList.toString(), expected.toString());
    siddhiAppRuntime.shutdown();
}
 
开发者ID:wso2-extensions,项目名称:siddhi-io-http,代码行数:65,代码来源:HttpCustomThreadPoolConfigTestCase.java

示例6: testCustomConfiguration

import org.wso2.siddhi.core.SiddhiManager; //导入方法依赖的package包/类
/**
 * Creating test for publishing events with XML mapping.
 *
 * @throws Exception Interrupted exception
 */
@Test
public void testCustomConfiguration() throws Exception {
    logger.info("Creating test for publishing events with XML mapping.");
    URI baseURI = URI.create(String.format("http://%s:%d", "localhost", 8005));
    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 = "" + "@source(type='http', @map(type='xml'), "
            + "receiver.url='http://localhost:8005/endpoints/RecPro', " +
            "basic.auth.enabled='false'," +
            "socket.idle.timeout='150000'," +
            "verify.client='require'," +
            "ssl.protocol='TLS'," +
            "tls.store.type='JKS'," +
            "parameters=\"'ciphers : TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256','sslEnabledProtocols : TLSv1.1," +
            "TLSv1.2'\"," +
            "request.size.validation.configurations=\"'header.size.validation:true','header.validation.maximum" +
            ".request.line:4096'\"," +
            "server.bootstrap.configurations=\"'server.bootstrap.nodelay:true','server.bootstrap" +
            ".sendbuffersize:1048576'\")"
            + "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.httpPublishEvent(event1, baseURI, "/endpoints/RecPro",
            "POST");
    HttpTestUtil.httpPublishEvent(event2, baseURI, "/endpoints/RecPro",
            "POST");
    SiddhiTestHelper.waitForEvents(waitTime, 2, eventCount, timeout);
    Assert.assertEquals(receivedEventNameList.toString(), expected.toString());
    siddhiAppRuntime.shutdown();
}
 
开发者ID:wso2-extensions,项目名称:siddhi-io-http,代码行数:75,代码来源:HttpCustomConfigTestCase.java

示例7: testPauseResume

import org.wso2.siddhi.core.SiddhiManager; //导入方法依赖的package包/类
/**
 * Creating test for publishing events with XML mapping.
 *
 * @throws Exception Interrupted exception
 */
@Test
public void testPauseResume() throws Exception {
    logger.info("Creating test for publishing events with XML mapping.");
    URI baseURI = URI.create(String.format("http://%s:%d", "localhost", 8005));
    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 = "" + "@source(type='http', @map(type='xml'), "
            + "receiver.url='http://localhost:8005/endpoints/RecPro', " + "basic.auth.enabled='false'" + ")"
            + "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.httpPublishEvent(event1, baseURI, "/endpoints/RecPro",
            "POST");
    siddhiAppRuntime.restoreLastRevision();
    HttpTestUtil.httpPublishEvent(event2, baseURI, "/endpoints/RecPro",
            "POST");
    SiddhiTestHelper.waitForEvents(waitTime, 2, eventCount, timeout);
    Assert.assertEquals(receivedEventNameList.toString(), expected.toString());
    siddhiAppRuntime.shutdown();
}
 
开发者ID:wso2-extensions,项目名称:siddhi-io-http,代码行数:66,代码来源:HttpCustomConfigTestCase.java

示例8: testXmlMapping

import org.wso2.siddhi.core.SiddhiManager; //导入方法依赖的package包/类
/**
 * Creating test for publishing events with XML mapping.
 * @throws Exception Interrupted exception
 */
@Test
public void testXmlMapping() throws Exception {
    logger.info("Creating test for publishing events with XML mapping.");
    URI baseURI = URI.create(String.format("http://%s:%d", "localhost", 8005));
    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 = "" + "@source(type='http', @map(type='xml'), "
            + "receiver.url='http://localhost:8005/endpoints/RecPro', " + "basic.auth.enabled='false'" + ")"
            + "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.httpPublishEvent(event1, baseURI, "/endpoints/RecPro",
            "POST");
    HttpTestUtil.httpPublishEvent(event2, baseURI, "/endpoints/RecPro",
            "POST");
    SiddhiTestHelper.waitForEvents(waitTime, 2, eventCount, timeout);
    Assert.assertEquals(receivedEventNameList.toString(), expected.toString());
    siddhiAppRuntime.shutdown();
}
 
开发者ID:wso2-extensions,项目名称:siddhi-io-http,代码行数:63,代码来源:HttpSourceMappingTestCase.java

示例9: testTextMappingSingle

import org.wso2.siddhi.core.SiddhiManager; //导入方法依赖的package包/类
/**
 * Creating test for publishing events with Text mapping.
 *
 * @throws Exception Interrupted exception
 */
@Test
public void testTextMappingSingle() throws Exception {
    AtomicInteger eventCount = new AtomicInteger(0);
    int waitTime = 50;
    int timeout = 30000;
    URI baseURI = URI.create(String.format("http://%s:%d", "localhost", 8005));
    List<String> receivedEventNameList = new ArrayList<>(2);
    PersistenceStore persistenceStore = new InMemoryPersistenceStore();
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setPersistenceStore(persistenceStore);
    siddhiManager.setExtension("text", TextSourceMapper.class);
    String inStreamDefinition = "" + "@source(type='http',  @map(type='text'), "
            + "receiver.url='http://localhost:8005/endpoints/RecPro', " + "basic.auth.enabled='false'" + ")"
            + "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 = "name:\'John\',\n" +
            "age:100,\n" +
            "country:\'USA\'";
    String event2 = "name:\'Mike\',\n" +
            "age:100,\n" +
            "country:\'USA\'";
    HttpTestUtil.httpPublishEvent(event1, baseURI, "/endpoints/RecPro",
            "POST");
    HttpTestUtil.httpPublishEvent(event2, baseURI, "/endpoints/RecPro",
            "POST");
    SiddhiTestHelper.waitForEvents(waitTime, 2, eventCount, timeout);
    Assert.assertEquals(receivedEventNameList.toString(), expected.toString());
    siddhiAppRuntime.shutdown();
}
 
开发者ID:wso2-extensions,项目名称:siddhi-io-http,代码行数:59,代码来源:HttpSourceMappingTestCase.java

示例10: testTextMapping

import org.wso2.siddhi.core.SiddhiManager; //导入方法依赖的package包/类
/**
 * Creating test for publishing events with Text mapping.
 * @throws Exception Interrupted exception
 */
@Test
public void testTextMapping() throws Exception {
    logger.info("Creating test for publishing events with Text mapping.");
    URI baseURI = URI.create(String.format("http://%s:%d", "localhost", 8005));
    List<String> receivedEventNameList = new ArrayList<>(2);
    PersistenceStore persistenceStore = new InMemoryPersistenceStore();
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setPersistenceStore(persistenceStore);
    siddhiManager.setExtension("text", TextSourceMapper.class);
    String inStreamDefinition = "" + "@source(type='http',  @map(type='text',fail.on.missing.attribute='false'), "
            + "receiver.url='http://localhost:8005/endpoints/RecPro', " + "basic.auth.enabled='false'" + ")"
            + "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 = "name:\"John\",\n" +
            "age:100,\n" +
            "country:\"USA\"";
    String event2 = "name:\"Mike\",\n" +
            "age:100,\n" +
            "country:\"USA\"";
    HttpTestUtil.httpPublishEvent(event1, baseURI, "/endpoints/RecPro",
            "POST");
    HttpTestUtil.httpPublishEvent(event2, baseURI, "/endpoints/RecPro",
            "POST");
    SiddhiTestHelper.waitForEvents(waitTime, 1, eventCount, timeout);
    Assert.assertEquals(receivedEventNameList.toString(), expected.toString());
    siddhiAppRuntime.shutdown();
}
 
开发者ID:wso2-extensions,项目名称:siddhi-io-http,代码行数:56,代码来源:HttpSourceMappingTestCase.java

示例11: testJsonMapping

import org.wso2.siddhi.core.SiddhiManager; //导入方法依赖的package包/类
/**
 * Creating test for publishing events with Json mapping.
 * @throws Exception Interrupted exception
 */
@Test
public void testJsonMapping() throws Exception {
    logger.info("Creating test for publishing events with Json mapping.");
    URI baseURI = URI.create(String.format("http://%s:%d", "localhost", 8005));
    List<String> receivedEventNameList = new ArrayList<>(2);
    PersistenceStore persistenceStore = new InMemoryPersistenceStore();
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setPersistenceStore(persistenceStore);
    siddhiManager.setExtension("xml-input-mapper", JsonSourceMapper.class);
    String inStreamDefinition = "" + "@source(type='http', @map(type='json'), "
            + "receiver.url='http://localhost:8005/endpoints/RecPro', " + "basic.auth.enabled='false'" + ")"
            + "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 = " {\n" +
            "      \"event\":{\n" +
            "         \"name\":\"John\",\n" +
            "         \"age\":55,\n" +
            "         \"country\":\"US\"\n" +
            "      }\n" +
            " }";
    String event2 = " {\n" +
            "      \"event\":{\n" +
            "         \"name\":\"Mike\",\n" +
            "         \"age\":55,\n" +
            "         \"country\":\"US\"\n" +
            "      }\n" +
            " }";
    HttpTestUtil.httpPublishEvent(event1, baseURI, "/endpoints/RecPro",
            "POST");
    HttpTestUtil.httpPublishEvent(event2, baseURI, "/endpoints/RecPro",
            "POST");
    SiddhiTestHelper.waitForEvents(waitTime, 2, eventCount, timeout);
    Assert.assertEquals(receivedEventNameList.toString(), expected.toString());
    siddhiAppRuntime.shutdown();
}
 
开发者ID:wso2-extensions,项目名称:siddhi-io-http,代码行数:62,代码来源:HttpSourceMappingTestCase.java

示例12: testBasicAuthFalse

import org.wso2.siddhi.core.SiddhiManager; //导入方法依赖的package包/类
/**
 * Creating test for publishing events with basic auth false.
 * @throws Exception Interrupted exception
 */
@Test
public void testBasicAuthFalse() throws Exception {
    logger.info(" Creating test for publishing events with basic auth false.");
    URI baseURI = URI.create(String.format("http://%s:%d", "localhost", 8005));
    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 = "@source(type='http', @map(type='xml'), receiver.url='http://localhost:8005"
            + "/endpoints/RecPro', basic.auth.enabled='false' )"
            + "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.httpPublishEvent(event1, baseURI, "/endpoints/RecPro",
            "POST");
    HttpTestUtil.httpPublishEvent(event2, baseURI, "/endpoints/RecPro",
            "POST");
    SiddhiTestHelper.waitForEvents(waitTime, 2, eventCount, timeout);
    Assert.assertEquals(receivedEventNameList.toString(), expected.toString());
    siddhiAppRuntime.shutdown();
}
 
开发者ID:wso2-extensions,项目名称:siddhi-io-http,代码行数:63,代码来源:HttpSourceBasicAuthTestCase.java

示例13: testBasicAuthTrue

import org.wso2.siddhi.core.SiddhiManager; //导入方法依赖的package包/类
/**
 * Creating test for publishing events with basic auth false.
 * @throws Exception Interrupted exception
 */
@Test
public void testBasicAuthTrue() throws Exception {
    logger.info(" Creating test for publishing events with basic auth false.");
    URI baseURI = URI.create(String.format("http://%s:%d", "localhost", 8005));
    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 = "@source(type='http', @map(type='xml'), receiver.url='http://localhost:8005"
            + "/endpoints/RecPro', basic.auth.enabled='true' )"
            + "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.httpPublishEvent(event1, baseURI, "/endpoints/RecPro",
            "POST");
    HttpTestUtil.httpPublishEvent(event2, baseURI, "/endpoints/RecPro",
            "POST");
    SiddhiTestHelper.waitForEvents(waitTime, 2, eventCount, timeout);
    Assert.assertEquals(receivedEventNameList.toString(), expected.toString());
    siddhiAppRuntime.shutdown();
}
 
开发者ID:wso2-extensions,项目名称:siddhi-io-http,代码行数:63,代码来源:HttpSourceBasicAuthTestCase.java

示例14: testBasicAuthNotProvided

import org.wso2.siddhi.core.SiddhiManager; //导入方法依赖的package包/类
/**
 * Creating test for publishing events with basic auth is not provided.
 * @throws Exception Interrupted exception
 */
@Test
public void testBasicAuthNotProvided() throws Exception {
    logger.info("Creating test for publishing events with basic auth is not provided.");
    URI baseURI = URI.create(String.format("http://%s:%d", "localhost", 8005));
    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 = "@source(type='http', @map(type='xml'), receiver.url='http://localhost:8005"
            + "/endpoints/RecPro' )"
            + "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.httpPublishEvent(event1, baseURI, "/endpoints/RecPro",
            "POST");
    HttpTestUtil.httpPublishEvent(event2, baseURI, "/endpoints/RecPro",
            "POST");
    SiddhiTestHelper.waitForEvents(waitTime, 2, eventCount, timeout);
    Assert.assertEquals(receivedEventNameList.toString(), expected.toString());
    siddhiAppRuntime.shutdown();
}
 
开发者ID:wso2-extensions,项目名称:siddhi-io-http,代码行数:63,代码来源:HttpSourceBasicAuthTestCase.java


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