org.wso2.siddhi.core.SiddhiManager

Here are the examples of the java api class org.wso2.siddhi.core.SiddhiManager taken from open source projects.

1. EvalScriptTestCase#testMissingReturnTypeWhileParsing()

Project: siddhi
File: EvalScriptTestCase.java
@Test(expected = SiddhiParserException.class)
public void testMissingReturnTypeWhileParsing() throws InterruptedException {
    log.info("testDefineManyFunctionsAndCallThemRandom");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setExtension("evalscript:javascript", org.wso2.siddhi.extension.evalscript.EvalJavaScript.class);
    siddhiManager.setExtension("evalscript:scala", org.wso2.siddhi.extension.evalscript.EvalScala.class);
    String concatFunc1 = "define function concat[Scala] {\n" + "  var concatenatedString = \"\"\n" + "  for(i <- 0 until data.length) {\n" + "     concatenatedString += data(i).toString\n" + "  }\n" + "  concatenatedString\n" + "};";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(concatFunc1);
    executionPlanRuntime.shutdown();
}

2. EvalScriptTestCase#testWrongBrackets()

Project: siddhi
File: EvalScriptTestCase.java
@Test(expected = SiddhiParserException.class)
public void testWrongBrackets() throws InterruptedException {
    log.info("testDefineManyFunctionsAndCallThemRandom");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setExtension("evalscript:javascript", org.wso2.siddhi.extension.evalscript.EvalJavaScript.class);
    siddhiManager.setExtension("evalscript:scala", org.wso2.siddhi.extension.evalscript.EvalScala.class);
    String concatFunc1 = "define function concat(Scala) return string {\n" + "  var concatenatedString = \"\"\n" + "  for(i <- 0 until data.length) {\n" + "     concatenatedString += data(i).toString\n" + "  }\n" + "  concatenatedString\n" + "};";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(concatFunc1);
    executionPlanRuntime.shutdown();
}

3. EvalScriptTestCase#testMissingBrackets()

Project: siddhi
File: EvalScriptTestCase.java
@Test(expected = SiddhiParserException.class)
public void testMissingBrackets() throws InterruptedException {
    log.info("testDefineManyFunctionsAndCallThemRandom");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setExtension("evalscript:javascript", org.wso2.siddhi.extension.evalscript.EvalJavaScript.class);
    siddhiManager.setExtension("evalscript:scala", org.wso2.siddhi.extension.evalscript.EvalScala.class);
    String concatFunc1 = "define function concat Scala return string {\n" + "  var concatenatedString = \"\"\n" + "  for(i <- 0 until data.length) {\n" + "     concatenatedString += data(i).toString\n" + "  }\n" + "  concatenatedString\n" + "};";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(concatFunc1);
    executionPlanRuntime.shutdown();
}

4. EvalScriptTestCase#testMissingLanguage()

Project: siddhi
File: EvalScriptTestCase.java
@Test(expected = SiddhiParserException.class)
public void testMissingLanguage() throws InterruptedException {
    log.info("testDefineManyFunctionsAndCallThemRandom");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setExtension("evalscript:javascript", org.wso2.siddhi.extension.evalscript.EvalJavaScript.class);
    siddhiManager.setExtension("evalscript:scala", org.wso2.siddhi.extension.evalscript.EvalScala.class);
    String concatFunc1 = "define function concat[] return string {\n" + "  var concatenatedString = \"\"\n" + "  for(i <- 0 until data.length) {\n" + "     concatenatedString += data(i).toString\n" + "  }\n" + "  concatenatedString\n" + "};";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(concatFunc1);
    executionPlanRuntime.shutdown();
}

5. EvalScriptTestCase#testMissingFunctionName()

Project: siddhi
File: EvalScriptTestCase.java
@Test(expected = SiddhiParserException.class)
public void testMissingFunctionName() throws InterruptedException {
    log.info("testDefineManyFunctionsAndCallThemRandom");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setExtension("evalscript:javascript", org.wso2.siddhi.extension.evalscript.EvalJavaScript.class);
    siddhiManager.setExtension("evalscript:scala", org.wso2.siddhi.extension.evalscript.EvalScala.class);
    String concatFunc1 = "define function [Scala] return string {\n" + "  var concatenatedString = \"\"\n" + "  for(i <- 0 until data.length) {\n" + "     concatenatedString += data(i).toString\n" + "  }\n" + "  concatenatedString\n" + "};";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(concatFunc1);
    executionPlanRuntime.shutdown();
}

6. EvalScriptTestCase#testMissingDefineKeyWord()

Project: siddhi
File: EvalScriptTestCase.java
@Test(expected = SiddhiParserException.class)
public void testMissingDefineKeyWord() throws InterruptedException {
    log.info("testDefineManyFunctionsAndCallThemRandom");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setExtension("evalscript:javascript", org.wso2.siddhi.extension.evalscript.EvalJavaScript.class);
    siddhiManager.setExtension("evalscript:scala", org.wso2.siddhi.extension.evalscript.EvalScala.class);
    String concatFunc1 = "function concat[Scala] return string {\n" + "  var concatenatedString = \"\"\n" + "  for(i <- 0 until data.length) {\n" + "     concatenatedString += data(i).toString\n" + "  }\n" + "  concatenatedString\n" + "};";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(concatFunc1);
    executionPlanRuntime.shutdown();
}

7. EvalScriptTestCase#testMissingFunctionKeyWord()

Project: siddhi
File: EvalScriptTestCase.java
@Test(expected = SiddhiParserException.class)
public void testMissingFunctionKeyWord() throws InterruptedException {
    log.info("testDefineManyFunctionsAndCallThemRandom");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setExtension("evalscript:javascript", org.wso2.siddhi.extension.evalscript.EvalJavaScript.class);
    siddhiManager.setExtension("evalscript:scala", org.wso2.siddhi.extension.evalscript.EvalScala.class);
    String concatFunc1 = "define concat[Scala] return string {\n" + "  var concatenatedString = \"\"\n" + "  for(i <- 0 until data.length) {\n" + "     concatenatedString += data(i).toString\n" + "  }\n" + "  concatenatedString\n" + "};";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(concatFunc1);
    executionPlanRuntime.shutdown();
}

8. EvalScriptTestCase#testMissingReturnType()

Project: siddhi
File: EvalScriptTestCase.java
@Test(expected = ExecutionPlanValidationException.class)
public void testMissingReturnType() {
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setExtension("evalscript:javascript", org.wso2.siddhi.extension.evalscript.EvalJavaScript.class);
    siddhiManager.setExtension("evalscript:scala", org.wso2.siddhi.extension.evalscript.EvalScala.class);
    ExecutionPlan.executionPlan("test").defineFunction((new FunctionDefinition().id("concat").language("Scala").body("var concatenatedString = \"\"\n" + "for(i <- 0 until data.length){\n" + "  concatenatedString += data(i).toString\n" + "}\n" + "concatenatedString")));
}

9. EvalScriptTestCase#testJavaScriptCompilationFailure()

Project: siddhi
File: EvalScriptTestCase.java
@Test(expected = ExecutionPlanCreationException.class)
public void testJavaScriptCompilationFailure() throws InterruptedException {
    log.info("testJavaScriptCompilationFailure");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setExtension("evalscript:javascript", org.wso2.siddhi.extension.evalscript.EvalJavaScript.class);
    siddhiManager.setExtension("evalscript:scala", org.wso2.siddhi.extension.evalscript.EvalScala.class);
    String concatFunc = "define function concatJ[JavaScript] return string {\n" + "  var str1 = data[0;\n" + "  var str2 = data[1];\n" + "  var str3 = data[2];\n" + "  var res = str1.concat(str2,str3);\n" + "  return res;\n" + "};";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(concatFunc);
    executionPlanRuntime.shutdown();
}

10. EvalScriptTestCase#testScalaCompilationFailure()

Project: siddhi
File: EvalScriptTestCase.java
@Test(expected = ExecutionPlanCreationException.class)
public void testScalaCompilationFailure() throws InterruptedException {
    log.info("testScalaCompilationFailure");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setExtension("evalscript:javascript", org.wso2.siddhi.extension.evalscript.EvalJavaScript.class);
    siddhiManager.setExtension("evalscript:scala", org.wso2.siddhi.extension.evalscript.EvalScala.class);
    String concatFunc = "define function concat[Scala] return string {\n" + "  for(i <- 0 until data.length){\n" + "  concatenatedString += data(i).toString\n" + "  }\n" + "  concatenatedString\n" + "}";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(concatFunc);
    executionPlanRuntime.shutdown();
}

11. ValidateTestCase#ValidateTest2()

Project: siddhi
File: ValidateTestCase.java
@Test(expected = ExecutionPlanValidationException.class)
public void ValidateTest2() throws InterruptedException {
    log.info("validate test2");
    SiddhiManager siddhiManager = new SiddhiManager();
    String executionPlan = "" + "@Plan:name('validateTest') " + "" + "define stream cseEventStream (symbol string, price float, volume long);" + "" + "@info(name = 'query1') " + "from cseEventStreamA[symbol is null] " + "select symbol, price " + "insert into outputStream;";
    siddhiManager.validateExecutionPlan(executionPlan);
}

12. ValidateTestCase#ValidateTest1()

Project: siddhi
File: ValidateTestCase.java
@Test
public void ValidateTest1() throws InterruptedException {
    log.info("validate test1");
    SiddhiManager siddhiManager = new SiddhiManager();
    String executionPlan = "" + "@Plan:name('validateTest') " + "" + "define stream cseEventStream (symbol string, price float, volume long);" + "" + "@info(name = 'query1') " + "from cseEventStream[symbol is null] " + "select symbol, price " + "insert into outputStream;";
    siddhiManager.validateExecutionPlan(executionPlan);
}

13. DefineTableTestCase#testQuery8()

Project: siddhi
File: DefineTableTestCase.java
@Test(expected = SiddhiParserException.class)
public void testQuery8() throws InterruptedException {
    log.info("testTableDefinition8 - OUT 0");
    SiddhiManager siddhiManager = new SiddhiManager();
    String executionPlan = "" + "define stream StockStream(symbol string, price int, volume float);" + "" + "from StockStream " + "select symbol, price, volume " + "insert into OutputStream;" + "" + "define table OutputStream (symbol string, price float, volume long); ";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(executionPlan);
    executionPlanRuntime.shutdown();
}

14. DefineTableTestCase#testQuery1()

Project: siddhi
File: DefineTableTestCase.java
@Test
public void testQuery1() throws InterruptedException {
    log.info("testTableDefinition1 - OUT 0");
    SiddhiManager siddhiManager = new SiddhiManager();
    TableDefinition tableDefinition = TableDefinition.id("cseEventStream").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.INT);
    ExecutionPlan executionPlan = new ExecutionPlan("ep1");
    executionPlan.defineTable(tableDefinition);
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(executionPlan);
    executionPlanRuntime.shutdown();
}

15. TriggerTestCase#testQuery4()

Project: siddhi
File: TriggerTestCase.java
@Test
public void testQuery4() throws InterruptedException {
    log.info("testTrigger4 - OUT 0");
    SiddhiManager siddhiManager = new SiddhiManager();
    String streams = "" + "define stream StockStream (triggered_time long); " + "define trigger StockStream at 'start' ";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(streams);
    executionPlanRuntime.start();
    executionPlanRuntime.shutdown();
}

16. TriggerTestCase#testQuery3()

Project: siddhi
File: TriggerTestCase.java
@Test(expected = DuplicateDefinitionException.class)
public void testQuery3() throws InterruptedException {
    log.info("testTrigger3 - OUT 0");
    SiddhiManager siddhiManager = new SiddhiManager();
    String streams = "" + "define stream StockStream (symbol string, price float, volume long); " + "define trigger StockStream at 'start' ";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(streams);
    executionPlanRuntime.start();
    executionPlanRuntime.shutdown();
}

17. TriggerTestCase#testQuery2()

Project: siddhi
File: TriggerTestCase.java
@Test(expected = ExecutionPlanValidationException.class)
public void testQuery2() throws InterruptedException {
    log.info("testTrigger2 - OUT 0");
    SiddhiManager siddhiManager = new SiddhiManager();
    TriggerDefinition triggerDefinition = TriggerDefinition.id("cseEventStream").atEvery(Expression.Time.milliSec(500)).at("start");
    ExecutionPlan executionPlan = new ExecutionPlan("ep1");
    executionPlan.defineTrigger(triggerDefinition);
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(executionPlan);
    executionPlanRuntime.shutdown();
}

18. TriggerTestCase#testQuery1()

Project: siddhi
File: TriggerTestCase.java
@Test
public void testQuery1() throws InterruptedException {
    log.info("testTrigger1 - OUT 0");
    SiddhiManager siddhiManager = new SiddhiManager();
    TriggerDefinition triggerDefinition = TriggerDefinition.id("cseEventStream").atEvery(Expression.Time.milliSec(500));
    ExecutionPlan executionPlan = new ExecutionPlan("ep1");
    executionPlan.defineTrigger(triggerDefinition);
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(executionPlan);
    executionPlanRuntime.shutdown();
}

19. DefineTableTestCase#testQuery15()

Project: siddhi
File: DefineTableTestCase.java
@Test(expected = ExecutionPlanValidationException.class)
public void testQuery15() throws InterruptedException {
    log.info("testTableDefinition15 - OUT 0");
    SiddhiManager siddhiManager = new SiddhiManager();
    String executionPlan = "" + "define stream StockStream(symbol string, price int, volume float);" + "define table OutputStream (symbol string, price int, volume float); " + "" + "from OutputStream " + "select symbol, price, volume " + "insert into StockStream;";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(executionPlan);
    executionPlanRuntime.shutdown();
}

20. DefineTableTestCase#testQuery14()

Project: siddhi
File: DefineTableTestCase.java
@Test(expected = DuplicateDefinitionException.class)
public void testQuery14() throws InterruptedException {
    log.info("testTableDefinition14 - OUT 0");
    SiddhiManager siddhiManager = new SiddhiManager();
    String executionPlan = "" + "define stream StockStream(symbol string, price int, volume float);" + "define table OutputStream (symbol string, price int, volume int); " + "" + "from StockStream " + "select * " + "insert into OutputStream;";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(executionPlan);
    executionPlanRuntime.shutdown();
}

21. DefineTableTestCase#testQuery13()

Project: siddhi
File: DefineTableTestCase.java
@Test(expected = DuplicateDefinitionException.class)
public void testQuery13() throws InterruptedException {
    log.info("testTableDefinition13 - OUT 0");
    SiddhiManager siddhiManager = new SiddhiManager();
    String executionPlan = "" + "define stream StockStream(symbol string, price int, volume float);" + "define table OutputStream (symbol string, price int, volume float, time long); " + "" + "from StockStream " + "select * " + "insert into OutputStream;";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(executionPlan);
    executionPlanRuntime.shutdown();
}

22. DefineTableTestCase#testQuery12()

Project: siddhi
File: DefineTableTestCase.java
@Test
public void testQuery12() throws InterruptedException {
    log.info("testTableDefinition12 - OUT 0");
    SiddhiManager siddhiManager = new SiddhiManager();
    String executionPlan = "" + "define stream StockStream(symbol string, price int, volume float);" + "define table OutputStream (symbol string, price int, volume float); " + "" + "from StockStream " + "select * " + "insert into OutputStream;";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(executionPlan);
    executionPlanRuntime.shutdown();
}

23. DefineTableTestCase#testQuery11()

Project: siddhi
File: DefineTableTestCase.java
@Test
public void testQuery11() throws InterruptedException {
    log.info("testTableDefinition11 - OUT 0");
    SiddhiManager siddhiManager = new SiddhiManager();
    String executionPlan = "" + "define stream StockStream(symbol string, price int, volume float);" + "define table OutputStream (symbol string, price int, volume float); " + "" + "from StockStream " + "select symbol, price, volume " + "insert into OutputStream;";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(executionPlan);
    executionPlanRuntime.shutdown();
}

24. DefineTableTestCase#testQuery10()

Project: siddhi
File: DefineTableTestCase.java
@Test(expected = DuplicateDefinitionException.class)
public void testQuery10() throws InterruptedException {
    log.info("testTableDefinition10 - OUT 0");
    SiddhiManager siddhiManager = new SiddhiManager();
    String executionPlan = "" + "define stream StockStream(symbol string, price int, volume float); " + "define table OutputStream (symbol string, price float, volume long);" + "" + "from StockStream " + "select symbol, price " + "insert into OutputStream;";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(executionPlan);
    executionPlanRuntime.shutdown();
}

25. DefineTableTestCase#testQuery9()

Project: siddhi
File: DefineTableTestCase.java
@Test(expected = DuplicateDefinitionException.class)
public void testQuery9() throws InterruptedException {
    log.info("testTableDefinition9 - OUT 0");
    SiddhiManager siddhiManager = new SiddhiManager();
    String executionPlan = "" + "define stream StockStream(symbol string, price int, volume float);" + "define table OutputStream (symbol string, price float, volume long); " + "" + "from StockStream " + "select symbol, price, volume " + "insert into OutputStream;";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(executionPlan);
    executionPlanRuntime.shutdown();
}

26. DefineTableTestCase#testQuery17()

