use of org.wso2.siddhi.core.exception.NoPersistenceStoreException in project siddhi by wso2.
the class PersistenceTestCase method persistenceTest3.
@Test(expectedExceptions = NoPersistenceStoreException.class, dependsOnMethods = "persistenceTest2")
public void persistenceTest3() throws Exception {
log.info("persistence test 3 - no store defined");
SiddhiManager siddhiManager = new SiddhiManager();
String siddhiApp = "" + "@app:name('Test') " + "" + "define stream Stream1 (symbol string, price float, volume int); " + "define stream Stream2 (symbol string, price float, volume int); " + "" + "@info(name = 'query1') " + "from e1=Stream1[price>20] <2:5> -> e2=Stream2[price>20] " + "select e1[0].price as price1_0, e1[1].price as price1_1, e1[2].price as price1_2, " + " e1[3].price as price1_3, e2.price as price2 " + "insert into OutputStream ;";
QueryCallback queryCallback = new QueryCallback() {
@Override
public void receive(long timestamp, Event[] inEvents, Event[] removeEvents) {
EventPrinter.print(timestamp, inEvents, removeEvents);
eventArrived = true;
for (Event inEvent : inEvents) {
count++;
AssertJUnit.assertArrayEquals(new Object[] { 25.6f, 47.6f, null, null, 45.7f }, inEvent.getData());
}
}
};
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp);
siddhiAppRuntime.addCallback("query1", queryCallback);
InputHandler stream1 = siddhiAppRuntime.getInputHandler("Stream1");
InputHandler stream2 = siddhiAppRuntime.getInputHandler("Stream2");
siddhiAppRuntime.start();
stream1.send(new Object[] { "WSO2", 25.6f, 100 });
Thread.sleep(100);
stream1.send(new Object[] { "GOOG", 47.6f, 100 });
Thread.sleep(100);
stream1.send(new Object[] { "GOOG", 13.7f, 100 });
Thread.sleep(100);
AssertJUnit.assertEquals("Number of success events", 0, count);
AssertJUnit.assertEquals("Event arrived", false, eventArrived);
// persisting
Thread.sleep(500);
PersistenceReference persistenceReference = siddhiAppRuntime.persist();
try {
persistenceReference.getFuture().get();
} catch (ExecutionException e) {
throw e.getCause() instanceof NoPersistenceStoreException ? new NoPersistenceStoreException() : e;
}
// restarting siddhi app
Thread.sleep(500);
siddhiAppRuntime.shutdown();
}
Aggregations