io.siddhi.core.exception.SiddhiAppCreationException Java Examples

The following examples show how to use io.siddhi.core.exception.SiddhiAppCreationException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Aggregation2TestCase.java    From siddhi with Apache License 2.0 6 votes vote down vote up
@Test(dependsOnMethods = {"incrementalStreamProcessorTest54"}, expectedExceptions =
        SiddhiAppCreationException.class)
public void incrementalStreamProcessorTest55() {

    Map<String, String> propertiesMap = new HashMap<>();
    propertiesMap.put("partitionById", "true");
    InMemoryConfigManager inMemoryConfigManager = new InMemoryConfigManager(null, null, propertiesMap);

    LOG.info("incrementalStreamProcessorTest55 - Checking @partitionbyid overriding");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setConfigManager(inMemoryConfigManager);
    String stockStream =
            "define stream stockStream (symbol string, price float, lastClosingPrice float, volume long , " +
                    "quantity int);\n";
    String query = "@PartitionById(enable='false') " +
            "define aggregation stockAggregation " +
            "from stockStream " +
            "select avg(price) as avgPrice, sum(price) as totalPrice, (price * quantity) " +
            "as lastTradeValue  " +
            "aggregate every sec...year; ";

    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(stockStream + query);
    siddhiAppRuntime.start();
}
 
Example #2
Source File: InMemoryTransportTestCase.java    From siddhi with Apache License 2.0 6 votes vote down vote up
@Test(expectedExceptions = SiddhiAppCreationException.class, dependsOnMethods = {"inMemoryTestCase3"})
public void inMemoryTestCase4() throws InterruptedException {
    log.info("Test inMemory 4");

    String streams = "" +
            "@app:name('TestSiddhiApp')" +
            "@source(type='inMemory', topic='Foo', @map(type='passThrough', @attributes('symbol','price'))) " +
            "define stream FooStream (symbol string, price float, volume long); " +
            "@sink(type='inMemory', topic='{{symbol}}', @map(type='passThrough')) " +
            "define stream BarStream (symbol string, price float, volume long); ";

    String query = "" +
            "from FooStream " +
            "select * " +
            "insert into BarStream; ";

    SiddhiManager siddhiManager = new SiddhiManager();
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query);

}
 
Example #3
Source File: Sink.java    From siddhi with Apache License 2.0 6 votes vote down vote up
public final void initOnlyTransport(StreamDefinition streamDefinition, OptionHolder transportOptionHolder,
                                    ConfigReader sinkConfigReader, String type,
                                    DistributedTransport.ConnectionCallback connectionCallback,
                                    Map<String, String> deploymentProperties, SiddhiAppContext siddhiAppContext) {
    this.type = type;
    this.streamDefinition = streamDefinition;
    this.connectionCallback = connectionCallback;
    this.siddhiAppContext = siddhiAppContext;
    init(streamDefinition, transportOptionHolder, sinkConfigReader, siddhiAppContext);
    scheduledExecutorService = siddhiAppContext.getScheduledExecutorService();
    serviceDeploymentInfo = exposeServiceDeploymentInfo();
    if (serviceDeploymentInfo != null) {
        serviceDeploymentInfo.addDeploymentProperties(deploymentProperties);
    } else if (!deploymentProperties.isEmpty()) {
        throw new SiddhiAppCreationException("Deployment properties '" + deploymentProperties +
                "' are defined for sink '" + type + "' which does not expose a service");
    }
}
 
Example #4
Source File: InstanceOfFunctionTestCase.java    From siddhi with Apache License 2.0 6 votes vote down vote up
@Test(expectedExceptions = SiddhiAppCreationException.class)
public void testInstanceOfBooleanFunctionExtensionExceptionTestCase() throws InterruptedException {
    log.info("testInstanceOfBooleanFunctionExtensionException TestCase");

    SiddhiManager siddhiManager = new SiddhiManager();

    String sensorEventStream = "define stream sensorEventStream (timestamp long, " +
            "isPowerSaverEnabled bool, sensorId int , sensorName string, longitude double, " +
            "latitude double, " +
            "humidity float, sensorValue double);";

    String query = ("@info(name = 'query1') " +
            "from sensorEventStream " +
            "select sensorName ,instanceOfBoolean(isPowerSaverEnabled,sensorName) as valid, " +
            "isPowerSaverEnabled " +
            "insert into outputStream;");

    siddhiManager.createSiddhiAppRuntime(sensorEventStream + query);
}
 