Project: siddhi
File: DefineTableTestCase.java
@Test
public void testQuery17() throws InterruptedException {
    log.info("testTableDefinition17 - OUT 0");
    String clusterName = "siddhi_cluster_t17";
    SiddhiManager siddhiManager = new SiddhiManager();
    String tables = "" + "@from(eventtable = 'hazelcast', cluster.name = '" + clusterName + "')" + "define table EventTable(symbol string, price int, volume float) ";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(tables);
    try {
        Map<String, HazelcastInstance> instanceMap = new HashMap<String, HazelcastInstance>();
        for (HazelcastInstance hci : Hazelcast.getAllHazelcastInstances()) {
            instanceMap.put(hci.getName(), hci);
        }
        Assert.assertTrue(instanceMap.containsKey(HazelcastEventTableConstants.HAZELCAST_INSTANCE_PREFIX + executionPlanRuntime.getName()));
        HazelcastInstance instance = instanceMap.get(HazelcastEventTableConstants.HAZELCAST_INSTANCE_PREFIX + executionPlanRuntime.getName());
        Assert.assertEquals(clusterName, instance.getConfig().getGroupConfig().getName());
    } finally {
        executionPlanRuntime.shutdown();
    }
}

27. DefineTableTestCase#testQuery16()

Project: siddhi
File: DefineTableTestCase.java
@Test(expected = ExecutionPlanValidationException.class)
public void testQuery16() throws InterruptedException {
    log.info("testTableDefinition16 - OUT 0");
    SiddhiManager siddhiManager = new SiddhiManager();
    String executionPlan = "" + "define stream StockStream(symbol string, price int, volume float);" + "@from(eventtable = 'hazelcast')" + "define table OutputStream (symbol string, price int, volume float); " + "" + "from OutputStream " + "select symbol, price, volume " + "insert into StockStream;";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(executionPlan);
    executionPlanRuntime.shutdown();
}

28. DefineTableTestCase#testQuery15()

Project: siddhi
File: DefineTableTestCase.java
@Test(expected = DuplicateDefinitionException.class)
public void testQuery15() throws InterruptedException {
    log.info("testTableDefinition15 - OUT 0");
    SiddhiManager siddhiManager = new SiddhiManager();
    String executionPlan = "" + "define stream StockStream(symbol string, price int, volume float);" + "@from(eventtable = 'hazelcast')" + "define table OutputStream (symbol string, price int, volume int); " + "" + "from StockStream " + "select * " + "insert into OutputStream;";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(executionPlan);
    executionPlanRuntime.shutdown();
}

29. DefineTableTestCase#testQuery14()

Project: siddhi
File: DefineTableTestCase.java
@Test(expected = DuplicateDefinitionException.class)
public void testQuery14() throws InterruptedException {
    log.info("testTableDefinition14 - OUT 0");
    SiddhiManager siddhiManager = new SiddhiManager();
    String executionPlan = "" + "define stream StockStream(symbol string, price int, volume float);" + "@from(eventtable = 'hazelcast')" + "define table OutputStream (symbol string, price int, volume float, time long); " + "" + "from StockStream " + "select * " + "insert into OutputStream;";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(executionPlan);
    executionPlanRuntime.shutdown();
}

30. DefineTableTestCase#testQuery13()

Project: siddhi
File: DefineTableTestCase.java
@Test
public void testQuery13() throws InterruptedException {
    log.info("testTableDefinition13 - OUT 0");
    SiddhiManager siddhiManager = new SiddhiManager();
    String executionPlan = "" + "define stream StockStream(symbol string, price int, volume float);" + "@from(eventtable = 'hazelcast')" + "define table OutputStream (symbol string, price int, volume float); " + "" + "from StockStream " + "select * " + "insert into OutputStream;";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(executionPlan);
    executionPlanRuntime.shutdown();
}

31. DefineTableTestCase#testQuery12()

Project: siddhi
File: DefineTableTestCase.java
@Test
public void testQuery12() throws InterruptedException {
    log.info("testTableDefinition12 - OUT 0");
    SiddhiManager siddhiManager = new SiddhiManager();
    String executionPlan = "" + "define stream StockStream(symbol string, price int, volume float);" + "@from(eventtable = 'hazelcast')" + "define table OutputStream (symbol string, price int, volume float); " + "" + "from StockStream " + "select symbol, price, volume " + "insert into OutputStream;";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(executionPlan);
    executionPlanRuntime.shutdown();
}

32. DefineTableTestCase#testQuery11()

Project: siddhi
File: DefineTableTestCase.java
@Test(expected = DuplicateDefinitionException.class)
public void testQuery11() throws InterruptedException {
    log.info("testTableDefinition11 - OUT 0");
    SiddhiManager siddhiManager = new SiddhiManager();
    String executionPlan = "" + "define stream StockStream(symbol string, price int, volume float); " + "@from(eventtable = 'hazelcast')" + "define table OutputStream (symbol string, price float, volume long);" + "" + "from StockStream " + "select symbol, price " + "insert into OutputStream;";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(executionPlan);
    executionPlanRuntime.shutdown();
}

33. DefineTableTestCase#testQuery10()

Project: siddhi
File: DefineTableTestCase.java
@Test(expected = DuplicateDefinitionException.class)
public void testQuery10() throws InterruptedException {
    log.info("testTableDefinition10 - OUT 0");
    SiddhiManager siddhiManager = new SiddhiManager();
    String executionPlan = "" + "define stream StockStream(symbol string, price int, volume float);" + "@from(eventtable = 'hazelcast')" + "define table OutputStream (symbol string, price float, volume long); " + "" + "from StockStream " + "select symbol, price, volume " + "insert into OutputStream;";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(executionPlan);
    executionPlanRuntime.shutdown();
}

34. DefineTableTestCase#testQuery9()

Project: siddhi
File: DefineTableTestCase.java
@Test(expected = SiddhiParserException.class)
public void testQuery9() throws InterruptedException {
    log.info("testTableDefinition9 - OUT 0");
    SiddhiManager siddhiManager = new SiddhiManager();
    String executionPlan = "" + "define stream StockStream(symbol string, price int, volume float);" + "" + "from StockStream " + "select symbol, price, volume " + "insert into OutputStream;" + "" + "@from(eventtable = 'hazelcast')" + "define table OutputStream (symbol string, price float, volume long); ";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(executionPlan);
    executionPlanRuntime.shutdown();
}

35. DefineTableTestCase#testQuery8()

Project: siddhi
File: DefineTableTestCase.java
@Test(expected = DuplicateDefinitionException.class)
public void testQuery8() throws InterruptedException {
    log.info("testTableDefinition8 - OUT 0");
    SiddhiManager siddhiManager = new SiddhiManager();
    String definitions = "" + "@from(eventtable = 'hazelcast')" + "define table TestEventTable(symbol string, price int, volume float); " + "define stream TestEventTable(symbol string, price int, volume float); ";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(definitions);
    executionPlanRuntime.shutdown();
}

36. DefineTableTestCase#testQuery7()

Project: siddhi
File: DefineTableTestCase.java
@Test(expected = DuplicateDefinitionException.class)
public void testQuery7() throws InterruptedException {
    log.info("testTableDefinition7 - OUT 0");
    SiddhiManager siddhiManager = new SiddhiManager();
    String definitions = "" + "define stream TestEventTable(symbol string, price int, volume float); " + "@from(eventtable = 'hazelcast')" + "define table TestEventTable(symbol string, price int, volume float); ";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(definitions);
    executionPlanRuntime.shutdown();
}

37. DefineTableTestCase#testQuery6()

Project: siddhi
File: DefineTableTestCase.java
@Test
public void testQuery6() throws InterruptedException {
    log.info("testTableDefinition6 - OUT 0");
    SiddhiManager siddhiManager = new SiddhiManager();
    String tables = "" + "@from(eventtable = 'hazelcast')" + "define table TestEventTable(symbol string, price int, volume float); " + "@from(eventtable = 'hazelcast')" + "define table TestEventTable(symbol string, price int, volume float); ";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(tables);
    try {
        List<String> hciNames = new ArrayList<String>();
        for (HazelcastInstance hci : Hazelcast.getAllHazelcastInstances()) {
            hciNames.add(hci.getName());
        }
        Assert.assertTrue(hciNames.contains(HazelcastEventTableConstants.HAZELCAST_INSTANCE_PREFIX + executionPlanRuntime.getName()));
    } finally {
        executionPlanRuntime.shutdown();
    }
}

38. DefineTableTestCase#testQuery5()

Project: siddhi
File: DefineTableTestCase.java
@Test(expected = DuplicateDefinitionException.class)
public void testQuery5() throws InterruptedException {
    log.info("testTableDefinition5 - OUT 0");
    SiddhiManager siddhiManager = new SiddhiManager();
    String tables = "" + "@from(eventtable = 'hazelcast')" + "define table TestEventTable(symbol string, volume float); " + "@from(eventtable = 'hazelcast')" + "define table TestEventTable(symbols string, price int, volume float); ";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(tables);
    executionPlanRuntime.shutdown();
}

39. DefineTableTestCase#testQuery4()

Project: siddhi
File: DefineTableTestCase.java
@Test(expected = DuplicateDefinitionException.class)
public void testQuery4() throws InterruptedException {
    log.info("testTableDefinition4 - OUT 0");
    SiddhiManager siddhiManager = new SiddhiManager();
    String tables = "" + "@from(eventtable = 'hazelcast')" + "define table TestEventTable(symbol string, price int, volume float); " + "@from(eventtable = 'hazelcast')" + "define table TestEventTable(symbols string, price int, volume float); ";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(tables);
    executionPlanRuntime.shutdown();
}

40. DefineTableTestCase#testQuery3()

Project: siddhi
File: DefineTableTestCase.java
@Test
public void testQuery3() throws InterruptedException {
    log.info("testTableDefinition3 - OUT 0");
    SiddhiManager siddhiManager = new SiddhiManager();
    String tables = "" + "@from(eventtable = 'hazelcast')" + "define table EventTable(symbol string, price int, volume float) ";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(tables);
    try {
        List<String> hciNames = new ArrayList<String>();
        for (HazelcastInstance hci : Hazelcast.getAllHazelcastInstances()) {
            hciNames.add(hci.getName());
        }
        Assert.assertTrue(hciNames.contains(HazelcastEventTableConstants.HAZELCAST_INSTANCE_PREFIX + executionPlanRuntime.getName()));
    } finally {
        executionPlanRuntime.shutdown();
    }
}

41. DefineTableTestCase#testQuery1()

Project: siddhi
File: DefineTableTestCase.java
@Test
public void testQuery1() throws InterruptedException {
    log.info("testTableDefinition1 - OUT 0");
    SiddhiManager siddhiManager = new SiddhiManager();
    TableDefinition tableDefinition = TableDefinition.id("cseEventStream").annotation(Annotation.annotation("from").element("eventtable", "hazelcast")).attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.INT);
    ExecutionPlan executionPlan = new ExecutionPlan("ep1");
    executionPlan.defineTable(tableDefinition);
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(executionPlan);
    try {
        List<String> hciNames = new ArrayList<String>();
        for (HazelcastInstance hci : Hazelcast.getAllHazelcastInstances()) {
            hciNames.add(hci.getName());
        }
        Assert.assertTrue(hciNames.contains(HazelcastEventTableConstants.HAZELCAST_INSTANCE_PREFIX + executionPlanRuntime.getName()));
    } finally {
        executionPlanRuntime.shutdown();
    }
}

42. ExceptionHandlerTestCase#createTestExecutionRuntime()

Project: siddhi
File: ExceptionHandlerTestCase.java
private ExecutionPlanRuntime createTestExecutionRuntime() {
    siddhiManager = new SiddhiManager();
    String executionPlan = "" + "@Plan:name('callbackTest1') " + "@Plan:async " + "" + "define stream StockStream (symbol string, price float, volume long);" + "" + "@info(name = 'query1') " + "@Parallel " + "from StockStream[price + 0.0 > 0.0] " + "select symbol, price " + "insert into outputStream;";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(executionPlan);
    executionPlanRuntime.addCallback("outputStream", new StreamCallback() {

        @Override
        public void receive(Event[] events) {
            EventPrinter.print(events);
            count.addAndGet(events.length);
            eventArrived = true;
        }
    });
    return executionPlanRuntime;
}

43. OuterJoinTestCase#joinTest5()

Project: siddhi
File: OuterJoinTestCase.java
@Test(expected = ExecutionPlanValidationException.class)
public void joinTest5() throws InterruptedException {
    log.info("Outer Join test5");
    SiddhiManager siddhiManager = new SiddhiManager();
    String streams = "define stream cseEventStream (symbol string, price float, volume int); " + "define stream twitterStream (user string, tweet string, symbol string); ";
    String query = "@info(name = 'query1') " + "from cseEventStream#window.time(1 sec) full outer join twitterStream#window.time(1 sec) " + "on cseEventStream.symbol== twitterStream.symbol " + "select * " + "insert into outputStream ;";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(streams + query);
    executionPlanRuntime.start();
    executionPlanRuntime.shutdown();
}

44. OuterJoinTestCase#joinTest4()

Project: siddhi
File: OuterJoinTestCase.java
@Test(expected = SiddhiParserException.class)
public void joinTest4() throws InterruptedException {
    log.info("Outer Join test4");
    SiddhiManager siddhiManager = new SiddhiManager();
    String streams = "define stream cseEventStream (symbol string, price float, volume int); " + "define stream twitterStream (user string, tweet string, symbol string); ";
    String query = "@info(name = 'query1') " + "from cseEventStream#window.time(1 sec) outer join twitterStream#window.time(1 sec) " + "on cseEventStream.symbol== twitterStream.symbol " + "select * " + "insert into outputStream ;";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(streams + query);
    executionPlanRuntime.start();
    executionPlanRuntime.shutdown();
}

45. JoinTestCase#joinTest13()

Project: siddhi
File: JoinTestCase.java
@Test(expected = ExecutionPlanValidationException.class)
public void joinTest13() throws InterruptedException {
    log.info("Join test13");
    SiddhiManager siddhiManager = new SiddhiManager();
    String streams = "" + "define stream cseEventStream (symbol string, price float, volume int); " + "define stream twitterStream (user string, tweet string, symbol string); ";
    String query = "" + "@info(name = 'query1') " + "from cseEventStream#window.time(1 sec) join twitterStream#window.time(1 sec) " + "on cseEventStream.symbol== twitterStream.symbol " + "select * " + "insert into outputStream ;";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(streams + query);
    try {
        executionPlanRuntime.start();
    } finally {
        executionPlanRuntime.shutdown();
    }
}

46. JoinTestCase#joinTest7()

Project: siddhi
File: JoinTestCase.java
@Test(expected = ExecutionPlanValidationException.class)
public void joinTest7() throws InterruptedException {
    log.info("Join test7");
    SiddhiManager siddhiManager = new SiddhiManager();
    String streams = "" + "define stream cseEventStream (symbol string, price float, volume int); " + "define stream twitterStream (user string, tweet string, symbol string); ";
    String query = "" + "@info(name = 'query1') " + "from cseEventStream as a join twitterStream as b " + "select a.symbol, twitterStream.tweet, a.price " + "insert all events into outputStream ;";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(streams + query);
    executionPlanRuntime.shutdown();
}

47. JoinTestCase#joinTest6()

Project: siddhi
File: JoinTestCase.java
@Test(expected = ExecutionPlanValidationException.class)
public void joinTest6() throws InterruptedException {
    log.info("Join test6");
    SiddhiManager siddhiManager = new SiddhiManager();
    String streams = "" + "define stream cseEventStream (symbol string, price float, volume int); " + "define stream twitterStream (user string, tweet string, symbol string); ";
    String query = "" + "@info(name = 'query1') " + "from cseEventStream join twitterStream " + "select symbol, twitterStream.tweet, cseEventStream.price " + "insert all events into outputStream ;";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(streams + query);
    executionPlanRuntime.shutdown();
}

48. MinimumFunctionExtensionTestCase#testMinFunctionExtension2()

Project: siddhi
File: MinimumFunctionExtensionTestCase.java
@Test(expected = ExecutionPlanValidationException.class)
public void testMinFunctionExtension2() throws InterruptedException {
    log.info("MinimumFunctionExecutor TestCase 2");
    SiddhiManager siddhiManager = new SiddhiManager();
    String inStreamDefinition = "define stream inputStream (price1 int,price2 double, price3 double);";
    String query = ("@info(name = 'query1') from inputStream " + "select minimum(price1, price2, price3) as min " + "insert into outputStream;");
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(inStreamDefinition + query);
    executionPlanRuntime.shutdown();
}

49. FilterTestCase#testFilterQuery49()

Project: siddhi
File: FilterTestCase.java
@Test(expected = ExecutionPlanValidationException.class)
public void testFilterQuery49() throws InterruptedException {
    log.info("Filter test49");
    SiddhiManager siddhiManager = new SiddhiManager();
    StreamDefinition cseEventStream = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.FLOAT).attribute("available", Attribute.Type.BOOL);
    Query query = new Query();
    query.from(InputStream.stream("cseEventStream").filter(Expression.variable("price")));
    query.annotation(Annotation.annotation("info").element("name", "query1"));
    query.select(Selector.selector().select("symbol", Expression.variable("symbol")).select("price", Expression.variable("price")).select("available", Expression.variable("available")));
    query.insertInto("StockQuote");
    ExecutionPlan executionPlan = new ExecutionPlan("ep1");
    executionPlan.defineStream(cseEventStream);
    executionPlan.addQuery(query);
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(executionPlan);
}

50. FilterTestCase#testFilterQuery48()

