Java Code Examples for org.testng.AssertJUnit#assertFalse()

The following examples show how to use org.testng.AssertJUnit#assertFalse() . 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: SimpleQueryTestCase.java    From siddhi with Apache License 2.0 6 votes vote down vote up
@Test
public void testCreatingReturnFilterQueryWithExtension3() {
    Query query = Query.query();
    Window window1 = new Window("Foo");
    AssertJUnit.assertFalse(window1.equals("falsewindow"));
    query.from(
            InputStream.stream("StockStream").
                    filter(Expression.and(Expression.compare(Expression.function("ext", "FooBarCond", Expression
                                    .value(7), Expression.value(9.5)),
                            Compare.Operator.GREATER_THAN,
                            Expression.variable("price")),
                            Expression.function("ext", "BarCond", Expression.value(100),
                                    Expression.variable("volume")
                            )
                            )
                    ).function("ext", "Foo", Expression.value(67), Expression.value(89)).
                    window(window1)
    );
    query.select(
            Selector.selector().
                    select("symbol", Expression.variable("symbol")).
                    select("avgPrice", Expression.function("ext", "avg", Expression.variable("price")))
    );
}
 
Example 2
Source File: TimestampEqualsRuleTest.java    From otroslogviewer with Apache License 2.0 5 votes vote down vote up
/**
 * Tests evaluate of a deserialized clone when timestamps are not equal.
 */
@Test
public void test4() throws IOException, ClassNotFoundException {
  TimestampEqualsRule rule = (TimestampEqualsRule) SerializationTestHelper.serializeClone(TimestampEqualsRule.getRule("2008-05-21 00:46:44"));
  LogData event = createLogData();
  AssertJUnit.assertFalse(rule.evaluate(event, null));
}
 
Example 3
Source File: LogicalAbsentSequenceTestCase.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Test(dependsOnMethods = {"testQueryAbsent26"})
public void testQueryAbsent27() throws InterruptedException {
    log.info("Test the query e1, (not e2 for 1 sec and not e3 for 1 sec) within 2 sec with e1 and e3");

    SiddhiManager siddhiManager = new SiddhiManager();

    String streams = "" +
            "define stream Stream1 (symbol string, price float, volume int); " +
            "define stream Stream2 (symbol string, price float, volume int); " +
            "define stream Stream3 (symbol string, price float, volume int); ";
    String query = "" +
            "@info(name = 'query1') " +
            "from e1=Stream1[price>10], (not Stream2[price>20] for 1 sec and not Stream3[price>30] for 1 sec) " +
            "within 2 sec " +
            "select e1.symbol as symbol1 " +
            "insert into OutputStream ;";

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

    TestUtil.TestCallback callback = TestUtil.addQueryCallback(siddhiAppRuntime, "query1");

    InputHandler stream1 = siddhiAppRuntime.getInputHandler("Stream1");
    InputHandler stream3 = siddhiAppRuntime.getInputHandler("Stream3");

    siddhiAppRuntime.start();

    stream1.send(new Object[]{"WSO2", 15.0f, 100});
    Thread.sleep(100);
    stream3.send(new Object[]{"IBM", 35.0f, 102});

    TestUtil.waitForInEvents(1000, callback, 5);
    callback.throwAssertionErrors();
    AssertJUnit.assertEquals("Number of success events", 0, callback.getInEventCount());
    AssertJUnit.assertEquals("Number of remove events", 0, callback.getRemoveEventCount());
    AssertJUnit.assertFalse("Event arrived", callback.isEventArrived());

    siddhiAppRuntime.shutdown();
}
 
Example 4
Source File: TimestampInequalityRuleTest.java    From otroslogviewer with Apache License 2.0 5 votes vote down vote up
@Test
public void testRuleWithTBetweenDateAndTime2() throws IOException, ClassNotFoundException {
  Rule rule = TimestampInequalityRule.getRule("<", "2008-05-21T00:44:44");
  Calendar cal = new GregorianCalendar(2008, Calendar.MAY, 21, 0, 45, 44);
  LogData logData = createLogData(cal);
  AssertJUnit.assertFalse(rule.evaluate(logData, null));
}
 
