Search in sources :

Example 96 with And

use of org.wso2.siddhi.query.api.expression.condition.And in project siddhi by wso2.

the class EveryAbsentSequenceTestCase method testQueryAbsent20.

@Test
public void testQueryAbsent20() throws InterruptedException {
    log.info("Test the query every (not e1 and e2), e3 with e1, e2, e2 and e3");
    SiddhiManager siddhiManager = new SiddhiManager();
    String streams = "" + "define stream Stream1 (symbol string, price float, volume int); " + "define stream Stream2 (symbol string, price float, volume int); " + "define stream Stream3 (symbol string, price float, volume int); ";
    String query = "" + "@info(name = 'query1') " + "from every (not Stream1[price>10] and e2=Stream2[price>20]), e3=Stream3[price>30] " + "select e2.symbol as symbol2, e3.symbol as symbol3 " + "insert into OutputStream ;";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query);
    TestUtil.TestCallback callback = TestUtil.addQueryCallback(siddhiAppRuntime, "query1", new Object[] { "MICROSOFT", "GOOGLE" });
    InputHandler stream1 = siddhiAppRuntime.getInputHandler("Stream1");
    InputHandler stream2 = siddhiAppRuntime.getInputHandler("Stream2");
    InputHandler stream3 = siddhiAppRuntime.getInputHandler("Stream3");
    siddhiAppRuntime.start();
    stream1.send(new Object[] { "WSO2", 15.0f, 100 });
    Thread.sleep(100);
    stream2.send(new Object[] { "IBM", 25.0f, 100 });
    Thread.sleep(100);
    stream2.send(new Object[] { "MICROSOFT", 28.0f, 100 });
    Thread.sleep(100);
    stream3.send(new Object[] { "GOOGLE", 35.0f, 100 });
    Thread.sleep(100);
    callback.throwAssertionErrors();
    AssertJUnit.assertEquals("Number of success events", 1, callback.getInEventCount());
    AssertJUnit.assertEquals("Number of remove events", 0, callback.getRemoveEventCount());
    AssertJUnit.assertTrue("Event arrived", callback.isEventArrived());
    siddhiAppRuntime.shutdown();
}
Also used : InputHandler(org.wso2.siddhi.core.stream.input.InputHandler) TestUtil(org.wso2.siddhi.core.TestUtil) SiddhiAppRuntime(org.wso2.siddhi.core.SiddhiAppRuntime) SiddhiManager(org.wso2.siddhi.core.SiddhiManager) Test(org.testng.annotations.Test)

Example 97 with And

use of org.wso2.siddhi.query.api.expression.condition.And in project siddhi by wso2.

the class EveryAbsentSequenceTestCase method testQueryAbsent12.

@Test
public void testQueryAbsent12() throws InterruptedException {
    log.info("Test the query every not e1 for 1 sec, e2, e3-> e4 with e1, e2, e3, and e4");
    SiddhiManager siddhiManager = new SiddhiManager();
    String streams = "" + "define stream Stream1 (symbol string, price float, volume int); " + "define stream Stream2 (symbol string, price float, volume int); " + "define stream Stream3 (symbol string, price float, volume int); " + "define stream Stream4 (symbol string, price float, volume int); ";
    String query = "" + "@info(name = 'query1') " + "from every not Stream1[price>10] for 1 sec, e2=Stream2[price>20], e3=Stream3[price>30], " + "e4=Stream4[price>40] " + "select e2.symbol as symbol2, e3.symbol as symbol3, e4.symbol as symbol4 " + "insert into OutputStream ;";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query);
    TestUtil.TestCallback callback = TestUtil.addQueryCallback(siddhiAppRuntime, "query1");
    InputHandler stream1 = siddhiAppRuntime.getInputHandler("Stream1");
    InputHandler stream2 = siddhiAppRuntime.getInputHandler("Stream2");
    InputHandler stream3 = siddhiAppRuntime.getInputHandler("Stream3");
    InputHandler stream4 = siddhiAppRuntime.getInputHandler("Stream4");
    siddhiAppRuntime.start();
    stream1.send(new Object[] { "WSO2", 15.6f, 100 });
    Thread.sleep(100);
    stream2.send(new Object[] { "IBM", 28.7f, 100 });
    Thread.sleep(100);
    stream3.send(new Object[] { "GOOGLE", 38.7f, 100 });
    Thread.sleep(100);
    stream4.send(new Object[] { "ORACLE", 44.7f, 100 });
    Thread.sleep(100);
    callback.throwAssertionErrors();
    AssertJUnit.assertEquals("Number of success events", 0, callback.getInEventCount());
    AssertJUnit.assertEquals("Number of remove events", 0, callback.getRemoveEventCount());
    AssertJUnit.assertFalse("Event arrived", callback.isEventArrived());
    siddhiAppRuntime.shutdown();
}
Also used : InputHandler(org.wso2.siddhi.core.stream.input.InputHandler) TestUtil(org.wso2.siddhi.core.TestUtil) SiddhiAppRuntime(org.wso2.siddhi.core.SiddhiAppRuntime) SiddhiManager(org.wso2.siddhi.core.SiddhiManager) Test(org.testng.annotations.Test)