Project: siddhi
File: FilterTestCase.java
@Test(expected = ExecutionPlanValidationException.class)
public void testFilterQuery48() throws InterruptedException {
    log.info("Filter test48");
    SiddhiManager siddhiManager = new SiddhiManager();
    StreamDefinition cseEventStream = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.FLOAT).attribute("available", Attribute.Type.BOOL);
    Query query = new Query();
    query.from(InputStream.stream("cseEventStream").filter(Expression.not(Expression.variable("price"))));
    query.annotation(Annotation.annotation("info").element("name", "query1"));
    query.select(Selector.selector().select("symbol", Expression.variable("symbol")).select("price", Expression.variable("price")).select("available", Expression.variable("available")));
    query.insertInto("StockQuote");
    ExecutionPlan executionPlan = new ExecutionPlan("ep1");
    executionPlan.defineStream(cseEventStream);
    executionPlan.addQuery(query);
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(executionPlan);
}

51. TestSiddhiStateSnapshotAndRestore#setupRuntimeForInternalTimeSlideWindowWithGroupby()

Project: incubator-eagle
File: TestSiddhiStateSnapshotAndRestore.java
private ExecutionPlanRuntime setupRuntimeForInternalTimeSlideWindowWithGroupby() {
    SiddhiManager siddhiManager = new SiddhiManager();
    String cseEventStream = "define stream testStream (user string, cmd string);";
    String query = "@info(name = 'query1') from testStream[cmd == 'open']#window.time(5 sec)" + " select user, count(user) as cnt" + " group by user" + " having cnt > 2" + " insert events into outputStream;";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime("@Plan:name('testPlan') " + cseEventStream + query);
    executionPlanRuntime.addCallback("query1", new QueryCallback() {

        @Override
        public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
            EventPrinter.print(timeStamp, inEvents, removeEvents);
        }
    });
    executionPlanRuntime.start();
    return executionPlanRuntime;
}

52. TestSiddhiStateSnapshotAndRestore#setupRuntimeForExternalTimeSlideWindowWithGroupby()

Project: incubator-eagle
File: TestSiddhiStateSnapshotAndRestore.java
private ExecutionPlanRuntime setupRuntimeForExternalTimeSlideWindowWithGroupby() {
    SiddhiManager siddhiManager = new SiddhiManager();
    String cseEventStream = "define stream testStream (timeStamp long, user string, cmd string);";
    String query = "@info(name = 'query1') from testStream[cmd == 'open']#window.externalTime(timeStamp,30 sec)" + " select user, timeStamp, count(user) as cnt" + " group by user" + " having cnt > 2" + " insert all events into outputStream;";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime("@Plan:name('testPlan') " + cseEventStream + query);
    executionPlanRuntime.addCallback("query1", new QueryCallback() {

        @Override
        public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
            EventPrinter.print(timeStamp, inEvents, removeEvents);
        }
    });
    executionPlanRuntime.start();
    return executionPlanRuntime;
}

53. TestSiddhiStateSnapshotAndRestore#setupRuntimeForTimeSlideWindow()

Project: incubator-eagle
File: TestSiddhiStateSnapshotAndRestore.java
private ExecutionPlanRuntime setupRuntimeForTimeSlideWindow() {
    SiddhiManager siddhiManager = new SiddhiManager();
    String cseEventStream = "define stream testStream (timeStamp long, user string, cmd string);";
    String query = "@info(name = 'query1') from testStream[cmd == 'open']#window.externalTime(timeStamp,3 sec)" + " select user, timeStamp " + "insert all events into outputStream;";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime("@Plan:name('testPlan') " + cseEventStream + query);
    executionPlanRuntime.addCallback("query1", new QueryCallback() {

        @Override
        public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
            EventPrinter.print(timeStamp, inEvents, removeEvents);
        }
    });
    executionPlanRuntime.start();
    return executionPlanRuntime;
}

54. TestSiddhiStateSnapshotAndRestore#setupRuntimeForLengthSlideWindowWithGroupby()

Project: incubator-eagle
File: TestSiddhiStateSnapshotAndRestore.java
private ExecutionPlanRuntime setupRuntimeForLengthSlideWindowWithGroupby() {
    SiddhiManager siddhiManager = new SiddhiManager();
    String cseEventStream = "define stream testStream (user string, cmd string);";
    String query = "@info(name = 'query1') from testStream#window.length(50) " + " select user, cmd, count(user) as cnt" + " insert all events into OutputStream";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime("@Plan:name('testPlan') " + cseEventStream + query);
    executionPlanRuntime.addCallback("query1", new QueryCallback() {

        @Override
        public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
            EventPrinter.print(timeStamp, inEvents, removeEvents);
        }
    });
    executionPlanRuntime.start();
    return executionPlanRuntime;
}

55. TestSiddhiStateSnapshotAndRestore#setupRuntimeForLengthSlideWindow()

Project: incubator-eagle
File: TestSiddhiStateSnapshotAndRestore.java
private ExecutionPlanRuntime setupRuntimeForLengthSlideWindow() {
    SiddhiManager siddhiManager = new SiddhiManager();
    String cseEventStream = "define stream testStream (user string, cmd string);";
    String query = "@info(name = 'query1') from testStream#window.length(3) " + " select *" + " insert all events into OutputStream";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime("@Plan:name('testPlan') " + cseEventStream + query);
    executionPlanRuntime.addCallback("query1", new QueryCallback() {

        @Override
        public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
            EventPrinter.print(timeStamp, inEvents, removeEvents);
        }
    });
    executionPlanRuntime.start();
    return executionPlanRuntime;
}

56. TestSiddhiStateSnapshotAndRestore#setupRuntimeForSimple()

Project: incubator-eagle
File: TestSiddhiStateSnapshotAndRestore.java
private ExecutionPlanRuntime setupRuntimeForSimple() {
    SiddhiManager siddhiManager = new SiddhiManager();
    String cseEventStream = "" + "define stream testStream (cmd string, src string) ;";
    String queryString = "" + "@info(name = 'query1') " + "from testStream[(cmd == 'rename') and (src == '/tmp/pii')] " + "select cmd, src " + "insert into outputStream ;";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime("@Plan:name('testPlan') " + cseEventStream + queryString);
    QueryCallback callback = new QueryCallback() {

        @Override
        public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
            EventPrinter.print(timeStamp, inEvents, removeEvents);
        }
    };
    executionPlanRuntime.addCallback("query1", callback);
    executionPlanRuntime.start();
    return executionPlanRuntime;
}

57. StreamingSiddhiConfiguration#siddhiManager()

Project: Decision
File: StreamingSiddhiConfiguration.java
@Bean(destroyMethod = "shutdown")
public SiddhiManager siddhiManager() {
    SiddhiConfiguration conf = new SiddhiConfiguration();
    conf.setInstanceIdentifier("StratioStreamingCEP-Instance-" + UUID.randomUUID().toString());
    conf.setQueryPlanIdentifier(QUERY_PLAN_IDENTIFIER);
    conf.setDistributedProcessing(false);
    @SuppressWarnings("rawtypes") List<Class> extensions = new ArrayList<>();
    extensions.add(DistinctWindowExtension.class);
    conf.setSiddhiExtensions(extensions);
    // Create Siddhi Manager
    SiddhiManager siddhiManager = new SiddhiManager(conf);
    return siddhiManager;
}

58. ExtensionSample#main()

Project: siddhi
File: ExtensionSample.java
public static void main(String[] args) throws InterruptedException {
    // Creating Siddhi Manager
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setExtension("custom:plus", CustomFunctionExtension.class);
    String executionPlan = "" + "define stream cseEventStream (symbol string, price long, volume long);" + "" + "@info(name = 'query1') " + "from cseEventStream " + "select symbol , custom:plus(price,volume) as totalCount " + "insert into Output;";
    //Generating runtime
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(executionPlan);
    //Adding callback to retrieve output events from query
    executionPlanRuntime.addCallback("query1", new QueryCallback() {

        @Override
        public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
            EventPrinter.print(timeStamp, inEvents, removeEvents);
        }
    });
    //Retrieving InputHandler to push events into Siddhi
    InputHandler inputHandler = executionPlanRuntime.getInputHandler("cseEventStream");
    //Starting event processing
    executionPlanRuntime.start();
    //Sending events to Siddhi
    inputHandler.send(new Object[] { "IBM", 700l, 100l });
    inputHandler.send(new Object[] { "WSO2", 605l, 200l });
    inputHandler.send(new Object[] { "GOOG", 60l, 200l });
    Thread.sleep(500);
    //Shutting down the runtime
    executionPlanRuntime.shutdown();
    //Shutting down Siddhi
    siddhiManager.shutdown();
}

59. EvalScriptTestCase#testUseUndefinedFunction()

Project: siddhi
File: EvalScriptTestCase.java
@Test(expected = ExecutionPlanValidationException.class)
public void testUseUndefinedFunction() throws InterruptedException {
    log.info("testUseUndefinedFunction");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setExtension("evalscript:javascript", org.wso2.siddhi.extension.evalscript.EvalJavaScript.class);
    siddhiManager.setExtension("evalscript:scala", org.wso2.siddhi.extension.evalscript.EvalScala.class);
    //siddhiManager.defineFunction(concatFunc);
    String cseEventStream = "define stream cseEventStream (symbol string, price float, volume long);";
    String query = ("@info(name = 'query1') from cseEventStream select price , undefinedFunc(symbol,' ',price) as concatStr " + "group by volume insert into mailOutput;");
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(cseEventStream + query);
    executionPlanRuntime.addCallback("query1", new QueryCallback() {

        @Override
        public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
            EventPrinter.print(timeStamp, inEvents, removeEvents);
            Object value = inEvents[inEvents.length - 1].getData(1);
            Assert.assertEquals("IBM 700.0", value);
            count.incrementAndGet();
        }
    });
    InputHandler inputHandler = executionPlanRuntime.getInputHandler("cseEventStream");
    executionPlanRuntime.start();
    inputHandler.send(new Object[] { "IBM", 700f, 100l });
    SiddhiTestHelper.waitForEvents(1000, 1, count, 60000);
    Assert.assertEquals(1, count.get());
    executionPlanRuntime.shutdown();
}

60. EvalScriptTestCase#testReturnType()

Project: siddhi
File: EvalScriptTestCase.java
@Test
public void testReturnType() throws InterruptedException {
    log.info("testReturnType");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setExtension("evalscript:javascript", org.wso2.siddhi.extension.evalscript.EvalJavaScript.class);
    siddhiManager.setExtension("evalscript:scala", org.wso2.siddhi.extension.evalscript.EvalScala.class);
    String toFloatSFunc = "define function toFloatS[Scala] return float {\n" + "   data(0).asInstanceOf[String].toFloat\n" + "};\n";
    String cseEventStream = "define stream cseEventStream (symbol string, price string, volume long);\n";
    String query1 = ("@info(name = 'query1') from cseEventStream select price , toFloatS(price) as priceF insert into mailto1;\n");
    String query2 = ("@info(name = 'query2') from mailto1 select priceF/2 as newPrice insert into mailto2;\n");
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(toFloatSFunc + cseEventStream + query1 + query2);
    executionPlanRuntime.addCallback("query2", new QueryCallback() {

        @Override
        public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
            EventPrinter.print(timeStamp, inEvents, removeEvents);
            Object value = inEvents[inEvents.length - 1].getData(0);
            Assert.assertEquals(25.0f, value);
            count.incrementAndGet();
        }
    });
    InputHandler inputHandler = executionPlanRuntime.getInputHandler("cseEventStream");
    executionPlanRuntime.start();
    inputHandler.send(new Object[] { "WSO2", "50.0", 60f, 60l, 6 });
    SiddhiTestHelper.waitForEvents(1000, 1, count, 60000);
    Assert.assertEquals(1, count.get());
    executionPlanRuntime.shutdown();
}

61. EvalScriptTestCase#testDefineManyFunctionsAndCallThemRandom()

Project: siddhi
File: EvalScriptTestCase.java
@Test
public void testDefineManyFunctionsAndCallThemRandom() throws InterruptedException {
    log.info("testDefineManyFunctionsAndCallThemRandom");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setExtension("evalscript:javascript", org.wso2.siddhi.extension.evalscript.EvalJavaScript.class);
    siddhiManager.setExtension("evalscript:scala", org.wso2.siddhi.extension.evalscript.EvalScala.class);
    String concatSFunc = "define function concatS[Scala] return string {\n" + "  var concatenatedString = \"\"\n" + "  for(i <- 0 until data.length){\n" + "     concatenatedString += data(i).toString\n" + "  }\n" + "  concatenatedString\n" + "};\n";
    String concatJFunc = "define function concatJ[JavaScript] return string {\n" + "   var str1 = data[0].toString();\n" + "   var str2 = data[1].toString();\n" + "   var str3 = data[2].toString();\n" + "   var res = str1.concat(str2,str3);\n" + "   return res;\n" + "};\n";
    String toFloatSFunc = "define function toFloatS[Scala] return float {\n" + "   data(0).asInstanceOf[Long].toFloat\n" + "};\n";
    String toStringJFunc = "define function toStringJ[JavaScript] return string {\n" + "   return data[0].toString();\n" + "};\n";
    String cseEventStream = "define stream cseEventStream (symbol string, price float, volume long);\n";
    String query1 = ("@info(name = 'query1') from cseEventStream select price , toStringJ(price) as concatStr insert into mailto1;\n");
    String query2 = ("@info(name = 'query2') from cseEventStream select price , toFloatS(volume) as concatStr insert into mailto2;\n");
    String query3 = ("@info(name = 'query3') from cseEventStream select price , concatJ(symbol,' ',price) as concatStr insert into mailto3;\n");
    String query4 = ("@info(name = 'query4') from cseEventStream select price , concatS(symbol,' ',price) as concatStr insert into mailto4;\n");
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(concatSFunc + concatJFunc + toFloatSFunc + toStringJFunc + cseEventStream + query1 + query2 + query3 + query4);
    executionPlanRuntime.addCallback("query1", new QueryCallback() {

        @Override
        public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
            EventPrinter.print(timeStamp, inEvents, removeEvents);
            Object value = inEvents[inEvents.length - 1].getData(1);
            Assert.assertEquals("50", value);
            count.incrementAndGet();
        }
    });
    executionPlanRuntime.addCallback("query2", new QueryCallback() {

        @Override
        public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
            EventPrinter.print(timeStamp, inEvents, removeEvents);
            Object value = inEvents[inEvents.length - 1].getData(1);
            Assert.assertEquals(6f, value);
            count.incrementAndGet();
        }
    });
    executionPlanRuntime.addCallback("query3", new QueryCallback() {

        @Override
        public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
            EventPrinter.print(timeStamp, inEvents, removeEvents);
            Object value = inEvents[inEvents.length - 1].getData(1);
            Assert.assertEquals("WSO2 50", value);
            count.incrementAndGet();
        }
    });
    executionPlanRuntime.addCallback("query4", new QueryCallback() {

        @Override
        public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
            EventPrinter.print(timeStamp, inEvents, removeEvents);
            Object value = inEvents[inEvents.length - 1].getData(1);
            Assert.assertEquals("WSO2 50.0", value);
            count.incrementAndGet();
        }
    });
    InputHandler inputHandler = executionPlanRuntime.getInputHandler("cseEventStream");
    executionPlanRuntime.start();
    inputHandler.send(new Object[] { "WSO2", 50f, 6l });
    SiddhiTestHelper.waitForEvents(1000, 4, count, 60000);
    Assert.assertEquals(4, count.get());
    executionPlanRuntime.shutdown();
}

62. EvalScriptTestCase#testDefineFunctionsWithSameFunctionID()

Project: siddhi
File: EvalScriptTestCase.java
@Test(expected = DuplicateDefinitionException.class)
public void testDefineFunctionsWithSameFunctionID() throws InterruptedException {
    log.info("testDefineFunctionsWithSameFunctionID");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setExtension("evalscript:javascript", org.wso2.siddhi.extension.evalscript.EvalJavaScript.class);
    siddhiManager.setExtension("evalscript:scala", org.wso2.siddhi.extension.evalscript.EvalScala.class);
    String concatFunc1 = "define function concat[Scala] return string {\n" + "  var concatenatedString = \"\"\n" + "  for(i <- 0 until data.length) {\n" + "     concatenatedString += data(i).toString\n" + "  }\n" + "  concatenatedString\n" + "};";
    String concatFunc2 = "define function concat[JavaScript] return string {\n" + "  var str1 = data[0];\n" + "  var str2 = data[1];\n" + "  var str3 = data[2];\n" + "  var res = str1.concat(str2,str3);\n" + "  return res;\n" + "};\n";
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(concatFunc1 + concatFunc2);
    executionPlanRuntime.shutdown();
}

63. EvalScriptTestCase#testEvalJavaScriptConcat()

