use of org.ballerinalang.siddhi.core.util.config.InMemoryConfigManager in project ballerina by ballerina-lang.
the class DefineTableTestCase method testQuery16.
@Test
public void testQuery16() {
log.info("testTableDefinition16 - Table w/ ref");
Map<String, String> systemConfigs = new HashMap<>();
systemConfigs.put("test1.type", "test");
systemConfigs.put("test1.uri", "http://localhost");
InMemoryConfigManager inMemoryConfigManager = new InMemoryConfigManager(null, systemConfigs);
inMemoryConfigManager.extractSystemConfigs("test1");
SiddhiManager siddhiManager = new SiddhiManager();
siddhiManager.setConfigManager(inMemoryConfigManager);
siddhiManager.setExtension("store:test", TestStore.class);
String siddhiApp = "" + "@store(ref='test1')" + "define table testTable (symbol string, price int, volume float); ";
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp);
siddhiAppRuntime.shutdown();
Map<String, String> expectedSystemConfigs = new HashMap<>();
expectedSystemConfigs.put("type", "test");
expectedSystemConfigs.put("uri", "http://localhost");
AssertJUnit.assertEquals("Test store initialization failure", expectedSystemConfigs, TestStore.systemConfigs);
}
use of org.ballerinalang.siddhi.core.util.config.InMemoryConfigManager in project ballerina by ballerina-lang.
the class DefineTableTestCase method testQuery18.
@Test
public void testQuery18() {
log.info("testTableDefinition18 - Table w/ ref and additional properties");
Map<String, String> systemConfigs = new HashMap<>();
systemConfigs.put("test1.type", "test");
systemConfigs.put("test1.uri", "http://localhost");
InMemoryConfigManager inMemoryConfigManager = new InMemoryConfigManager(null, systemConfigs);
inMemoryConfigManager.extractSystemConfigs("test1");
SiddhiManager siddhiManager = new SiddhiManager();
siddhiManager.setConfigManager(inMemoryConfigManager);
siddhiManager.setExtension("store:test", TestStore.class);
String siddhiApp = "" + "@store(ref='test1', uri='http://localhost:8080', table.name ='Foo')" + "define table testTable (symbol string, price int, volume float); ";
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp);
siddhiAppRuntime.shutdown();
Map<String, String> expectedSystemConfigs = new HashMap<>();
expectedSystemConfigs.put("type", "test");
expectedSystemConfigs.put("uri", "http://localhost:8080");
expectedSystemConfigs.put("table.name", "Foo");
AssertJUnit.assertEquals("Test store initialization failure", expectedSystemConfigs, TestStore.systemConfigs);
}
use of org.ballerinalang.siddhi.core.util.config.InMemoryConfigManager in project ballerina by ballerina-lang.
the class DefineTableTestCase method testQuery21.
@Test(expectedExceptions = SiddhiAppCreationException.class)
public void testQuery21() {
log.info("testTableDefinition21 - Table w/ ref to an undefined store type");
Map<String, String> systemConfigs = new HashMap<>();
systemConfigs.put("test1.type", "testdb");
systemConfigs.put("test1.uri", "http://localhost");
InMemoryConfigManager inMemoryConfigManager = new InMemoryConfigManager(null, systemConfigs);
inMemoryConfigManager.extractSystemConfigs("test2");
SiddhiManager siddhiManager = new SiddhiManager();
siddhiManager.setConfigManager(inMemoryConfigManager);
siddhiManager.setExtension("store:test", TestStore.class);
String siddhiApp = "" + "@store(ref='test2', uri='http://localhost:8080', table.name ='Foo')" + "define table testTable (symbol string, price int, volume float); ";
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp);
siddhiAppRuntime.shutdown();
}
use of org.ballerinalang.siddhi.core.util.config.InMemoryConfigManager in project ballerina by ballerina-lang.
the class ExtensionTestCase method extensionTest5.
@Test
public void extensionTest5() throws InterruptedException, ClassNotFoundException {
log.info("extension test5");
SiddhiManager siddhiManager = new SiddhiManager();
Map<String, String> configMap = new HashMap<>();
configMap.put("email.getAllNew.append.abc", "true");
siddhiManager.setConfigManager(new InMemoryConfigManager(configMap, null));
siddhiManager.setExtension("custom:plus", CustomFunctionExtension.class);
siddhiManager.setExtension("email:getAllNew", StringConcatAggregatorString.class);
String cseEventStream = "" + "" + "define stream cseEventStream (symbol string, price float, volume long);";
String query = ("" + "@info(name = 'query1') " + "from cseEventStream " + "select price , email:getAllNew(symbol,'') as toConcat " + "group by volume " + "insert into mailOutput;");
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(cseEventStream + query);
siddhiAppRuntime.addCallback("query1", new QueryCallback() {
@Override
public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
EventPrinter.print(timeStamp, inEvents, removeEvents);
count = count + inEvents.length;
if (count == 3) {
AssertJUnit.assertEquals("WSO2ABC-abc", inEvents[inEvents.length - 1].getData(1));
}
eventArrived = true;
}
});
InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream");
siddhiAppRuntime.start();
inputHandler.send(new Object[] { "IBM", 700f, 100L });
Thread.sleep(100);
inputHandler.send(new Object[] { "WSO2", 60.5f, 200L });
Thread.sleep(100);
inputHandler.send(new Object[] { "ABC", 60.5f, 200L });
Thread.sleep(100);
AssertJUnit.assertEquals(3, count);
AssertJUnit.assertTrue(eventArrived);
siddhiAppRuntime.shutdown();
}
Aggregations