Example 98 with And

use of org.wso2.siddhi.query.api.expression.condition.And in project siddhi by wso2.

the class EveryAbsentSequenceTestCase method testQueryAbsent11.

@Test
public void testQueryAbsent11() throws InterruptedException {
    log.info("Test the query not e1 for 1 sec, e2, e3 with e1, e2 after 2 sec and e3");
    SiddhiManager siddhiManager = new SiddhiManager();
    String streams = "" + "define stream Stream1 (symbol string, price float, volume int); " + "define stream Stream2 (symbol string, price float, volume int); " + "define stream Stream3 (symbol string, price float, volume int); ";
    String query = "" + "@info(name = 'query1') " + "from  not Stream1[price>10] for 1 sec, e2=Stream2[price>20], e3=Stream3[price>30] " + "select e2.symbol as symbol2, e3.symbol as symbol3 " + "insert into OutputStream ;";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query);
    TestUtil.TestCallback callback = TestUtil.addQueryCallback(siddhiAppRuntime, "query1");
    InputHandler stream1 = siddhiAppRuntime.getInputHandler("Stream1");
    InputHandler stream2 = siddhiAppRuntime.getInputHandler("Stream2");
    InputHandler stream3 = siddhiAppRuntime.getInputHandler("Stream3");
    siddhiAppRuntime.start();
    stream1.send(new Object[] { "WSO2", 25.6f, 100 });
    Thread.sleep(1100);
    stream2.send(new Object[] { "IBM", 28.7f, 100 });
    Thread.sleep(100);
    stream3.send(new Object[] { "GOOGLE", 55.7f, 100 });
    Thread.sleep(100);
    callback.throwAssertionErrors();
    AssertJUnit.assertEquals("Number of success events", 0, callback.getInEventCount());
    AssertJUnit.assertEquals("Number of remove events", 0, callback.getRemoveEventCount());
    AssertJUnit.assertFalse("Event arrived", callback.isEventArrived());
    siddhiAppRuntime.shutdown();
}
Also used : InputHandler(org.wso2.siddhi.core.stream.input.InputHandler) TestUtil(org.wso2.siddhi.core.TestUtil) SiddhiAppRuntime(org.wso2.siddhi.core.SiddhiAppRuntime) SiddhiManager(org.wso2.siddhi.core.SiddhiManager) Test(org.testng.annotations.Test)

Example 99 with And

use of org.wso2.siddhi.query.api.expression.condition.And in project siddhi by wso2.

the class EveryAbsentSequenceTestCase method testQueryAbsent4.