Project: siddhi
File: EvalScriptTestCase.java
@Test
public void testEvalJavaScriptConcat() throws InterruptedException {
    log.info("testEvalJavaScriptConcat");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setExtension("evalscript:javascript", org.wso2.siddhi.extension.evalscript.EvalJavaScript.class);
    siddhiManager.setExtension("evalscript:scala", org.wso2.siddhi.extension.evalscript.EvalScala.class);
    String concatFunc = "define function concatJ[JavaScript] return string {\n" + "  var str1 = data[0];\n" + "  var str2 = data[1];\n" + "  var str3 = data[2];\n" + "  var res = str1.concat(str2,str3);\n" + "  return res;\n" + "};";
    String cseEventStream = "define stream cseEventStream (symbol string, price float, volume long);";
    String query = ("@info(name = 'query1') from cseEventStream select price , concatJ(symbol,' ',price) as concatStr " + "group by volume insert into mailOutput;");
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(concatFunc + cseEventStream + query);
    executionPlanRuntime.addCallback("query1", new QueryCallback() {

        @Override
        public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
            EventPrinter.print(timeStamp, inEvents, removeEvents);
            Object value = inEvents[inEvents.length - 1].getData(1);
            Assert.assertEquals("WSO2 50", value);
            count.incrementAndGet();
        }
    });
    InputHandler inputHandler = executionPlanRuntime.getInputHandler("cseEventStream");
    executionPlanRuntime.start();
    inputHandler.send(new Object[] { "WSO2", 50f, 60f, 60l, 6 });
    SiddhiTestHelper.waitForEvents(100, 1, count, 60000);
    Assert.assertEquals(1, count.get());
    executionPlanRuntime.shutdown();
}

64. EvalScriptTestCase#testEvalScalaConcat()

Project: siddhi
File: EvalScriptTestCase.java
@Test
public void testEvalScalaConcat() throws InterruptedException {
    log.info("TestEvalScalaConcat");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setExtension("evalscript:javascript", org.wso2.siddhi.extension.evalscript.EvalJavaScript.class);
    siddhiManager.setExtension("evalscript:scala", org.wso2.siddhi.extension.evalscript.EvalScala.class);
    String concatFunc = "define function concatS[Scala] return string {\n" + "  var concatenatedString = \"\"\n" + "  for(i <- 0 until data.length){\n" + "  concatenatedString += data(i).toString\n" + "  }\n" + "  concatenatedString\n" + "};";
    //siddhiManager.defineFunction(concatFunc);
    String cseEventStream = "define stream cseEventStream (symbol string, price float, volume long);";
    String query = ("@info(name = 'query1') from cseEventStream select price , concatS(symbol,' ',price) as concatStr " + "group by volume insert into mailOutput;");
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(concatFunc + cseEventStream + query);
    executionPlanRuntime.addCallback("query1", new QueryCallback() {

        @Override
        public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
            EventPrinter.print(timeStamp, inEvents, removeEvents);
            Object value = inEvents[inEvents.length - 1].getData(1);
            Assert.assertEquals("IBM 700.0", value);
            count.incrementAndGet();
        }
    });
    InputHandler inputHandler = executionPlanRuntime.getInputHandler("cseEventStream");
    executionPlanRuntime.start();
    inputHandler.send(new Object[] { "IBM", 700f, 100l });
    SiddhiTestHelper.waitForEvents(100, 1, count, 60000);
    Assert.assertEquals(1, count.get());
    executionPlanRuntime.shutdown();
}

65. ExtensionTestCase#extensionTest4()

Project: siddhi
File: ExtensionTestCase.java
@Test
public void extensionTest4() throws InterruptedException, ClassNotFoundException {
    log.info("extension test4");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setExtension("custom:plus", CustomFunctionExtension.class);
    siddhiManager.setExtension("email:getAll", StringConcatAggregatorString.class);
    String cseEventStream = "define stream cseEventStream (price long, volume long);";
    String query = ("@info(name = 'query1') from cseEventStream select  custom:plus(*) as totalCount " + "insert into mailOutput;");
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(cseEventStream + query);
    executionPlanRuntime.addCallback("query1", new QueryCallback() {

        @Override
        public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
            EventPrinter.print(timeStamp, inEvents, removeEvents);
            for (Event inEvent : inEvents) {
                count++;
                if (count == 1) {
                    Assert.assertEquals(800l, inEvent.getData(0));
                } else if (count == 2) {
                    Assert.assertEquals(805l, inEvent.getData(0));
                } else if (count == 3) {
                    Assert.assertEquals(260l, inEvent.getData(0));
                }
            }
            eventArrived = true;
        }
    });
    InputHandler inputHandler = executionPlanRuntime.getInputHandler("cseEventStream");
    executionPlanRuntime.start();
    inputHandler.send(new Object[] { 700l, 100l });
    inputHandler.send(new Object[] { 605l, 200l });
    inputHandler.send(new Object[] { 60l, 200l });
    Thread.sleep(100);
    Assert.assertEquals(3, count);
    Assert.assertTrue(eventArrived);
    executionPlanRuntime.shutdown();
}

66. ExtensionTestCase#extensionTest3()

Project: siddhi
File: ExtensionTestCase.java
@Test
public void extensionTest3() throws InterruptedException {
    log.info("extension test3");
    SiddhiManager siddhiManager = new SiddhiManager();
    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;");
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(cseEventStream + query);
    executionPlanRuntime.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) {
                Assert.assertEquals("WSO2ABC", inEvents[inEvents.length - 1].getData(1));
            }
            eventArrived = true;
        }
    });
    InputHandler inputHandler = executionPlanRuntime.getInputHandler("cseEventStream");
    executionPlanRuntime.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);
    Assert.assertEquals(3, count);
    Assert.assertTrue(eventArrived);
    executionPlanRuntime.shutdown();
}

67. ExtensionTestCase#extensionTest2()

Project: siddhi
File: ExtensionTestCase.java
@Test
public void extensionTest2() throws InterruptedException, ClassNotFoundException {
    log.info("extension test2");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setExtension("custom:plus", CustomFunctionExtension.class);
    siddhiManager.setExtension("email:getAll", StringConcatAggregatorString.class);
    String cseEventStream = "define stream cseEventStream (symbol string, price long, volume long);";
    String query = ("@info(name = 'query1') from cseEventStream select symbol , custom:plus(price,volume) as totalCount " + "insert into mailOutput;");
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(cseEventStream + query);
    executionPlanRuntime.addCallback("query1", new QueryCallback() {

        @Override
        public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
            EventPrinter.print(timeStamp, inEvents, removeEvents);
            for (Event inEvent : inEvents) {
                count++;
                if (count == 1) {
                    Assert.assertEquals(800l, inEvent.getData(1));
                } else if (count == 2) {
                    Assert.assertEquals(805l, inEvent.getData(1));
                } else if (count == 3) {
                    Assert.assertEquals(260l, inEvent.getData(1));
                }
            }
            eventArrived = true;
        }
    });
    InputHandler inputHandler = executionPlanRuntime.getInputHandler("cseEventStream");
    executionPlanRuntime.start();
    inputHandler.send(new Object[] { "IBM", 700l, 100l });
    inputHandler.send(new Object[] { "WSO2", 605l, 200l });
    inputHandler.send(new Object[] { "ABC", 60l, 200l });
    Thread.sleep(100);
    Assert.assertEquals(3, count);
    Assert.assertTrue(eventArrived);
    executionPlanRuntime.shutdown();
}

68. ExternalTimeBatchWindowTestCase#test01DownSampling()

Project: siddhi
File: ExternalTimeBatchWindowTestCase.java
@Test
public void test01DownSampling() throws Exception {
    siddhiManager = new SiddhiManager();
    String stream = "define stream jmxMetric(cpu int, memory int, bytesIn long, bytesOut long, timestamp long);";
    String query = "@info(name = 'downSample') " + "from jmxMetric#window.externalTimeBatch(timestamp, 10 sec) " + "select " + "avg(cpu) as avgCpu, max(cpu) as maxCpu, min(cpu) as minCpu, " + " '|' as s, " + " avg(memory) as avgMem, max(memory) as maxMem, min(memory) as minMem, " + " '|' as s1, " + " avg(bytesIn) as avgBytesIn, max(bytesIn) as maxBytesIn, min(bytesIn) as minBytesIn, " + " '|' as s2, " + " avg(bytesOut) as avgBytesOut, max(bytesOut) as maxBytesOut, min(bytesOut) as minBytesOut, " + " '|' as s3, " + " timestamp as timeWindowEnds, " + " '|' as s4, " + " count(1) as metric_count " + " INSERT INTO tmp;";
    SiddhiManager sm = new SiddhiManager();
    ExecutionPlanRuntime plan = sm.createExecutionPlanRuntime(stream + query);
    InputHandler input = plan.getInputHandler("jmxMetric");
    // stream call back doesn't follow the counter
    final AtomicInteger counter = new AtomicInteger();
    {
        // stream callback
        plan.addCallback("jmxMetric", new StreamCallback() {

            @Override
            public void receive(Event[] arg0) {
                counter.addAndGet(arg0.length);
            }
        });
    }
    final AtomicInteger queryWideCounter = new AtomicInteger();
    {
        plan.addCallback("downSample", new QueryCallback() {

            @Override
            public void receive(long timeStamp, Event[] inevents, Event[] removevents) {
                int currentCount = queryWideCounter.addAndGet(inevents.length);
                log.info(MessageFormat.format("Round {0} ====", currentCount));
                log.info(" events count " + inevents.length);
                EventPrinter.print(inevents);
            }
        });
    }
    plan.start();
    int round = 4;
    int eventsPerRound = 0;
    long externalTs = System.currentTimeMillis();
    for (int i = 0; i < round; i++) {
        eventsPerRound = sendEvent(input, i, externalTs);
        Thread.sleep(3000);
    }
    // trigger next round
    sendEvent(input, round, externalTs);
    plan.shutdown();
    Thread.sleep(1000);
    Assert.assertEquals(round * eventsPerRound + eventsPerRound, counter.get());
    Assert.assertEquals(round, queryWideCounter.get());
}

69. InsertOverwriteTableTestCase#insertOverwriteTableTest4()

Project: siddhi
File: InsertOverwriteTableTestCase.java
@Test
public void insertOverwriteTableTest4() throws InterruptedException {
    log.info("insertOverwriteTableTest4");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setDataSource(RDBMSTestConstants.DATA_SOURCE_NAME, dataSource);
    try {
        if (dataSource.getConnection() != null) {
            DBConnectionHelper.getDBConnectionHelperInstance().clearDatabaseTable(dataSource, RDBMSTestConstants.TABLE_NAME);
            String streams = "" + "define stream StockStream (symbol string, price float, volume long); " + "define stream CheckStockStream (symbol string, volume long); " + "@from(eventtable = 'rdbms' , datasource.name = '" + RDBMSTestConstants.DATA_SOURCE_NAME + "' , table.name = '" + RDBMSTestConstants.TABLE_NAME + "') " + "define table StockTable (symbol string, price float, volume long); ";
            String query = "" + "@info(name = 'query2') " + "from StockStream " + "insert overwrite StockTable " + "   on StockTable.symbol==symbol;" + "" + "@info(name = 'query3') " + "from CheckStockStream[(symbol==StockTable.symbol and  volume==StockTable.volume) in StockTable] " + "insert into OutStream;";
            ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(streams + query);
            executionPlanRuntime.addCallback("query3", new QueryCallback() {

                @Override
                public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
                    EventPrinter.print(timeStamp, inEvents, removeEvents);
                    if (inEvents != null) {
                        for (Event event : inEvents) {
                            inEventCount++;
                            switch(inEventCount) {
                                case 1:
                                    Assert.assertArrayEquals(new Object[] { "IBM", 100l }, event.getData());
                                    break;
                                case 2:
                                    Assert.assertArrayEquals(new Object[] { "WSO2", 100l }, event.getData());
                                    break;
                                case 3:
                                    Assert.assertArrayEquals(new Object[] { "WSO2", 100l }, event.getData());
                                    break;
                                default:
                                    Assert.assertSame(3, inEventCount);
                            }
                        }
                        eventArrived = true;
                    }
                    if (removeEvents != null) {
                        removeEventCount = removeEventCount + removeEvents.length;
                    }
                    eventArrived = true;
                }
            });
            InputHandler stockStream = executionPlanRuntime.getInputHandler("StockStream");
            InputHandler checkStockStream = executionPlanRuntime.getInputHandler("CheckStockStream");
            executionPlanRuntime.start();
            stockStream.send(new Object[] { "WSO2", 55.6f, 100l });
            stockStream.send(new Object[] { "IBM", 55.6f, 100l });
            checkStockStream.send(new Object[] { "IBM", 100l });
            checkStockStream.send(new Object[] { "WSO2", 100l });
            stockStream.send(new Object[] { "IBM", 77.6f, 200l });
            checkStockStream.send(new Object[] { "IBM", 100l });
            checkStockStream.send(new Object[] { "WSO2", 100l });
            Thread.sleep(500);
            Assert.assertEquals("Number of success events", 3, inEventCount);
            Assert.assertEquals("Number of remove events", 0, removeEventCount);
            Assert.assertEquals("Event arrived", true, eventArrived);
            executionPlanRuntime.shutdown();
        }
    } catch (SQLException e) {
        log.info("Test case ignored due to DB connection unavailability");
    }
}

70. InsertOverwriteTableTestCase#insertOverwriteTableTest3()

Project: siddhi
File: InsertOverwriteTableTestCase.java
@Test
public void insertOverwriteTableTest3() throws InterruptedException {
    log.info("insertOverwriteTableTest3");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setDataSource(RDBMSTestConstants.DATA_SOURCE_NAME, dataSource);
    try {
        if (dataSource.getConnection() != null) {
            DBConnectionHelper.getDBConnectionHelperInstance().clearDatabaseTable(dataSource, RDBMSTestConstants.TABLE_NAME);
            String streams = "" + "define stream StockStream (symbol string, price float, volume long); " + "define stream CheckStockStream (symbol string, volume long); " + "define stream UpdateStockStream (symbol string, price float, volume long); " + "@from(eventtable = 'rdbms' , datasource.name = '" + RDBMSTestConstants.DATA_SOURCE_NAME + "' , table.name = '" + RDBMSTestConstants.TABLE_NAME + "') " + "define table StockTable (symbol string, price float, volume long); ";
            String query = "" + "@info(name = 'query1') " + "from StockStream " + "insert into StockTable ;" + "" + "@info(name = 'query2') " + "from UpdateStockStream " + "insert overwrite StockTable " + "   on StockTable.symbol==symbol;" + "" + "@info(name = 'query3') " + "from CheckStockStream[(symbol==StockTable.symbol and  volume==StockTable.volume) in StockTable] " + "insert into OutStream;";
            ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(streams + query);
            executionPlanRuntime.addCallback("query3", new QueryCallback() {

                @Override
                public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
                    EventPrinter.print(timeStamp, inEvents, removeEvents);
                    if (inEvents != null) {
                        for (Event event : inEvents) {
                            inEventCount++;
                            switch(inEventCount) {
                                case 1:
                                    Assert.assertArrayEquals(new Object[] { "IBM", 100l }, event.getData());
                                    break;
                                case 2:
                                    Assert.assertArrayEquals(new Object[] { "WSO2", 100l }, event.getData());
                                    break;
                                case 3:
                                    Assert.assertArrayEquals(new Object[] { "WSO2", 100l }, event.getData());
                                    break;
                                default:
                                    Assert.assertSame(3, inEventCount);
                            }
                        }
                        eventArrived = true;
                    }
                    if (removeEvents != null) {
                        removeEventCount = removeEventCount + removeEvents.length;
                    }
                    eventArrived = true;
                }
            });
            InputHandler stockStream = executionPlanRuntime.getInputHandler("StockStream");
            InputHandler checkStockStream = executionPlanRuntime.getInputHandler("CheckStockStream");
            InputHandler updateStockStream = executionPlanRuntime.getInputHandler("UpdateStockStream");
            executionPlanRuntime.start();
            stockStream.send(new Object[] { "WSO2", 55.6f, 100l });
            stockStream.send(new Object[] { "IBM", 55.6f, 100l });
            checkStockStream.send(new Object[] { "IBM", 100l });
            checkStockStream.send(new Object[] { "WSO2", 100l });
            updateStockStream.send(new Object[] { "IBM", 77.6f, 200l });
            checkStockStream.send(new Object[] { "IBM", 100l });
            checkStockStream.send(new Object[] { "WSO2", 100l });
            Thread.sleep(500);
            Assert.assertEquals("Number of success events", 3, inEventCount);
            Assert.assertEquals("Number of remove events", 0, removeEventCount);
            Assert.assertEquals("Event arrived", true, eventArrived);
            executionPlanRuntime.shutdown();
        }
    } catch (SQLException e) {
        log.info("Test case ignored due to DB connection unavailability");
    }
}

71. InsertOverwriteTableTestCase#insertOverwriteTableTest2()

Project: siddhi
File: InsertOverwriteTableTestCase.java
@Test
public void insertOverwriteTableTest2() throws InterruptedException {
    log.info("insertOverwriteTableTest2");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setDataSource(RDBMSTestConstants.DATA_SOURCE_NAME, dataSource);
    try {
        if (dataSource.getConnection() != null) {
            DBConnectionHelper.getDBConnectionHelperInstance().clearDatabaseTable(dataSource, RDBMSTestConstants.TABLE_NAME);
            String streams = "" + "define stream StockStream (symbol string, price float, volume long); " + "@from(eventtable = 'rdbms' , datasource.name = '" + RDBMSTestConstants.DATA_SOURCE_NAME + "' , table.name = '" + RDBMSTestConstants.TABLE_NAME + "') " + "define table StockTable (symbol string, price float, volume long); ";
            String query = "" + "@info(name = 'query2') " + "from StockStream " + "insert overwrite StockTable " + "   on StockTable.symbol==symbol ;";
            ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(streams + query);
            InputHandler stockStream = executionPlanRuntime.getInputHandler("StockStream");
            executionPlanRuntime.start();
            stockStream.send(new Object[] { "WSO2", 55.6f, 100l });
            stockStream.send(new Object[] { "IBM", 75.6f, 100l });
            stockStream.send(new Object[] { "WSO2", 57.6f, 100l });
            stockStream.send(new Object[] { "WSO2", 10f, 100l });
            Thread.sleep(500);
            executionPlanRuntime.shutdown();
        }
    } catch (SQLException e) {
        log.info("Test case ignored due to DB connection unavailability");
    }
}

