本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}