Example 5
Source File: LogicalAbsentSequenceTestCase.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Test(dependsOnMethods = {"testQueryAbsent44"})
public void testQueryAbsent45() throws InterruptedException {
    log.info("Test the query e1 or not e2 for 1 sec, e3 with e3 within 1 sec");

    SiddhiManager siddhiManager = new SiddhiManager();

    String streams = "" +
            "define stream Stream1 (symbol string, price float, volume int); " +
            "define stream Stream2 (symbol string, price float, volume int); " +
            "define stream Stream3 (symbol string, price float, volume int); ";
    String query = "" +
            "@info(name = 'query1') " +
            "from e1=Stream1[price>10] or not Stream2[price>20] for 1 sec, e3=Stream3[price>30] " +
            "select e1.symbol as symbol1, e3.symbol as symbol3 " +
            "insert into OutputStream ;";

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

    TestUtil.TestCallback callback = TestUtil.addQueryCallback(siddhiAppRuntime, "query1");

    InputHandler stream3 = siddhiAppRuntime.getInputHandler("Stream3");
    siddhiAppRuntime.start();

    Thread.sleep(100);
    stream3.send(new Object[]{"GOOGLE", 35.0f, 100});

    TestUtil.waitForInEvents(100, callback, 5);
    callback.throwAssertionErrors();
    AssertJUnit.assertEquals("Number of success events", 0, callback.getInEventCount());
    AssertJUnit.assertEquals("Number of remove events", 0, callback.getRemoveEventCount());
    AssertJUnit.assertFalse("Event arrived", callback.isEventArrived());

    siddhiAppRuntime.shutdown();
}
 
Example 6
Source File: OuterJoinTestCase.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Test
public void joinTest9() throws InterruptedException {
    log.info("Outer Join test9");

    SiddhiManager siddhiManager = new SiddhiManager();

    String streams = "define stream cseEventStream (symbol string, price float, volume int); " +
            "define stream twitterStream (user string, tweet string, company string); ";
    String query = "@info(name = 'query1') " +
            "from cseEventStream#window.length(3) join twitterStream#window.length(1) " +
            "on cseEventStream.symbol== twitterStream.company " +
            "select cseEventStream.symbol as symbol, twitterStream.tweet, cseEventStream.price " +
            "insert all events into outputStream ;";

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

    siddhiAppRuntime.addCallback("query1", new QueryCallback() {
        @Override
        public void receive(long timestamp, Event[] inEvents, Event[] removeEvents) {
            EventPrinter.print(timestamp, inEvents, removeEvents);
            eventArrived = true;
        }
    });

    InputHandler cseEventStreamHandler = siddhiAppRuntime.getInputHandler("cseEventStream");
    InputHandler twitterStreamHandler = siddhiAppRuntime.getInputHandler("twitterStream");
    siddhiAppRuntime.start();
    cseEventStreamHandler.send(new Object[]{"WSO2", 55.6f, 100});
    twitterStreamHandler.send(new Object[]{"User", "Hello World", "BMW"});
    cseEventStreamHandler.send(new Object[]{"IBM", 75.6f, 100});
    cseEventStreamHandler.send(new Object[]{"WSO2", 57.6f, 100});
    Thread.sleep(500);
    AssertJUnit.assertFalse(eventArrived);
    siddhiAppRuntime.shutdown();
}
 
