Search in sources :

Example 31 with SiddhiManager

use of io.siddhi.core.SiddhiManager in project siddhi by siddhi-io.

the class FilterTestCase1 method testFilterQuery21.

@Test
public void testFilterQuery21() throws InterruptedException {
    log.info("Filter test21");
    SiddhiManager siddhiManager = new SiddhiManager();
    String cseEventStream = "define stream cseEventStream (symbol string, price float, volume long);";
    String query = "@info(name = 'query1') from cseEventStream[volume != 100] select symbol,price,volume insert " + "into outputStream ;";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(cseEventStream + query);
    siddhiAppRuntime.addCallback("query1", new QueryCallback() {

        @Override
        public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
            EventPrinter.print(timeStamp, inEvents, removeEvents);
            AssertJUnit.assertEquals(10L, ((Long) inEvents[0].getData(2)).longValue());
            count.addAndGet(inEvents.length);
        }
    });
    InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream");
    siddhiAppRuntime.start();
    inputHandler.send(new Object[] { "WSO2", 55.6f, 100L });
    inputHandler.send(new Object[] { "WSO2", 57.6f, 10L });
    SiddhiTestHelper.waitForEvents(10, 1, count, 100);
    siddhiAppRuntime.shutdown();
}
Also used : InputHandler(io.siddhi.core.stream.input.InputHandler) SiddhiAppRuntime(io.siddhi.core.SiddhiAppRuntime) Event(io.siddhi.core.event.Event) SiddhiManager(io.siddhi.core.SiddhiManager) QueryCallback(io.siddhi.core.query.output.callback.QueryCallback) Test(org.testng.annotations.Test)

Example 32 with SiddhiManager

use of io.siddhi.core.SiddhiManager in project siddhi by siddhi-io.

the class FilterTestCase1 method testFilterQuery12.

@Test
public void testFilterQuery12() throws InterruptedException {
    log.info("Filter test12");
    SiddhiManager siddhiManager = new SiddhiManager();
    String cseEventStream = "define stream cseEventStream (symbol string, price float, volume double);";
    String query = "@info(name = 'query1') from cseEventStream[volume > 45] select symbol,price insert into " + "outputStream ;";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(cseEventStream + query);
    siddhiAppRuntime.addCallback("query1", new QueryCallback() {

        @Override
        public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
            EventPrinter.print(timeStamp, inEvents, removeEvents);
            count.addAndGet(inEvents.length);
        }
    });
    InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream");
    siddhiAppRuntime.start();
    inputHandler.send(new Object[] { "WSO2", 50f, 60d });
    inputHandler.send(new Object[] { "WSO2", 70f, 40d });
    inputHandler.send(new Object[] { "WSO2", 44f, 200d });
    SiddhiTestHelper.waitForEvents(10, 2, count, 100);
    siddhiAppRuntime.shutdown();
}
Also used : InputHandler(io.siddhi.core.stream.input.InputHandler) SiddhiAppRuntime(io.siddhi.core.SiddhiAppRuntime) Event(io.siddhi.core.event.Event) SiddhiManager(io.siddhi.core.SiddhiManager) QueryCallback(io.siddhi.core.query.output.callback.QueryCallback) Test(org.testng.annotations.Test)

Example 33 with SiddhiManager

use of io.siddhi.core.SiddhiManager in project siddhi by siddhi-io.

the class FilterTestCase1 method testFilterQuery9.

@Test
public void testFilterQuery9() throws InterruptedException {
    log.info("Filter test9");
    SiddhiManager siddhiManager = new SiddhiManager();
    String cseEventStream = "define stream cseEventStream (symbol string, price float, volume float);";
    String query = "@info(name = 'query1') from cseEventStream[volume > 50f] select symbol,price insert into " + "outputStream ;";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(cseEventStream + query);
    siddhiAppRuntime.addCallback("query1", new QueryCallback() {

        @Override
        public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
            EventPrinter.print(timeStamp, inEvents, removeEvents);
            count.addAndGet(inEvents.length);
        }
    });
    InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream");
    siddhiAppRuntime.start();
    inputHandler.send(new Object[] { "WSO2", 50f, 60f });
    inputHandler.send(new Object[] { "WSO2", 70f, 40f });
    inputHandler.send(new Object[] { "WSO2", 44f, 200f });
    SiddhiTestHelper.waitForEvents(10, 2, count, 100);
    siddhiAppRuntime.shutdown();
}
Also used : InputHandler(io.siddhi.core.stream.input.InputHandler) SiddhiAppRuntime(io.siddhi.core.SiddhiAppRuntime) Event(io.siddhi.core.event.Event) SiddhiManager(io.siddhi.core.SiddhiManager) QueryCallback(io.siddhi.core.query.output.callback.QueryCallback) Test(org.testng.annotations.Test)