72. InsertOverwriteTableTestCase#insertOverwriteTableTest1()

Project: siddhi
File: InsertOverwriteTableTestCase.java
@Test
public void insertOverwriteTableTest1() throws InterruptedException {
    log.info("insertOverwriteTableTest1");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setDataSource(RDBMSTestConstants.DATA_SOURCE_NAME, dataSource);
    try {
        if (dataSource.getConnection() != null) {
            DBConnectionHelper.getDBConnectionHelperInstance().clearDatabaseTable(dataSource, RDBMSTestConstants.TABLE_NAME);
            String streams = "" + "define stream StockStream (symbol string, price float, volume long); " + "define stream UpdateStockStream (symbol string, price float, volume long); " + "@from(eventtable = 'rdbms' , datasource.name = '" + RDBMSTestConstants.DATA_SOURCE_NAME + "' , table.name = '" + RDBMSTestConstants.TABLE_NAME + "') " + "define table StockTable (symbol string, price float, volume long); ";
            String query = "" + "@info(name = 'query1') " + "from StockStream " + "insert into StockTable ;" + "" + "@info(name = 'query2') " + "from UpdateStockStream " + "insert overwrite StockTable " + "   on StockTable.symbol=='IBM' ;";
            ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(streams + query);
            InputHandler stockStream = executionPlanRuntime.getInputHandler("StockStream");
            InputHandler updateStockStream = executionPlanRuntime.getInputHandler("UpdateStockStream");
            executionPlanRuntime.start();
            stockStream.send(new Object[] { "WSO2", 55.6f, 100l });
            stockStream.send(new Object[] { "IBM", 75.6f, 100l });
            stockStream.send(new Object[] { "WSO2", 57.6f, 100l });
            updateStockStream.send(new Object[] { "GOOG", 10.6f, 100l });
            Thread.sleep(500);
            executionPlanRuntime.shutdown();
        }
    } catch (SQLException e) {
        log.info("Test case ignored due to DB connection unavailability");
    }
}

73. InsertIntoRDBMSTestCase#insertIntoRDBMSTableTest1()

Project: siddhi
File: InsertIntoRDBMSTestCase.java
@Test
public void insertIntoRDBMSTableTest1() throws InterruptedException {
    log.info("InsertIntoTableTest1");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setDataSource(RDBMSTestConstants.DATA_SOURCE_NAME, dataSource);
    try {
        if (dataSource.getConnection() != null) {
            DBConnectionHelper.getDBConnectionHelperInstance().clearDatabaseTable(dataSource, RDBMSTestConstants.TABLE_NAME);
            String streams = "" + "define stream StockStream (symbol string, price float, volume long); " + "@from(eventtable = 'rdbms' , datasource.name = '" + RDBMSTestConstants.DATA_SOURCE_NAME + "' , table.name = '" + RDBMSTestConstants.TABLE_NAME + "') " + "define table StockTable (symbol string, price float, volume long); ";
            String query = "" + "@info(name = 'query1') " + "from StockStream   " + "insert into StockTable ;";
            ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(streams + query);
            InputHandler stockStream = executionPlanRuntime.getInputHandler("StockStream");
            executionPlanRuntime.start();
            stockStream.send(new Object[] { "WSO2", 55.6f, 100l });
            stockStream.send(new Object[] { "IBM", 75.6f, 100l });
            stockStream.send(new Object[] { "WSO2", 57.6f, 100l });
            Thread.sleep(1000);
            long totalRowsInTable = DBConnectionHelper.getDBConnectionHelperInstance().getRowsInTable(dataSource);
            Assert.assertEquals("Insertion failed", 3, totalRowsInTable);
            executionPlanRuntime.shutdown();
        }
    } catch (SQLException e) {
        log.info("Test case ignored due to DB connection unavailability");
    }
}

74. DeleteFromRDBMSTestCase#deleteFromRDBMSTableTest11()

Project: siddhi
File: DeleteFromRDBMSTestCase.java
@Test
public void deleteFromRDBMSTableTest11() throws InterruptedException {
    log.info("deleteFromTableTest11");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setDataSource(RDBMSTestConstants.DATA_SOURCE_NAME, dataSource);
    try {
        if (dataSource.getConnection() != null) {
            DBConnectionHelper.getDBConnectionHelperInstance().clearDatabaseTable(dataSource, RDBMSTestConstants.TABLE_NAME);
            String streams = "" + "define stream StockStream (symbol string, price float, volume long); " + "define stream DeleteStockStream (symbol string, price float, volume long); " + "@from(eventtable = 'rdbms' ,datasource.name = '" + RDBMSTestConstants.DATA_SOURCE_NAME + "' , table.name = '" + RDBMSTestConstants.TABLE_NAME + "', bloom.filters = 'enable')  " + "define table StockTable (symbol string, price float, volume long); ";
            String query = "" + "@info(name = 'query1') " + "from StockStream " + "insert into StockTable ;" + "" + "@info(name = 'query2') " + "from DeleteStockStream " + "delete StockTable " + "   on StockTable.symbol == symbol ;";
            ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(streams + query);
            InputHandler stockStream = executionPlanRuntime.getInputHandler("StockStream");
            InputHandler deleteStockStream = executionPlanRuntime.getInputHandler("DeleteStockStream");
            executionPlanRuntime.start();
            stockStream.send(new Object[] { "WSO2", 55.6f, 100l });
            stockStream.send(new Object[] { "IBM", 75.6f, 100l });
            stockStream.send(new Object[] { "WSO2", 57.6f, 100l });
            deleteStockStream.send(new Object[] { "IBM", 57.6f, 100l });
            Thread.sleep(1000);
            long totalRowsInTable = DBConnectionHelper.getDBConnectionHelperInstance().getRowsInTable(dataSource);
            Assert.assertEquals("Deletion failed", 2, totalRowsInTable);
            Thread.sleep(1000);
            stockStream.send(new Object[] { null, 45.5f, 100l });
            executionPlanRuntime.shutdown();
            Thread.sleep(1000);
            try {
                siddhiManager.createExecutionPlanRuntime(streams + query);
            } catch (NullPointerException ex) {
                Assert.fail("Cannot Process null values in bloom filter");
            }
        }
    } catch (SQLException e) {
        log.info("Test case ignored due to DB connection unavailability");
    }
}

75. DeleteFromRDBMSTestCase#deleteFromRDBMSTableTest10()

Project: siddhi
File: DeleteFromRDBMSTestCase.java
@Test
public void deleteFromRDBMSTableTest10() throws InterruptedException {
    log.info("deleteFromTableTest10");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setDataSource(RDBMSTestConstants.DATA_SOURCE_NAME, dataSource);
    try {
        if (dataSource.getConnection() != null) {
            DBConnectionHelper.getDBConnectionHelperInstance().clearDatabaseTable(dataSource, RDBMSTestConstants.TABLE_NAME);
            String streams = "" + "define stream StockStream (symbol string, price float, volume long); " + "define stream DeleteStockStream (symbol string, price float, volume long); " + "@from(eventtable = 'rdbms' ,datasource.name = '" + RDBMSTestConstants.DATA_SOURCE_NAME + "' , table.name = '" + RDBMSTestConstants.TABLE_NAME + "', bloom.filters = 'enable')  " + "define table StockTable (symbol string, price float, volume long); ";
            String query = "" + "@info(name = 'query1') " + "from StockStream " + "insert into StockTable ;" + "" + "@info(name = 'query2') " + "from DeleteStockStream " + "delete StockTable " + "   on StockTable.symbol == symbol ;";
            ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(streams + query);
            InputHandler stockStream = executionPlanRuntime.getInputHandler("StockStream");
            InputHandler deleteStockStream = executionPlanRuntime.getInputHandler("DeleteStockStream");
            executionPlanRuntime.start();
            stockStream.send(new Object[] { "WSO2", 55.6f, 100l });
            stockStream.send(new Object[] { "IBM", 75.6f, 100l });
            stockStream.send(new Object[] { "WSO2", 57.6f, 100l });
            deleteStockStream.send(new Object[] { "IBM", 57.6f, 100l });
            Thread.sleep(1000);
            long totalRowsInTable = DBConnectionHelper.getDBConnectionHelperInstance().getRowsInTable(dataSource);
            Assert.assertEquals("Deletion failed", 2, totalRowsInTable);
            executionPlanRuntime.shutdown();
        }
    } catch (SQLException e) {
        log.info("Test case ignored due to DB connection unavailability");
    }
}

76. DeleteFromRDBMSTestCase#deleteFromRDBMSTableTest9()

Project: siddhi
File: DeleteFromRDBMSTestCase.java
@Test
public void deleteFromRDBMSTableTest9() throws InterruptedException {
    log.info("deleteFromTableTest9");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setDataSource(RDBMSTestConstants.DATA_SOURCE_NAME, dataSource);
    try {
        if (dataSource.getConnection() != null) {
            DBConnectionHelper.getDBConnectionHelperInstance().clearDatabaseTable(dataSource, RDBMSTestConstants.TABLE_NAME);
            String streams = "" + "define stream StockStream (symbol string, price float, volume long); " + "define stream DeleteStockStream (symbol string, price float, volume long); " + "@from(eventtable = 'rdbms' ,datasource.name = '" + RDBMSTestConstants.DATA_SOURCE_NAME + "' , table.name = '" + RDBMSTestConstants.TABLE_NAME + "', cache='lfu', cache.size='1000')  " + "define table StockTable (symbol string, price float, volume long); ";
            String query = "" + "@info(name = 'query1') " + "from StockStream " + "insert into StockTable ;" + "" + "@info(name = 'query2') " + "from DeleteStockStream " + "delete StockTable " + "   on StockTable.symbol == symbol ;";
            ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(streams + query);
            InputHandler stockStream = executionPlanRuntime.getInputHandler("StockStream");
            InputHandler deleteStockStream = executionPlanRuntime.getInputHandler("DeleteStockStream");
            executionPlanRuntime.start();
            stockStream.send(new Object[] { "WSO2", 55.6f, 100l });
            stockStream.send(new Object[] { "IBM", 75.6f, 100l });
            stockStream.send(new Object[] { "WSO2", 57.6f, 100l });
            deleteStockStream.send(new Object[] { "IBM", 57.6f, 100l });
            Thread.sleep(1000);
            long totalRowsInTable = DBConnectionHelper.getDBConnectionHelperInstance().getRowsInTable(dataSource);
            Assert.assertEquals("Deletion failed", 2, totalRowsInTable);
            executionPlanRuntime.shutdown();
        }
    } catch (SQLException e) {
        log.info("Test case ignored due to DB connection unavailability");
    }
}

77. DeleteFromRDBMSTestCase#deleteFromTableTest8()

Project: siddhi
File: DeleteFromRDBMSTestCase.java
@Test
public void deleteFromTableTest8() throws InterruptedException {
    log.info("deleteFromTableTest8");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setDataSource(RDBMSTestConstants.DATA_SOURCE_NAME, dataSource);
    try {
        if (dataSource.getConnection() != null) {
            DBConnectionHelper.getDBConnectionHelperInstance().clearDatabaseTable(dataSource, RDBMSTestConstants.TABLE_NAME);
            String streams = "" + "define stream StockStream (symbol string, price float, volume long); " + "define stream DeleteStockStream (symbol string, price float, volume long); " + "@from(eventtable = 'rdbms' ,datasource.name = '" + RDBMSTestConstants.DATA_SOURCE_NAME + "' , table.name = '" + RDBMSTestConstants.TABLE_NAME + "') " + "define table StockTable (symbol string, price float, volume long); ";
            String query = "" + "@info(name = 'query1') " + "from StockStream " + "insert into StockTable ;" + "" + "@info(name = 'query2') " + "from DeleteStockStream " + "delete StockTable " + "   on StockTable.symbol=='IBM' and StockTable.price > 50 and  StockTable.volume == volume  ;";
            ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(streams + query);
            InputHandler stockStream = executionPlanRuntime.getInputHandler("StockStream");
            InputHandler deleteStockStream = executionPlanRuntime.getInputHandler("DeleteStockStream");
            executionPlanRuntime.start();
            stockStream.send(new Object[] { "WSO2", 55.6f, 100l });
            stockStream.send(new Object[] { "IBM", 75.6f, 100l });
            stockStream.send(new Object[] { "IBM", 57.6f, 100l });
            deleteStockStream.send(new Object[] { "IBM", 57.6f, 100l });
            Thread.sleep(1000);
            long totalRowsInTable = DBConnectionHelper.getDBConnectionHelperInstance().getRowsInTable(dataSource);
            Assert.assertEquals("Deletion failed", 1, totalRowsInTable);
            executionPlanRuntime.shutdown();
        }
    } catch (SQLException e) {
        log.info("Test case ignored due to DB connection unavailability");
    }
}

78. DeleteFromRDBMSTestCase#deleteFromTableTest7()

Project: siddhi
File: DeleteFromRDBMSTestCase.java
@Test
public void deleteFromTableTest7() throws InterruptedException {
    log.info("deleteFromTableTest7");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setDataSource(RDBMSTestConstants.DATA_SOURCE_NAME, dataSource);
    try {
        if (dataSource.getConnection() != null) {
            DBConnectionHelper.getDBConnectionHelperInstance().clearDatabaseTable(dataSource, RDBMSTestConstants.TABLE_NAME);
            String streams = "" + "define stream StockStream (symbol string, price float, volume long); " + "define stream DeleteStockStream (symbol string, price float, volume long); " + "@from(eventtable = 'rdbms' ,datasource.name = '" + RDBMSTestConstants.DATA_SOURCE_NAME + "' , table.name = '" + RDBMSTestConstants.TABLE_NAME + "') " + "define table StockTable (symbol string, price float, volume long); ";
            String query = "" + "@info(name = 'query1') " + "from StockStream " + "insert into StockTable ;" + "" + "@info(name = 'query2') " + "from DeleteStockStream " + "delete StockTable " + "   on StockTable.symbol==symbol and StockTable.price > price and  StockTable.volume == volume  ;";
            ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(streams + query);
            InputHandler stockStream = executionPlanRuntime.getInputHandler("StockStream");
            InputHandler deleteStockStream = executionPlanRuntime.getInputHandler("DeleteStockStream");
            executionPlanRuntime.start();
            stockStream.send(new Object[] { "WSO2", 55.6f, 100l });
            stockStream.send(new Object[] { "IBM", 75.6f, 100l });
            stockStream.send(new Object[] { "IBM", 57.6f, 100l });
            deleteStockStream.send(new Object[] { "IBM", 57.6f, 100l });
            Thread.sleep(1000);
            long totalRowsInTable = DBConnectionHelper.getDBConnectionHelperInstance().getRowsInTable(dataSource);
            Assert.assertEquals("Deletion failed", 2, totalRowsInTable);
            executionPlanRuntime.shutdown();
        }
    } catch (SQLException e) {
        log.info("Test case ignored due to DB connection unavailability");
    }
}

79. DeleteFromRDBMSTestCase#deleteFromRDBMSTableTest6()

Project: siddhi
File: DeleteFromRDBMSTestCase.java
@Test
public void deleteFromRDBMSTableTest6() throws InterruptedException {
    log.info("deleteFromTableTest6");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setDataSource(RDBMSTestConstants.DATA_SOURCE_NAME, dataSource);
    try {
        if (dataSource.getConnection() != null) {
            DBConnectionHelper.getDBConnectionHelperInstance().clearDatabaseTable(dataSource, RDBMSTestConstants.TABLE_NAME);
            String streams = "" + "define stream StockStream (symbol string, price float, volume long); " + "define stream DeleteStockStream (symbol string, price float, volume long); " + "@from(eventtable = 'rdbms' ,datasource.name = '" + RDBMSTestConstants.DATA_SOURCE_NAME + "' , table.name = '" + RDBMSTestConstants.TABLE_NAME + "')  " + "define table StockTable (symbol string, price float, volume long); ";
            String query = "" + "@info(name = 'query1') " + "from StockStream " + "insert into StockTable ;" + "" + "@info(name = 'query2') " + "from DeleteStockStream " + "delete StockTable " + "   on symbol == 'IBM'  ;";
            ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(streams + query);
            InputHandler stockStream = executionPlanRuntime.getInputHandler("StockStream");
            InputHandler deleteStockStream = executionPlanRuntime.getInputHandler("DeleteStockStream");
            executionPlanRuntime.start();
            stockStream.send(new Object[] { "WSO2", 55.6f, 100l });
            stockStream.send(new Object[] { "IBM", 75.6f, 100l });
            stockStream.send(new Object[] { "WSO2", 57.6f, 100l });
            deleteStockStream.send(new Object[] { "IBM", 57.6f, 100l });
            Thread.sleep(1000);
            long totalRowsInTable = DBConnectionHelper.getDBConnectionHelperInstance().getRowsInTable(dataSource);
            Assert.assertEquals("Deletion failed", 2, totalRowsInTable);
            executionPlanRuntime.shutdown();
        }
    } catch (SQLException e) {
        log.info("Test case ignored due to DB connection unavailability");
    }
}