Example 7
Source File: LogicalAbsentPatternTestCase.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Test(dependsOnMethods = {"testQueryAbsent23"})
public void testQueryAbsent24() throws InterruptedException {
    log.info("Test the query e1 -> (not e2 for 1 sec and e3) within 2 sec with e1 and e3 after 2 sec");

    SiddhiManager siddhiManager = new SiddhiManager();

    String streams = "" +
            "define stream Stream1 (symbol string, price float, volume int); " +
            "define stream Stream2 (symbol string, price float, volume int); " +
            "define stream Stream3 (symbol string, price float, volume int); ";
    String query = "" +
            "@info(name = 'query1') " +
            "from e1=Stream1[price>10] -> (not Stream2[price>20] for 1 sec and e3=Stream3[price>30]) within 2 sec" +
            " " +
            "select e1.symbol as symbol1, e3.symbol as symbol3 " +
            "insert into OutputStream ;";

    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query);
    TestUtil.TestCallback callback = TestUtil.addQueryCallback(siddhiAppRuntime, "query1");

    InputHandler stream1 = siddhiAppRuntime.getInputHandler("Stream1");
    InputHandler stream3 = siddhiAppRuntime.getInputHandler("Stream3");
    siddhiAppRuntime.start();

    stream1.send(new Object[]{"WSO2", 15.0f, 100});
    Thread.sleep(2100);
    stream3.send(new Object[]{"GOOGLE", 35.0f, 100});
    Thread.sleep(100);

    callback.throwAssertionErrors();
    AssertJUnit.assertEquals("Number of success events", 0, callback.getInEventCount());
    AssertJUnit.assertEquals("Number of remove events", 0, callback.getRemoveEventCount());
    AssertJUnit.assertFalse("Event arrived", callback.isEventArrived());

    siddhiAppRuntime.shutdown();
}
 
Example 8
Source File: TimestampInequalityRuleTest.java    From otroslogviewer with Apache License 2.0 5 votes vote down vote up
@Test
public void testRuleWithTBetweenDateAndTime4() throws IOException, ClassNotFoundException {
  Rule rule = TimestampInequalityRule.getRule("<", "2008-05-21T00:44");
  Calendar cal = new GregorianCalendar(2008, Calendar.MAY, 21, 0, 45, 44);
  LogData logData = createLogData(cal);
  AssertJUnit.assertFalse(rule.evaluate(logData, null));
}
 
Example 9
Source File: AbsentSequenceTestCase.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Test(dependsOnMethods = {"testQueryAbsent34"})
public void testQueryAbsent35() throws InterruptedException {
    log.info("Test the query not e1 for 1 sec, e2<2:5> with e1 and e2");

    SiddhiManager siddhiManager = new SiddhiManager();

    String streams = "" +
            "define stream Stream1 (symbol string, price float, volume int); " +
            "define stream Stream2 (symbol string, price float, volume int); ";
    String query = "" +
            "@info(name = 'query1') " +
            "from not Stream1[price>10] for 1 sec, e2=Stream2[price>20]<2:5> " +
            "select e2[0].symbol as symbol0, e2[1].symbol as symbol1, e2[2].symbol as symbol2, e2[3].symbol as " +
            "symbol3 " +
            "insert into OutputStream ;";

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

    TestUtil.TestCallback callback = TestUtil.addQueryCallback(siddhiAppRuntime, "query1");

    InputHandler stream1 = siddhiAppRuntime.getInputHandler("Stream1");
    InputHandler stream2 = siddhiAppRuntime.getInputHandler("Stream2");


    siddhiAppRuntime.start();

    stream1.send(new Object[]{"WSO2", 15.0f, 100});
    Thread.sleep(100);
    stream2.send(new Object[]{"GOOGLE", 35.0f, 100});
    Thread.sleep(100);
    stream2.send(new Object[]{"ORACLE", 45.0f, 100});

    TestUtil.waitForInEvents(100, callback, 5);
    callback.throwAssertionErrors();
    AssertJUnit.assertEquals("Number of success events", 0, callback.getInEventCount());
    AssertJUnit.assertEquals("Number of remove events", 0, callback.getRemoveEventCount());
    AssertJUnit.assertFalse("Event arrived", callback.isEventArrived());

    siddhiAppRuntime.shutdown();
}
 
