Example #1
0
        private void RunAssertionOrderByTwoCriteriaAsc(EPServiceProvider epService, bool join)
        {
            epService.EPRuntime.SendEvent(new CurrentTimeEvent(0));
            string[] fields   = "c0,c1,c2".Split(',');
            var      listener = new SupportUpdateListener();

            epService.EPAdministrator.CreateEPL("@Name('s1')" +
                                                "select irstream TheString as c0, IntPrimitive as c1, sum(LongPrimitive) as c2 " +
                                                "from SupportBean#time_batch(1 sec) " + (join ? ", SupportBean_S0#lastevent " : "") +
                                                "group by Rollup(TheString, IntPrimitive) " +
                                                "order by TheString, IntPrimitive").Events += listener.Update;
            epService.EPRuntime.SendEvent(new SupportBean_S0(1));

            epService.EPRuntime.SendEvent(MakeEvent("E2", 10, 100));
            epService.EPRuntime.SendEvent(MakeEvent("E1", 11, 200));
            epService.EPRuntime.SendEvent(MakeEvent("E1", 10, 300));
            epService.EPRuntime.SendEvent(MakeEvent("E1", 11, 400));
            Assert.IsFalse(listener.IsInvoked);

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(1000));
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields,
                                              new object[][] { new object[] { null, null, 1000L },
                                                               new object[] { "E1", null, 900L },
                                                               new object[] { "E1", 10, 300L },
                                                               new object[] { "E1", 11, 600L },
                                                               new object[] { "E2", null, 100L },
                                                               new object[] { "E2", 10, 100L }, },
                                              new object[][] { new object[] { null, null, null },
                                                               new object[] { "E1", null, null },
                                                               new object[] { "E1", 10, null },
                                                               new object[] { "E1", 11, null },
                                                               new object[] { "E2", null, null },
                                                               new object[] { "E2", 10, null }, });

            epService.EPRuntime.SendEvent(MakeEvent("E1", 11, 500));
            epService.EPRuntime.SendEvent(MakeEvent("E1", 10, 600));
            epService.EPRuntime.SendEvent(MakeEvent("E1", 12, 700));
            Assert.IsFalse(listener.IsInvoked);

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(2000));
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields,
                                              new object[][] { new object[] { null, null, 1800L },
                                                               new object[] { "E1", null, 1800L },
                                                               new object[] { "E1", 10, 600L },
                                                               new object[] { "E1", 11, 500L },
                                                               new object[] { "E1", 12, 700L },
                                                               new object[] { "E2", null, null },
                                                               new object[] { "E2", 10, null }, },
                                              new object[][] { new object[] { null, null, 1000L },
                                                               new object[] { "E1", null, 900L },
                                                               new object[] { "E1", 10, 300L },
                                                               new object[] { "E1", 11, 600L },
                                                               new object[] { "E1", 12, null },
                                                               new object[] { "E2", null, 100L },
                                                               new object[] { "E2", 10, 100L }, });

            epService.EPAdministrator.DestroyAllStatements();
        }
        public override void Run(EPServiceProvider epService)
        {
            epService.EPAdministrator.Configuration.AddEventType <SupportBean>();
            epService.EPAdministrator.Configuration.AddEventType <SupportBean_S0>();

            var listenerInsert = new SupportUpdateListener();
            var listenerSelect = new SupportUpdateListener();

            string[] fields      = "c0,c1".Split(',');
            string   stmtTextOne = "insert irstream into MyStream " +
                                   "select irstream TheString as c0, istream() as c1 " +
                                   "from SupportBean#lastevent";

            epService.EPAdministrator.CreateEPL(stmtTextOne).Events += listenerInsert.Update;

            string stmtTextTwo = "select * from MyStream";

            epService.EPAdministrator.CreateEPL(stmtTextTwo).Events += listenerSelect.Update;

            epService.EPRuntime.SendEvent(new SupportBean("E1", 0));
            EPAssertionUtil.AssertProps(listenerInsert.AssertOneGetNewAndReset(), fields, new object[] { "E1", true });
            EPAssertionUtil.AssertProps(listenerSelect.AssertOneGetNewAndReset(), fields, new object[] { "E1", true });

            epService.EPRuntime.SendEvent(new SupportBean("E2", 0));
            EPAssertionUtil.AssertProps(listenerInsert.AssertPairGetIRAndReset(), fields, new object[] { "E2", true }, new object[] { "E1", false });
            EPAssertionUtil.AssertPropsPerRow(listenerSelect.GetAndResetDataListsFlattened(), fields, new object[][] { new object[] { "E2", true }, new object[] { "E1", false } }, new Object[0][]);

            epService.EPRuntime.SendEvent(new SupportBean("E3", 0));
            EPAssertionUtil.AssertProps(listenerInsert.AssertPairGetIRAndReset(), fields, new object[] { "E3", true }, new object[] { "E2", false });
            EPAssertionUtil.AssertPropsPerRow(listenerSelect.GetAndResetDataListsFlattened(), fields, new object[][] { new object[] { "E3", true }, new object[] { "E2", false } }, new Object[0][]);

            // test SODA
            string eplModel = "select istream() from SupportBean";
            EPStatementObjectModel model = epService.EPAdministrator.CompileEPL(eplModel);

            Assert.AreEqual(eplModel, model.ToEPL());
            EPStatement stmt = epService.EPAdministrator.Create(model);

            Assert.AreEqual(eplModel, stmt.Text);
            Assert.AreEqual(typeof(bool), stmt.EventType.GetPropertyType("istream()"));

            // test join
            epService.EPAdministrator.DestroyAllStatements();
            fields = "c0,c1,c2".Split(',');
            string stmtTextJoin = "select irstream TheString as c0, id as c1, istream() as c2 " +
                                  "from SupportBean#lastevent, SupportBean_S0#lastevent";

            epService.EPAdministrator.CreateEPL(stmtTextJoin).Events += listenerSelect.Update;
            epService.EPRuntime.SendEvent(new SupportBean("E1", 0));
            epService.EPRuntime.SendEvent(new SupportBean_S0(10));
            EPAssertionUtil.AssertProps(listenerSelect.AssertOneGetNewAndReset(), fields, new object[] { "E1", 10, true });

            epService.EPRuntime.SendEvent(new SupportBean("E2", 0));
            EPAssertionUtil.AssertProps(listenerSelect.LastOldData[0], fields, new object[] { "E1", 10, false });
            EPAssertionUtil.AssertProps(listenerSelect.LastNewData[0], fields, new object[] { "E2", 10, true });
        }
        private void RunAssertionNewestEventOldestEvent(EPServiceProvider epService)
        {
            // try with include-trigger-event
            var         fields   = new string[] { "TheString" };
            EPStatement stmtOne  = epService.EPAdministrator.CreateEPL("select irstream * from SupportBean#expr_batch(newest_event.IntPrimitive != oldest_event.IntPrimitive, false)");
            var         listener = new SupportUpdateListener();

            stmtOne.Events += listener.Update;

            epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            epService.EPRuntime.SendEvent(new SupportBean("E2", 1));
            Assert.IsFalse(listener.IsInvoked);

            epService.EPRuntime.SendEvent(new SupportBean("E3", 2));
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields,
                                              new object[][] { new object[] { "E1" }, new object[] { "E2" } }, null);

            epService.EPRuntime.SendEvent(new SupportBean("E4", 3));
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields,
                                              new object[][] { new object[] { "E3" } }, new object[][] { new object[] { "E1" }, new object[] { "E2" } });

            epService.EPRuntime.SendEvent(new SupportBean("E5", 3));
            epService.EPRuntime.SendEvent(new SupportBean("E6", 3));
            Assert.IsFalse(listener.IsInvoked);

            epService.EPRuntime.SendEvent(new SupportBean("E7", 2));
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields,
                                              new object[][] { new object[] { "E4" }, new object[] { "E5" }, new object[] { "E6" } }, new object[][] { new object[] { "E3" } });
            stmtOne.Dispose();

            // try with include-trigger-event
            EPStatement stmtTwo = epService.EPAdministrator.CreateEPL("select irstream * from SupportBean#expr_batch(newest_event.IntPrimitive != oldest_event.IntPrimitive, true)");

            stmtTwo.Events += listener.Update;

            epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            epService.EPRuntime.SendEvent(new SupportBean("E2", 1));
            Assert.IsFalse(listener.IsInvoked);

            epService.EPRuntime.SendEvent(new SupportBean("E3", 2));
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields,
                                              new object[][] { new object[] { "E1" }, new object[] { "E2" }, new object[] { "E3" } }, null);

            epService.EPRuntime.SendEvent(new SupportBean("E4", 3));
            epService.EPRuntime.SendEvent(new SupportBean("E5", 3));
            epService.EPRuntime.SendEvent(new SupportBean("E6", 3));
            Assert.IsFalse(listener.IsInvoked);

            epService.EPRuntime.SendEvent(new SupportBean("E7", 2));
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields,
                                              new object[][] { new object[] { "E4" }, new object[] { "E5" }, new object[] { "E6" }, new object[] { "E7" } }, new object[][] { new object[] { "E1" }, new object[] { "E2" }, new object[] { "E3" } });

            stmtTwo.Dispose();
        }
        private void RunAssertionNamedWindowDelete(EPServiceProvider epService)
        {
            epService.EPAdministrator.Configuration.AddEventType("SupportBean_A", typeof(SupportBean_A));

            var         fields   = new string[] { "TheString" };
            EPStatement stmt     = epService.EPAdministrator.CreateEPL("create window NW#expr_batch(current_count > 3) as SupportBean");
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            epService.EPAdministrator.CreateEPL("insert into NW select * from SupportBean");

            epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            epService.EPRuntime.SendEvent(new SupportBean("E2", 2));
            epService.EPRuntime.SendEvent(new SupportBean("E3", 3));
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1" }, new object[] { "E2" }, new object[] { "E3" } });

            epService.EPAdministrator.CreateEPL("on SupportBean_A delete from NW where TheString = id");
            epService.EPRuntime.SendEvent(new SupportBean_A("E2"));
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1" }, new object[] { "E3" } });

            epService.EPRuntime.SendEvent(new SupportBean("E4", 4));
            Assert.IsFalse(listener.IsInvoked);

            epService.EPRuntime.SendEvent(new SupportBean("E5", 5));
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new object[][] { new object[] { "E1" }, new object[] { "E3" }, new object[] { "E4" }, new object[] { "E5" } }, null);

            epService.EPAdministrator.DestroyAllStatements();
        }