Example 34 with SiddhiManager

use of io.siddhi.core.SiddhiManager in project siddhi by siddhi-io.

the class FilterTestCase1 method testFilterQuery11.

@Test
public void testFilterQuery11() throws InterruptedException {
    log.info("Filter test11");
    SiddhiManager siddhiManager = new SiddhiManager();
    String cseEventStream = "define stream cseEventStream (symbol string, price float, volume double);";
    String query = "@info(name = 'query1') from cseEventStream[volume > 50f] select symbol,price insert into " + "outputStream ;";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(cseEventStream + query);
    siddhiAppRuntime.addCallback("query1", new QueryCallback() {

        @Override
        public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
            EventPrinter.print(timeStamp, inEvents, removeEvents);
            count.addAndGet(inEvents.length);
        }
    });
    InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream");
    siddhiAppRuntime.start();
    inputHandler.send(new Object[] { "WSO2", 50f, 60d });
    inputHandler.send(new Object[] { "WSO2", 70f, 40d });
    inputHandler.send(new Object[] { "WSO2", 44f, 200d });
    SiddhiTestHelper.waitForEvents(10, 2, count, 100);
    siddhiAppRuntime.shutdown();
}
Also used : InputHandler(io.siddhi.core.stream.input.InputHandler) SiddhiAppRuntime(io.siddhi.core.SiddhiAppRuntime) Event(io.siddhi.core.event.Event) SiddhiManager(io.siddhi.core.SiddhiManager) QueryCallback(io.siddhi.core.query.output.callback.QueryCallback) Test(org.testng.annotations.Test)

Example 35 with SiddhiManager

use of io.siddhi.core.SiddhiManager in project siddhi by siddhi-io.

the class FilterTestCase1 method testFilterQuery24.

@Test
public void testFilterQuery24() throws InterruptedException {
    log.info("Filter test24");
    SiddhiManager siddhiManager = new SiddhiManager();
    String cseEventStream = "define stream cseEventStream (symbol string, price float, volume long);";
    String query = "@info(name = 'query1') from cseEventStream[volume != 50f] select symbol,price insert into " + "outputStream ;";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(cseEventStream + query);
    siddhiAppRuntime.addCallback("query1", new QueryCallback() {

        @Override
        public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
            EventPrinter.print(timeStamp, inEvents, removeEvents);
            count.addAndGet(inEvents.length);
        }
    });
    InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream");
    siddhiAppRuntime.start();
    inputHandler.send(new Object[] { "WSO2", 45f, 100L });
    inputHandler.send(new Object[] { "IBM", 35f, 50L });
    SiddhiTestHelper.waitForEvents(10, 1, count, 100);
    siddhiAppRuntime.shutdown();
}
Also used : InputHandler(io.siddhi.core.stream.input.InputHandler) SiddhiAppRuntime(io.siddhi.core.SiddhiAppRuntime) Event(io.siddhi.core.event.Event) SiddhiManager(io.siddhi.core.SiddhiManager) QueryCallback(io.siddhi.core.query.output.callback.QueryCallback) Test(org.testng.annotations.Test)

Aggregations

SiddhiManager (io.siddhi.core.SiddhiManager)3831 Test (org.testng.annotations.Test)3780 SiddhiAppRuntime (io.siddhi.core.SiddhiAppRuntime)3594 InputHandler (io.siddhi.core.stream.input.InputHandler)3208 Event (io.siddhi.core.event.Event)2567 QueryCallback (io.siddhi.core.query.output.callback.QueryCallback)1642 StreamCallback (io.siddhi.core.stream.output.StreamCallback)668 TestUtil (io.siddhi.core.TestUtil)608 ArrayList (java.util.ArrayList)181 SiddhiApp (io.siddhi.query.api.SiddhiApp)178 Query (io.siddhi.query.api.execution.query.Query)170 StreamDefinition (io.siddhi.query.api.definition.StreamDefinition)169 Logger (org.apache.logging.log4j.core.Logger)119 TestAppenderToValidateLogsForCachingTests (io.siddhi.core.query.table.util.TestAppenderToValidateLogsForCachingTests)68 InMemoryBroker (io.siddhi.core.util.transport.InMemoryBroker)64 CannotRestoreSiddhiAppStateException (io.siddhi.core.exception.CannotRestoreSiddhiAppStateException)60 HashMap (java.util.HashMap)51 UnitTestAppender (io.siddhi.core.UnitTestAppender)46 InMemoryConfigManager (io.siddhi.core.util.config.InMemoryConfigManager)43 InMemoryPersistenceStore (io.siddhi.core.util.persistence.InMemoryPersistenceStore)40