use of io.siddhi.core.exception.SiddhiAppCreationException in project siddhi by wso2.
the class SessionWindowTestCase method testSessionWindow8.
@Test(description = "This test checks if Siddhi App creation fails when" + " provided 2 paramters and 2nd parameter with wrong data type", expectedExceptions = SiddhiAppCreationException.class)
public void testSessionWindow8() {
log.info("SessionWindow Test8: Testing session window " + "with providing 2 parameters and 2nd parameter type is wrong");
SiddhiManager siddhiManager = new SiddhiManager();
SiddhiAppRuntime siddhiAppRuntime = null;
String purchaseEventStream = "" + "define stream purchaseEventStream (user string, item_number int, price float, quantity int);";
String query = "" + "@info(name = 'query0') " + "from purchaseEventStream#window.session(5 sec, item_number) " + "select * " + "insert all events into outputStream ;";
try {
siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(purchaseEventStream + query);
} catch (SiddhiAppCreationException e) {
AssertJUnit.assertEquals("There is no parameterOverload for 'session' that matches attribute types" + " '<LONG, INT>'. Supported parameter overloads are (<INT|LONG|TIME> session.gap), " + "(<INT|LONG|TIME> session.gap, <STRING> session.key), (<INT|LONG|TIME> session.gap, " + "<STRING> session.key, <INT|LONG|TIME> allowed.latency).", e.getCause().getMessage());
throw e;
} finally {
if (siddhiAppRuntime != null) {
siddhiAppRuntime.shutdown();
}
}
}
use of io.siddhi.core.exception.SiddhiAppCreationException in project siddhi by wso2.
the class SessionWindowTestCase method testSessionWindow1.
@Test(description = "This test checks if Siddhi App creation fails when more than three parameters are provided'", expectedExceptions = SiddhiAppCreationException.class)
public void testSessionWindow1() {
log.info("SessionWindow Test1: Testing session window with more than defined parameters");
SiddhiManager siddhiManager = new SiddhiManager();
SiddhiAppRuntime siddhiAppRuntime = null;
String purchaseEventStream = "" + "define stream purchaseEventStream (user string, item_number int, price float, quantity int);";
String query = "" + "@info(name = 'query0') " + "from purchaseEventStream#window.session(5 sec, user, 2 sec, 1) " + "select * " + "insert all events into outputStream ;";
try {
siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(purchaseEventStream + query);
} catch (SiddhiAppCreationException e) {
AssertJUnit.assertEquals("There is no parameterOverload for 'session' that matches attribute types " + "'<LONG, STRING, LONG, INT>'. Supported parameter overloads are " + "(<INT|LONG|TIME> session.gap), " + "(<INT|LONG|TIME> session.gap, <STRING> session.key), (<INT|LONG|TIME> session.gap, " + "<STRING> session.key, <INT|LONG|TIME> allowed.latency).", e.getCause().getMessage());
throw e;
} finally {
if (siddhiAppRuntime != null) {
siddhiAppRuntime.shutdown();
}
}
}
use of io.siddhi.core.exception.SiddhiAppCreationException in project siddhi by wso2.
the class SessionWindowTestCase method testSessionWindow4.
@Test(description = "This test checks if Siddhi App creation fails " + "when session key parameter with a constant value", expectedExceptions = SiddhiAppCreationException.class)
public void testSessionWindow4() {
log.info("SessionWindow Test4: Testing session window " + "with providing a constant value for session key parameter ");
SiddhiManager siddhiManager = new SiddhiManager();
SiddhiAppRuntime siddhiAppRuntime = null;
String purchaseEventStream = "" + "define stream purchaseEventStream (user string, item_number int, price float, quantity int);";
String query = "" + "@info(name = 'query0') " + "from purchaseEventStream#window.session(5 sec, 'user', 2 sec) " + "select * " + "insert all events into outputStream ;";
try {
siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(purchaseEventStream + query);
} catch (SiddhiAppCreationException e) {
AssertJUnit.assertEquals("Session window's 2nd parameter, session key should be a " + "dynamic parameter attribute but found a constant attribute " + "io.siddhi.core.executor.ConstantExpressionExecutor", e.getCause().getMessage());
throw e;
} finally {
if (siddhiAppRuntime != null) {
siddhiAppRuntime.shutdown();
}
}
}
use of io.siddhi.core.exception.SiddhiAppCreationException in project siddhi by wso2.
the class SessionWindowTestCase method testSessionWindow7.
@Test(description = "This test checks if Siddhi App creation fails when" + " allowedLatency parameter with a wrong data type", expectedExceptions = SiddhiAppCreationException.class)
public void testSessionWindow7() {
log.info("SessionWindow Test7: Testing session window " + "with providing wrong data type for allowedLatency");
SiddhiManager siddhiManager = new SiddhiManager();
SiddhiAppRuntime siddhiAppRuntime = null;
String purchaseEventStream = "" + "define stream purchaseEventStream (user string, item_number int, price float, quantity int);";
String query = "" + "@info(name = 'query0') " + "from purchaseEventStream#window.session(5 sec, user, '4') " + "select * " + "insert all events into outputStream ;";
try {
siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(purchaseEventStream + query);
} catch (SiddhiAppCreationException e) {
AssertJUnit.assertEquals("There is no parameterOverload for 'session' that matches attribute " + "types '<LONG, STRING, STRING>'. Supported parameter overloads are " + "(<INT|LONG|TIME> session.gap), " + "(<INT|LONG|TIME> session.gap, <STRING> session.key), " + "(<INT|LONG|TIME> session.gap, <STRING> session.key, " + "<INT|LONG|TIME> allowed.latency).", e.getCause().getMessage());
throw e;
} finally {
if (siddhiAppRuntime != null) {
siddhiAppRuntime.shutdown();
}
}
}
use of io.siddhi.core.exception.SiddhiAppCreationException in project siddhi by wso2.
the class DelayWindowTestCase method delayWindowTest2.
@Test(description = "Check if Siddhi App Creation fails when the type of parameter is neither int or long", expectedExceptions = SiddhiAppCreationException.class)
public void delayWindowTest2() {
log.info("DelayWindow Test2 : Testing window parameter definition3");
SiddhiManager siddhiManager = new SiddhiManager();
String query = "define window eventWindow(symbol string, price int, volume float) delay('abc') ";
SiddhiAppRuntime siddhiAppRuntime = null;
try {
siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(query);
} catch (SiddhiAppCreationException e) {
error = false;
AssertJUnit.assertEquals("There is no parameterOverload for 'delay' that matches attribute types " + "'<STRING>'. Supported parameter overloads are (<INT|LONG|TIME> window.delay).", e.getCause().getMessage());
throw e;
} finally {
if (siddhiAppRuntime != null) {
siddhiAppRuntime.shutdown();
}
}
}
Aggregations