80. DeleteFromRDBMSTestCase#deleteFromRDBMSTableTest5()

Project: siddhi
File: DeleteFromRDBMSTestCase.java
@Test
public void deleteFromRDBMSTableTest5() throws InterruptedException {
    log.info("deleteFromTableTest5");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setDataSource(RDBMSTestConstants.DATA_SOURCE_NAME, dataSource);
    try {
        if (dataSource.getConnection() != null) {
            DBConnectionHelper.getDBConnectionHelperInstance().clearDatabaseTable(dataSource, RDBMSTestConstants.TABLE_NAME);
            String streams = "" + "define stream StockStream (symbol string, price float, volume long); " + "define stream DeleteStockStream (symbol string, price float, volume long); " + "@from(eventtable = 'rdbms' ,datasource.name = '" + RDBMSTestConstants.DATA_SOURCE_NAME + "' , table.name = '" + RDBMSTestConstants.TABLE_NAME + "')  " + "define table StockTable (symbol string, price float, volume long); ";
            String query = "" + "@info(name = 'query1') " + "from StockStream " + "insert into StockTable ;" + "" + "@info(name = 'query2') " + "from DeleteStockStream " + "delete StockTable " + "   on 'IBM' == symbol  ;";
            ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(streams + query);
            InputHandler stockStream = executionPlanRuntime.getInputHandler("StockStream");
            InputHandler deleteStockStream = executionPlanRuntime.getInputHandler("DeleteStockStream");
            executionPlanRuntime.start();
            stockStream.send(new Object[] { "WSO2", 55.6f, 100l });
            stockStream.send(new Object[] { "IBM", 75.6f, 100l });
            stockStream.send(new Object[] { "WSO2", 57.6f, 100l });
            deleteStockStream.send(new Object[] { "IBM", 57.6f, 100l });
            Thread.sleep(1000);
            long totalRowsInTable = DBConnectionHelper.getDBConnectionHelperInstance().getRowsInTable(dataSource);
            Assert.assertEquals("Deletion failed", 2, totalRowsInTable);
            executionPlanRuntime.shutdown();
        }
    } catch (SQLException e) {
        log.info("Test case ignored due to DB connection unavailability");
    }
}

81. DeleteFromRDBMSTestCase#deleteFromRDBMSTableTest4()

Project: siddhi
File: DeleteFromRDBMSTestCase.java
@Test
public void deleteFromRDBMSTableTest4() throws InterruptedException {
    log.info("deleteFromTableTest4");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setDataSource(RDBMSTestConstants.DATA_SOURCE_NAME, dataSource);
    try {
        if (dataSource.getConnection() != null) {
            DBConnectionHelper.getDBConnectionHelperInstance().clearDatabaseTable(dataSource, RDBMSTestConstants.TABLE_NAME);
            String streams = "" + "define stream StockStream (symbol string, price float, volume long); " + "define stream DeleteStockStream (symbol string, price float, volume long); " + "@from(eventtable = 'rdbms' ,datasource.name = '" + RDBMSTestConstants.DATA_SOURCE_NAME + "' , table.name = '" + RDBMSTestConstants.TABLE_NAME + "')  " + "define table StockTable (symbol string, price float, volume long); ";
            String query = "" + "@info(name = 'query1') " + "from StockStream " + "insert into StockTable ;" + "" + "@info(name = 'query2') " + "from DeleteStockStream " + "delete StockTable " + "   on 'IBM' == StockTable.symbol  ;";
            ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(streams + query);
            InputHandler stockStream = executionPlanRuntime.getInputHandler("StockStream");
            InputHandler deleteStockStream = executionPlanRuntime.getInputHandler("DeleteStockStream");
            executionPlanRuntime.start();
            stockStream.send(new Object[] { "WSO2", 55.6f, 100l });
            stockStream.send(new Object[] { "IBM", 75.6f, 100l });
            stockStream.send(new Object[] { "WSO2", 57.6f, 100l });
            deleteStockStream.send(new Object[] { "IBM", 57.6f, 100l });
            Thread.sleep(1000);
            long totalRowsInTable = DBConnectionHelper.getDBConnectionHelperInstance().getRowsInTable(dataSource);
            Assert.assertEquals("Deletion failed", 2, totalRowsInTable);
            executionPlanRuntime.shutdown();
        }
    } catch (SQLException e) {
        log.info("Test case ignored due to DB connection unavailability");
    }
}

82. DeleteFromRDBMSTestCase#deleteFromRDBMSTableTest3()

Project: siddhi
File: DeleteFromRDBMSTestCase.java
@Test
public void deleteFromRDBMSTableTest3() throws InterruptedException {
    log.info("deleteFromTableTest3");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setDataSource(RDBMSTestConstants.DATA_SOURCE_NAME, dataSource);
    try {
        if (dataSource.getConnection() != null) {
            DBConnectionHelper.getDBConnectionHelperInstance().clearDatabaseTable(dataSource, RDBMSTestConstants.TABLE_NAME);
            String streams = "" + "define stream StockStream (symbol string, price float, volume long); " + "define stream DeleteStockStream (symbol string, price float, volume long); " + "@from(eventtable = 'rdbms' ,datasource.name = '" + RDBMSTestConstants.DATA_SOURCE_NAME + "' , table.name = '" + RDBMSTestConstants.TABLE_NAME + "')  " + "define table StockTable (symbol string, price float, volume long); ";
            String query = "" + "@info(name = 'query1') " + "from StockStream " + "insert into StockTable ;" + "" + "@info(name = 'query2') " + "from DeleteStockStream " + "delete StockTable " + "   on StockTable.symbol == 'IBM'  ;";
            ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(streams + query);
            InputHandler stockStream = executionPlanRuntime.getInputHandler("StockStream");
            InputHandler deleteStockStream = executionPlanRuntime.getInputHandler("DeleteStockStream");
            executionPlanRuntime.start();
            stockStream.send(new Object[] { "WSO2", 55.6f, 100l });
            stockStream.send(new Object[] { "IBM", 75.6f, 100l });
            stockStream.send(new Object[] { "WSO2", 57.6f, 100l });
            deleteStockStream.send(new Object[] { "IBM", 57.6f, 100l });
            Thread.sleep(1000);
            long totalRowsInTable = DBConnectionHelper.getDBConnectionHelperInstance().getRowsInTable(dataSource);
            Assert.assertEquals("Deletion failed", 2, totalRowsInTable);
            executionPlanRuntime.shutdown();
        }
    } catch (SQLException e) {
        log.info("Test case ignored due to DB connection unavailability");
    }
}

83. DeleteFromRDBMSTestCase#deleteFromRDBMSTableTest2()

Project: siddhi
File: DeleteFromRDBMSTestCase.java
@Test
public void deleteFromRDBMSTableTest2() throws InterruptedException {
    log.info("deleteFromTableTest2");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setDataSource(RDBMSTestConstants.DATA_SOURCE_NAME, dataSource);
    try {
        if (dataSource.getConnection() != null) {
            DBConnectionHelper.getDBConnectionHelperInstance().clearDatabaseTable(dataSource, RDBMSTestConstants.TABLE_NAME);
            String streams = "" + "define stream StockStream (symbol string, price float, volume long); " + "define stream DeleteStockStream (symbol string, price float, volume long); " + "@from(eventtable = 'rdbms' ,datasource.name = '" + RDBMSTestConstants.DATA_SOURCE_NAME + "' , table.name = '" + RDBMSTestConstants.TABLE_NAME + "' , bloom.filters = 'enable')  " + "define table StockTable (symbol string, price float, volume long); ";
            String query = "" + "@info(name = 'query1') " + "from StockStream " + "insert into StockTable ;" + "" + "@info(name = 'query2') " + "from DeleteStockStream " + "delete StockTable " + "   on symbol == StockTable.symbol ;";
            ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(streams + query);
            InputHandler stockStream = executionPlanRuntime.getInputHandler("StockStream");
            InputHandler deleteStockStream = executionPlanRuntime.getInputHandler("DeleteStockStream");
            executionPlanRuntime.start();
            stockStream.send(new Object[] { "WSO2", 55.6f, 100l });
            stockStream.send(new Object[] { "IBM", 75.6f, 100l });
            stockStream.send(new Object[] { "WSO2", 57.6f, 100l });
            deleteStockStream.send(new Object[] { "IBM", 57.6f, 100l });
            deleteStockStream.send(new Object[] { "WSO2", 57.6f, 100l });
            Thread.sleep(1000);
            long totalRowsInTable = DBConnectionHelper.getDBConnectionHelperInstance().getRowsInTable(dataSource);
            Assert.assertEquals("Deletion failed", 0, totalRowsInTable);
            executionPlanRuntime.shutdown();
        }
    } catch (SQLException e) {
        log.info("Test case ignored due to DB connection unavailability");
    }
}

84. DeleteFromRDBMSTestCase#deleteFromRDBMSTableTest1()

Project: siddhi
File: DeleteFromRDBMSTestCase.java
@Test
public void deleteFromRDBMSTableTest1() throws InterruptedException {
    log.info("deleteFromTableTest1");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setDataSource(RDBMSTestConstants.DATA_SOURCE_NAME, dataSource);
    try {
        if (dataSource.getConnection() != null) {
            DBConnectionHelper.getDBConnectionHelperInstance().clearDatabaseTable(dataSource, RDBMSTestConstants.TABLE_NAME);
            String streams = "" + "define stream StockStream (symbol string, price float, volume long); " + "define stream DeleteStockStream (symbol string, price float, volume long); " + "@from(eventtable = 'rdbms' ,datasource.name = '" + RDBMSTestConstants.DATA_SOURCE_NAME + "' , table.name = '" + RDBMSTestConstants.TABLE_NAME + "')  " + "define table StockTable (symbol string, price float, volume long); ";
            String query = "" + "@info(name = 'query1') " + "from StockStream " + "insert into StockTable ;" + "" + "@info(name = 'query2') " + "from DeleteStockStream " + "delete StockTable " + "   on StockTable.symbol == symbol ;";
            ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(streams + query);
            InputHandler stockStream = executionPlanRuntime.getInputHandler("StockStream");
            InputHandler deleteStockStream = executionPlanRuntime.getInputHandler("DeleteStockStream");
            executionPlanRuntime.start();
            stockStream.send(new Object[] { "WSO2", 55.6f, 100l });
            stockStream.send(new Object[] { "IBM", 75.6f, 100l });
            stockStream.send(new Object[] { "WSO2", 57.6f, 100l });
            deleteStockStream.send(new Object[] { "IBM", 57.6f, 100l });
            deleteStockStream.send(new Object[] { "WSO2", 57.6f, 100l });
            Thread.sleep(1000);
            long totalRowsInTable = DBConnectionHelper.getDBConnectionHelperInstance().getRowsInTable(dataSource);
            Assert.assertEquals("Deletion failed", 0, totalRowsInTable);
            executionPlanRuntime.shutdown();
        }
    } catch (SQLException e) {
        log.info("Test case ignored due to DB connection unavailability");
    }
}

85. ToXMLFunctionExtensionTestCase#testCreateFromXMLFunctionExtension2()

Project: siddhi
File: ToXMLFunctionExtensionTestCase.java
@Test
public void testCreateFromXMLFunctionExtension2() throws InterruptedException {
    log.info("CreateFromXMLFunctionExtension TestCase 2");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setExtension("str:concat", ConcatFunctionExtension.class);
    String inStreamDefinition = "\ndefine stream inputStream (longAttr long, doubleAttr double, booleanAttr bool, strAttr string);";
    String query = ("@info(name = 'query1') from inputStream select " + "map:createFromXML(str:concat('<sensor><commonAttr1>',longAttr,'</commonAttr1><commonAttr2>'," + "doubleAttr,'</commonAttr2><commonAttr3>',booleanAttr,'</commonAttr3><commonAttr4>',strAttr,'</commonAttr4></sensor>')) " + "as hashMap insert into outputStream;" + "from outputStream " + "select map:toXML(hashMap) as xmlString " + "insert into outputStream2");
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(inStreamDefinition + query);
    executionPlanRuntime.addCallback("outputStream2", new StreamCallback() {

        @Override
        public void receive(Event[] inEvents) {
            EventPrinter.print(inEvents);
            for (Event event : inEvents) {
                count.incrementAndGet();
                if (count.get() == 1) {
                    try {
                        Assert.assertEquals(true, new XMLComparator().compare(AXIOMUtil.stringToOM("<sensor>" + "<commonAttr1>25</commonAttr1>" + "<commonAttr2>100.1</commonAttr2>" + "<commonAttr3>true</commonAttr3>" + "<commonAttr4>Event1</commonAttr4>" + "</sensor>"), AXIOMUtil.stringToOM((String) event.getData(0))));
                    } catch (XMLComparisonException e) {
                        log.error("Error comparing two XML elements:" + e.getMessage(), e);
                    } catch (XMLStreamException e) {
                        log.error("Error parsing XML:" + e.getMessage(), e);
                    }
                    eventArrived = true;
                }
                if (count.get() == 2) {
                    try {
                        Assert.assertEquals(true, new XMLComparator().compare(AXIOMUtil.stringToOM("<sensor>" + "<commonAttr1>35</commonAttr1>" + "<commonAttr2>100.11</commonAttr2>" + "<commonAttr3>false</commonAttr3>" + "<commonAttr4>Event2</commonAttr4>" + "</sensor>"), AXIOMUtil.stringToOM((String) event.getData(0))));
                    } catch (XMLComparisonException e) {
                        log.error("Error comparing two XML elements:" + e.getMessage(), e);
                    } catch (XMLStreamException e) {
                        log.error("Error parsing XML:" + e.getMessage(), e);
                    }
                    eventArrived = true;
                }
                if (count.get() == 3) {
                    try {
                        Assert.assertEquals(true, new XMLComparator().compare(AXIOMUtil.stringToOM("<sensor>" + "<commonAttr1>45</commonAttr1>" + "<commonAttr2>100.13456</commonAttr2>" + "<commonAttr3>true</commonAttr3>" + "<commonAttr4>Event3</commonAttr4>" + "</sensor>"), AXIOMUtil.stringToOM((String) event.getData(0))));
                    } catch (XMLComparisonException e) {
                        log.error("Error comparing two XML elements:" + e.getMessage(), e);
                    } catch (XMLStreamException e) {
                        log.error("Error parsing XML:" + e.getMessage(), e);
                    }
                    eventArrived = true;
                }
            }
        }
    });
    InputHandler inputHandler = executionPlanRuntime.getInputHandler("inputStream");
    executionPlanRuntime.start();
    inputHandler.send(new Object[] { 25, 100.1, true, "Event1" });
    inputHandler.send(new Object[] { 35, 100.11, false, "Event2" });
    inputHandler.send(new Object[] { 45, 100.13456, true, "Event3" });
    SiddhiTestHelper.waitForEvents(100, 3, count, 60000);
    Assert.assertEquals(3, count.get());
    Assert.assertTrue(eventArrived);
    executionPlanRuntime.shutdown();
}

86. ToXMLFunctionExtensionTestCase#testToXMLFunctionExtension()

Project: siddhi
File: ToXMLFunctionExtensionTestCase.java
@Test
public void testToXMLFunctionExtension() throws InterruptedException {
    log.info("ToXMLFunctionExtension TestCase");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setExtension("str:concat", ConcatFunctionExtension.class);
    String inStreamDefinition = "\ndefine stream inputStream (symbol string, price long, volume long);";
    String query = ("@info(name = 'query1') from inputStream select " + "map:createFromXML(\"<sensor>" + "<commonAttr1>19</commonAttr1>" + "<commonAttr2>11.45</commonAttr2>" + "<commonAttr3>true</commonAttr3>" + "<commonAttr4>ELEMENT_TEXT</commonAttr4>" + "<specAttributesObj>" + "<specAttr1>111</specAttr1>" + "<specAttr2>222</specAttr2>" + "</specAttributesObj>" + "</sensor>\") as hashMap insert into outputStream;" + "from outputStream " + "select map:toXML(hashMap) as xmlString " + "insert into outputStream2;");
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(inStreamDefinition + query);
    executionPlanRuntime.addCallback("outputStream2", new StreamCallback() {

        @Override
        public void receive(Event[] inEvents) {
            EventPrinter.print(inEvents);
            for (Event event : inEvents) {
                count.incrementAndGet();
                if (count.get() == 1) {
                    try {
                        Assert.assertEquals(true, new XMLComparator().compare(AXIOMUtil.stringToOM("<sensor>" + "<commonAttr1>19</commonAttr1>" + "<commonAttr2>11.45</commonAttr2>" + "<commonAttr3>true</commonAttr3>" + "<commonAttr4>ELEMENT_TEXT</commonAttr4>" + "<specAttributesObj><specAttr1>111</specAttr1><specAttr2>222</specAttr2></specAttributesObj>" + "</sensor>"), AXIOMUtil.stringToOM((String) event.getData(0))));
                    } catch (XMLStreamException e) {
                        log.error("Error parsing XML:" + e.getMessage(), e);
                    } catch (XMLComparisonException e) {
                        log.error("Error comparing two XML elements:" + e.getMessage(), e);
                    }
                    eventArrived = true;
                }
            }
        }
    });
    InputHandler inputHandler = executionPlanRuntime.getInputHandler("inputStream");
    executionPlanRuntime.start();
    inputHandler.send(new Object[] { "IBM", 100, 100l });
    inputHandler.send(new Object[] { "WSO2", 200, 200l });
    inputHandler.send(new Object[] { "XYZ", 300, 200l });
    SiddhiTestHelper.waitForEvents(100, 3, count, 60000);
    Assert.assertEquals(3, count.get());
    Assert.assertTrue(eventArrived);
    executionPlanRuntime.shutdown();
}

