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();
}
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();
}
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();
}
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();
}
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();
}
Aggregations