Example #5
0
        private void RunAssertionTimeToLive(EPServiceProvider epService)
        {
            epService.EPRuntime.SendEvent(new CurrentTimeEvent(0));

            string[]    fields   = "id".Split(',');
            string      epl      = "select irstream * from SupportBeanTimestamp#timetolive(timestamp)";
            EPStatement stmt     = epService.EPAdministrator.CreateEPL(epl);
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            SendEvent(epService, "E1", 1000);
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E1" });
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1" } });

            SendEvent(epService, "E2", 500);
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E2" });
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E2" }, new object[] { "E1" } });

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(499));
            Assert.IsFalse(listener.GetAndClearIsInvoked());

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(500));
            EPAssertionUtil.AssertProps(listener.AssertOneGetOldAndReset(), fields, new object[] { "E2" });
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1" } });

            SendEvent(epService, "E3", 200);
            EPAssertionUtil.AssertProps(listener.AssertPairGetIRAndReset(), fields, new object[] { "E3" }, new object[] { "E3" });
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1" } });

            SendEvent(epService, "E4", 1200);
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E4" });
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1" }, new object[] { "E4" } });

            SendEvent(epService, "E5", 1000);
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E5" });
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1" }, new object[] { "E4" }, new object[] { "E5" } });

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(999));
            Assert.IsFalse(listener.GetAndClearIsInvoked());

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(1000));
            EPAssertionUtil.AssertPropsPerRowAnyOrder(listener.GetAndResetDataListsFlattened(), fields, null, new object[][] { new object[] { "E1" }, new object[] { "E5" } });
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E4" } });

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(1199));
            Assert.IsFalse(listener.GetAndClearIsInvoked());

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(1200));
            EPAssertionUtil.AssertProps(listener.AssertOneGetOldAndReset(), fields, new object[] { "E4" });
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, null);

            SendEvent(epService, "E6", 1200);
            EPAssertionUtil.AssertProps(listener.AssertPairGetIRAndReset(), fields, new object[] { "E6" }, new object[] { "E6" });
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, null);

            epService.EPAdministrator.DestroyAllStatements();
        }
        private void RunAssertionDynamicTimeBatch(EPServiceProvider epService)
        {
            epService.EPRuntime.SendEvent(new CurrentTimeEvent(0));
            epService.EPAdministrator.CreateEPL("create variable long SIZE = 1000");

            var         fields   = new string[] { "TheString" };
            EPStatement stmt     = epService.EPAdministrator.CreateEPL("select irstream * from SupportBean#expr_batch(newest_timestamp - oldest_timestamp > SIZE)");
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(1000));
            epService.EPRuntime.SendEvent(new SupportBean("E1", 0));
            epService.EPRuntime.SendEvent(new CurrentTimeEvent(1900));
            epService.EPRuntime.SendEvent(new SupportBean("E2", 0));
            Assert.IsFalse(listener.IsInvoked);

            epService.EPRuntime.SetVariableValue("SIZE", 500);
            epService.EPRuntime.SendEvent(new CurrentTimeEvent(1901));
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new object[][] { new object[] { "E1" }, new object[] { "E2" } }, null);

            epService.EPRuntime.SendEvent(new SupportBean("E3", 0));
            epService.EPRuntime.SendEvent(new CurrentTimeEvent(2300));
            epService.EPRuntime.SendEvent(new SupportBean("E4", 0));
            epService.EPRuntime.SendEvent(new CurrentTimeEvent(2500));
            Assert.IsFalse(listener.IsInvoked);

            epService.EPRuntime.SendEvent(new SupportBean("E5", 0));
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new object[][] { new object[] { "E3" }, new object[] { "E4" }, new object[] { "E5" } }, new object[][] { new object[] { "E1" }, new object[] { "E2" } });

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(3100));
            epService.EPRuntime.SendEvent(new SupportBean("E6", 0));
            Assert.IsFalse(listener.IsInvoked);

            epService.EPRuntime.SetVariableValue("SIZE", 999);
            epService.EPRuntime.SendEvent(new CurrentTimeEvent(3700));
            epService.EPRuntime.SendEvent(new SupportBean("E7", 0));
            Assert.IsFalse(listener.IsInvoked);

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(4100));
            epService.EPRuntime.SendEvent(new SupportBean("E8", 0));
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new object[][] { new object[] { "E6" }, new object[] { "E7" }, new object[] { "E8" } }, new object[][] { new object[] { "E3" }, new object[] { "E4" }, new object[] { "E5" } });

            stmt.Dispose();
        }