Example #5
Source File: InstanceOfFunctionTestCase.java    From siddhi with Apache License 2.0 6 votes vote down vote up
@Test(expectedExceptions = SiddhiAppCreationException.class)
public void testInstanceOfFloatFunctionExtensionExceptionTestCase() throws InterruptedException {
    log.info("testInstanceOfFloatFunctionExtensionException TestCase");

    SiddhiManager siddhiManager = new SiddhiManager();

    String sensorEventStream = "define stream sensorEventStream (timestamp long, " +
            "isPowerSaverEnabled bool, sensorId int , sensorName string, longitude double, " +
            "latitude double, " +
            "humidity float, sensorValue double);";

    String query = ("@info(name = 'query1') " +
            "from sensorEventStream " +
            "select sensorName ,instanceOfFloat(humidity,sensorName) as valid, longitude " +
            "insert into outputStream;");

    siddhiManager.createSiddhiAppRuntime(sensorEventStream + query);
}
 
Example #6
Source File: ValidateTestCase.java    From siddhi with Apache License 2.0 6 votes vote down vote up
@Test(expectedExceptions = SiddhiAppCreationException.class)
public void validateTest2() throws InterruptedException {
    log.info("validate test2");
    SiddhiManager siddhiManager = new SiddhiManager();

    String siddhiApp = "" +
            "@app:name('validateTest') " +
            "" +
            "define stream cseEventStream (symbol string, price float, volume long);" +
            "" +
            "@info(name = 'query1') " +
            "from cseEventStreamA[symbol is null] " +
            "select symbol, price " +
            "insert into outputStream;";


    siddhiManager.validateSiddhiApp(siddhiApp);

}
 
Example #7
Source File: Aggregation2TestCase.java    From siddhi with Apache License 2.0 6 votes vote down vote up
@Test(dependsOnMethods = {"incrementalStreamProcessorTest5SGTTimeZoneYear"}, expectedExceptions =
        SiddhiAppCreationException.class)
public void incrementalStreamProcessorTestInvalidTimeZone() throws InterruptedException {
    LOG.info("incrementalStreamProcessorTest5");
    SiddhiManager siddhiManager = new SiddhiManager();
    Map<String, String> configMap = new HashMap<>();
    configMap.put("aggTimeZone", "Asia/Singapo");
    ConfigManager configManager = new InMemoryConfigManager(null, null, configMap);
    siddhiManager.setConfigManager(configManager);

    String stockStream =
            "define stream stockStream (symbol string, price float, timestamp long);";
    String query = " define aggregation stockAggregation " +
            "from stockStream " +
            "select symbol, avg(price) as avgPrice  " +
            "group by symbol " +
            "aggregate by timestamp every year ;";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(stockStream + query);
    siddhiAppRuntime.shutdown();
}
 
Example #8
Source File: MinIncrementalAttributeAggregator.java    From siddhi with Apache License 2.0 6 votes vote down vote up
@Override
public void init(String attributeName, Attribute.Type attributeType) {

    if (attributeName == null) {
        throw new SiddhiAppCreationException("Min incremental attribute aggregation cannot be executed " +
                "when no parameters are given");
    }

    if (attributeType.equals(Attribute.Type.INT) || attributeType.equals(Attribute.Type.LONG) ||
            attributeType.equals(Attribute.Type.DOUBLE) || attributeType.equals(Attribute.Type.FLOAT)) {
        this.baseAttributes = new Attribute[]{new Attribute("AGG_MIN_".concat(attributeName), attributeType)};
        this.baseAttributesInitialValues = new Expression[]{Expression.variable(attributeName)};
        this.returnType = attributeType;
    } else {
        throw new SiddhiAppRuntimeException(
                "Min aggregation cannot be executed on attribute type " + attributeType.toString());
    }
}
 
Example #9
Source File: AsyncTestCase.java    From siddhi with Apache License 2.0 6 votes vote down vote up
@Test(expectedExceptions = SiddhiAppCreationException.class, dependsOnMethods = {"asyncTest7"})
public void asyncTest8() throws InterruptedException {
    log.info("async test 8");

    SiddhiManager siddhiManager = new SiddhiManager();

    String siddhiApp = "" +
            " " +
            "@async(buffer.size='16', workers='1', batch.size.max='0')" +
            "define stream cseEventStream (symbol string, price float, volume int);" +
            "define stream cseEventStream2 (symbol string, price float, volume int);" +
            "" +
            "@info(name = 'query1') " +
            "from cseEventStream[70 > price] " +
            "select * " +
            "insert into innerStream ;" +
            "" +
            "@info(name = 'query2') " +
            "from innerStream[volume > 90] " +
            "select * " +
            "insert into outputStream ;";

    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp);

}
 