Example 10
Source File: EveryAbsentPatternTestCase.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Test(dependsOnMethods = {"testQueryAbsent17"})
public void testQueryAbsent18() throws InterruptedException {
    log.info("Test the query every not e1 for 1 sec -> e2 -> e3 with e1, e2 e3");

    SiddhiManager siddhiManager = new SiddhiManager();

    String streams = "" +
            "define stream Stream1 (symbol string, price float, volume int); " +
            "define stream Stream2 (symbol string, price float, volume int); " +
            "define stream Stream3 (symbol string, price float, volume int); ";
    String query = "" +
            "@info(name = 'query1') " +
            "from every not Stream1[price>10] for 1 sec -> e2=Stream2[price>20] -> e3=Stream3[price>30] " +
            "select e2.symbol as symbol2, e3.symbol as symbol3 " +
            "insert into OutputStream ;";

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

    TestUtil.TestCallback callback = TestUtil.addQueryCallback(siddhiAppRuntime, "query1");

    InputHandler stream1 = siddhiAppRuntime.getInputHandler("Stream1");
    InputHandler stream2 = siddhiAppRuntime.getInputHandler("Stream2");
    InputHandler stream3 = siddhiAppRuntime.getInputHandler("Stream3");

    siddhiAppRuntime.start();

    stream1.send(new Object[]{"WSO2", 15.6f, 100});
    Thread.sleep(100);
    stream2.send(new Object[]{"IBM", 28.7f, 100});
    Thread.sleep(100);
    stream3.send(new Object[]{"GOOGLE", 55.7f, 100});
    Thread.sleep(100);

    callback.throwAssertionErrors();
    AssertJUnit.assertEquals("Number of success events", 0, callback.getInEventCount());
    AssertJUnit.assertEquals("Number of remove events", 0, callback.getRemoveEventCount());
    AssertJUnit.assertFalse("Event arrived", callback.isEventArrived());

    siddhiAppRuntime.shutdown();
}
 
Example 11
Source File: TestZKUtil.java    From helix with Apache License 2.0 5 votes vote down vote up
@BeforeClass()
public void beforeClass() throws Exception {
  boolean result = ZKUtil.isClusterSetup(clusterName, _gZkClient);
  AssertJUnit.assertFalse(result);
  result = ZKUtil.isClusterSetup(null, _gZkClient);
  AssertJUnit.assertFalse(result);

  result = ZKUtil.isClusterSetup(null, (HelixZkClient) null);
  AssertJUnit.assertFalse(result);

  result = ZKUtil.isClusterSetup(clusterName, (HelixZkClient) null);
  AssertJUnit.assertFalse(result);

  TestHelper.setupEmptyCluster(_gZkClient, clusterName);
}
 
Example 12
Source File: AbsentWithEverySequenceTestCase.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Test
public void testQuery2() throws InterruptedException {
    log.info("Test the query every e1, not e2 for 1 sec with e1 and e2");

    SiddhiManager siddhiManager = new SiddhiManager();

    String streams = "" +
            "define stream Stream1 (symbol string, price float, volume int); " +
            "define stream Stream2 (symbol string, price1 float, volume int); ";
    String query = "" +
            "@info(name = 'query1') " +
            "from every e1=Stream1[price>20], not Stream2[price1>e1.price] for 1sec " +
            "select e1.symbol as symbol " +
            "insert into OutputStream ;";

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

    TestUtil.TestCallback callback = TestUtil.addQueryCallback(siddhiAppRuntime, "query1");

    InputHandler stream1 = siddhiAppRuntime.getInputHandler("Stream1");
    InputHandler stream2 = siddhiAppRuntime.getInputHandler("Stream2");

    siddhiAppRuntime.start();

    stream1.send(new Object[]{"WSO2", 55.6f, 100});
    Thread.sleep(100);
    stream1.send(new Object[]{"GOOG", 55.6f, 100});
    Thread.sleep(100);
    stream2.send(new Object[]{"IBM", 55.7f, 100});
    Thread.sleep(1100);

    callback.throwAssertionErrors();
    AssertJUnit.assertEquals("Number of success events", 0, callback.getInEventCount());
    AssertJUnit.assertEquals("Number of remove events", 0, callback.getRemoveEventCount());
    AssertJUnit.assertFalse("Event arrived", callback.isEventArrived());

    siddhiAppRuntime.shutdown();
}
 