87. ToJSONFunctionExtensionTestCase#testToJSONFunctionExtension2()

Project: siddhi
File: ToJSONFunctionExtensionTestCase.java
@Test
public void testToJSONFunctionExtension2() throws InterruptedException {
    log.info("ToJSONFunctionExtension TestCase 2");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setExtension("str:concat", ConcatFunctionExtension.class);
    String inStreamDefinition = "\ndefine stream inputStream (symbol string, price long, volume long);";
    String query = ("@info(name = 'query1') from inputStream select " + "map:createFromJSON(str:concat('{symbol :',symbol,', price :',price,', volume :',volume,'}')) as hashMap insert into outputStream;" + "from outputStream " + "select map:toJSON(hashMap) as jsonString " + "insert into outputStream2");
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(inStreamDefinition + query);
    executionPlanRuntime.addCallback("outputStream2", new StreamCallback() {

        @Override
        public void receive(Event[] inEvents) {
            EventPrinter.print(inEvents);
            for (Event event : inEvents) {
                count.incrementAndGet();
                if (count.get() == 1) {
                    Assert.assertEquals(event.getData(0) instanceof String, true);
                    try {
                        JSONAssert.assertEquals(new JSONObject("{\"volume\":100,\"symbol\":\"IBM\",\"price\":100}"), new JSONObject((String) event.getData(0)), false);
                    } catch (JSONException e) {
                        log.error(e);
                        Assert.fail(e.getMessage());
                    }
                    eventArrived = true;
                }
                if (count.get() == 2) {
                    Assert.assertEquals(event.getData(0) instanceof String, true);
                    try {
                        JSONAssert.assertEquals(new JSONObject("{\"volume\":200,\"symbol\":\"WSO2\",\"price\":200}"), new JSONObject((String) event.getData(0)), false);
                    } catch (JSONException e) {
                        log.error(e);
                        Assert.fail(e.getMessage());
                    }
                    eventArrived = true;
                }
                if (count.get() == 3) {
                    Assert.assertEquals(event.getData(0) instanceof String, true);
                    try {
                        JSONAssert.assertEquals(new JSONObject("{\"volume\":200,\"symbol\":\"XYZ\",\"price\":300}"), new JSONObject((String) event.getData(0)), false);
                    } catch (JSONException e) {
                        log.error(e);
                        Assert.fail(e.getMessage());
                    }
                    eventArrived = true;
                }
            }
        }
    });
    InputHandler inputHandler = executionPlanRuntime.getInputHandler("inputStream");
    executionPlanRuntime.start();
    inputHandler.send(new Object[] { "IBM", 100, 100l });
    inputHandler.send(new Object[] { "WSO2", 200, 200l });
    inputHandler.send(new Object[] { "XYZ", 300, 200l });
    SiddhiTestHelper.waitForEvents(100, 3, count, 60000);
    Assert.assertEquals(3, count.get());
    Assert.assertTrue(eventArrived);
    executionPlanRuntime.shutdown();
}

88. ToJSONFunctionExtensionTestCase#testToJSONFunctionExtension()

Project: siddhi
File: ToJSONFunctionExtensionTestCase.java
@Test
public void testToJSONFunctionExtension() throws InterruptedException {
    log.info("ToJSONFunctionExtension TestCase");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setExtension("str:concat", ConcatFunctionExtension.class);
    String inStreamDefinition = "\ndefine stream inputStream (symbol string, price long, volume long);";
    String query = ("@info(name = 'query1') from inputStream select " + "map:createFromJSON(\"{'symbol':'WSO2','price':100,'volume':100,'last5val':{'price':150,'volume':200}}\") as hashMap insert into outputStream;" + "from outputStream " + "select map:toJSON(hashMap) as jsonString " + "insert into outputStream2");
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(inStreamDefinition + query);
    executionPlanRuntime.addCallback("outputStream2", new StreamCallback() {

        @Override
        public void receive(Event[] inEvents) {
            EventPrinter.print(inEvents);
            for (Event event : inEvents) {
                count.incrementAndGet();
                if (count.get() == 1) {
                    Assert.assertEquals(event.getData(0) instanceof String, true);
                    try {
                        JSONAssert.assertEquals(new JSONObject("{\"volume\":100,\"symbol\":\"WSO2\",\"price\":100,\"last5val\":{\"volume\":200,\"price\":150}}"), new JSONObject((String) event.getData(0)), false);
                    } catch (JSONException e) {
                        log.error(e);
                        Assert.fail(e.getMessage());
                    }
                    eventArrived = true;
                }
            }
        }
    });
    InputHandler inputHandler = executionPlanRuntime.getInputHandler("inputStream");
    executionPlanRuntime.start();
    inputHandler.send(new Object[] { "IBM", 100, 100l });
    inputHandler.send(new Object[] { "WSO2", 200, 200l });
    inputHandler.send(new Object[] { "XYZ", 300, 200l });
    SiddhiTestHelper.waitForEvents(100, 3, count, 60000);
    Assert.assertEquals(3, count.get());
    Assert.assertTrue(eventArrived);
    executionPlanRuntime.shutdown();
}

89. CreateFromXMLFunctionExtensionTestCase#testCreateFromXMLFunctionExtension2()

Project: siddhi
File: CreateFromXMLFunctionExtensionTestCase.java
@Test
public void testCreateFromXMLFunctionExtension2() throws InterruptedException {
    log.info("CreateFromXMLFunctionExtension TestCase 2");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setExtension("str:concat", ConcatFunctionExtension.class);
    String inStreamDefinition = "\ndefine stream inputStream (longAttr long, doubleAttr double, booleanAttr bool, strAttr string);";
    String query = ("@info(name = 'query1') from inputStream select " + "map:createFromXML(str:concat('<sensor><commonAttr1>',longAttr,'</commonAttr1><commonAttr2>'," + "doubleAttr,'</commonAttr2><commonAttr3>',booleanAttr,'</commonAttr3><commonAttr4>',strAttr,'</commonAttr4></sensor>')) " + "as hashMap insert into outputStream;");
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(inStreamDefinition + query);
    executionPlanRuntime.addCallback("outputStream", new StreamCallback() {

        @Override
        public void receive(Event[] inEvents) {
            EventPrinter.print(inEvents);
            for (Event event : inEvents) {
                count.incrementAndGet();
                Map map = (Map) ((Map) event.getData(0)).get("sensor");
                if (count.get() == 1) {
                    Assert.assertEquals(map.get("commonAttr1"), 25l);
                    Assert.assertEquals(map.get("commonAttr2"), 100.1d);
                    Assert.assertEquals(map.get("commonAttr3"), true);
                    Assert.assertEquals(map.get("commonAttr4"), "Event1");
                    eventArrived = true;
                }
                if (count.get() == 2) {
                    Assert.assertEquals(map.get("commonAttr1"), 35l);
                    Assert.assertEquals(map.get("commonAttr2"), 100.11d);
                    Assert.assertEquals(map.get("commonAttr3"), false);
                    Assert.assertEquals(map.get("commonAttr4"), "Event2");
                    eventArrived = true;
                }
                if (count.get() == 3) {
                    Assert.assertEquals(map.get("commonAttr1"), 45l);
                    Assert.assertEquals(map.get("commonAttr2"), 100.13456d);
                    Assert.assertEquals(map.get("commonAttr3"), true);
                    Assert.assertEquals(map.get("commonAttr4"), "Event3");
                    eventArrived = true;
                }
            }
        }
    });
    InputHandler inputHandler = executionPlanRuntime.getInputHandler("inputStream");
    executionPlanRuntime.start();
    inputHandler.send(new Object[] { 25, 100.1, true, "Event1" });
    inputHandler.send(new Object[] { 35, 100.11, false, "Event2" });
    inputHandler.send(new Object[] { 45, 100.13456, true, "Event3" });
    SiddhiTestHelper.waitForEvents(100, 3, count, 60000);
    Assert.assertEquals(3, count.get());
    Assert.assertTrue(eventArrived);
    executionPlanRuntime.shutdown();
}

90. CreateFromXMLFunctionExtensionTestCase#testCreateFromXMLFunctionExtension()

Project: siddhi
File: CreateFromXMLFunctionExtensionTestCase.java
@Test
public void testCreateFromXMLFunctionExtension() throws InterruptedException {
    log.info("CreateFromXMLFunctionExtension TestCase");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setExtension("str:concat", ConcatFunctionExtension.class);
    String inStreamDefinition = "\ndefine stream inputStream (symbol string, price long, volume long);";
    String query = ("@info(name = 'query1') from inputStream select " + "map:createFromXML(\"<sensor>" + "<commonAttr1>19</commonAttr1>" + "<commonAttr2>11.45</commonAttr2>" + "<commonAttr3>true</commonAttr3>" + "<commonAttr4>ELEMENT_TEXT</commonAttr4>" + "<specAttributesObj>" + "<specAttr1>111</specAttr1>" + "<specAttr2>222</specAttr2>" + "</specAttributesObj>" + "</sensor>\") as hashMap insert into outputStream;");
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(inStreamDefinition + query);
    executionPlanRuntime.addCallback("outputStream", new StreamCallback() {

        @Override
        public void receive(Event[] inEvents) {
            EventPrinter.print(inEvents);
            for (Event event : inEvents) {
                count.incrementAndGet();
                if (count.get() == 1) {
                    Map map = (Map) ((Map) event.getData(0)).get("sensor");
                    Assert.assertEquals(map.get("commonAttr1"), 19l);
                    Assert.assertEquals(map.get("commonAttr2"), 11.45d);
                    Assert.assertEquals(map.get("commonAttr3"), true);
                    Assert.assertEquals(map.get("commonAttr4"), "ELEMENT_TEXT");
                    eventArrived = true;
                }
            }
        }
    });
    InputHandler inputHandler = executionPlanRuntime.getInputHandler("inputStream");
    executionPlanRuntime.start();
    inputHandler.send(new Object[] { "IBM", 100, 100l });
    inputHandler.send(new Object[] { "WSO2", 200, 200l });
    inputHandler.send(new Object[] { "XYZ", 300, 200l });
    SiddhiTestHelper.waitForEvents(100, 3, count, 60000);
    Assert.assertEquals(3, count.get());
    Assert.assertTrue(eventArrived);
    executionPlanRuntime.shutdown();
}

91. CreateFromJSONFunctionExtensionTestCase#testCreateFromJSONFunctionExtension2()

Project: siddhi
File: CreateFromJSONFunctionExtensionTestCase.java
@Test
public void testCreateFromJSONFunctionExtension2() throws InterruptedException {
    log.info("CreateFromJSONFunctionExtension TestCase 2");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setExtension("str:concat", ConcatFunctionExtension.class);
    String inStreamDefinition = "\ndefine stream inputStream (symbol string, price long, volume long);";
    String query = ("@info(name = 'query1') from inputStream select " + "map:createFromJSON(str:concat('{symbol :',symbol,', price :',price,', volume :',volume,'}')) as hashMap insert into outputStream;");
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(inStreamDefinition + query);
    executionPlanRuntime.addCallback("outputStream", new StreamCallback() {

        @Override
        public void receive(Event[] inEvents) {
            EventPrinter.print(inEvents);
            for (Event event : inEvents) {
                count.incrementAndGet();
                HashMap map = (HashMap) event.getData(0);
                if (count.get() == 1) {
                    Assert.assertEquals("IBM", map.get("symbol"));
                    eventArrived = true;
                }
                if (count.get() == 2) {
                    Assert.assertEquals("WSO2", map.get("symbol"));
                    eventArrived = true;
                }
                if (count.get() == 3) {
                    Assert.assertEquals("XYZ", map.get("symbol"));
                    eventArrived = true;
                }
            }
        }
    });
    InputHandler inputHandler = executionPlanRuntime.getInputHandler("inputStream");
    executionPlanRuntime.start();
    inputHandler.send(new Object[] { "IBM", 100, 100l });
    inputHandler.send(new Object[] { "WSO2", 200, 200l });
    inputHandler.send(new Object[] { "XYZ", 300, 200l });
    SiddhiTestHelper.waitForEvents(100, 3, count, 60000);
    Assert.assertEquals(3, count.get());
    Assert.assertTrue(eventArrived);
    executionPlanRuntime.shutdown();
}

92. CreateFromJSONFunctionExtensionTestCase#testCreateFromJSONFunctionExtension()

Project: siddhi
File: CreateFromJSONFunctionExtensionTestCase.java
@Test
public void testCreateFromJSONFunctionExtension() throws InterruptedException {
    log.info("CreateFromJSONFunctionExtension TestCase");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setExtension("str:concat", ConcatFunctionExtension.class);
    String inStreamDefinition = "\ndefine stream inputStream (symbol string, price long, volume long);";
    String query = ("@info(name = 'query1') from inputStream select " + "map:createFromJSON(\"{'symbol':'IBM','price':100,'volume':100 }\") as hashMap insert into outputStream;");
    ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(inStreamDefinition + query);
    executionPlanRuntime.addCallback("outputStream", new StreamCallback() {

        @Override
        public void receive(Event[] inEvents) {
            EventPrinter.print(inEvents);
            for (Event event : inEvents) {
                count.incrementAndGet();
                if (count.get() == 1) {
                    HashMap map = (HashMap) event.getData(0);
                    Assert.assertEquals("IBM", map.get("symbol"));
                    eventArrived = true;
                }
            }
        }
    });
    InputHandler inputHandler = executionPlanRuntime.getInputHandler("inputStream");
    executionPlanRuntime.start();
    inputHandler.send(new Object[] { "IBM", 100, 100l });
    inputHandler.send(new Object[] { "WSO2", 200, 200l });
    inputHandler.send(new Object[] { "XYZ", 300, 200l });
    SiddhiTestHelper.waitForEvents(100, 3, count, 60000);
    Assert.assertEquals(3, count.get());
    Assert.assertTrue(eventArrived);
    executionPlanRuntime.shutdown();
}

93. UpdateFromRDBMSTestCase#updateFromTableTest7()

Project: siddhi
File: UpdateFromRDBMSTestCase.java
@Test
public void updateFromTableTest7() throws InterruptedException {
    log.info("updateFromTableTest7");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setDataSource(RDBMSTestConstants.DATA_SOURCE_NAME, dataSource);
    try {
        if (dataSource.getConnection() != null) {
            DBConnectionHelper.getDBConnectionHelperInstance().clearDatabaseTable(dataSource, RDBMSTestConstants.TABLE_NAME);
            String streams = "" + "define stream StockStream (symbol string, price float, volume long); " + "define stream CheckStockStream (symbol string, price float, volume long); " + "define stream UpdateStockStream (comp string, prc float); " + "@from(eventtable = 'rdbms' ,datasource.name = '" + RDBMSTestConstants.DATA_SOURCE_NAME + "' , table.name = '" + RDBMSTestConstants.TABLE_NAME + "') " + "define table StockTable (symbol string, price float, volume long); ";
            String query = "" + "@info(name = 'query1') " + "from StockStream " + "insert into StockTable ;" + "" + "@info(name = 'query2') " + "from UpdateStockStream " + "select comp as symbol, prc as price " + "update StockTable " + "   on StockTable.symbol==symbol;" + "" + "@info(name = 'query3') " + "from CheckStockStream[(symbol==StockTable.symbol and volume==StockTable.volume and price<StockTable.price) in StockTable] " + "insert into OutStream;";
            ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(streams + query);
            executionPlanRuntime.addCallback("query3", new QueryCallback() {

                @Override
                public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
                    EventPrinter.print(timeStamp, inEvents, removeEvents);
                    if (inEvents != null) {
                        for (Event event : inEvents) {
                            inEventCount++;
                            switch(inEventCount) {
                                case 1:
                                    Assert.assertArrayEquals(new Object[] { "IBM", 150.6f, 100l }, event.getData());
                                    break;
                                case 2:
                                    Assert.assertArrayEquals(new Object[] { "IBM", 190.6f, 100l }, event.getData());
                                    break;
                                default:
                                    Assert.assertSame(2, inEventCount);
                            }
                        }
                        eventArrived = true;
                    }
                    if (removeEvents != null) {
                        removeEventCount = removeEventCount + removeEvents.length;
                    }
                    eventArrived = true;
                }
            });
            InputHandler stockStream = executionPlanRuntime.getInputHandler("StockStream");
            InputHandler checkStockStream = executionPlanRuntime.getInputHandler("CheckStockStream");
            InputHandler updateStockStream = executionPlanRuntime.getInputHandler("UpdateStockStream");
            executionPlanRuntime.start();
            stockStream.send(new Object[] { "WSO2", 55.6f, 100l });
            stockStream.send(new Object[] { "IBM", 185.6f, 100l });
            checkStockStream.send(new Object[] { "IBM", 150.6f, 100l });
            checkStockStream.send(new Object[] { "WSO2", 175.6f, 100l });
            updateStockStream.send(new Object[] { "IBM", 200f });
            checkStockStream.send(new Object[] { "IBM", 190.6f, 100l });
            checkStockStream.send(new Object[] { "WSO2", 155.6f, 100l });
            Thread.sleep(2000);
            Assert.assertEquals("Number of success events", 2, inEventCount);
            Assert.assertEquals("Number of remove events", 0, removeEventCount);
            Assert.assertEquals("Event arrived", true, eventArrived);
            executionPlanRuntime.shutdown();
        }
    } catch (SQLException e) {
        log.info("Test case ignored due to DB connection unavailability");
    }
}