@Test
public void testQueryAbsent4() throws InterruptedException {
    log.info("Test the query every not e1, e2 with e1 and e2 for 1 sec where e1 filter fails");
    SiddhiManager siddhiManager = new SiddhiManager();
    String streams = "" + "define stream Stream1 (symbol string, price float, volume int); " + "define stream Stream2 (symbol string, price float, volume int); ";
    String query = "" + "@info(name = 'query1') " + "from every not Stream1[price>20] for 1 sec, e2=Stream2[price>30] " + "select e2.symbol as symbol " + "insert into OutputStream ;";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query);
    TestUtil.TestCallback callback = TestUtil.addQueryCallback(siddhiAppRuntime, "query1");
    InputHandler stream1 = siddhiAppRuntime.getInputHandler("Stream1");
    InputHandler stream2 = siddhiAppRuntime.getInputHandler("Stream2");
    siddhiAppRuntime.start();
    stream1.send(new Object[] { "WSO2", 25.6f, 100 });
    Thread.sleep(500);
    stream1.send(new Object[] { "WSO2", 25.6f, 100 });
    Thread.sleep(500);
    stream1.send(new Object[] { "WSO2", 25.6f, 100 });
    Thread.sleep(500);
    stream2.send(new Object[] { "IBM", 58.7f, 100 });
    Thread.sleep(100);
    callback.throwAssertionErrors();
    AssertJUnit.assertEquals("Number of success events", 0, callback.getInEventCount());
    AssertJUnit.assertEquals("Number of remove events", 0, callback.getRemoveEventCount());
    AssertJUnit.assertFalse("Event not arrived", callback.isEventArrived());
    siddhiAppRuntime.shutdown();
}
Also used : InputHandler(org.wso2.siddhi.core.stream.input.InputHandler) TestUtil(org.wso2.siddhi.core.TestUtil) SiddhiAppRuntime(org.wso2.siddhi.core.SiddhiAppRuntime) SiddhiManager(org.wso2.siddhi.core.SiddhiManager) Test(org.testng.annotations.Test)

Example 100 with And

use of org.wso2.siddhi.query.api.expression.condition.And in project siddhi by wso2.

the class EveryAbsentSequenceTestCase method testQueryAbsent8.

@Test
public void testQueryAbsent8() throws InterruptedException {
    log.info("Test the query every not e1 for 1 sec, e2, e3 with e2 and e3");
    SiddhiManager siddhiManager = new SiddhiManager();
    String streams = "" + "define stream Stream1 (symbol string, price float, volume int); " + "define stream Stream2 (symbol string, price float, volume int); " + "define stream Stream3 (symbol string, price float, volume int); ";
    String query = "" + "@info(name = 'query1') " + "from every not Stream1[price>10] for 1 sec, e2=Stream2[price>20], e3=Stream3[price>30] " + "select e2.symbol as symbol2, e3.symbol as symbol3 " + "insert into OutputStream ;";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query);
    TestUtil.TestCallback callback = TestUtil.addQueryCallback(siddhiAppRuntime, "query1", new Object[] { "IBM", "GOOGLE" });
    InputHandler stream2 = siddhiAppRuntime.getInputHandler("Stream2");
    InputHandler stream3 = siddhiAppRuntime.getInputHandler("Stream3");
    siddhiAppRuntime.start();
    Thread.sleep(2100);
    stream2.send(new Object[] { "IBM", 28.7f, 100 });
    Thread.sleep(100);
    stream3.send(new Object[] { "GOOGLE", 55.7f, 100 });
    Thread.sleep(100);
    callback.throwAssertionErrors();
    AssertJUnit.assertEquals("Number of success events", 1, callback.getInEventCount());
    AssertJUnit.assertEquals("Number of remove events", 0, callback.getRemoveEventCount());
    AssertJUnit.assertTrue("Event arrived", callback.isEventArrived());
    siddhiAppRuntime.shutdown();
}
Also used : InputHandler(org.wso2.siddhi.core.stream.input.InputHandler) TestUtil(org.wso2.siddhi.core.TestUtil) SiddhiAppRuntime(org.wso2.siddhi.core.SiddhiAppRuntime) SiddhiManager(org.wso2.siddhi.core.SiddhiManager) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)409 SiddhiAppRuntime (org.wso2.siddhi.core.SiddhiAppRuntime)337 SiddhiManager (org.wso2.siddhi.core.SiddhiManager)336 InputHandler (org.wso2.siddhi.core.stream.input.InputHandler)327 TestUtil (org.wso2.siddhi.core.TestUtil)204 Event (org.wso2.siddhi.core.event.Event)119 ArrayList (java.util.ArrayList)110 QueryCallback (org.wso2.siddhi.core.query.output.callback.QueryCallback)86 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)77 HashMap (java.util.HashMap)61 PreparedStatement (java.sql.PreparedStatement)55 SQLException (java.sql.SQLException)51 IOException (java.io.IOException)45 Connection (java.sql.Connection)45 ActivityInterface (org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface)44 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)43 API (org.wso2.carbon.apimgt.core.models.API)39 ResultSet (java.sql.ResultSet)35 Map (java.util.Map)33 CharonException (org.wso2.charon3.core.exceptions.CharonException)33