Example #7
0
        private void RunAssertionNewestEventOldestEvent(EPServiceProvider epService)
        {
            var         fields   = new[] { "TheString" };
            EPStatement stmt     = epService.EPAdministrator.CreateEPL("select irstream * from SupportBean#expr(newest_event.IntPrimitive = oldest_event.IntPrimitive)");
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E1" });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new[] { new object[] { "E1" } });

            epService.EPRuntime.SendEvent(new SupportBean("E2", 1));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E2" });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new[] { new object[] { "E1" }, new object[] { "E2" } });

            epService.EPRuntime.SendEvent(new SupportBean("E3", 2));
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields,
                                              new[] { new object[] { "E3" } }, new[] { new object[] { "E1" }, new object[] { "E2" } });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new[] { new object[] { "E3" } });

            epService.EPRuntime.SendEvent(new SupportBean("E4", 3));
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields,
                                              new[] { new object[] { "E4" } }, new[] { new object[] { "E3" } });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new[] { new object[] { "E4" } });

            epService.EPRuntime.SendEvent(new SupportBean("E5", 3));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E5" });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new[] { new object[] { "E4" }, new object[] { "E5" } });

            epService.EPRuntime.SendEvent(new SupportBean("E6", 3));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E6" });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new[] { new object[] { "E4" }, new object[] { "E5" }, new object[] { "E6" } });

            epService.EPRuntime.SendEvent(new SupportBean("E7", 2));
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields,
                                              new[] { new object[] { "E7" } }, new[] { new object[] { "E4" }, new object[] { "E5" }, new object[] { "E6" } });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new[] { new object[] { "E7" } });

            stmt.Dispose();
        }
 private void AssertEvents(SupportUpdateListener listener, string symbolOne,
                           double?oldSumOne, double?oldAvgOne,
                           double newSumOne, double newAvgOne,
                           string symbolTwo,
                           double?oldSumTwo, double?oldAvgTwo,
                           double newSumTwo, double newAvgTwo)
 {
     EPAssertionUtil.AssertPropsPerRowAnyOrder(listener.GetAndResetDataListsFlattened(),
                                               "mySum,myAvg".Split(','),
                                               new object[][] { new object[] { newSumOne, newAvgOne }, new object[] { newSumTwo, newAvgTwo } },
                                               new object[][] { new object[] { oldSumOne, oldAvgOne }, new object[] { oldSumTwo, oldAvgTwo } });
 }
        private void RunAssertionVariableBatch(EPServiceProvider epService)
        {
            epService.EPRuntime.SendEvent(new CurrentTimeEvent(0));
            epService.EPAdministrator.CreateEPL("create variable bool POST = false");

            var         fields   = new string[] { "TheString" };
            EPStatement stmt     = epService.EPAdministrator.CreateEPL("select irstream * from SupportBean#expr_batch(POST)");
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(1000));
            epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            Assert.IsFalse(listener.IsInvoked);

            epService.EPRuntime.SetVariableValue("POST", true);
            epService.EPRuntime.SendEvent(new CurrentTimeEvent(1001));
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new object[][] { new object[] { "E1" } }, null);

            epService.EPRuntime.SendEvent(new SupportBean("E2", 1));
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new object[][] { new object[] { "E2" } }, new object[][] { new object[] { "E1" } });

            epService.EPRuntime.SendEvent(new SupportBean("E3", 1));
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new object[][] { new object[] { "E3" } }, new object[][] { new object[] { "E2" } });

            epService.EPRuntime.SetVariableValue("POST", false);
            epService.EPRuntime.SendEvent(new SupportBean("E4", 1));
            epService.EPRuntime.SendEvent(new SupportBean("E5", 2));
            epService.EPRuntime.SendEvent(new CurrentTimeEvent(2000));
            Assert.IsFalse(listener.IsInvoked);

            epService.EPRuntime.SetVariableValue("POST", true);
            epService.EPRuntime.SendEvent(new CurrentTimeEvent(2001));
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new object[][] { new object[] { "E4" }, new object[] { "E5" } }, new object[][] { new object[] { "E3" } });

            epService.EPRuntime.SendEvent(new SupportBean("E6", 1));
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new object[][] { new object[] { "E6" } }, new object[][] { new object[] { "E4" }, new object[] { "E5" } });

            stmt.Stop();
        }
        private void RunAssertionEventPropBatch(EPServiceProvider epService)
        {
            var         fields   = new string[] { "val0" };
            EPStatement stmt     = epService.EPAdministrator.CreateEPL("select irstream TheString as val0 from SupportBean#expr_batch(IntPrimitive > 0)");
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new object[][] { new object[] { "E1" } }, null);

            epService.EPRuntime.SendEvent(new SupportBean("E2", 1));
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new object[][] { new object[] { "E2" } }, new object[][] { new object[] { "E1" } });

            epService.EPRuntime.SendEvent(new SupportBean("E3", -1));
            Assert.IsFalse(listener.IsInvoked);

            epService.EPRuntime.SendEvent(new SupportBean("E4", 2));
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new object[][] { new object[] { "E3" }, new object[] { "E4" } }, new object[][] { new object[] { "E2" } });

            stmt.Dispose();
        }