Example 13
Source File: LogicalAbsentPatternTestCase.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Test(dependsOnMethods = {"testQueryAbsent56"})
public void testQueryAbsent57() throws InterruptedException {
    log.info("Test the query every (not e1 for 1 sec and e2) -> e3 with only e3 after 2 seconds");

    SiddhiManager siddhiManager = new SiddhiManager();

    String streams = "" +
            "define stream Stream1 (symbol string, price float, volume int); " +
            "define stream Stream2 (symbol string, price float, volume int); " +
            "define stream Stream3 (symbol string, price float, volume int); ";
    String query = "" +
            "@info(name = 'query1') " +
            "from every (not Stream1[price>10] for 1 sec and e2=Stream2[price>20]) -> " +
            "e3=Stream3[price>30] " +
            "select e2.symbol as symbol2, e3.symbol as symbol3 " +
            "insert into OutputStream ;";

    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query);
    TestUtil.TestCallback callback = TestUtil.addQueryCallback(siddhiAppRuntime, "query1");

    InputHandler stream3 = siddhiAppRuntime.getInputHandler("Stream3");
    siddhiAppRuntime.start();

    Thread.sleep(1100);
    stream3.send(new Object[]{"WSO2", 35.0f, 100});
    Thread.sleep(100);


    callback.throwAssertionErrors();
    AssertJUnit.assertEquals("Number of success events", 0, callback.getInEventCount());
    AssertJUnit.assertEquals("Number of remove events", 0, callback.getRemoveEventCount());
    AssertJUnit.assertFalse("Event arrived", callback.isEventArrived());

    siddhiAppRuntime.shutdown();
}
 
Example 14
Source File: LogicalAbsentSequenceTestCase.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Test(dependsOnMethods = {"testQueryAbsent38"})
public void testQueryAbsent39() throws InterruptedException {
    log.info("Test the query (not e1 for 1 sec and not e2 for 1 sec), e3 with e2 and e3");

    SiddhiManager siddhiManager = new SiddhiManager();

    String streams = "" +
            "define stream Stream1 (symbol string, price float, volume int); " +
            "define stream Stream2 (symbol string, price float, volume int); " +
            "define stream Stream3 (symbol string, price float, volume int); ";
    String query = "" +
            "@info(name = 'query1') " +
            "from (not Stream1[price>10] for 1 sec and not Stream2[price>20] for 1 sec), e3=Stream3[price>30] " +
            "select e3.symbol as symbol " +
            "insert into OutputStream ;";

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

    TestUtil.TestCallback callback = TestUtil.addQueryCallback(siddhiAppRuntime, "query1");

    InputHandler stream2 = siddhiAppRuntime.getInputHandler("Stream2");
    InputHandler stream3 = siddhiAppRuntime.getInputHandler("Stream3");

    siddhiAppRuntime.start();

    Thread.sleep(500);
    stream2.send(new Object[]{"IBM", 25.0f, 100});
    Thread.sleep(600);
    stream3.send(new Object[]{"WSO2", 35.0f, 100});

    TestUtil.waitForInEvents(100, callback, 5);
    callback.throwAssertionErrors();
    AssertJUnit.assertEquals("Number of success events", 0, callback.getInEventCount());
    AssertJUnit.assertEquals("Number of remove events", 0, callback.getRemoveEventCount());
    AssertJUnit.assertFalse("Event arrived", callback.isEventArrived());

    siddhiAppRuntime.shutdown();
}
 
Example 15
Source File: PropertyAcceptConditionTest.java    From otroslogviewer with Apache License 2.0 4 votes vote down vote up
@Test
public void testRejectKey() throws Exception {
    AssertJUnit.assertFalse(new PropertyAcceptCondition("key1","value").accept(logData));
}
 