Example #10
Source File: FunctionTestCase.java    From siddhi with Apache License 2.0 6 votes vote down vote up
@Test(expectedExceptions = SiddhiAppCreationException.class)
public void testFunctionQuery8() throws InterruptedException {

    log.info("CurrentTimestamp Test1");

    SiddhiManager siddhiManager = new SiddhiManager();

    String planName = "@app:name('eventTimestamp') ";
    String cseEventStream = "define stream fooStream (symbol string, currentTime string);";
    String query = "@info(name = 'query1') " +
            "from fooStream " +
            "select symbol as name, currentTimeMillis(currentTime) as eventTimestamp " +
            "insert into barStream;";

    siddhiManager.createSiddhiAppRuntime(cseEventStream + query);
}
 
Example #11
Source File: InMemoryTransportTestCase.java    From siddhi with Apache License 2.0 6 votes vote down vote up
@Test(expectedExceptions = SiddhiAppCreationException.class, dependsOnMethods = {"inMemoryTestCase8"})
public void inMemoryTestCase9() throws InterruptedException {
    log.info("Test inMemory 9");

    String streams = "" +
            "@app:name('TestSiddhiApp')" +
            "define stream FooStream (symbol string, price float, volume long); " +
            "@sink(type='testStringInMemory', topic='{{symbol}}', @map(type='passThrough')) " +
            "define stream BarStream (symbol string, price float, volume long); ";

    String query = "" +
            "from FooStream " +
            "select * " +
            "insert into BarStream; ";

    SiddhiManager siddhiManager = new SiddhiManager();
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query);

}
 
Example #12
Source File: DefineTableTestCase.java    From siddhi with Apache License 2.0 6 votes vote down vote up
@Test(expectedExceptions = SiddhiAppCreationException.class)
public void testQuery19() {
    log.info("testTableDefinition19 - Table w/ ref w/o type");

    Map<String, String> systemConfigs = new HashMap<>();
    systemConfigs.put("test1.uri", "http://localhost");
    InMemoryConfigManager inMemoryConfigManager = new InMemoryConfigManager(null, systemConfigs);
    inMemoryConfigManager.extractSystemConfigs("test1");

    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setConfigManager(inMemoryConfigManager);
    siddhiManager.setExtension("store:test", TestStore.class);
    String siddhiApp = "" +
            "@store(ref='test1', uri='http://localhost:8080', table.name ='Foo')" +
            "define table testTable (symbol string, price int, volume float); ";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp);
    siddhiAppRuntime.shutdown();
}
 
Example #13
Source File: ConvertFunctionTestCase.java    From siddhi with Apache License 2.0 6 votes vote down vote up
@Test(expectedExceptions = SiddhiAppCreationException.class)
public void convertFunctionExceptionTest7() throws InterruptedException {
    log.info("convert function test 7");

    SiddhiManager siddhiManager = new SiddhiManager();

    String cseEventStream = "define stream typeStream (typeS string, typeF float, typeD double, typeI int, typeL " +
            "long, typeB bool, typeN double) ;";
    String query = "" +
            "@info(name = 'query1') " +
            "from typeStream " +
            "select convert(typeS,'234') as valueS, convert(typeF,'float') as valueF, convert(typeD," +
            "'double') as valueD , convert(typeI,'int') as valueI , convert(typeL,'long') as valueL , " +
            "convert(typeB,'bool') as valueB, convert(typeN,'string') as valueN " +
            "insert into outputStream ;";

    siddhiManager.createSiddhiAppRuntime(cseEventStream + query);
}
 
Example #14
Source File: Aggregation2TestCase.java    From siddhi with Apache License 2.0 6 votes vote down vote up
@Test(dependsOnMethods = {"incrementalStreamProcessorTest52"}, expectedExceptions =
        SiddhiAppCreationException.class)
public void incrementalStreamProcessorTest53() {

    LOG.info("incrementalStreamProcessorTest53 - Checking partitionbyid enable=true");
    SiddhiManager siddhiManager = new SiddhiManager();
    String stockStream =
            "define stream stockStream (symbol string, price float, lastClosingPrice float, volume long , " +
                    "quantity int);\n";
    String query = "@PartitionById(enable='true') " +
            "define aggregation stockAggregation " +
            "from stockStream " +
            "select avg(price) as avgPrice, sum(price) as totalPrice, (price * quantity) " +
            "as lastTradeValue  " +
            "aggregate every sec...year; ";

    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(stockStream + query);
    siddhiAppRuntime.start();
}
 