Example #11
0
        public void TestNewestEventOldestEvent()
        {
            // try with include-trigger-event
            String[]    fields  = new String[] { "TheString" };
            EPStatement stmtOne = _epService.EPAdministrator.CreateEPL("select irstream * from SupportBean.win:expr_batch(newest_event.IntPrimitive != oldest_event.IntPrimitive, false)");

            stmtOne.Events += _listener.Update;

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            _epService.EPRuntime.SendEvent(new SupportBean("E2", 1));
            Assert.IsFalse(_listener.IsInvoked);

            _epService.EPRuntime.SendEvent(new SupportBean("E3", 2));
            EPAssertionUtil.AssertPropsPerRow(_listener.GetAndResetDataListsFlattened(), fields,
                                              new Object[][] { new Object[] { "E1" }, new Object[] { "E2" } }, null);

            _epService.EPRuntime.SendEvent(new SupportBean("E4", 3));
            EPAssertionUtil.AssertPropsPerRow(_listener.GetAndResetDataListsFlattened(), fields,
                                              new Object[][] { new Object[] { "E3" } }, new Object[][] { new Object[] { "E1" }, new Object[] { "E2" } });

            _epService.EPRuntime.SendEvent(new SupportBean("E5", 3));
            _epService.EPRuntime.SendEvent(new SupportBean("E6", 3));
            Assert.IsFalse(_listener.IsInvoked);

            _epService.EPRuntime.SendEvent(new SupportBean("E7", 2));
            EPAssertionUtil.AssertPropsPerRow(_listener.GetAndResetDataListsFlattened(), fields,
                                              new Object[][] { new Object[] { "E4" }, new Object[] { "E5" }, new Object[] { "E6" } }, new Object[][] { new Object[] { "E3" } });
            stmtOne.Dispose();

            // try with include-trigger-event
            EPStatement stmtTwo = _epService.EPAdministrator.CreateEPL("select irstream * from SupportBean.win:expr_batch(newest_event.IntPrimitive != oldest_event.IntPrimitive, true)");

            stmtTwo.Events += _listener.Update;

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            _epService.EPRuntime.SendEvent(new SupportBean("E2", 1));
            Assert.IsFalse(_listener.IsInvoked);

            _epService.EPRuntime.SendEvent(new SupportBean("E3", 2));
            EPAssertionUtil.AssertPropsPerRow(_listener.GetAndResetDataListsFlattened(), fields,
                                              new Object[][] { new Object[] { "E1" }, new Object[] { "E2" }, new Object[] { "E3" } }, null);

            _epService.EPRuntime.SendEvent(new SupportBean("E4", 3));
            _epService.EPRuntime.SendEvent(new SupportBean("E5", 3));
            _epService.EPRuntime.SendEvent(new SupportBean("E6", 3));
            Assert.IsFalse(_listener.IsInvoked);

            _epService.EPRuntime.SendEvent(new SupportBean("E7", 2));
            EPAssertionUtil.AssertPropsPerRow(_listener.GetAndResetDataListsFlattened(), fields,
                                              new Object[][] { new Object[] { "E4" }, new Object[] { "E5" }, new Object[] { "E6" }, new Object[] { "E7" } }, new Object[][] { new Object[] { "E1" }, new Object[] { "E2" }, new Object[] { "E3" } });
        }
        private void RunAssertionAggregation(EPServiceProvider epService)
        {
            var fields = new string[] { "TheString" };

            // Test un-grouped
            EPStatement stmtUngrouped = epService.EPAdministrator.CreateEPL("select irstream TheString from SupportBean#expr_batch(sum(IntPrimitive) > 100)");
            var         listener      = new SupportUpdateListener();

            stmtUngrouped.Events += listener.Update;

            epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            epService.EPRuntime.SendEvent(new SupportBean("E2", 90));
            Assert.IsFalse(listener.IsInvoked);

            epService.EPRuntime.SendEvent(new SupportBean("E3", 10));
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new object[][] { new object[] { "E1" }, new object[] { "E2" }, new object[] { "E3" } }, null);

            epService.EPRuntime.SendEvent(new SupportBean("E4", 101));
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new object[][] { new object[] { "E4" } }, new object[][] { new object[] { "E1" }, new object[] { "E2" }, new object[] { "E3" } });

            epService.EPRuntime.SendEvent(new SupportBean("E5", 1));
            epService.EPRuntime.SendEvent(new SupportBean("E6", 99));
            Assert.IsFalse(listener.IsInvoked);

            epService.EPRuntime.SendEvent(new SupportBean("E7", 1));
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new object[][] { new object[] { "E5" }, new object[] { "E6" }, new object[] { "E7" } }, new object[][] { new object[] { "E4" } });
            stmtUngrouped.Dispose();

            // Test grouped
            EPStatement stmtGrouped = epService.EPAdministrator.CreateEPL("select irstream TheString from SupportBean#groupwin(IntPrimitive)#expr_batch(sum(LongPrimitive) > 100)");

            stmtGrouped.Events += listener.Update;

            SendEvent(epService, "E1", 1, 10);
            SendEvent(epService, "E2", 2, 10);
            SendEvent(epService, "E3", 1, 90);
            SendEvent(epService, "E4", 2, 80);
            SendEvent(epService, "E5", 2, 10);
            Assert.IsFalse(listener.IsInvoked);

            SendEvent(epService, "E6", 2, 1);
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new object[][] { new object[] { "E2" }, new object[] { "E4" }, new object[] { "E5" }, new object[] { "E6" } }, null);

            SendEvent(epService, "E7", 2, 50);
            Assert.IsFalse(listener.IsInvoked);

            SendEvent(epService, "E8", 1, 2);
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new object[][] { new object[] { "E1" }, new object[] { "E3" }, new object[] { "E8" } }, null);

            SendEvent(epService, "E9", 2, 50);
            SendEvent(epService, "E10", 1, 101);
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new object[][] { new object[] { "E10" } }, new object[][] { new object[] { "E1" }, new object[] { "E3" }, new object[] { "E8" } });

            SendEvent(epService, "E11", 2, 1);
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new object[][] { new object[] { "E7" }, new object[] { "E9" }, new object[] { "E11" } }, new object[][] { new object[] { "E2" }, new object[] { "E4" }, new object[] { "E5" }, new object[] { "E6" } });

            SendEvent(epService, "E12", 1, 102);
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new object[][] { new object[] { "E12" } }, new object[][] { new object[] { "E10" } });
            stmtGrouped.Dispose();

            // Test on-delete
            epService.EPAdministrator.Configuration.AddEventType("SupportBean_A", typeof(SupportBean_A));
            EPStatement stmt = epService.EPAdministrator.CreateEPL("create window NW#expr_batch(sum(IntPrimitive) >= 10) as SupportBean");

            stmt.Events += listener.Update;
            epService.EPAdministrator.CreateEPL("insert into NW select * from SupportBean");

            epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            epService.EPRuntime.SendEvent(new SupportBean("E2", 8));
            epService.EPAdministrator.CreateEPL("on SupportBean_A delete from NW where TheString = id");
            epService.EPRuntime.SendEvent(new SupportBean_A("E2"));

            epService.EPRuntime.SendEvent(new SupportBean("E3", 8));
            Assert.IsFalse(listener.IsInvoked);

            epService.EPRuntime.SendEvent(new SupportBean("E4", 1));
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new object[][] { new object[] { "E1" }, new object[] { "E3" }, new object[] { "E4" } }, null);

            epService.EPAdministrator.DestroyAllStatements();
        }