94. UpdateFromRDBMSTestCase#updateFromTableTest6()

Project: siddhi
File: UpdateFromRDBMSTestCase.java
@Test
public void updateFromTableTest6() throws InterruptedException {
    log.info("updateFromTableTest6");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setDataSource(RDBMSTestConstants.DATA_SOURCE_NAME, dataSource);
    try {
        if (dataSource.getConnection() != null) {
            DBConnectionHelper.getDBConnectionHelperInstance().clearDatabaseTable(dataSource, RDBMSTestConstants.TABLE_NAME);
            String streams = "" + "define stream StockStream (symbol string, price float, volume long); " + "define stream CheckStockStream (symbol string, volume long); " + "@from(eventtable = 'rdbms' ,datasource.name = '" + RDBMSTestConstants.DATA_SOURCE_NAME + "' , table.name = '" + RDBMSTestConstants.TABLE_NAME + "') " + "define table StockTable (symbol string, price float, volume long); ";
            String query = "" + "@info(name = 'query1') " + "from StockStream " + "insert into StockTable ;" + "" + "@info(name = 'query2') " + "from CheckStockStream[(StockTable.symbol==symbol) in StockTable] " + "insert into OutStream;";
            ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(streams + query);
            executionPlanRuntime.addCallback("query2", new QueryCallback() {

                @Override
                public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
                    EventPrinter.print(timeStamp, inEvents, removeEvents);
                    if (inEvents != null) {
                        for (Event event : inEvents) {
                            inEventCount++;
                        }
                        eventArrived = true;
                    }
                }
            });
            InputHandler stockStream = executionPlanRuntime.getInputHandler("StockStream");
            InputHandler checkStockStream = executionPlanRuntime.getInputHandler("CheckStockStream");
            executionPlanRuntime.start();
            stockStream.send(new Object[] { "WSO2", 55.6f, 100l });
            stockStream.send(new Object[] { "IBM", 55.6f, 100l });
            checkStockStream.send(new Object[] { "IBM", 100l });
            checkStockStream.send(new Object[] { "WSO2", 100l });
            checkStockStream.send(new Object[] { "IBM", 100l });
            Thread.sleep(1000);
            Assert.assertEquals("Number of success events", 3, inEventCount);
            Assert.assertEquals("Event arrived", true, eventArrived);
            executionPlanRuntime.shutdown();
        }
    } catch (SQLException e) {
        log.info("Test case ignored due to DB connection unavailability");
    }
}

95. UpdateFromRDBMSTestCase#updateFromTableTest5()

Project: siddhi
File: UpdateFromRDBMSTestCase.java
@Test
public void updateFromTableTest5() throws InterruptedException {
    log.info("updateFromTableTest5");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setDataSource(RDBMSTestConstants.DATA_SOURCE_NAME, dataSource);
    try {
        if (dataSource.getConnection() != null) {
            DBConnectionHelper.getDBConnectionHelperInstance().clearDatabaseTable(dataSource, RDBMSTestConstants.TABLE_NAME);
            String streams = "" + "define stream StockStream (symbol string, price float, volume long); " + "define stream CheckStockStream (symbol string, volume long); " + "@from(eventtable = 'rdbms' ,datasource.name = '" + RDBMSTestConstants.DATA_SOURCE_NAME + "' , table.name = '" + RDBMSTestConstants.TABLE_NAME + "' , bloom.filters = 'enable') " + "define table StockTable (symbol string, price float, volume long); ";
            String query = "" + "@info(name = 'query1') " + "from StockStream " + "insert into StockTable ;" + "" + "@info(name = 'query2') " + "from CheckStockStream[(StockTable.symbol==symbol) in StockTable] " + "insert into OutStream;";
            ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(streams + query);
            executionPlanRuntime.addCallback("query2", new QueryCallback() {

                @Override
                public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
                    EventPrinter.print(timeStamp, inEvents, removeEvents);
                    if (inEvents != null) {
                        for (Event event : inEvents) {
                            inEventCount++;
                        }
                        eventArrived = true;
                    }
                }
            });
            InputHandler stockStream = executionPlanRuntime.getInputHandler("StockStream");
            InputHandler checkStockStream = executionPlanRuntime.getInputHandler("CheckStockStream");
            executionPlanRuntime.start();
            stockStream.send(new Object[] { "WSO2", 55.6f, 100l });
            stockStream.send(new Object[] { "IBM", 55.6f, 100l });
            checkStockStream.send(new Object[] { "BSD", 100l });
            checkStockStream.send(new Object[] { "WSO2", 100l });
            checkStockStream.send(new Object[] { "IBM", 100l });
            Thread.sleep(1000);
            Assert.assertEquals("Number of success events", 2, inEventCount);
            Assert.assertEquals("Event arrived", true, eventArrived);
            executionPlanRuntime.shutdown();
        }
    } catch (SQLException e) {
        log.info("Test case ignored due to DB connection unavailability");
    }
}

96. UpdateFromRDBMSTestCase#updateFromTableTest4()

Project: siddhi
File: UpdateFromRDBMSTestCase.java
@Test
public void updateFromTableTest4() throws InterruptedException {
    log.info("updateFromTableTest4");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setDataSource(RDBMSTestConstants.DATA_SOURCE_NAME, dataSource);
    try {
        if (dataSource.getConnection() != null) {
            DBConnectionHelper.getDBConnectionHelperInstance().clearDatabaseTable(dataSource, RDBMSTestConstants.TABLE_NAME);
            String streams = "" + "define stream StockStream (symbol string, price float, volume long); " + "define stream CheckStockStream (symbol string, volume long); " + "@from(eventtable = 'rdbms' ,datasource.name = '" + RDBMSTestConstants.DATA_SOURCE_NAME + "' , table.name = '" + RDBMSTestConstants.TABLE_NAME + "' , bloom.filters = 'enable') " + "define table StockTable (symbol string, price float, volume long); ";
            String query = "" + "@info(name = 'query1') " + "from StockStream " + "insert into StockTable ;" + "" + "@info(name = 'query2') " + "from CheckStockStream[(StockTable.symbol==symbol) in StockTable] " + "insert into OutStream;";
            ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(streams + query);
            executionPlanRuntime.addCallback("query2", new QueryCallback() {

                @Override
                public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
                    EventPrinter.print(timeStamp, inEvents, removeEvents);
                    if (inEvents != null) {
                        for (Event event : inEvents) {
                            inEventCount++;
                        }
                        eventArrived = true;
                    }
                }
            });
            InputHandler stockStream = executionPlanRuntime.getInputHandler("StockStream");
            InputHandler checkStockStream = executionPlanRuntime.getInputHandler("CheckStockStream");
            executionPlanRuntime.start();
            stockStream.send(new Object[] { "WSO2", 55.6f, 100l });
            stockStream.send(new Object[] { "IBM", 55.6f, 100l });
            checkStockStream.send(new Object[] { "IBM", 100l });
            checkStockStream.send(new Object[] { "WSO2", 100l });
            checkStockStream.send(new Object[] { "IBM", 100l });
            Thread.sleep(1000);
            Assert.assertEquals("Number of success events", 3, inEventCount);
            Assert.assertEquals("Event arrived", true, eventArrived);
            executionPlanRuntime.shutdown();
        }
    } catch (SQLException e) {
        log.info("Test case ignored due to DB connection unavailability");
    }
}

97. UpdateFromRDBMSTestCase#updateFromTableTest3()

Project: siddhi
File: UpdateFromRDBMSTestCase.java
@Test
public void updateFromTableTest3() throws InterruptedException {
    log.info("updateFromTableTest3");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setDataSource(RDBMSTestConstants.DATA_SOURCE_NAME, dataSource);
    try {
        if (dataSource.getConnection() != null) {
            DBConnectionHelper.getDBConnectionHelperInstance().clearDatabaseTable(dataSource, RDBMSTestConstants.TABLE_NAME);
            String streams = "" + "define stream StockStream (symbol string, price float, volume long); " + "define stream CheckStockStream (symbol string, volume long); " + "@from(eventtable = 'rdbms' ,datasource.name = '" + RDBMSTestConstants.DATA_SOURCE_NAME + "' , table.name = '" + RDBMSTestConstants.TABLE_NAME + "', cache='lru', cache.size='1000') " + "define table StockTable (symbol string, price float, volume long); ";
            String query = "" + "@info(name = 'query1') " + "from StockStream " + "insert into StockTable ;" + "" + "@info(name = 'query2') " + "from CheckStockStream[(StockTable.symbol==symbol) in StockTable] " + "insert into OutStream;";
            ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(streams + query);
            executionPlanRuntime.addCallback("query2", new QueryCallback() {

                @Override
                public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
                    EventPrinter.print(timeStamp, inEvents, removeEvents);
                    if (inEvents != null) {
                        for (Event event : inEvents) {
                            inEventCount++;
                        }
                        eventArrived = true;
                    }
                }
            });
            InputHandler stockStream = executionPlanRuntime.getInputHandler("StockStream");
            InputHandler checkStockStream = executionPlanRuntime.getInputHandler("CheckStockStream");
            executionPlanRuntime.start();
            stockStream.send(new Object[] { "WSO2", 55.6f, 100l });
            stockStream.send(new Object[] { "IBM", 55.6f, 100l });
            checkStockStream.send(new Object[] { "IBM", 100l });
            checkStockStream.send(new Object[] { "WSO2", 100l });
            checkStockStream.send(new Object[] { "IBM", 100l });
            Thread.sleep(1000);
            Assert.assertEquals("Number of success events", 3, inEventCount);
            Assert.assertEquals("Event arrived", true, eventArrived);
            executionPlanRuntime.shutdown();
        }
    } catch (SQLException e) {
        log.info("Test case ignored due to DB connection unavailability");
    }
}

98. UpdateFromRDBMSTestCase#updateFromRDBMSTableTest2()

Project: siddhi
File: UpdateFromRDBMSTestCase.java
@Test
public void updateFromRDBMSTableTest2() throws InterruptedException {
    log.info("updateFromTableTest2");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setDataSource(RDBMSTestConstants.DATA_SOURCE_NAME, dataSource);
    try {
        if (dataSource.getConnection() != null) {
            DBConnectionHelper.getDBConnectionHelperInstance().clearDatabaseTable(dataSource, RDBMSTestConstants.TABLE_NAME);
            String streams = "" + "define stream StockStream (symbol string, price float, volume long); " + "define stream UpdateStockStream (symbol string, price float, volume long); " + "@from(eventtable = 'rdbms' ,datasource.name = '" + RDBMSTestConstants.DATA_SOURCE_NAME + "' , table.name = '" + RDBMSTestConstants.TABLE_NAME + "', cache='lru', cache.size='1000')  " + "define table StockTable (symbol string, price float, volume long); ";
            String query = "" + "@info(name = 'query1') " + "from StockStream " + "insert into StockTable ;" + "" + "@info(name = 'query2') " + "from UpdateStockStream " + "update StockTable " + "   on StockTable.symbol == symbol ;";
            ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(streams + query);
            InputHandler stockStream = executionPlanRuntime.getInputHandler("StockStream");
            InputHandler updateStockStream = executionPlanRuntime.getInputHandler("UpdateStockStream");
            executionPlanRuntime.start();
            stockStream.send(new Object[] { "WSO2", 55.6f, 100l });
            stockStream.send(new Object[] { "IBM", 75.6f, 100l });
            stockStream.send(new Object[] { "WSO2", 57.6f, 100l });
            updateStockStream.send(new Object[] { "IBM", 57.6f, 100l });
            Thread.sleep(1000);
            long totalRowsInTable = DBConnectionHelper.getDBConnectionHelperInstance().getRowsInTable(dataSource);
            Assert.assertEquals("Update failed", 3, totalRowsInTable);
            executionPlanRuntime.shutdown();
        }
    } catch (SQLException e) {
        log.info("Test case ignored due to DB connection unavailability");
    }
}

99. UpdateFromRDBMSTestCase#updateFromRDBMSTableTest1()

Project: siddhi
File: UpdateFromRDBMSTestCase.java
@Test
public void updateFromRDBMSTableTest1() throws InterruptedException {
    log.info("updateFromTableTest1");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setDataSource(RDBMSTestConstants.DATA_SOURCE_NAME, dataSource);
    try {
        if (dataSource.getConnection() != null) {
            DBConnectionHelper.getDBConnectionHelperInstance().clearDatabaseTable(dataSource, RDBMSTestConstants.TABLE_NAME);
            String streams = "" + "define stream StockStream (symbol string, price float, volume long); " + "define stream UpdateStockStream (symbol string, price float, volume long); " + "@from(eventtable = 'rdbms' ,datasource.name = '" + RDBMSTestConstants.DATA_SOURCE_NAME + "' , table.name = '" + RDBMSTestConstants.TABLE_NAME + "')  " + "define table StockTable (symbol string, price float, volume long); ";
            String query = "" + "@info(name = 'query1') " + "from StockStream " + "insert into StockTable ;" + "" + "@info(name = 'query2') " + "from UpdateStockStream " + "update StockTable " + "   on StockTable.symbol == symbol ;";
            ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(streams + query);
            InputHandler stockStream = executionPlanRuntime.getInputHandler("StockStream");
            InputHandler updateStockStream = executionPlanRuntime.getInputHandler("UpdateStockStream");
            executionPlanRuntime.start();
            stockStream.send(new Object[] { "WSO2", 55.6f, 100l });
            stockStream.send(new Object[] { "IBM", 75.6f, 100l });
            stockStream.send(new Object[] { "WSO2", 57.6f, 100l });
            updateStockStream.send(new Object[] { "IBM", 57.6f, 100l });
            Thread.sleep(1000);
            long totalRowsInTable = DBConnectionHelper.getDBConnectionHelperInstance().getRowsInTable(dataSource);
            Assert.assertEquals("Update failed", 3, totalRowsInTable);
            executionPlanRuntime.shutdown();
        }
    } catch (SQLException e) {
        log.info("Test case ignored due to DB connection unavailability");
    }
}

100. JoinRDBMSTableTestCase#testTableJoinQuery9()

Project: siddhi
File: JoinRDBMSTableTestCase.java
//----------------------------------------------- Connection Properties ----------------------------------------------------------
@Test
public void testTableJoinQuery9() throws InterruptedException {
    log.info("testTableJoinQuery9 - OUT 2");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setDataSource(RDBMSTestConstants.DATA_SOURCE_NAME, dataSource);
    try {
        if ((dataSource.getConnection()) != null) {
            DBConnectionHelper.getDBConnectionHelperInstance().clearDatabaseTable(dataSource, RDBMSTestConstants.TABLE_NAME);
            String streams = "" + "define stream StockStream (symbol string, price float, volume long); " + "define stream CheckStockStream (symbol string); " + "@from(eventtable = 'rdbms' , jdbc.url = 'jdbc:mysql://localhost:3306/cepdb' , username = 'root' , password = 'root' , driver.name = 'com.mysql.jdbc.Driver' , table.name = '" + RDBMSTestConstants.TABLE_NAME + "') " + "@connection(maxWait = '4000')" + "define table StockTable (symbol string, price float, volume long); ";
            String query = "" + "@info(name = 'query1') " + "from StockStream " + "insert into StockTable ;" + "" + "@info(name = 'query2') " + "from CheckStockStream#window.length(1) join StockTable " + "select CheckStockStream.symbol as checkSymbol, StockTable.symbol as symbol, StockTable.volume as volume  " + "insert into OutputStream ;";
            ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(streams + query);
            executionPlanRuntime.addCallback("query2", new QueryCallback() {

                @Override
                public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
                    EventPrinter.print(timeStamp, inEvents, removeEvents);
                    if (inEvents != null) {
                        for (Event event : inEvents) {
                            inEventCount++;
                            switch(inEventCount) {
                                case 1:
                                    Assert.assertArrayEquals(new Object[] { "WSO2", "WSO2", 100l }, event.getData());
                                    break;
                                case 2:
                                    Assert.assertArrayEquals(new Object[] { "WSO2", "IBM", 10l }, event.getData());
                                    break;
                                default:
                                    Assert.assertSame(2, inEventCount);
                            }
                        }
                        eventArrived = true;
                    }
                    if (removeEvents != null) {
                        removeEventCount = removeEventCount + removeEvents.length;
                    }
                    eventArrived = true;
                }
            });
            InputHandler stockStream = executionPlanRuntime.getInputHandler("StockStream");
            InputHandler checkStockStream = executionPlanRuntime.getInputHandler("CheckStockStream");
            executionPlanRuntime.start();
            stockStream.send(new Object[] { "WSO2", 55.6f, 100l });
            stockStream.send(new Object[] { "IBM", 75.6f, 10l });
            checkStockStream.send(new Object[] { "WSO2" });
            Thread.sleep(1000);
            Assert.assertEquals("Number of success events", 2, inEventCount);
            Assert.assertEquals("Number of remove events", 0, removeEventCount);
            Assert.assertEquals("Event arrived", true, eventArrived);
            executionPlanRuntime.shutdown();
        }
    } catch (SQLException e) {
        log.info("Test case ignored due to DB connection unavailability");
    }
}