Example #15
Source File: DefineTableTestCase.java    From siddhi with Apache License 2.0 6 votes vote down vote up
@Test(expectedExceptions = SiddhiAppCreationException.class)
public void testQuery20() {
    log.info("testTableDefinition20 - Table w/ ref to an undefined store");

    Map<String, String> systemConfigs = new HashMap<>();
    systemConfigs.put("test1.uri", "http://localhost");
    InMemoryConfigManager inMemoryConfigManager = new InMemoryConfigManager(null, systemConfigs);
    inMemoryConfigManager.extractSystemConfigs("test2");

    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setConfigManager(inMemoryConfigManager);
    siddhiManager.setExtension("store:test", TestStore.class);
    String siddhiApp = "" +
            "@store(ref='test2', uri='http://localhost:8080', table.name ='Foo')" +
            "define table testTable (symbol string, price int, volume float); ";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp);
    siddhiAppRuntime.shutdown();
}
 
Example #16
Source File: DelayWindowTestCase.java    From siddhi with Apache License 2.0 6 votes vote down vote up
@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();
        }
    }
}
 
Example #17
Source File: JoinInputStreamParser.java    From siddhi with Apache License 2.0 6 votes vote down vote up
private static void populateJoinProcessors(MetaStreamEvent metaStreamEvent, String inputStreamId,
                                           JoinProcessor preJoinProcessor, JoinProcessor postJoinProcessor,
                                           CompiledCondition compiledCondition,
                                           CompiledSelection compiledSelection,
                                           List<Attribute> expectedOutputAttributes) {
    if (metaStreamEvent.getEventType() == TABLE && metaStreamEvent.getEventType() == AGGREGATE) {
        throw new SiddhiAppCreationException(inputStreamId + " of join query cannot trigger join " +
                "because its a " + metaStreamEvent.getEventType() + ", only WINDOW and STEAM can " +
                "trigger join");
    }
    preJoinProcessor.setTrigger(false);    // Pre JoinProcessor does not process the events
    preJoinProcessor.setCompiledCondition(compiledCondition);
    preJoinProcessor.setCompiledSelection(compiledSelection);
    preJoinProcessor.setExpectedOutputAttributes(expectedOutputAttributes);
    postJoinProcessor.setTrigger(true);
    postJoinProcessor.setCompiledCondition(compiledCondition);
    postJoinProcessor.setCompiledSelection(compiledSelection);
    postJoinProcessor.setExpectedOutputAttributes(expectedOutputAttributes);
}
 
Example #18
Source File: FunctionTestCase.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Test(expectedExceptions = SiddhiAppCreationException.class)
public void testFunctionQuery18() throws InterruptedException {
    log.info("SizeOfSet");
    SiddhiManager siddhiManager = new SiddhiManager();
    String planName = "@app:name('SizeOfSetFunction') ";
    String cseEventStream = "define stream cseEventStream (distinctSymbols string, roomNo int);";
    String query = "@info(name = 'query1') " +
            "from cseEventStream " +
            "select sizeOfSet(distinctSymbols, roomNo) as sizeOfSymbolSet " +
            "insert into StandardTempStream;";
    siddhiManager.createSiddhiAppRuntime(cseEventStream + query);
}
 
Example #19
Source File: IncrementalStreamProcessorTestCase.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Test(expectedExceptions = SiddhiAppCreationException.class)
public void incrementalStreamProcessorTest5() {
    SiddhiManager siddhiManager = new SiddhiManager();
    String cseEventStream = "" +
            " define stream cseEventStream (arrival long, symbol string, price float, volume int); ";
    String query = "" +
            " @info(name = 'query1') " +
            " define aggregation cseEventAggregation " +
            " from cseEventStream " +
            " select sum() as sumPrice " +
            " aggregate by arrival every sec ... min";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(cseEventStream + query);
}
 
Example #20
Source File: TimeWindowTestCase.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Test(expectedExceptions = SiddhiAppCreationException.class)
public void timeWindowTest6() throws InterruptedException, SiddhiAppCreationException {

    SiddhiManager siddhiManager = new SiddhiManager();

    String cseEventStream = "" +
            "define stream cseEventStream (symbol string, time long, volume int);";
    String query = "" +
            "@info(name = 'query1') " +
            "from cseEventStream#window.time(4.7) " +
            "select symbol,price,volume " +
            "insert all events into outputStream ;";

    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(cseEventStream + query);
}
 