Example 16
Source File: EveryAbsentSequenceTestCase.java    From siddhi with Apache License 2.0 4 votes vote down vote up
@Test
public void testQueryAbsent19() throws InterruptedException {
    log.info("Test the query every (not e1 and e2), e3 with e1, e2 and e3");

    SiddhiManager siddhiManager = new SiddhiManager();

    String streams = "" +
            "define stream Stream1 (symbol string, price float, volume int); " +
            "define stream Stream2 (symbol string, price float, volume int); " +
            "define stream Stream3 (symbol string, price float, volume int); ";
    String query = "" +
            "@info(name = 'query1') " +
            "from every (not Stream1[price>10] and e2=Stream2[price>20]), e3=Stream3[price>30] " +
            "select e2.symbol as symbol2, e3.symbol as symbol3 " +
            "insert into OutputStream ;";

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

    TestUtil.TestCallback callback = TestUtil.addQueryCallback(siddhiAppRuntime, "query1");

    InputHandler stream1 = siddhiAppRuntime.getInputHandler("Stream1");
    InputHandler stream2 = siddhiAppRuntime.getInputHandler("Stream2");
    InputHandler stream3 = siddhiAppRuntime.getInputHandler("Stream3");


    siddhiAppRuntime.start();

    stream1.send(new Object[]{"WSO2", 15.0f, 100});
    Thread.sleep(100);
    stream2.send(new Object[]{"IBM", 25.0f, 100});
    Thread.sleep(100);
    stream3.send(new Object[]{"GOOGLE", 35.0f, 100});
    Thread.sleep(100);

    callback.throwAssertionErrors();
    AssertJUnit.assertEquals("Number of success events", 0, callback.getInEventCount());
    AssertJUnit.assertEquals("Number of remove events", 0, callback.getRemoveEventCount());
    AssertJUnit.assertFalse("Event arrived", callback.isEventArrived());

    siddhiAppRuntime.shutdown();
}
 
Example 17
Source File: AbsentSequenceTestCase.java    From siddhi with Apache License 2.0 4 votes vote down vote up
@Test(dependsOnMethods = {"testQueryAbsent32"})
public void testQueryAbsent33() throws InterruptedException {
    log.info("Test the query e1, not e2 for 1 sec, e3 and e4 with e2");

    SiddhiManager siddhiManager = new SiddhiManager();

    String streams = "" +
            "define stream Stream1 (symbol string, price float, volume int); " +
            "define stream Stream2 (symbol string, price float, volume int); " +
            "define stream Stream3 (symbol string, price float, volume int); " +
            "define stream Stream4 (symbol string, price float, volume int); ";
    String query = "" +
            "@info(name = 'query1') " +
            "from e1=Stream1[price>10], not Stream2[price>20] for 1 sec, e2=Stream3[price>30] and " +
            "e3=Stream4[price>40]" +
            "select e1.symbol as symbol1, e2.symbol as symbol2, e3.symbol as symbol3 " +
            "insert into OutputStream ;";

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

    TestUtil.TestCallback callback = TestUtil.addQueryCallback(siddhiAppRuntime, "query1");

    InputHandler stream1 = siddhiAppRuntime.getInputHandler("Stream1");
    InputHandler stream2 = siddhiAppRuntime.getInputHandler("Stream2");
    InputHandler stream3 = siddhiAppRuntime.getInputHandler("Stream3");
    InputHandler stream4 = siddhiAppRuntime.getInputHandler("Stream4");


    siddhiAppRuntime.start();

    stream1.send(new Object[]{"IBM", 18.7f, 100});
    Thread.sleep(100);
    stream2.send(new Object[]{"ORACLE", 25.0f, 100});
    Thread.sleep(100);
    stream3.send(new Object[]{"WSO2", 35.0f, 100});
    Thread.sleep(100);
    stream4.send(new Object[]{"GOOGLE", 56.86f, 100});

    TestUtil.waitForInEvents(100, callback, 5);
    callback.throwAssertionErrors();
    AssertJUnit.assertEquals("Number of success events", 0, callback.getInEventCount());
    AssertJUnit.assertEquals("Number of remove events", 0, callback.getRemoveEventCount());
    AssertJUnit.assertFalse("Event not arrived", callback.isEventArrived());

    siddhiAppRuntime.shutdown();
}
 
