use of io.siddhi.core.SiddhiManager in project siddhi by wso2.
the class DeleteFromTestStoreTestCase method deleteFromTestStoreTest5.
@Test
public void deleteFromTestStoreTest5() throws InterruptedException, SQLException {
log.info("deleteFromTestStoreTest5");
SiddhiManager siddhiManager = new SiddhiManager();
String streams = "" + "define stream StockStream (symbol string, price float, volume long); " + "define stream DeleteStockStream (symbol string, price float, volume long); " + "@Store(type=\"testStoreContainingInMemoryTable\")\n" + "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 ;";
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query);
InputHandler stockStream = siddhiAppRuntime.getInputHandler("StockStream");
InputHandler deleteStockStream = siddhiAppRuntime.getInputHandler("DeleteStockStream");
siddhiAppRuntime.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);
Event[] events = siddhiAppRuntime.query("" + "from StockTable ");
EventPrinter.print(events);
try {
AssertJUnit.assertEquals(2, events.length);
} catch (NullPointerException ignore) {
}
siddhiAppRuntime.shutdown();
}
use of io.siddhi.core.SiddhiManager in project siddhi by wso2.
the class DeleteFromTestStoreTestCase method deleteFromTestStoreTest1.
@Test(description = "deleteFromTestStoreTest1")
public void deleteFromTestStoreTest1() throws InterruptedException, SQLException {
SiddhiManager siddhiManager = new SiddhiManager();
String streams = "" + "define stream StockStream (symbol string, price float, volume long); " + "define stream DeleteStockStream (symbol string, price float, volume long); " + "@Store(type=\"testStoreContainingInMemoryTable\")\n" + "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 ;";
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query);
InputHandler stockStream = siddhiAppRuntime.getInputHandler("StockStream");
InputHandler deleteStockStream = siddhiAppRuntime.getInputHandler("DeleteStockStream");
siddhiAppRuntime.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);
Event[] events = siddhiAppRuntime.query("" + "from StockTable ");
EventPrinter.print(events);
try {
AssertJUnit.assertEquals(0, events.length);
} catch (NullPointerException ignore) {
}
siddhiAppRuntime.shutdown();
}
use of io.siddhi.core.SiddhiManager in project siddhi by wso2.
the class QueryAPITestCaseForTestStore method test11.
@Test
public void test11() throws InterruptedException {
log.info("Test10 table with cache");
SiddhiManager siddhiManager = new SiddhiManager();
String streams = "" + "define stream StockStream (symbol string, price float, volume long); " + "@Store(type=\"testStoreContainingInMemoryTable\")\n" + "define table StockTable (symbol string, price float, volume long); ";
String query = "" + "@info(name = 'query1') " + "from StockStream " + "insert into StockTable ;";
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query);
InputHandler stockStream = siddhiAppRuntime.getInputHandler("StockStream");
siddhiAppRuntime.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(500);
String storeQuery = "" + "from StockTable " + "on price > 56 " + "select symbol, price, sum(volume) as totalVolume " + "group by symbol, price ";
Event[] events = siddhiAppRuntime.query(storeQuery);
EventPrinter.print(events);
AssertJUnit.assertEquals(2, events.length);
AssertJUnit.assertEquals(100L, events[0].getData()[2]);
AssertJUnit.assertEquals(100L, events[1].getData()[2]);
events = siddhiAppRuntime.query(storeQuery);
EventPrinter.print(events);
AssertJUnit.assertEquals(2, events.length);
AssertJUnit.assertEquals(100L, events[0].getData()[2]);
AssertJUnit.assertEquals(100L, events[1].getData()[2]);
}
use of io.siddhi.core.SiddhiManager in project siddhi by wso2.
the class QueryAPITestCaseForTestStore method test0.
@Test
public void test0() throws InterruptedException {
log.info("Test1 table with cache");
SiddhiManager siddhiManager = new SiddhiManager();
String streams = "" + "define stream StockStream (symbol string, price float, volume long); " + "@Store(type=\"testStoreContainingInMemoryTable\")\n" + "define table StockTable (symbol string, price float, volume long); ";
String query = "" + "@info(name = 'query1') " + "from StockStream " + "insert into StockTable ;";
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query);
InputHandler stockStream = siddhiAppRuntime.getInputHandler("StockStream");
siddhiAppRuntime.start();
stockStream.send(new Object[] { "WSO2", 55.6f, 100L });
stockStream.send(new Object[] { "IBM", 75.6f, 100L });
stockStream.send(new Object[] { "WSO2", 57.6f, 200L });
Thread.sleep(500);
Event[] events = siddhiAppRuntime.query("" + "from StockTable ");
EventPrinter.print(events);
AssertJUnit.assertEquals(3, events.length);
events = siddhiAppRuntime.query("" + "from StockTable " + "on price > 75 ");
EventPrinter.print(events);
AssertJUnit.assertEquals(1, events.length);
events = siddhiAppRuntime.query("" + "from StockTable " + "on price > volume*3/4 ");
EventPrinter.print(events);
AssertJUnit.assertEquals(1, events.length);
siddhiAppRuntime.shutdown();
}
use of io.siddhi.core.SiddhiManager in project siddhi by wso2.
the class QueryAPITestCaseForTestStore method test1.
@Test
public void test1() throws InterruptedException {
log.info("Test1 table with cache");
SiddhiManager siddhiManager = new SiddhiManager();
String streams = "" + "define stream StockStream (symbol string, price float, volume long); " + "@Store(type=\"testStoreContainingInMemoryTable\")\n" + "define table StockTable (symbol string, price float, volume long); ";
String query = "" + "@info(name = 'query1') " + "from StockStream " + "insert into StockTable ;";
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query);
InputHandler stockStream = siddhiAppRuntime.getInputHandler("StockStream");
siddhiAppRuntime.start();
stockStream.send(new Object[] { "WSO2", 55.6f, 100L });
stockStream.send(new Object[] { "IBM", 75.6f, 100L });
stockStream.send(new Object[] { "WSO3", 57.6f, 100L });
Thread.sleep(500);
Event[] events = siddhiAppRuntime.query("" + "from StockTable ");
EventPrinter.print(events);
AssertJUnit.assertEquals(3, events.length);
events = siddhiAppRuntime.query("" + "from StockTable " + "on price > 75 ");
EventPrinter.print(events);
AssertJUnit.assertEquals(1, events.length);
events = siddhiAppRuntime.query("" + "from StockTable " + "on price > volume*3/4 ");
EventPrinter.print(events);
AssertJUnit.assertEquals(1, events.length);
siddhiAppRuntime.shutdown();
}
Aggregations