Example #21
Source File: PartitionTestCase2.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Test(expectedExceptions = SiddhiAppCreationException.class)
public void partitionStreamValidationTest() throws InterruptedException {

    log.info("filter test1");
    SiddhiManager siddhiManager = new SiddhiManager();

    String siddhiApp = "" +
            "@App:name(\"ExtremaBottomKLeng\")\n" +
            "@App:Description('Demonstrates how to use the siddhi-execution-extrema with " +
            "bottomKLengthBatch function')\n" +
            "\n" +
            "define stream inputStream (item string, price long);\n" +
            "\n" +
            "@sink(type='log') \n" +
            "define stream outputStream(item string, price long);\n" +
            "\n" +
            "partition with (itemsss of inputStreamssss)\n" +
            "begin \n" +
            "    from inputStream select item\n" +
            "    insert into s\n" +
            "end;\n" +

            "from inputStream\n" +
            "insert all events into outputStream; ";

    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp);
    try {
        log.info("Running : " + siddhiAppRuntime.getName());

        siddhiAppRuntime.start();
    } finally {
        siddhiAppRuntime.shutdown();

    }
}
 
Example #22
Source File: LengthWindowTestCase.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Test(expectedExceptions = SiddhiAppCreationException.class)
public void sumAggregatorTest57() throws InterruptedException {

    SiddhiManager siddhiManager = new SiddhiManager();

    String execPlan = "" +
            "@app:name('sumAggregatorTests') " +
            "" +
            "define stream cseEventStream (weight double, deviceId string);" +
            "" +
            "@info(name = 'query1') " +
            "from cseEventStream#window.length(3) " +
            "select sum(weight,deviceId) as total " +
            "insert into outputStream;";

    SiddhiAppRuntime execPlanRunTime = siddhiManager.createSiddhiAppRuntime(execPlan);
    execPlanRunTime.addCallback("query1", new QueryCallback() {
        @Override
        public void receive(long timestamp, Event[] inEvents, Event[] removeEvents) {

            EventPrinter.print(timestamp, inEvents, removeEvents);
            AssertJUnit.assertEquals(55, inEvents[0].getData()[0]);
        }
    });

    InputHandler inputHandler = execPlanRunTime.getInputHandler("cseEventStream");

    execPlanRunTime.start();
    inputHandler.send(new Object[]{10.0, "Box1"});
    inputHandler.send(new Object[]{20.0, "Box2"});
    inputHandler.send(new Object[]{25.0, "Box3"});
    Thread.sleep(100);
    execPlanRunTime.shutdown();
}
 
Example #23
Source File: CastFunctionExecutorTestCase.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Test(expectedExceptions = SiddhiAppCreationException.class)
public void testCastFunctionExtensionException4() throws InterruptedException {
    log.info("CastFunctionExecutor TestCase 4");
    SiddhiManager siddhiManager = new SiddhiManager();
    String inStreamDefinition = "\ndefine stream inputStream (symbol string, price object, volume long);";
    String query = ("@info(name = 'query1') from inputStream select symbol,price, "
            + "cast(price, symbol) as priceInDouble insert into outputStream;");

    siddhiManager.createSiddhiAppRuntime(inStreamDefinition + query);
}
 
Example #24
Source File: CastFunctionExecutorTestCase.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Test(expectedExceptions = SiddhiAppCreationException.class)
public void testCastFunctionExtensionException3() throws InterruptedException {
    log.info("CastFunctionExecutor TestCase 3");
    SiddhiManager siddhiManager = new SiddhiManager();
    String inStreamDefinition = "\ndefine stream inputStream (symbol string, price object, volume long);";
    String query = ("@info(name = 'query1') from inputStream select symbol,price, "
            + "cast(price, 'newType') as priceInDouble insert into outputStream;");
    siddhiManager.createSiddhiAppRuntime(inStreamDefinition + query);
}
 
Example #25
Source File: IncrementalStreamProcessorTestCase.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Test(expectedExceptions = SiddhiAppCreationException.class)
public void incrementalStreamProcessorTest4() {
    SiddhiManager siddhiManager = new SiddhiManager();
    String cseEventStream = "" +
            " define stream cseEventStream (arrival long, symbol string, price float, volume int); ";
    String query = "" +
            " @info(name = 'query1') " +
            " define aggregation cseEventAggregation " +
            " from cseEventStream " +
            " select sum(symbol) as sumPrice " +
            " aggregate by arrival every sec ... min";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(cseEventStream + query);
}
 