Example #13
0
        private void RunAssertionAggregation(EPServiceProvider epService)
        {
            // Test ungrouped
            var         fields        = new[] { "TheString" };
            EPStatement stmtUngrouped = epService.EPAdministrator.CreateEPL("select irstream TheString from SupportBean#expr(sum(IntPrimitive) < 10)");
            var         listener      = new SupportUpdateListener();

            stmtUngrouped.Events += listener.Update;

            epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            EPAssertionUtil.AssertPropsPerRow(stmtUngrouped.GetEnumerator(), fields, new[] { new object[] { "E1" } });
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E1" });

            epService.EPRuntime.SendEvent(new SupportBean("E2", 9));
            EPAssertionUtil.AssertPropsPerRow(stmtUngrouped.GetEnumerator(), fields, new[] { new object[] { "E2" } });
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new[] { new object[] { "E2" } }, new[] { new object[] { "E1" } });

            epService.EPRuntime.SendEvent(new SupportBean("E3", 11));
            EPAssertionUtil.AssertPropsPerRow(stmtUngrouped.GetEnumerator(), fields, null);
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new[] { new object[] { "E3" } }, new[] { new object[] { "E2" }, new object[] { "E3" } });

            epService.EPRuntime.SendEvent(new SupportBean("E4", 12));
            EPAssertionUtil.AssertPropsPerRow(stmtUngrouped.GetEnumerator(), fields, null);
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new[] { new object[] { "E4" } }, new[] { new object[] { "E4" } });

            epService.EPRuntime.SendEvent(new SupportBean("E5", 1));
            EPAssertionUtil.AssertPropsPerRow(stmtUngrouped.GetEnumerator(), fields, new[] { new object[] { "E5" } });
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new[] { new object[] { "E5" } }, null);

            epService.EPRuntime.SendEvent(new SupportBean("E6", 2));
            EPAssertionUtil.AssertPropsPerRow(stmtUngrouped.GetEnumerator(), fields, new[] { new object[] { "E5" }, new object[] { "E6" } });
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new[] { new object[] { "E6" } }, null);

            epService.EPRuntime.SendEvent(new SupportBean("E7", 3));
            EPAssertionUtil.AssertPropsPerRow(stmtUngrouped.GetEnumerator(), fields, new[] { new object[] { "E5" }, new object[] { "E6" }, new object[] { "E7" } });
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new[] { new object[] { "E7" } }, null);

            epService.EPRuntime.SendEvent(new SupportBean("E8", 6));
            EPAssertionUtil.AssertPropsPerRow(stmtUngrouped.GetEnumerator(), fields, new[] { new object[] { "E7" }, new object[] { "E8" } });
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new[] { new object[] { "E8" } }, new[] { new object[] { "E5" }, new object[] { "E6" } });

            epService.EPRuntime.SendEvent(new SupportBean("E9", 9));
            EPAssertionUtil.AssertPropsPerRow(stmtUngrouped.GetEnumerator(), fields, new[] { new object[] { "E9" } });
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new[] { new object[] { "E9" } }, new[] { new object[] { "E7" }, new object[] { "E8" } });

            stmtUngrouped.Dispose();

            // Test grouped
            EPStatement stmtGrouped = epService.EPAdministrator.CreateEPL("select irstream TheString from SupportBean#groupwin(IntPrimitive)#expr(sum(LongPrimitive) < 10)");

            stmtGrouped.Events += listener.Update;

            SendEvent(epService, "E1", 1, 5);
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new[] { new object[] { "E1" } }, null);

            SendEvent(epService, "E2", 2, 2);
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new[] { new object[] { "E2" } }, null);

            SendEvent(epService, "E3", 1, 3);
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new[] { new object[] { "E3" } }, null);

            SendEvent(epService, "E4", 2, 4);
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new[] { new object[] { "E4" } }, null);

            SendEvent(epService, "E5", 2, 6);
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new[] { new object[] { "E5" } }, new[] { new object[] { "E2" }, new object[] { "E4" } });

            SendEvent(epService, "E6", 1, 2);
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new[] { new object[] { "E6" } }, new[] { new object[] { "E1" } });

            stmtGrouped.Dispose();

            // Test on-delete
            epService.EPAdministrator.Configuration.AddEventType("SupportBean_A", typeof(SupportBean_A));
            EPStatement stmt = epService.EPAdministrator.CreateEPL("create window NW#expr(sum(IntPrimitive) < 10) as SupportBean");

            stmt.Events += listener.Update;
            epService.EPAdministrator.CreateEPL("insert into NW select * from SupportBean");

            epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new[] { new object[] { "E1" } }, null);

            epService.EPRuntime.SendEvent(new SupportBean("E2", 8));
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new[] { new object[] { "E2" } }, null);

            epService.EPAdministrator.CreateEPL("on SupportBean_A delete from NW where TheString = id");
            epService.EPRuntime.SendEvent(new SupportBean_A("E2"));
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, null, new[] { new object[] { "E2" } });

            epService.EPRuntime.SendEvent(new SupportBean("E3", 7));
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new[] { new object[] { "E3" } }, null);

            epService.EPRuntime.SendEvent(new SupportBean("E4", 2));
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetDataListsFlattened(), fields, new[] { new object[] { "E4" } }, new[] { new object[] { "E1" } });

            stmt.Dispose();
        }