Example 18
Source File: EveryAbsentPatternTestCase.java    From siddhi with Apache License 2.0 4 votes vote down vote up
@Test(dependsOnMethods = {"testQueryAbsent38"})
public void testQueryAbsent39() throws InterruptedException {
    log.info("Test the query e1 -> every not e2 for 1 sec -> e3 and e4 with e2");

    SiddhiManager siddhiManager = new SiddhiManager();

    String streams = "" +
            "define stream Stream1 (symbol string, price float, volume int); " +
            "define stream Stream2 (symbol string, price float, volume int); " +
            "define stream Stream3 (symbol string, price float, volume int); " +
            "define stream Stream4 (symbol string, price float, volume int); ";
    String query = "" +
            "@info(name = 'query1') " +
            "from e1=Stream1[price>10] -> every not Stream2[price>20] for 1 sec -> e2=Stream3[price>30] and " +
            "e3=Stream4[price>40]" +
            "select e1.symbol as symbol1, e2.symbol as symbol2, e3.symbol as symbol3 " +
            "insert into OutputStream ;";

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

    TestUtil.TestCallback callback = TestUtil.addQueryCallback(siddhiAppRuntime, "query1");

    InputHandler stream1 = siddhiAppRuntime.getInputHandler("Stream1");
    InputHandler stream2 = siddhiAppRuntime.getInputHandler("Stream2");
    InputHandler stream3 = siddhiAppRuntime.getInputHandler("Stream3");
    InputHandler stream4 = siddhiAppRuntime.getInputHandler("Stream4");


    siddhiAppRuntime.start();

    stream1.send(new Object[]{"IBM", 18.7f, 100});
    Thread.sleep(100);
    stream2.send(new Object[]{"ORACLE", 25.0f, 100});
    Thread.sleep(100);
    stream3.send(new Object[]{"WSO2", 35.0f, 100});
    Thread.sleep(100);
    stream4.send(new Object[]{"GOOGLE", 56.86f, 100});
    Thread.sleep(100);

    callback.throwAssertionErrors();
    AssertJUnit.assertEquals("Number of success events", 0, callback.getInEventCount());
    AssertJUnit.assertEquals("Number of remove events", 0, callback.getRemoveEventCount());
    AssertJUnit.assertFalse("Event not arrived", callback.isEventArrived());

    siddhiAppRuntime.shutdown();
}
 
Example 19
Source File: AbsentPatternTestCase.java    From siddhi with Apache License 2.0 4 votes vote down vote up
@Test(dependsOnMethods = {"testQueryAbsent25"})
public void testQueryAbsent26() throws InterruptedException {
    log.info("Test the query not e1 for 1 sec -> e2 -> not e3 for 1 sec-> e4 with e2, e3 and e4");

    SiddhiManager siddhiManager = new SiddhiManager();

    String streams = "" +
            "define stream Stream1 (symbol string, price float, volume int); " +
            "define stream Stream2 (symbol string, price float, volume int); " +
            "define stream Stream3 (symbol string, price float, volume int); " +
            "define stream Stream4 (symbol string, price float, volume int); ";
    String query = "" +
            "@info(name = 'query1') " +
            "from not Stream1[price>10] for 1 sec -> e2=Stream2[price>20] -> not Stream3[price>30] for 1 " +
            "sec -> e4=Stream4[price>40] " +
            "select e2.symbol as symbol2, e4.symbol as symbol4 " +
            "insert into OutputStream ;";

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

    TestUtil.TestCallback callback = TestUtil.addQueryCallback(siddhiAppRuntime, "query1");

    InputHandler stream2 = siddhiAppRuntime.getInputHandler("Stream2");
    InputHandler stream3 = siddhiAppRuntime.getInputHandler("Stream3");
    InputHandler stream4 = siddhiAppRuntime.getInputHandler("Stream4");

    siddhiAppRuntime.start();

    stream2.send(new Object[]{"IBM", 28.7f, 100});
    Thread.sleep(100);
    stream3.send(new Object[]{"GOOGLE", 38.7f, 100});
    Thread.sleep(100);
    stream4.send(new Object[]{"ORACLE", 44.7f, 100});

    TestUtil.waitForInEvents(100, callback, 5);
    callback.throwAssertionErrors();
    AssertJUnit.assertEquals("Number of success events", 0, callback.getInEventCount());
    AssertJUnit.assertEquals("Number of remove events", 0, callback.getRemoveEventCount());
    AssertJUnit.assertFalse("Event arrived", callback.isEventArrived());

    siddhiAppRuntime.shutdown();
}
 
Example 20
Source File: BatchProcessingContextTest.java    From otroslogviewer with Apache License 2.0 4 votes vote down vote up
@Test
public void testGetAttributeStringClassOfTT() {

  AssertJUnit.assertFalse(batchProcessingContext.containsAttribute("A"));
  AssertJUnit.assertEquals("D", batchProcessingContext.getAttribute("A", String.class, "D"));
}