Example #26
Source File: WindowDefinitionTestCase.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Test(expectedExceptions = SiddhiAppCreationException.class)
public void testEventWindow6() throws InterruptedException {
    log.info("WindowDefinitionTestCase Test6");

    SiddhiManager siddhiManager = new SiddhiManager();

    String streams = "define window CheckStockWindow(symbol string, val int) sum(val); ";

    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams);
    siddhiAppRuntime.shutdown();
}
 
Example #27
Source File: SortWindowTestCase.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Test(expectedExceptions = SiddhiAppCreationException.class)
public void sortWindowTest4()
        throws InterruptedException {
    log.info("sortWindowTest4");
    SiddhiManager siddhiManager = new SiddhiManager();

    String cseEventStream = "" + "define stream cseEventStream (symbol string, price float, volume int);";
    String query =
            "" + "@info(name = 'query1') " + "from cseEventStream#window.sort(2.5) " + "select symbol,price,volume "
                    + "insert all events into outputStream ;";

    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(cseEventStream + query);
}
 
Example #28
Source File: SortWindowTestCase.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Test(expectedExceptions = SiddhiAppCreationException.class)
public void sortWindowTest6()
        throws InterruptedException {
    log.info("sortWindowTest6");
    SiddhiManager siddhiManager = new SiddhiManager();

    String cseEventStream = "" + "define stream cseEventStream (symbol string, time long, volume int);";
    String query = "" + "@info(name = 'query1') " + "from cseEventStream#window.sort(2, volume, 'ecs') "
            + "select symbol,price,volume " + "insert all events into outputStream ;";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(cseEventStream + query);
}
 
Example #29
Source File: MaxAggregatorExtensionTestCase.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Test(expectedExceptions = SiddhiAppCreationException.class)
public void minAttributeAggregatorTest2() throws InterruptedException {

    log.info("minAttributeAggregator Test #2");

    SiddhiManager siddhiManager = new SiddhiManager();

    String execPlan = "" +
            "@app:name('minAttributeAggregatorTests') " +
            "" +
            "define stream cseEventStream (weight double, deviceId string);" +
            "" +
            "@info(name = 'query1') " +
            "from cseEventStream#window.lengthBatch(5) " +
            "select min(weight, deviceId) as max " +
            "insert into outputStream;";

    SiddhiAppRuntime execPlanRunTime = siddhiManager.createSiddhiAppRuntime(execPlan);
    execPlanRunTime.addCallback("query1", new QueryCallback() {
        @Override
        public void receive(long timestamp, Event[] inEvents, Event[] removeEvents) {

            EventPrinter.print(timestamp, inEvents, removeEvents);
            AssertJUnit.assertEquals(10, inEvents[0].getData()[0]);
        }
    });

    InputHandler inputHandler = execPlanRunTime.getInputHandler("cseEventStream");

    execPlanRunTime.start();
    inputHandler.send(new Object[]{20.0, "Box1"});
    inputHandler.send(new Object[]{30.0, "Box2"});
    inputHandler.send(new Object[]{10.0, "Box3"});
    inputHandler.send(new Object[]{40.0, "Box4"});
    inputHandler.send(new Object[]{50.0, "Box5"});
    Thread.sleep(100);
    execPlanRunTime.shutdown();
}
 
Example #30
Source File: LengthBatchWindowTestCase.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Test(expectedExceptions = SiddhiAppCreationException.class)
public void lengthBatchWindowTest19() throws InterruptedException {
    log.info("Dynamic value");
    SiddhiManager siddhiManager = new SiddhiManager();
    String cseEventStream = "define stream cseEventStream (symbol string, price float, volume int);";
    String query = "" +
            "@info(name = 'query1') " +
            "from cseEventStream#window.lengthBatch(1/2) " +
            "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.fail("No events should arrive");
            inEventCount = inEventCount + inEvents.length;
            eventArrived = true;
        }

    });
    InputHandler inputHandler = siddhiAppRuntime.getInputHandler("cseEventStream");
    siddhiAppRuntime.start();
    inputHandler.send(new Object[]{"IBM", 700f, 0});
    inputHandler.send(new Object[]{"WSO2", 60.5f, 1});
    AssertJUnit.assertEquals(0, inEventCount);
    AssertJUnit.assertFalse(eventArrived);
    siddhiAppRuntime.shutdown();
}