Ejemplo n.º 1
0
            public void Run(RegressionEnvironment env)
            {
                var fieldsWin = new [] { "TheString","IntPrimitive" };
                var fieldsSelect = new [] { "c0" };
                var path = new RegressionPath();

                var eplCreate = namedWindow
                    ? "@Name('create') create window MyInfra#keepall as SupportBean"
                    : "@Name('create') create table MyInfra (TheString string primary key, IntPrimitive int primary key)";
                env.CompileDeploy(eplCreate, path);

                env.CompileDeploy("insert into MyInfra select TheString, IntPrimitive from SupportBean", path);

                var eplSelectDelete = "@Name('s0') on SupportBean_S0 as S0 " +
                                      "select and delete window(win.*).aggregate(0,(result,value) => result+value.IntPrimitive) as c0 " +
                                      "from MyInfra as win where S0.P00=win.TheString";
                env.CompileDeploy(eplSelectDelete, path).AddListener("s0");

                env.SendEventBean(new SupportBean("E1", 1));
                env.SendEventBean(new SupportBean("E2", 2));
                if (namedWindow) {
                    EPAssertionUtil.AssertPropsPerRow(
                        env.GetEnumerator("create"),
                        fieldsWin,
                        new[] {new object[] {"E1", 1}, new object[] {"E2", 2}});
                }
                else {
                    EPAssertionUtil.AssertPropsPerRowAnyOrder(
                        env.GetEnumerator("create"),
                        fieldsWin,
                        new[] {new object[] {"E1", 1}, new object[] {"E2", 2}});
                }

                // select and delete bean E1
                env.SendEventBean(new SupportBean_S0(100, "E1"));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsSelect,
                    new object[] {1});
                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    env.GetEnumerator("create"),
                    fieldsWin,
                    new[] {new object[] {"E2", 2}});

                env.Milestone(0);

                // add some E2 events
                env.SendEventBean(new SupportBean("E2", 3));
                env.SendEventBean(new SupportBean("E2", 4));
                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    env.GetEnumerator("create"),
                    fieldsWin,
                    new[] {new object[] {"E2", 2}, new object[] {"E2", 3}, new object[] {"E2", 4}});

                // select and delete beans E2
                env.SendEventBean(new SupportBean_S0(101, "E2"));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsSelect,
                    new object[] {2 + 3 + 4});
                EPAssertionUtil.AssertPropsPerRowAnyOrder(env.GetEnumerator("create"), fieldsWin, new object[0][]);

                // test SODA
                env.EplToModelCompileDeploy(eplSelectDelete, path);

                env.UndeployAll();
            }
Ejemplo n.º 2
0
        private void RunAssertionSimpleColumn(EPStatement stmt, String[] fields)
        {
            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields,
                                                      new Object[][] {
                new Object[] {
                    "E1", 1
                }
            }
                                                      );
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields,
                                        new Object[] {
                "E1", 1
            }
                                        );

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields,
                                                      new Object[][] {
                new Object[] {
                    "E1", 1
                }
            }
                                                      );
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields,
                                        new Object[] {
                "E1", 1
            }
                                        );

            _epService.EPRuntime.SendEvent(new SupportBean("E2", 1));
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields,
                                                      new Object[][] {
                new Object[] {
                    "E1", 1
                }
                ,
                new Object[] {
                    "E2", 1
                }
            }
                                                      );
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields,
                                        new Object[] {
                "E2", 1
            }
                                        );

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 2));
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields,
                                                      new Object[][] {
                new Object[] {
                    "E1", 1
                }
                ,
                new Object[] {
                    "E2", 1
                }
                ,
                new Object[] {
                    "E1", 2
                }
            }
                                                      );
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields,
                                        new Object[] {
                "E1", 2
            }
                                        );

            _epService.EPRuntime.SendEvent(new SupportBean("E2", 2));
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields,
                                                      new Object[][] {
                new Object[] {
                    "E1", 1
                }
                ,
                new Object[] {
                    "E2", 1
                }
                ,
                new Object[] {
                    "E1", 2
                }
                ,
                new Object[] {
                    "E2", 2
                }
            }
                                                      );
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields,
                                        new Object[] {
                "E2", 2
            }
                                        );

            _epService.EPRuntime.SendEvent(new SupportBean("E2", 2));
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields,
                                                      new Object[][] {
                new Object[] {
                    "E1", 1
                }
                ,
                new Object[] {
                    "E2", 1
                }
                ,
                new Object[] {
                    "E1", 2
                }
                ,
                new Object[] {
                    "E2", 2
                }
            }
                                                      );
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields,
                                        new Object[] {
                "E2", 2
            }
                                        );

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields,
                                                      new Object[][] {
                new Object[] {
                    "E1", 1
                }
                ,
                new Object[] {
                    "E2", 1
                }
                ,
                new Object[] {
                    "E1", 2
                }
                ,
                new Object[] {
                    "E2", 2
                }
            }
                                                      );
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields,
                                        new Object[] {
                "E1", 1
            }
                                        );
        }
Ejemplo n.º 3
0
        private void RunAssertionSubquerySelfCheck(bool namedWindow)
        {
            string[] fields = { "key", "value" };

            // create window
            string stmtTextCreate = namedWindow ?
                                    "create window MyInfra#keepall as select TheString as key, IntBoxed as value from " + typeof(SupportBean).FullName :
                                    "create table MyInfra (key string primary key, value int)";
            EPStatement stmtCreate = epService.EPAdministrator.CreateEPL(stmtTextCreate);

            stmtCreate.AddListener(listenerWindow);

            // create insert into (not does insert if key already exists)
            string stmtTextInsertOne = "insert into MyInfra select TheString as key, IntBoxed as value from " + typeof(SupportBean).FullName + " as s0" +
                                       " where not exists (select * from MyInfra as win where win.key = s0.TheString)";

            epService.EPAdministrator.CreateEPL(stmtTextInsertOne);

            SendSupportBean("E1", 1);
            if (namedWindow)
            {
                EPAssertionUtil.AssertProps(listenerWindow.AssertOneGetNewAndReset(), fields, new object[] { "E1", 1 });
            }
            else
            {
                Assert.IsFalse(listenerWindow.IsInvoked);
            }
            EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E1", 1 } });

            SendSupportBean("E2", 2);
            if (namedWindow)
            {
                EPAssertionUtil.AssertProps(listenerWindow.AssertOneGetNewAndReset(), fields, new object[] { "E2", 2 });
            }
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E1", 1 }, new object[] { "E2", 2 } });

            SendSupportBean("E1", 3);
            Assert.IsFalse(listenerWindow.IsInvoked);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E1", 1 }, new object[] { "E2", 2 } });

            SendSupportBean("E3", 4);
            if (namedWindow)
            {
                EPAssertionUtil.AssertProps(listenerWindow.AssertOneGetNewAndReset(), fields, new object[] { "E3", 4 });
                EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E1", 1 }, new object[] { "E2", 2 }, new object[] { "E3", 4 } });
            }
            else
            {
                EPAssertionUtil.AssertPropsPerRowAnyOrder(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E1", 1 }, new object[] { "E2", 2 }, new object[] { "E3", 4 } });
            }

            // Add delete
            string      stmtTextDelete = "on " + typeof(SupportBean_A).FullName + " delete from MyInfra where key = id";
            EPStatement stmtDelete     = epService.EPAdministrator.CreateEPL(stmtTextDelete);

            stmtDelete.AddListener(listenerStmtDelete);

            // delete E2
            epService.EPRuntime.SendEvent(new SupportBean_A("E2"));
            if (namedWindow)
            {
                EPAssertionUtil.AssertProps(listenerWindow.AssertOneGetOldAndReset(), fields, new object[] { "E2", 2 });
            }
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E1", 1 }, new object[] { "E3", 4 } });

            SendSupportBean("E2", 5);
            if (namedWindow)
            {
                EPAssertionUtil.AssertProps(listenerWindow.AssertOneGetNewAndReset(), fields, new object[] { "E2", 5 });
            }
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E1", 1 }, new object[] { "E3", 4 }, new object[] { "E2", 5 } });

            epService.EPAdministrator.DestroyAllStatements();
            epService.EPAdministrator.Configuration.RemoveEventType("MyInfra", false);
        }
Ejemplo n.º 4
0
        private void RunAssertionStartStopConsumer(bool namedWindow)
        {
            // create window
            string stmtTextCreate = namedWindow ?
                                    "create window MyInfra#keepall as select TheString as a, IntPrimitive as b from " + typeof(SupportBean).FullName :
                                    "create table MyInfra(a string primary key, b int primary key)";
            EPStatement stmtCreate = _epService.EPAdministrator.CreateEPL(stmtTextCreate);

            stmtCreate.AddListener(_listenerWindow);

            // create insert into
            string stmtTextInsertOne = "insert into MyInfra select TheString as a, IntPrimitive as b from " + typeof(SupportBean).FullName;

            _epService.EPAdministrator.CreateEPL(stmtTextInsertOne);

            // create consumer
            string[]    fields         = new string[] { "a", "b" };
            string      stmtTextSelect = "select a, b from MyInfra as s1";
            EPStatement stmtSelect     = _epService.EPAdministrator.CreateEPL(stmtTextSelect);

            stmtSelect.AddListener(_listenerSelect);

            // send 1 event
            SendSupportBean("E1", 1);
            if (namedWindow)
            {
                EPAssertionUtil.AssertProps(_listenerWindow.AssertOneGetNewAndReset(), fields, new object[] { "E1", 1 });
                EPAssertionUtil.AssertProps(_listenerSelect.AssertOneGetNewAndReset(), fields, new object[] { "E1", 1 });
            }
            EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E1", 1 } });

            // stop consumer
            stmtSelect.Stop();
            SendSupportBean("E2", 2);
            if (namedWindow)
            {
                EPAssertionUtil.AssertProps(_listenerWindow.AssertOneGetNewAndReset(), fields, new object[] { "E2", 2 });
            }
            Assert.IsFalse(_listenerSelect.IsInvoked);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E1", 1 }, new object[] { "E2", 2 } });

            // start consumer: the consumer has the last event even though he missed it
            stmtSelect.Start();
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmtSelect.GetEnumerator(), fields, new object[][] { new object[] { "E1", 1 }, new object[] { "E2", 2 } });

            // consumer receives the next event
            SendSupportBean("E3", 3);
            if (namedWindow)
            {
                EPAssertionUtil.AssertProps(_listenerWindow.AssertOneGetNewAndReset(), fields, new object[] { "E3", 3 });
                EPAssertionUtil.AssertProps(_listenerSelect.AssertOneGetNewAndReset(), fields, new object[] { "E3", 3 });
                EPAssertionUtil.AssertPropsPerRow(stmtSelect.GetEnumerator(), fields, new object[][] { new object[] { "E1", 1 }, new object[] { "E2", 2 }, new object[] { "E3", 3 } });
            }
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E1", 1 }, new object[] { "E2", 2 }, new object[] { "E3", 3 } });

            // destroy consumer
            stmtSelect.Dispose();
            SendSupportBean("E4", 4);
            if (namedWindow)
            {
                EPAssertionUtil.AssertProps(_listenerWindow.AssertOneGetNewAndReset(), fields, new object[] { "E4", 4 });
            }
            Assert.IsFalse(_listenerSelect.IsInvoked);

            _epService.EPAdministrator.DestroyAllStatements();
            _epService.EPAdministrator.Configuration.RemoveEventType("MyInfra", false);
        }
Ejemplo n.º 5
0
            public void Run(RegressionEnvironment env)
            {
                var eplDeclare =
                    "create table varagg as (k0 string primary key, k1 int primary key, v1 string, total sum(long))";
                var eplPopulate =
                    "into table varagg select sum(LongPrimitive) as total from SupportBean group by TheString, IntPrimitive";
                var eplQuery = "select total as value from SupportBean_S0 as S0 unidirectional";

                string[] createIndexEmpty = { };
                object[] preloadedEventsTwo = {
                    MakeEvent("G1", 10, 1000L), MakeEvent("G2", 20, 2000L),
                    MakeEvent("G3", 30, 3000L), MakeEvent("G4", 40, 4000L)
                };
                var milestone = new AtomicLong();

                IndexAssertionEventSend eventSendAssertionRangeTwoExpected = () => {
                    env.SendEventBean(new SupportBean_S0(-1, null));
                    EPAssertionUtil.AssertPropsPerRowAnyOrder(
                        env.Listener("s0").NewDataListFlattened,
                        new[] {"value"},
                        new[] {new object[] {2000L}, new object[] {3000L}});
                    env.Listener("s0").Reset();
                };

                object[] preloadedEventsHash = {MakeEvent("G1", 10, 1000L)};
                IndexAssertionEventSend eventSendAssertionHash = () => {
                    env.SendEventBean(new SupportBean_S0(10, "G1"));
                    EPAssertionUtil.AssertPropsPerRow(
                        env.Listener("s0").NewDataListFlattened,
                        new[] {"value"},
                        new[] {new object[] {1000L}});
                    env.Listener("s0").Reset();
                };

                // no secondary indexes
                AssertIndexChoice(
                    env,
                    eplDeclare,
                    eplPopulate,
                    eplQuery,
                    createIndexEmpty,
                    preloadedEventsHash,
                    milestone,
                    new[] {
                        // primary index found
                        new IndexAssertion(
                            "k1 = Id and k0 = P00",
                            "varagg",
                            typeof(IndexedTableLookupPlanHashedOnlyForge),
                            eventSendAssertionHash),
                        new IndexAssertion(
                            "k0 = P00 and k1 = Id",
                            "varagg",
                            typeof(IndexedTableLookupPlanHashedOnlyForge),
                            eventSendAssertionHash),
                        new IndexAssertion(
                            "k0 = P00 and k1 = Id and v1 is null",
                            "varagg",
                            typeof(IndexedTableLookupPlanHashedOnlyForge),
                            eventSendAssertionHash),
                        // no index found
                        new IndexAssertion(
                            "k1 = Id",
                            "varagg",
                            typeof(FullTableScanUniquePerKeyLookupPlanForge),
                            eventSendAssertionHash)
                    }
                );

                // one secondary hash index on single field
                string[] createIndexHashSingleK1 = {"create index idx_k1 on varagg (k1)"};
                AssertIndexChoice(
                    env,
                    eplDeclare,
                    eplPopulate,
                    eplQuery,
                    createIndexHashSingleK1,
                    preloadedEventsHash,
                    milestone,
                    new[] {
                        // primary index found
                        new IndexAssertion(
                            "k1 = Id and k0 = P00",
                            "varagg",
                            typeof(IndexedTableLookupPlanHashedOnlyForge),
                            eventSendAssertionHash),
                        // secondary index found
                        new IndexAssertion(
                            "k1 = Id",
                            "idx_k1",
                            typeof(IndexedTableLookupPlanHashedOnlyForge),
                            eventSendAssertionHash),
                        new IndexAssertion(
                            "Id = k1",
                            "idx_k1",
                            typeof(IndexedTableLookupPlanHashedOnlyForge),
                            eventSendAssertionHash),
                        // no index found
                        new IndexAssertion(
                            "k0 = P00",
                            "varagg",
                            typeof(FullTableScanUniquePerKeyLookupPlanForge),
                            eventSendAssertionHash)
                    }
                );

                // two secondary hash indexes on one field each
                string[] createIndexHashTwoDiscrete =
                    {"create index idx_k1 on varagg (k1)", "create index idx_k0 on varagg (k0)"};
                AssertIndexChoice(
                    env,
                    eplDeclare,
                    eplPopulate,
                    eplQuery,
                    createIndexHashTwoDiscrete,
                    preloadedEventsHash,
                    milestone,
                    new[] {
                        // primary index found
                        new IndexAssertion(
                            "k1 = Id and k0 = P00",
                            "varagg",
                            typeof(IndexedTableLookupPlanHashedOnlyForge),
                            eventSendAssertionHash),
                        // secondary index found
                        new IndexAssertion(
                            "k0 = P00",
                            "idx_k0",
                            typeof(IndexedTableLookupPlanHashedOnlyForge),
                            eventSendAssertionHash),
                        new IndexAssertion(
                            "k1 = Id",
                            "idx_k1",
                            typeof(IndexedTableLookupPlanHashedOnlyForge),
                            eventSendAssertionHash),
                        new IndexAssertion(
                            "v1 is null and k1 = Id",
                            "idx_k1",
                            typeof(IndexedTableLookupPlanHashedOnlyForge),
                            eventSendAssertionHash),
                        // no index found
                        new IndexAssertion(
                            "1=1",
                            "varagg",
                            typeof(FullTableScanUniquePerKeyLookupPlanForge),
                            eventSendAssertionHash)
                    }
                );

                // one range secondary index
                // no secondary indexes
                AssertIndexChoice(
                    env,
                    eplDeclare,
                    eplPopulate,
                    eplQuery,
                    createIndexEmpty,
                    preloadedEventsTwo,
                    milestone,
                    new[] {
                        // no index found
                        new IndexAssertion(
                            "k1 between 20 and 30",
                            "varagg",
                            typeof(FullTableScanUniquePerKeyLookupPlanForge),
                            eventSendAssertionRangeTwoExpected)
                    }
                );

                // single range secondary index, expecting two events
                string[] createIndexRangeOne = {"create index b_k1 on varagg (k1 btree)"};
                AssertIndexChoice(
                    env,
                    eplDeclare,
                    eplPopulate,
                    eplQuery,
                    createIndexRangeOne,
                    preloadedEventsTwo,
                    milestone,
                    new[] {
                        new IndexAssertion(
                            "k1 between 20 and 30",
                            "b_k1",
                            typeof(SortedTableLookupPlanForge),
                            eventSendAssertionRangeTwoExpected),
                        new IndexAssertion(
                            "(k0 = 'G3' or k0 = 'G2') and k1 between 20 and 30",
                            "b_k1",
                            typeof(SortedTableLookupPlanForge),
                            eventSendAssertionRangeTwoExpected)
                    }
                );

                // single range secondary index, expecting single event
                IndexAssertionEventSend eventSendAssertionRangeOneExpected = () => {
                    env.SendEventBean(new SupportBean_S0(-1, null));
                    EPAssertionUtil.AssertPropsPerRowAnyOrder(
                        env.Listener("s0").NewDataListFlattened,
                        new[] {"value"},
                        new[] {new object[] {2000L}});
                    env.Listener("s0").Reset();
                };
                AssertIndexChoice(
                    env,
                    eplDeclare,
                    eplPopulate,
                    eplQuery,
                    createIndexRangeOne,
                    preloadedEventsTwo,
                    milestone,
                    new[] {
                        new IndexAssertion(
                            "k0 = 'G2' and k1 between 20 and 30",
                            "b_k1",
                            typeof(SortedTableLookupPlanForge),
                            eventSendAssertionRangeOneExpected),
                        new IndexAssertion(
                            "k1 between 20 and 30 and k0 = 'G2'",
                            "b_k1",
                            typeof(SortedTableLookupPlanForge),
                            eventSendAssertionRangeOneExpected)
                    }
                );

                // combined hash+range index
                string[] createIndexRangeCombined = {"create index h_k0_b_k1 on varagg (k0 hash, k1 btree)"};
                AssertIndexChoice(
                    env,
                    eplDeclare,
                    eplPopulate,
                    eplQuery,
                    createIndexRangeCombined,
                    preloadedEventsTwo,
                    milestone,
                    new[] {
                        new IndexAssertion(
                            "k0 = 'G2' and k1 between 20 and 30",
                            "h_k0_b_k1",
                            typeof(CompositeTableLookupPlanForge),
                            eventSendAssertionRangeOneExpected),
                        new IndexAssertion(
                            "k1 between 20 and 30 and k0 = 'G2'",
                            "h_k0_b_k1",
                            typeof(CompositeTableLookupPlanForge),
                            eventSendAssertionRangeOneExpected)
                    }
                );

                string[] createIndexHashSingleK0 = {"create index idx_k0 on varagg (k0)"};
                // in-keyword single-directional use
                AssertIndexChoice(
                    env,
                    eplDeclare,
                    eplPopulate,
                    eplQuery,
                    createIndexHashSingleK0,
                    preloadedEventsTwo,
                    milestone,
                    new[] {
                        new IndexAssertion(
                            "k0 in ('G2', 'G3')",
                            "idx_k0",
                            typeof(InKeywordTableLookupPlanSingleIdxForge),
                            eventSendAssertionRangeTwoExpected)
                    }
                );
                // in-keyword multi-directional use
                AssertIndexChoice(
                    env,
                    eplDeclare,
                    eplPopulate,
                    eplQuery,
                    createIndexHashSingleK0,
                    preloadedEventsHash,
                    milestone,
                    new[] {
                        new IndexAssertion(
                            "'G1' in (k0)",
                            "varagg",
                            typeof(FullTableScanUniquePerKeyLookupPlanForge),
                            eventSendAssertionHash)
                    }
                );
            }
Ejemplo n.º 6
0
        private void TryAssertionMultiIdx(EPServiceProvider epService, SupportUpdateListener listener)
        {
            var fields = "s0.Id,s1.Id".Split(',');

            // single row tests
            epService.EPRuntime.SendEvent(new SupportBean_S1(101, "a", "b", "c", "d"));

            epService.EPRuntime.SendEvent(new SupportBean_S0(0, "a", "x"));
            epService.EPRuntime.SendEvent(new SupportBean_S0(0, "x", "c"));
            Assert.IsFalse(listener.IsInvoked);

            epService.EPRuntime.SendEvent(new SupportBean_S0(1, "a", "c"));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] {1, 101});

            epService.EPRuntime.SendEvent(new SupportBean_S0(2, "b", "d"));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] {2, 101});

            epService.EPRuntime.SendEvent(new SupportBean_S0(3, "a", "d"));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] {3, 101});

            // 2-row tests
            epService.EPRuntime.SendEvent(new SupportBean_S1(102, "a1", "a", "d1", "d"));

            epService.EPRuntime.SendEvent(new SupportBean_S0(0, "a", "x"));
            epService.EPRuntime.SendEvent(new SupportBean_S0(0, "x", "c"));
            Assert.IsFalse(listener.IsInvoked);

            epService.EPRuntime.SendEvent(new SupportBean_S0(10, "a", "c"));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] {10, 101});

            epService.EPRuntime.SendEvent(new SupportBean_S0(11, "a", "d"));
            EPAssertionUtil.AssertPropsPerRow(
                listener.GetAndResetLastNewData(), fields, new[] {new object[] {11, 101}, new object[] {11, 102}});

            epService.EPRuntime.SendEvent(new SupportBean_S0(12, "a1", "d"));
            EPAssertionUtil.AssertPropsPerRow(
                listener.GetAndResetLastNewData(), fields, new[] {new object[] {12, 102}});

            epService.EPRuntime.SendEvent(new SupportBean_S0(13, "a", "d1"));
            EPAssertionUtil.AssertPropsPerRow(
                listener.GetAndResetLastNewData(), fields, new[] {new object[] {13, 102}});

            // 3-row tests
            epService.EPRuntime.SendEvent(new SupportBean_S1(103, "a", "a2", "d", "d2"));

            epService.EPRuntime.SendEvent(new SupportBean_S0(20, "a", "c"));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] {20, 101});

            epService.EPRuntime.SendEvent(new SupportBean_S0(21, "a", "d"));
            EPAssertionUtil.AssertPropsPerRowAnyOrder(
                listener.GetAndResetLastNewData(), fields,
                new[] {new object[] {21, 101}, new object[] {21, 102}, new object[] {21, 103}});

            epService.EPRuntime.SendEvent(new SupportBean_S0(22, "a2", "d"));
            EPAssertionUtil.AssertPropsPerRow(
                listener.GetAndResetLastNewData(), fields, new[] {new object[] {22, 103}});

            epService.EPRuntime.SendEvent(new SupportBean_S0(23, "a", "d2"));
            EPAssertionUtil.AssertPropsPerRow(
                listener.GetAndResetLastNewData(), fields, new[] {new object[] {23, 103}});

            epService.EPAdministrator.DestroyAllStatements();
        }
Ejemplo n.º 7
0
            public void Run(RegressionEnvironment env)
            {
                var fields = new[] {"pkey", "sumint"};
                var valueList = "E1,E2,E3";
                var path = new RegressionPath();

                var eplCreateTable =
                    "@Name('Create-Table') create table MyTable(pkey string primary key, sumint sum(int))";
                env.CompileDeploy(eplCreateTable, path);

                var eplIntoTable =
                    "@Name('Into-Table') into table MyTable select sum(IntPrimitive) as sumint from SupportBean group by TheString";
                env.CompileDeploy(eplIntoTable, path);

                var eplQueryTable =
                    "@Name('s0') select (select sumint from MyTable where pkey = S0.P00) as c0 from SupportBean_S0 as S0";
                env.CompileDeploy(eplQueryTable, path).AddListener("s0");

                env.Milestone(1);

                AssertValues(env, valueList, new int?[] {null, null, null});

                MakeSendBean(env, "E1", 10);
                AssertValues(env, valueList, new int?[] {10, null, null});

                env.Milestone(2);

                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    env.GetEnumerator("Create-Table"),
                    fields,
                    new[] {
                        new object[] {"E1", 10}
                    });
                MakeSendBean(env, "E2", 200);
                AssertValues(env, valueList, new int?[] {10, 200, null});

                env.Milestone(3);

                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    env.GetEnumerator("Create-Table"),
                    fields,
                    new[] {
                        new object[] {"E1", 10},
                        new object[] {"E2", 200}
                    });
                MakeSendBean(env, "E1", 11);
                AssertValues(env, valueList, new int?[] {21, 200, null});

                env.Milestone(4);

                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    env.GetEnumerator("Create-Table"),
                    fields,
                    new[] {
                        new object[] {"E1", 21},
                        new object[] {"E2", 200}
                    });
                MakeSendBean(env, "E3", 3000);
                AssertValues(env, valueList, new int?[] {21, 200, 3000});

                env.Milestone(5);
                env.Milestone(6);

                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    env.GetEnumerator("Create-Table"),
                    fields,
                    new[] {
                        new object[] {"E1", 21},
                        new object[] {"E2", 200},
                        new object[] {"E3", 3000}
                    });
                MakeSendBean(env, "E2", 201);
                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    env.GetEnumerator("Create-Table"),
                    fields,
                    new[] {
                        new object[] {"E1", 21},
                        new object[] {"E2", 401},
                        new object[] {"E3", 3000}
                    });
                MakeSendBean(env, "E3", 3001);
                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    env.GetEnumerator("Create-Table"),
                    fields,
                    new[] {
                        new object[] {"E1", 21},
                        new object[] {"E2", 401},
                        new object[] {"E3", 6001}
                    });

                MakeSendBean(env, "E1", 12);
                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    env.GetEnumerator("Create-Table"),
                    fields,
                    new[] {
                        new object[] {"E1", 33},
                        new object[] {"E2", 401},
                        new object[] {"E3", 6001}
                    });

                env.UndeployAll();
            }
        private void TryAssertionSeven(EPServiceProvider epService, string expression)
        {
            EPStatement stmt     = epService.EPAdministrator.CreateEPL(expression);
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;
            string[] fields = "valh0,valh1,valh2".Split(',');

            SendBeanInt(epService, "S00", 1, 1, 1);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(
                stmt.GetEnumerator(), fields, new object[][] {
                new object[] {
                    "H01",
                    "H01-H11",
                    "H01-H11-H21"
                }
            });

            SendBeanInt(epService, "S01", 0, 1, 1);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, null);

            SendBeanInt(epService, "S02", 1, 1, 0);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, null);

            SendBeanInt(epService, "S03", 1, 1, 2);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(
                stmt.GetEnumerator(), fields,
                new object[][] {
                new object[] {
                    "H01",
                    "H01-H11",
                    "H01-H11-H21"
                },
                new object[] {
                    "H01",
                    "H01-H11",
                    "H01-H11-H22"
                }
            });

            SendBeanInt(epService, "S04", 2, 2, 1);
            var result = new object[][] {
                new object[] {
                    "H01",
                    "H01-H11",
                    "H01-H11-H21"
                },
                new object[] {
                    "H02",
                    "H02-H11",
                    "H02-H11-H21"
                },
                new object[] {
                    "H01",
                    "H01-H12",
                    "H01-H12-H21"
                },
                new object[] {
                    "H02",
                    "H02-H12",
                    "H02-H12-H21"
                }
            };

            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, result);

            stmt.Dispose();
        }
Ejemplo n.º 9
0
        private void RunAssertionSingleRowSplitAndType(EventRepresentationChoice eventRepresentationEnum)
        {
            string[] methods;
            if (eventRepresentationEnum.IsObjectArrayEvent())
            {
                methods = "SplitSentenceMethodReturnObjectArray,SplitSentenceBeanMethodReturnObjectArray,SplitWordMethodReturnObjectArray".Split(',');
            }
            else if (eventRepresentationEnum.IsMapEvent())
            {
                methods = "SplitSentenceMethodReturnMap,SplitSentenceBeanMethodReturnMap,SplitWordMethodReturnMap".Split(',');
            }
            else if (eventRepresentationEnum.IsAvroEvent())
            {
                methods = "SplitSentenceMethodReturnAvro,SplitSentenceBeanMethodReturnAvro,SplitWordMethodReturnAvro".Split(',');
            }
            else
            {
                throw new IllegalStateException("Unrecognized enum " + eventRepresentationEnum);
            }
            var funcs = "SplitSentence,SplitSentenceBean,SplitWord".Split(',');

            for (var i = 0; i < funcs.Length; i++)
            {
                _epService.EPAdministrator.Configuration.AddPlugInSingleRowFunction(funcs[i], GetType().FullName, methods[i]);
            }
            _epService.EPAdministrator.Configuration.AddPlugInSingleRowFunction("invalidSentence", GetType().FullName, "InvalidSentenceMethod");

            _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema SentenceEvent(sentence string)");
            _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema WordEvent(word string)");
            _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema CharacterEvent(char string)");

            string      stmtText;
            EPStatement stmt;
            var         fields = "word".Split(',');

            // test single-row method
            stmtText = "select * from SentenceEvent[SplitSentence(sentence)@Type(WordEvent)]";
            stmt     = _epService.EPAdministrator.CreateEPL(stmtText);
            stmt.AddListener(_listener);
            Assert.AreEqual("WordEvent", stmt.EventType.Name);
            Assert.IsTrue(eventRepresentationEnum.MatchesClass(stmt.EventType.UnderlyingType));

            SendSentenceEvent(eventRepresentationEnum, "I am testing this code");
            EPAssertionUtil.AssertPropsPerRow(_listener.GetAndResetLastNewData(), fields, new Object[][]
            {
                new object[] { "I" },
                new object[] { "am" },
                new object[] { "testing" },
                new object[] { "this" },
                new object[] { "code" }
            });

            SendSentenceEvent(eventRepresentationEnum, "the second event");
            EPAssertionUtil.AssertPropsPerRow(_listener.GetAndResetLastNewData(), fields, new Object[][]
            {
                new object[] { "the" },
                new object[] { "second" },
                new object[] { "event" }
            });

            stmt.Dispose();

            // test SODA
            var model = _epService.EPAdministrator.CompileEPL(stmtText);

            Assert.AreEqual(stmtText, model.ToEPL());
            stmt = _epService.EPAdministrator.Create(model);
            Assert.AreEqual(stmtText, stmt.Text);
            stmt.AddListener(_listener);

            SendSentenceEvent(eventRepresentationEnum, "the third event");
            EPAssertionUtil.AssertPropsPerRow(_listener.GetAndResetLastNewData(), fields, new Object[][]
            {
                new object[] { "the" },
                new object[] { "third" },
                new object[] { "event" }
            });

            stmt.Dispose();

            // test script
            if (eventRepresentationEnum.IsMapEvent())
            {
                stmtText = "expression System.Collections.IList jscript:SplitSentenceJS(sentence) [" +
                           "  debug.Debug('test');" +
                           "  var listType = host.type('System.Collections.ArrayList');" +
                           "  var words = host.newObj(listType);" +
                           "  debug.Debug(words);" +
                           "  words.Add(Collections.SingletonDataMap('word', 'wordOne'));" +
                           "  words.Add(Collections.SingletonDataMap('word', 'wordTwo'));" +
                           "  return words;" +
                           "]" +
                           "select * from SentenceEvent[SplitSentenceJS(sentence)@Type(WordEvent)]";

                stmt = _epService.EPAdministrator.CreateEPL(stmtText);
                stmt.AddListener(_listener);
                Assert.AreEqual("WordEvent", stmt.EventType.Name);

                _epService.EPRuntime.SendEvent(Collections.EmptyDataMap, "SentenceEvent");
                EPAssertionUtil.AssertPropsPerRowAnyOrder(_listener.GetAndResetLastNewData(), fields, new Object[][]
                {
                    new object[] { "wordOne" },
                    new object[] { "wordTwo" }
                });

                stmt.Dispose();
            }

            // test multiple splitters
            stmtText = "select * from SentenceEvent[SplitSentence(sentence)@Type(WordEvent)][SplitWord(word)@Type(CharacterEvent)]";
            stmt     = _epService.EPAdministrator.CreateEPL(stmtText);
            stmt.AddListener(_listener);
            Assert.AreEqual("CharacterEvent", stmt.EventType.Name);

            SendSentenceEvent(eventRepresentationEnum, "I am");
            EPAssertionUtil.AssertPropsPerRowAnyOrder(_listener.GetAndResetLastNewData(), "char".Split(','), new Object[][]
            {
                new object[] { "I" },
                new object[] { "a" },
                new object[] { "m" }
            });

            stmt.Dispose();

            // test wildcard parameter
            stmtText = "select * from SentenceEvent[SplitSentenceBean(*)@Type(WordEvent)]";
            stmt     = _epService.EPAdministrator.CreateEPL(stmtText);
            stmt.AddListener(_listener);
            Assert.AreEqual("WordEvent", stmt.EventType.Name);

            SendSentenceEvent(eventRepresentationEnum, "another test sentence");
            EPAssertionUtil.AssertPropsPerRowAnyOrder(_listener.GetAndResetLastNewData(), fields, new Object[][]
            {
                new object[] { "another" },
                new object[] { "test" },
                new object[] { "sentence" }
            });

            stmt.Dispose();

            // test property returning untyped collection
            if (eventRepresentationEnum.IsObjectArrayEvent())
            {
                _epService.EPAdministrator.Configuration.AddEventType(typeof(ObjectArrayEvent));
                stmtText = eventRepresentationEnum.GetAnnotationText() + " select * from ObjectArrayEvent[someObjectArray@Type(WordEvent)]";
                stmt     = _epService.EPAdministrator.CreateEPL(stmtText);
                stmt.AddListener(_listener);
                Assert.AreEqual("WordEvent", stmt.EventType.Name);

                var rows = new Object[][]
                {
                    new object[] { "this" },
                    new object[] { "is" },
                    new object[] { "collection" }
                };
                _epService.EPRuntime.SendEvent(new ObjectArrayEvent(rows));
                EPAssertionUtil.AssertPropsPerRow(_listener.GetAndResetLastNewData(), fields, new Object[][]
                {
                    new object[] { "this" },
                    new object[] { "is" },
                    new object[] { "collection" }
                });
                stmt.Dispose();
            }
            else if (eventRepresentationEnum.IsMapEvent())
            {
                _epService.EPAdministrator.Configuration.AddEventType(typeof(MyCollectionEvent));
                stmtText = eventRepresentationEnum.GetAnnotationText() + " select * from MyCollectionEvent[someCollection@Type(WordEvent)]";
                stmt     = _epService.EPAdministrator.CreateEPL(stmtText);
                stmt.AddListener(_listener);
                Assert.AreEqual("WordEvent", stmt.EventType.Name);

                var coll = new List <Map>();
                coll.Add(Collections.SingletonDataMap("word", "this"));
                coll.Add(Collections.SingletonDataMap("word", "is"));
                coll.Add(Collections.SingletonDataMap("word", "collection"));

                _epService.EPRuntime.SendEvent(new MyCollectionEvent(coll));
                EPAssertionUtil.AssertPropsPerRowAnyOrder(_listener.GetAndResetLastNewData(), fields, new Object[][]
                {
                    new object[] { "this" },
                    new object[] { "is" },
                    new object[] { "collection" }
                });
                stmt.Dispose();
            }
            else if (eventRepresentationEnum.IsAvroEvent())
            {
                _epService.EPAdministrator.Configuration.AddEventType(typeof(AvroArrayEvent));
                stmtText = eventRepresentationEnum.GetAnnotationText() + " select * from AvroArrayEvent[someAvroArray@Type(WordEvent)]";
                stmt     = _epService.EPAdministrator.CreateEPL(stmtText);
                stmt.AddListener(_listener);
                Assert.AreEqual("WordEvent", stmt.EventType.Name);

                var rows  = new GenericRecord[3];
                var words = "this,is,avro".Split(',');
                for (var i = 0; i < words.Length; i++)
                {
                    rows[i] = new GenericRecord(((AvroEventType)stmt.EventType).SchemaAvro);
                    rows[i].Put("word", words[i]);
                }
                _epService.EPRuntime.SendEvent(new AvroArrayEvent(rows));
                EPAssertionUtil.AssertPropsPerRow(_listener.GetAndResetLastNewData(), fields, new Object[][]
                {
                    new object[] { "this" },
                    new object[] { "is" },
                    new object[] { "avro" }
                });
                stmt.Dispose();
            }
            else
            {
                throw new ArgumentException("Unrecognized enum " + eventRepresentationEnum);
            }

            // invalid: event type not found
            TryInvalid("select * from SentenceEvent[SplitSentence(sentence)@type(XYZ)]",
                       "Event type by name 'XYZ' could not be found [select * from SentenceEvent[SplitSentence(sentence)@type(XYZ)]]");

            // invalid lib-function annotation
            TryInvalid("select * from SentenceEvent[SplitSentence(sentence)@dummy(WordEvent)]",
                       "Invalid annotation for property selection, expected 'type' but found 'dummy' in text '@dummy(WordEvent)'");

            // invalid type assignment to event type
            if (eventRepresentationEnum.IsObjectArrayEvent())
            {
                TryInvalid("select * from SentenceEvent[InvalidSentence(sentence)@type(WordEvent)]",
                           "Event type 'WordEvent' underlying type System.Object[] cannot be assigned a value of type");
            }
            else if (eventRepresentationEnum.IsMapEvent())
            {
                TryInvalid("select * from SentenceEvent[InvalidSentence(sentence)@type(WordEvent)]",
                           "Event type 'WordEvent' underlying type " + Name.Of <IDictionary <string, object> >() + " cannot be assigned a value of type");
            }
            else if (eventRepresentationEnum.IsAvroEvent())
            {
                TryInvalid("select * from SentenceEvent[InvalidSentence(sentence)@Type(WordEvent)]",
                           "Event type 'WordEvent' underlying type " + AvroConstantsNoDep.GENERIC_RECORD_CLASSNAME + " cannot be assigned a value of type");
            }
            else
            {
                Assert.Fail();
            }

            // invalid subquery
            TryInvalid("select * from SentenceEvent[SplitSentence((select * from SupportBean#keepall))@type(WordEvent)]",
                       "Invalid contained-event expression 'SplitSentence(subselect_0)': Aggregation, sub-select, previous or prior functions are not supported in this context [select * from SentenceEvent[SplitSentence((select * from SupportBean#keepall))@type(WordEvent)]]");

            _epService.Initialize();
        }
        private void RunAssertion1Stream2HistStarSubordinateCartesianLast(EPServiceProvider epService)
        {
            string expression;

            expression = "select s0.id as id, h0.val as valh0, h1.val as valh1 " +
                         "from SupportBeanInt#lastevent as s0, " +
                         "method:SupportJoinMethods.FetchVal('H0', p00) as h0, " +
                         "method:SupportJoinMethods.FetchVal('H1', p01) as h1 " +
                         "order by h0.val, h1.val";

            EPStatement stmt     = epService.EPAdministrator.CreateEPL(expression);
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            string[] fields = "id,valh0,valh1".Split(',');
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, null);

            SendBeanInt(epService, "E1", 1, 1);
            EPAssertionUtil.AssertPropsPerRow(
                listener.GetAndResetLastNewData(), fields, new object[][] {
                new object[] {
                    "E1",
                    "H01",
                    "H11"
                }
            });
            EPAssertionUtil.AssertPropsPerRowAnyOrder(
                stmt.GetEnumerator(), fields, new object[][] {
                new object[] {
                    "E1",
                    "H01",
                    "H11"
                }
            });

            SendBeanInt(epService, "E2", 2, 0);
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetLastNewData(), fields, null);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, null);

            SendBeanInt(epService, "E3", 0, 1);
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetLastNewData(), fields, null);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, null);

            SendBeanInt(epService, "E3", 2, 2);
            var result = new object[][] {
                new object[] {
                    "E3",
                    "H01",
                    "H11"
                },
                new object[] {
                    "E3",
                    "H01",
                    "H12"
                },
                new object[] {
                    "E3",
                    "H02",
                    "H11"
                },
                new object[] {
                    "E3",
                    "H02",
                    "H12"
                }
            };

            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetLastNewData(), fields, result);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, result);

            SendBeanInt(epService, "E4", 2, 1);
            result = new object[][] {
                new object[] {
                    "E4",
                    "H01",
                    "H11"
                },
                new object[] {
                    "E4",
                    "H02",
                    "H11"
                }
            };
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetLastNewData(), fields, result);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, result);

            stmt.Dispose();
        }
        private void RunAssertion3Stream1HistSubordinate(EPServiceProvider epService)
        {
            string expression;

            expression = "select s0.id as ids0, s1.id as ids1, s2.id as ids2, h0.val as valh0 " +
                         "from SupportBeanInt(id like 'S0%')#keepall as s0, " +
                         "SupportBeanInt(id like 'S1%')#lastevent as s1, " +
                         "SupportBeanInt(id like 'S2%')#lastevent as s2, " +
                         "method:SupportJoinMethods.FetchVal(s1.id||s2.id||'H1', s0.p00) as h0 " +
                         "order by s0.id, s1.id, s2.id, h0.val";

            EPStatement stmt     = epService.EPAdministrator.CreateEPL(expression);
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            string[] fields = "ids0,ids1,ids2,valh0".Split(',');
            SendBeanInt(epService, "S00", 2);
            SendBeanInt(epService, "S10", 1);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, null);
            Assert.IsFalse(listener.IsInvoked);

            SendBeanInt(epService, "S20", 1);
            var resultOne = new object[][] {
                new object[] {
                    "S00",
                    "S10",
                    "S20",
                    "S10S20H11"
                },
                new object[] {
                    "S00",
                    "S10",
                    "S20",
                    "S10S20H12"
                }
            };

            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetLastNewData(), fields, resultOne);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, resultOne);

            SendBeanInt(epService, "S01", 1);
            var resultTwo = new object[][] {
                new object[] {
                    "S01",
                    "S10",
                    "S20",
                    "S10S20H11"
                }
            };

            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetLastNewData(), fields, resultTwo);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(
                stmt.GetEnumerator(), fields, EPAssertionUtil.ConcatenateArray2Dim(resultOne, resultTwo));

            SendBeanInt(epService, "S21", 1);
            var resultThree = new object[][] {
                new object[] {
                    "S00",
                    "S10",
                    "S21",
                    "S10S21H11"
                },
                new object[] {
                    "S00",
                    "S10",
                    "S21",
                    "S10S21H12"
                },
                new object[] {
                    "S01",
                    "S10",
                    "S21",
                    "S10S21H11"
                }
            };

            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetLastNewData(), fields, resultThree);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(
                stmt.GetEnumerator(), fields, EPAssertionUtil.ConcatenateArray2Dim(resultThree));

            stmt.Dispose();
        }
        private void TryAssertionFour(EPServiceProvider epService, string expression)
        {
            EPStatement stmt     = epService.EPAdministrator.CreateEPL(expression);
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            string[] fields = "id,valh0,valh1,valh2".Split(',');
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, null);

            SendBeanInt(epService, "E1", 2, 2, 2, 1);
            EPAssertionUtil.AssertPropsPerRow(
                listener.GetAndResetLastNewData(), fields,
                new object[][] {
                new object[] {
                    "E1",
                    "H01",
                    "H11",
                    "H01H21"
                }
            });
            EPAssertionUtil.AssertPropsPerRowAnyOrder(
                stmt.GetEnumerator(), fields, new object[][] {
                new object[] {
                    "E1",
                    "H01",
                    "H11",
                    "H01H21"
                }
            });

            SendBeanInt(epService, "E2", 4, 4, 4, 3);
            EPAssertionUtil.AssertPropsPerRow(
                listener.GetAndResetLastNewData(), fields,
                new object[][] {
                new object[] {
                    "E2",
                    "H03",
                    "H13",
                    "H03H23"
                }
            });
            EPAssertionUtil.AssertPropsPerRowAnyOrder(
                stmt.GetEnumerator(), fields,
                new object[][] {
                new object[] {
                    "E1",
                    "H01",
                    "H11",
                    "H01H21"
                },
                new object[] {
                    "E2",
                    "H03",
                    "H13",
                    "H03H23"
                }
            });

            stmt.Dispose();
        }
        private void TryAssertionTwo(EPServiceProvider epService, string expression)
        {
            EPStatement stmt     = epService.EPAdministrator.CreateEPL(expression);
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            string[] fields = "id,valh0,valh1".Split(',');
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, null);

            SendBeanInt(epService, "E1", 1, 1);
            EPAssertionUtil.AssertPropsPerRow(
                listener.GetAndResetLastNewData(), fields, new object[][] {
                new object[] {
                    "E1",
                    "H01",
                    "H011"
                }
            });
            EPAssertionUtil.AssertPropsPerRowAnyOrder(
                stmt.GetEnumerator(), fields, new object[][] {
                new object[] {
                    "E1",
                    "H01",
                    "H011"
                }
            });

            SendBeanInt(epService, "E2", 0, 1);
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetLastNewData(), fields, null);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(
                stmt.GetEnumerator(), fields, new object[][] {
                new object[] {
                    "E1",
                    "H01",
                    "H011"
                }
            });

            SendBeanInt(epService, "E3", 1, 0);
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetLastNewData(), fields, null);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(
                stmt.GetEnumerator(), fields, new object[][] {
                new object[] {
                    "E1",
                    "H01",
                    "H011"
                }
            });

            SendBeanInt(epService, "E4", 2, 2);
            object[][] result =
            {
                new object[] {
                    "E4",
                    "H01",
                    "H011"
                }, new object[]{
                    "E4",
                    "H01",
                    "H012"
                }, new object[]{
                    "E4",
                    "H02",
                    "H021"
                }, new object[]{
                    "E4",
                    "H02",
                    "H022"
                }
            };
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetLastNewData(), fields, result);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(
                stmt.GetEnumerator(), fields,
                EPAssertionUtil.ConcatenateArray2Dim(
                    result, new object[][] {
                new object[] {
                    "E1",
                    "H01",
                    "H011"
                }
            }));

            stmt.Dispose();
        }
Ejemplo n.º 14
0
        private void RunAssertionSelectIndexChoiceJoin(bool namedWindow)
        {
            var preloadedEventsOne = new object[] {
                new SupportSimpleBeanOne("E1", 10, 1, 2),
                new SupportSimpleBeanOne("E2", 11, 3, 4),
                new SupportSimpleBeanTwo("E1", 20, 1, 2),
                new SupportSimpleBeanTwo("E2", 21, 3, 4),
            };
            IndexAssertionFAF fafAssertion = (result) => {
                var fields = "w1.s1,w2.s2,w1.i1,w2.i2".Split(',');
                EPAssertionUtil.AssertPropsPerRowAnyOrder(result.Array, fields,
                                                          new object[][] { new object[] { "E1", "E1", 10, 20 }, new object[] { "E2", "E2", 11, 21 } });
            };

            var assertionsSingleProp = new IndexAssertion[] {
                new IndexAssertion(null, "s1 = s2", true, fafAssertion),
                new IndexAssertion(null, "s1 = s2 and l1 = l2", true, fafAssertion),
                new IndexAssertion(null, "l1 = l2 and s1 = s2", true, fafAssertion),
                new IndexAssertion(null, "d1 = d2 and l1 = l2 and s1 = s2", true, fafAssertion),
                new IndexAssertion(null, "d1 = d2 and l1 = l2", false, fafAssertion),
            };

            // single prop, no index, both declared unique (named window only)
            if (namedWindow)
            {
                AssertIndexChoiceJoin(namedWindow, new string[0], preloadedEventsOne, "std:unique(s1)", "std:unique(s2)", assertionsSingleProp);
            }

            // single prop, unique indexes, both declared keepall
            var uniqueIndex = new string[] { "create unique index W1I1 on W1(s1)", "create unique index W1I2 on W2(s2)" };

            AssertIndexChoiceJoin(namedWindow, uniqueIndex, preloadedEventsOne, "win:keepall()", "win:keepall()", assertionsSingleProp);

            // single prop, mixed indexes, both declared keepall
            var assertionsMultiProp = new IndexAssertion[] {
                new IndexAssertion(null, "s1 = s2", false, fafAssertion),
                new IndexAssertion(null, "s1 = s2 and l1 = l2", true, fafAssertion),
                new IndexAssertion(null, "l1 = l2 and s1 = s2", true, fafAssertion),
                new IndexAssertion(null, "d1 = d2 and l1 = l2 and s1 = s2", true, fafAssertion),
                new IndexAssertion(null, "d1 = d2 and l1 = l2", false, fafAssertion),
            };

            if (namedWindow)
            {
                var mixedIndex = new string[] { "create index W1I1 on W1(s1, l1)", "create unique index W1I2 on W2(s2)" };
                AssertIndexChoiceJoin(namedWindow, mixedIndex, preloadedEventsOne, "std:unique(s1)", "win:keepall()", assertionsSingleProp);

                // multi prop, no index, both declared unique
                AssertIndexChoiceJoin(namedWindow, new string[0], preloadedEventsOne, "std:unique(s1, l1)", "std:unique(s2, l2)", assertionsMultiProp);
            }

            // multi prop, unique indexes, both declared keepall
            var uniqueIndexMulti = new string[] { "create unique index W1I1 on W1(s1, l1)", "create unique index W1I2 on W2(s2, l2)" };

            AssertIndexChoiceJoin(namedWindow, uniqueIndexMulti, preloadedEventsOne, "win:keepall()", "win:keepall()", assertionsMultiProp);

            // multi prop, mixed indexes, both declared keepall
            if (namedWindow)
            {
                var mixedIndexMulti = new string[] { "create index W1I1 on W1(s1)", "create unique index W1I2 on W2(s2, l2)" };
                AssertIndexChoiceJoin(namedWindow, mixedIndexMulti, preloadedEventsOne, "std:unique(s1, l1)", "win:keepall()", assertionsMultiProp);
            }
        }
Ejemplo n.º 15
0
        private void RunAssertionJoinIndexChoice(EPServiceProvider epService)
        {
            string eplDeclare  = "create table varagg as (k0 string primary key, k1 int primary key, v1 string, total sum(long))";
            string eplPopulate = "into table varagg select sum(LongPrimitive) as total from SupportBean group by TheString, IntPrimitive";
            string eplQuery    = "select total as value from SupportBean_S0 as s0 unidirectional";

            var createIndexEmpty   = new string[] {};
            var preloadedEventsTwo = new object[] { MakeEvent("G1", 10, 1000L), MakeEvent("G2", 20, 2000L),
                                                    MakeEvent("G3", 30, 3000L), MakeEvent("G4", 40, 4000L) };
            var listener = new SupportUpdateListener();

            var eventSendAssertionRangeTwoExpected = new IndexAssertionEventSend(() => {
                epService.EPRuntime.SendEvent(new SupportBean_S0(-1, null));
                EPAssertionUtil.AssertPropsPerRowAnyOrder(listener.GetNewDataListFlattened(), "value".Split(','),
                                                          new object[][] { new object[] { 2000L }, new object[] { 3000L } });
                listener.Reset();
            });

            var preloadedEventsHash    = new object[] { MakeEvent("G1", 10, 1000L) };
            var eventSendAssertionHash = new IndexAssertionEventSend(() => {
                epService.EPRuntime.SendEvent(new SupportBean_S0(10, "G1"));
                EPAssertionUtil.AssertPropsPerRow(listener.GetNewDataListFlattened(), "value".Split(','),
                                                  new object[][] { new object[] { 1000L } });
                listener.Reset();
            });

            // no secondary indexes
            AssertIndexChoice(epService, listener, eplDeclare, eplPopulate, eplQuery, createIndexEmpty, preloadedEventsHash,
                              new IndexAssertion[] {
                // primary index found
                new IndexAssertion("k1 = id and k0 = p00", "varagg", typeof(IndexedTableLookupPlanMulti), eventSendAssertionHash),
                new IndexAssertion("k0 = p00 and k1 = id", "varagg", typeof(IndexedTableLookupPlanMulti), eventSendAssertionHash),
                new IndexAssertion("k0 = p00 and k1 = id and v1 is null", "varagg", typeof(IndexedTableLookupPlanMulti), eventSendAssertionHash),
                // no index found
                new IndexAssertion("k1 = id", "varagg", typeof(FullTableScanUniquePerKeyLookupPlan), eventSendAssertionHash)
            }
                              );

            // one secondary hash index on single field
            var createIndexHashSingleK1 = new string[] { "create index idx_k1 on varagg (k1)" };

            AssertIndexChoice(epService, listener, eplDeclare, eplPopulate, eplQuery, createIndexHashSingleK1, preloadedEventsHash,
                              new IndexAssertion[] {
                // primary index found
                new IndexAssertion("k1 = id and k0 = p00", "varagg", typeof(IndexedTableLookupPlanMulti), eventSendAssertionHash),
                // secondary index found
                new IndexAssertion("k1 = id", "idx_k1", typeof(IndexedTableLookupPlanSingle), eventSendAssertionHash),
                new IndexAssertion("id = k1", "idx_k1", typeof(IndexedTableLookupPlanSingle), eventSendAssertionHash),
                // no index found
                new IndexAssertion("k0 = p00", "varagg", typeof(FullTableScanUniquePerKeyLookupPlan), eventSendAssertionHash)
            }
                              );

            // two secondary hash indexes on one field each
            var createIndexHashTwoDiscrete = new string[] { "create index idx_k1 on varagg (k1)", "create index idx_k0 on varagg (k0)" };

            AssertIndexChoice(epService, listener, eplDeclare, eplPopulate, eplQuery, createIndexHashTwoDiscrete, preloadedEventsHash,
                              new IndexAssertion[] {
                // primary index found
                new IndexAssertion("k1 = id and k0 = p00", "varagg", typeof(IndexedTableLookupPlanMulti), eventSendAssertionHash),
                // secondary index found
                new IndexAssertion("k0 = p00", "idx_k0", typeof(IndexedTableLookupPlanSingle), eventSendAssertionHash),
                new IndexAssertion("k1 = id", "idx_k1", typeof(IndexedTableLookupPlanSingle), eventSendAssertionHash),
                new IndexAssertion("v1 is null and k1 = id", "idx_k1", typeof(IndexedTableLookupPlanSingle), eventSendAssertionHash),
                // no index found
                new IndexAssertion("1=1", "varagg", typeof(FullTableScanUniquePerKeyLookupPlan), eventSendAssertionHash)
            }
                              );

            // one range secondary index
            // no secondary indexes
            AssertIndexChoice(epService, listener, eplDeclare, eplPopulate, eplQuery, createIndexEmpty, preloadedEventsTwo,
                              new IndexAssertion[] {
                // no index found
                new IndexAssertion("k1 between 20 and 30", "varagg", typeof(FullTableScanUniquePerKeyLookupPlan), eventSendAssertionRangeTwoExpected)
            }
                              );

            // single range secondary index, expecting two events
            var createIndexRangeOne = new string[] { "create index b_k1 on varagg (k1 btree)" };

            AssertIndexChoice(epService, listener, eplDeclare, eplPopulate, eplQuery, createIndexRangeOne, preloadedEventsTwo,
                              new IndexAssertion[] {
                new IndexAssertion("k1 between 20 and 30", "b_k1", typeof(SortedTableLookupPlan), eventSendAssertionRangeTwoExpected),
                new IndexAssertion("(k0 = 'G3' or k0 = 'G2') and k1 between 20 and 30", "b_k1", typeof(SortedTableLookupPlan), eventSendAssertionRangeTwoExpected),
            }
                              );

            // single range secondary index, expecting single event
            var eventSendAssertionRangeOneExpected = new IndexAssertionEventSend(() => {
                epService.EPRuntime.SendEvent(new SupportBean_S0(-1, null));
                EPAssertionUtil.AssertPropsPerRowAnyOrder(listener.GetNewDataListFlattened(), "value".Split(','),
                                                          new object[][] { new object[] { 2000L } });
                listener.Reset();
            });

            AssertIndexChoice(epService, listener, eplDeclare, eplPopulate, eplQuery, createIndexRangeOne, preloadedEventsTwo,
                              new IndexAssertion[] {
                new IndexAssertion("k0 = 'G2' and k1 between 20 and 30", "b_k1", typeof(SortedTableLookupPlan), eventSendAssertionRangeOneExpected),
                new IndexAssertion("k1 between 20 and 30 and k0 = 'G2'", "b_k1", typeof(SortedTableLookupPlan), eventSendAssertionRangeOneExpected),
            }
                              );

            // combined hash+range index
            var createIndexRangeCombined = new string[] { "create index h_k0_b_k1 on varagg (k0 hash, k1 btree)" };

            AssertIndexChoice(epService, listener, eplDeclare, eplPopulate, eplQuery, createIndexRangeCombined, preloadedEventsTwo,
                              new IndexAssertion[] {
                new IndexAssertion("k0 = 'G2' and k1 between 20 and 30", "h_k0_b_k1", typeof(CompositeTableLookupPlan), eventSendAssertionRangeOneExpected),
                new IndexAssertion("k1 between 20 and 30 and k0 = 'G2'", "h_k0_b_k1", typeof(CompositeTableLookupPlan), eventSendAssertionRangeOneExpected),
            }
                              );

            var createIndexHashSingleK0 = new string[] { "create index idx_k0 on varagg (k0)" };

            // in-keyword single-directional use
            AssertIndexChoice(epService, listener, eplDeclare, eplPopulate, eplQuery, createIndexHashSingleK0, preloadedEventsTwo,
                              new IndexAssertion[] {
                new IndexAssertion("k0 in ('G2', 'G3')", "idx_k0", typeof(InKeywordTableLookupPlanSingleIdx), eventSendAssertionRangeTwoExpected),
            }
                              );
            // in-keyword multi-directional use
            AssertIndexChoice(epService, listener, eplDeclare, eplPopulate, eplQuery, createIndexHashSingleK0, preloadedEventsHash,
                              new IndexAssertion[] {
                new IndexAssertion("'G1' in (k0)", "varagg", typeof(FullTableScanUniquePerKeyLookupPlan), eventSendAssertionHash),
            }
                              );

            epService.EPAdministrator.Configuration.RemoveEventType("table_varagg__internal", false);
            epService.EPAdministrator.Configuration.RemoveEventType("table_varagg__public", false);
        }
Ejemplo n.º 16
0
        private void RunAssertion(EPStatement selectTestView)
        {
            var fields = new string[] { "Symbol", "mySum", "myAvg" };

            EPAssertionUtil.AssertPropsPerRowAnyOrder(selectTestView.GetEnumerator(), fields, null);

            // assert select result type
            Assert.AreEqual(typeof(string), selectTestView.EventType.GetPropertyType("Symbol"));
            Assert.AreEqual(typeof(double?), selectTestView.EventType.GetPropertyType("mySum"));
            Assert.AreEqual(typeof(double?), selectTestView.EventType.GetPropertyType("myAvg"));

            SendEvent(SYMBOL_DELL, 10);
            AssertEvents(SYMBOL_DELL,
                         null, null,
                         10d, 10d);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(selectTestView.GetEnumerator(), fields, new object[][] { new object[] { "DELL", 10d, 10d } });

            SendEvent(SYMBOL_DELL, 20);
            AssertEvents(SYMBOL_DELL,
                         10d, 10d,
                         30d, 15d);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(selectTestView.GetEnumerator(), fields, new object[][] { new object[] { "DELL", 30d, 15d } });

            SendEvent(SYMBOL_DELL, 100);
            AssertEvents(SYMBOL_DELL,
                         30d, 15d,
                         130d, 130d / 3d);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(selectTestView.GetEnumerator(), fields, new object[][] { new object[] { "DELL", 130d, 130d / 3d } });

            SendEvent(SYMBOL_DELL, 50);
            AssertEvents(SYMBOL_DELL,
                         130d, 130 / 3d,
                         170d, 170 / 3d); // 20 + 100 + 50
            EPAssertionUtil.AssertPropsPerRowAnyOrder(selectTestView.GetEnumerator(), fields, new object[][] { new object[] { "DELL", 170d, 170d / 3d } });

            SendEvent(SYMBOL_DELL, 5);
            AssertEvents(SYMBOL_DELL,
                         170d, 170 / 3d,
                         155d, 155 / 3d); // 100 + 50 + 5
            EPAssertionUtil.AssertPropsPerRowAnyOrder(selectTestView.GetEnumerator(), fields, new object[][] { new object[] { "DELL", 155d, 155d / 3d } });

            SendEvent("AAA", 1000);
            AssertEvents(SYMBOL_DELL,
                         155d, 155d / 3,
                         55d, 55d / 2); // 50 + 5
            EPAssertionUtil.AssertPropsPerRowAnyOrder(selectTestView.GetEnumerator(), fields, new object[][] { new object[] { "DELL", 55d, 55d / 2d } });

            SendEvent(SYMBOL_IBM, 70);
            AssertEvents(SYMBOL_DELL,
                         55d, 55 / 2d,
                         5, 5,
                         SYMBOL_IBM,
                         null, null,
                         70, 70);   // Dell:5
            EPAssertionUtil.AssertPropsPerRowAnyOrder(selectTestView.GetEnumerator(), fields, new object[][] {
                new object[] { "DELL", 5d, 5d }, new object[] { "IBM", 70d, 70d }
            });

            SendEvent("AAA", 2000);
            AssertEvents(SYMBOL_DELL,
                         5d, 5d,
                         null, null);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(selectTestView.GetEnumerator(), fields, new object[][] {
                new object[] { "IBM", 70d, 70d }
            });

            SendEvent("AAA", 3000);
            Assert.IsFalse(_listener.IsInvoked);

            SendEvent("AAA", 4000);
            AssertEvents(SYMBOL_IBM,
                         70d, 70d,
                         null, null);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(selectTestView.GetEnumerator(), fields, null);
        }
Ejemplo n.º 17
0
        private void TryAssertionSingleIdx(EPServiceProvider epService, SupportUpdateListener listener)
        {
            var fields = "s0.Id,s1.Id".Split(',');

            // single row tests
            epService.EPRuntime.SendEvent(new SupportBean_S0(100, "a", "c"));

            epService.EPRuntime.SendEvent(new SupportBean_S1(0, "a1", "b", "c", "d"));
            epService.EPRuntime.SendEvent(new SupportBean_S1(0, "a", "b", "x", "d"));
            Assert.IsFalse(listener.IsInvoked);

            epService.EPRuntime.SendEvent(new SupportBean_S1(1, "a", "b", "c", "d"));
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetLastNewData(), fields, new[] {new object[] {100, 1}});

            epService.EPRuntime.SendEvent(new SupportBean_S1(2, "x", "a", "x", "c"));
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetLastNewData(), fields, new[] {new object[] {100, 2}});

            // 2-rows available tests
            epService.EPRuntime.SendEvent(new SupportBean_S0(101, "a", "d"));

            epService.EPRuntime.SendEvent(new SupportBean_S1(0, "a1", "b", "c", "d"));
            epService.EPRuntime.SendEvent(new SupportBean_S1(0, "a", "b", "x", "c1"));
            Assert.IsFalse(listener.IsInvoked);

            epService.EPRuntime.SendEvent(new SupportBean_S1(10, "a", "b", "c", "d"));
            EPAssertionUtil.AssertPropsPerRow(
                listener.GetAndResetLastNewData(), fields, new[] {new object[] {100, 10}, new object[] {101, 10}});

            epService.EPRuntime.SendEvent(new SupportBean_S1(11, "x", "a", "x", "c"));
            EPAssertionUtil.AssertPropsPerRow(
                listener.GetAndResetLastNewData(), fields, new[] {new object[] {100, 11}});

            epService.EPRuntime.SendEvent(new SupportBean_S1(12, "x", "a", "d", "x"));
            EPAssertionUtil.AssertPropsPerRow(
                listener.GetAndResetLastNewData(), fields, new[] {new object[] {101, 12}});

            // 3-rows available tests
            epService.EPRuntime.SendEvent(new SupportBean_S0(102, "b", "c"));

            epService.EPRuntime.SendEvent(new SupportBean_S1(0, "a1", "b", "c1", "d"));
            epService.EPRuntime.SendEvent(new SupportBean_S1(0, "a", "b", "x", "c1"));
            Assert.IsFalse(listener.IsInvoked);

            epService.EPRuntime.SendEvent(new SupportBean_S1(20, "a", "b", "c", "d"));
            EPAssertionUtil.AssertPropsPerRow(
                listener.GetAndResetLastNewData(), fields,
                new[] {new object[] {100, 20}, new object[] {101, 20}, new object[] {102, 20}});

            epService.EPRuntime.SendEvent(new SupportBean_S1(21, "b", "a", "x", "c"));
            EPAssertionUtil.AssertPropsPerRowAnyOrder(
                listener.GetAndResetLastNewData(), fields, new[] {new object[] {100, 21}, new object[] {102, 21}});

            epService.EPRuntime.SendEvent(new SupportBean_S1(22, "b", "a", "d", "c"));
            EPAssertionUtil.AssertPropsPerRowAnyOrder(
                listener.GetAndResetLastNewData(), fields,
                new[] {new object[] {100, 22}, new object[] {101, 22}, new object[] {102, 22}});

            epService.EPRuntime.SendEvent(new SupportBean_S1(23, "b", "x", "x", "c"));
            EPAssertionUtil.AssertPropsPerRowAnyOrder(
                listener.GetAndResetLastNewData(), fields, new[] {new object[] {102, 23}});

            epService.EPAdministrator.DestroyAllStatements();
        }
Ejemplo n.º 18
0
 private void AssertEvents(
     RegressionEnvironment env,
     object[][] expected)
 {
     EPAssertionUtil.AssertPropsPerRowAnyOrder(env.Listener("s0").GetAndResetLastNewData(), "one.Id,two.Id".SplitCsv(), expected);
 }
Ejemplo n.º 19
0
            public void Run(RegressionEnvironment env)
            {
                var fields = new[] {"sumint"};
                var path = new RegressionPath();

                var eplCreateTable = "@Name('Create-Table') create table MyTable(sumint sum(int))";
                env.CompileDeploy(eplCreateTable, path);

                var eplIntoTable =
                    "@Name('Into-Table') into table MyTable select sum(IntPrimitive) as sumint from SupportBean";
                env.CompileDeploy(eplIntoTable, path);

                var eplQueryTable = "@Name('s0') select (select sumint from MyTable) as c0 from SupportBean_S0 as S0";
                env.CompileDeploy(eplQueryTable, path).AddListener("s0");

                env.Milestone(1);

                AssertValue(env, null);

                MakeSendBean(env, "E1", 10);
                AssertValue(env, 10);

                env.Milestone(2);

                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    env.GetEnumerator("Create-Table"),
                    fields,
                    new[] {
                        new object[] {10}
                    });
                MakeSendBean(env, "E2", 200);
                AssertValue(env, 210);

                env.Milestone(3);

                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    env.GetEnumerator("Create-Table"),
                    fields,
                    new[] {
                        new object[] {210}
                    });
                MakeSendBean(env, "E1", 11);
                AssertValue(env, 221);

                env.Milestone(4);

                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    env.GetEnumerator("Create-Table"),
                    fields,
                    new[] {
                        new object[] {221}
                    });
                MakeSendBean(env, "E3", 3000);
                AssertValue(env, 3221);

                env.Milestone(5);
                env.Milestone(6);

                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    env.GetEnumerator("Create-Table"),
                    fields,
                    new[] {
                        new object[] {3221}
                    });
                MakeSendBean(env, "E2", 201);
                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    env.GetEnumerator("Create-Table"),
                    fields,
                    new[] {
                        new object[] {3422}
                    });
                MakeSendBean(env, "E3", 3001);
                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    env.GetEnumerator("Create-Table"),
                    fields,
                    new[] {
                        new object[] {6423}
                    });

                MakeSendBean(env, "E1", 12);
                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    env.GetEnumerator("Create-Table"),
                    fields,
                    new[] {
                        new object[] {6435}
                    });

                env.UndeployAll();
            }
Ejemplo n.º 20
0
 public void Run(RegressionEnvironment env)
 {
     SetupStatement(env, "full");
     // Send S0[0]
     SendEvent(EVENTS_S0[0], env);
     CompareEvent(env.Listener("s0").AssertOneGetNewAndReset(), 100, "0", null, null);
     EPAssertionUtil.AssertPropsPerRowAnyOrder(env.GetEnumerator("s0"), FIELDS, new[] {new object[] {100, "0", null, null}});
     // Send S1[1]
     SendEvent(EVENTS_S1[1], env);
     CompareEvent(env.Listener("s0").AssertOneGetNewAndReset(), null, null, 201, "1");
     EPAssertionUtil.AssertPropsPerRowAnyOrder(
         env.GetEnumerator("s0"),
         FIELDS,
         new[] {new object[] {100, "0", null, null}, new object[] {null, null, 201, "1"}});
     // Send S1[2] and S0[2]
     SendEvent(EVENTS_S1[2], env);
     CompareEvent(env.Listener("s0").AssertOneGetNewAndReset(), null, null, 202, "2");
     EPAssertionUtil.AssertPropsPerRowAnyOrder(
         env.GetEnumerator("s0"),
         FIELDS,
         new[] {new object[] {100, "0", null, null}, new object[] {null, null, 201, "1"}, new object[] {null, null, 202, "2"}});
     SendEvent(EVENTS_S0[2], env);
     CompareEvent(env.Listener("s0").AssertOneGetNewAndReset(), 102, "2", 202, "2");
     EPAssertionUtil.AssertPropsPerRowAnyOrder(
         env.GetEnumerator("s0"),
         FIELDS,
         new[] {new object[] {100, "0", null, null}, new object[] {null, null, 201, "1"}, new object[] {102, "2", 202, "2"}});
     // Send S0[3] and S1[3]
     SendEvent(EVENTS_S0[3], env);
     CompareEvent(env.Listener("s0").AssertOneGetNewAndReset(), 103, "3", null, null);
     EPAssertionUtil.AssertPropsPerRowAnyOrder(
         env.GetEnumerator("s0"),
         FIELDS,
         new[] {
             new object[] {100, "0", null, null}, new object[] {null, null, 201, "1"}, new object[] {102, "2", 202, "2"},
             new object[] {103, "3", null, null}
         });
     SendEvent(EVENTS_S1[3], env);
     CompareEvent(env.Listener("s0").AssertOneGetNewAndReset(), 103, "3", 203, "3");
     EPAssertionUtil.AssertPropsPerRowAnyOrder(
         env.GetEnumerator("s0"),
         FIELDS,
         new[] {
             new object[] {100, "0", null, null}, new object[] {null, null, 201, "1"}, new object[] {102, "2", 202, "2"},
             new object[] {103, "3", 203, "3"}
         });
     // Send S0[4], pushes S0[0] out of window
     SendEvent(EVENTS_S0[4], env);
     var oldEvent = env.Listener("s0").LastOldData[0];
     var newEvent = env.Listener("s0").LastNewData[0];
     CompareEvent(oldEvent, 100, "0", null, null);
     CompareEvent(newEvent, 104, "4", null, null);
     env.Listener("s0").Reset();
     EPAssertionUtil.AssertPropsPerRowAnyOrder(
         env.GetEnumerator("s0"),
         FIELDS,
         new[] {
             new object[] {null, null, 201, "1"}, new object[] {102, "2", 202, "2"}, new object[] {103, "3", 203, "3"},
             new object[] {104, "4", null, null}
         });
     // Send S1[4]
     SendEvent(EVENTS_S1[4], env);
     CompareEvent(env.Listener("s0").AssertOneGetNewAndReset(), 104, "4", 204, "4");
     EPAssertionUtil.AssertPropsPerRowAnyOrder(
         env.GetEnumerator("s0"),
         FIELDS,
         new[] {
             new object[] {null, null, 201, "1"}, new object[] {102, "2", 202, "2"}, new object[] {103, "3", 203, "3"},
             new object[] {104, "4", 204, "4"}
         });
     // Send S1[5]
     SendEvent(EVENTS_S1[5], env);
     CompareEvent(env.Listener("s0").AssertOneGetNewAndReset(), null, null, 205, "5");
     EPAssertionUtil.AssertPropsPerRowAnyOrder(
         env.GetEnumerator("s0"),
         FIELDS,
         new[] {
             new object[] {null, null, 201, "1"}, new object[] {102, "2", 202, "2"}, new object[] {103, "3", 203, "3"},
             new object[] {104, "4", 204, "4"}, new object[] {null, null, 205, "5"}
         });
     // Send S1[6], pushes S1[1] out of window
     SendEvent(EVENTS_S1[5], env);
     oldEvent = env.Listener("s0").LastOldData[0];
     newEvent = env.Listener("s0").LastNewData[0];
     CompareEvent(oldEvent, null, null, 201, "1");
     CompareEvent(newEvent, null, null, 205, "5");
     EPAssertionUtil.AssertPropsPerRowAnyOrder(
         env.GetEnumerator("s0"),
         FIELDS,
         new[] {
             new object[] {102, "2", 202, "2"}, new object[] {103, "3", 203, "3"}, new object[] {104, "4", 204, "4"},
             new object[] {null, null, 205, "5"}, new object[] {null, null, 205, "5"}
         });
     env.UndeployAll();
 }
Ejemplo n.º 21
0
        private void RunAssertionGroupedWindow(EPServiceProvider epService)
        {
            SendTimer(epService, 20000);
            EPStatement stmt = epService.EPAdministrator.CreateEPL(
                "select irstream * from " + typeof(SupportBeanTimestamp).FullName +
                "#groupwin(groupId)#time_order(timestamp, 10 sec)");
            var listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            // 1st event is old
            SendEvent(epService, "E1", "G1", 10000);
            Assert.AreEqual(1, listener.NewDataList.Count);
            Assert.AreEqual(1, listener.LastNewData.Length);
            Assert.AreEqual("E1", listener.LastNewData[0].Get("id"));
            Assert.AreEqual(1, listener.LastOldData.Length);
            Assert.AreEqual("E1", listener.LastOldData[0].Get("id"));
            listener.Reset();
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), new string[] { "id" }, null);

            // 2nd just fits
            SendEvent(epService, "E2", "G2", 10001);
            Assert.AreEqual("E2", listener.AssertOneGetNewAndReset().Get("id"));
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), new string[] { "id" }, new object[][] { new object[] { "E2" } });

            SendEvent(epService, "E3", "G3", 20000);
            Assert.AreEqual("E3", listener.AssertOneGetNewAndReset().Get("id"));
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), new string[] { "id" }, new object[][] { new object[] { "E2" }, new object[] { "E3" } });

            SendEvent(epService, "E4", "G2", 20000);
            Assert.AreEqual("E4", listener.AssertOneGetNewAndReset().Get("id"));
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), new string[] { "id" }, new object[][] { new object[] { "E2" }, new object[] { "E4" }, new object[] { "E3" } });

            SendTimer(epService, 20001);
            Assert.IsNull(listener.LastNewData);
            Assert.AreEqual(1, listener.OldDataList.Count);
            Assert.AreEqual(1, listener.LastOldData.Length);
            Assert.AreEqual("E2", listener.LastOldData[0].Get("id"));
            listener.Reset();
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), new string[] { "id" }, new object[][] { new object[] { "E4" }, new object[] { "E3" } });

            SendTimer(epService, 22000);
            SendEvent(epService, "E5", "G2", 19000);
            Assert.AreEqual("E5", listener.AssertOneGetNewAndReset().Get("id"));
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), new string[] { "id" }, new object[][] { new object[] { "E5" }, new object[] { "E4" }, new object[] { "E3" } });

            SendTimer(epService, 29000);
            Assert.IsNull(listener.LastNewData);
            Assert.AreEqual(1, listener.OldDataList.Count);
            Assert.AreEqual(1, listener.LastOldData.Length);
            Assert.AreEqual("E5", listener.LastOldData[0].Get("id"));
            listener.Reset();
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), new string[] { "id" }, new object[][] { new object[] { "E4" }, new object[] { "E3" } });

            SendTimer(epService, 30000);
            Assert.IsNull(listener.LastNewData);
            Assert.AreEqual(1, listener.OldDataList.Count);
            Assert.AreEqual(2, listener.LastOldData.Length);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(listener.LastOldData, "id".Split(','), new object[][] { new object[] { "E4" }, new object[] { "E3" } });
            listener.Reset();
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), new string[] { "id" }, null);

            SendTimer(epService, 100000);
            Assert.IsFalse(listener.IsInvoked);

            epService.EPAdministrator.DestroyAllStatements();
        }
Ejemplo n.º 22
0
 public void Run(RegressionEnvironment env)
 {
     SetupStatement(env, "right");
     // Send S0 events, no events expected
     SendEvent(EVENTS_S0[0], env);
     SendEvent(EVENTS_S0[1], env);
     Assert.IsFalse(env.Listener("s0").IsInvoked);
     EPAssertionUtil.AssertPropsPerRowAnyOrder(env.GetEnumerator("s0"), FIELDS, null);
     // Send S1[2]
     SendEvent(EVENTS_S1[2], env);
     var theEvent = env.Listener("s0").AssertOneGetNewAndReset();
     CompareEvent(theEvent, null, null, 202, "2");
     EPAssertionUtil.AssertPropsPerRowAnyOrder(env.GetEnumerator("s0"), FIELDS, new[] {new object[] {null, null, 202, "2"}});
     // Send S0[2] events, joined event expected
     SendEvent(EVENTS_S0[2], env);
     theEvent = env.Listener("s0").AssertOneGetNewAndReset();
     CompareEvent(theEvent, 102, "2", 202, "2");
     EPAssertionUtil.AssertPropsPerRowAnyOrder(env.GetEnumerator("s0"), FIELDS, new[] {new object[] {102, "2", 202, "2"}});
     // Send S1[3]
     SendEvent(EVENTS_S1[3], env);
     theEvent = env.Listener("s0").AssertOneGetNewAndReset();
     CompareEvent(theEvent, null, null, 203, "3");
     EPAssertionUtil.AssertPropsPerRowAnyOrder(
         env.GetEnumerator("s0"),
         FIELDS,
         new[] {new object[] {102, "2", 202, "2"}, new object[] {null, null, 203, "3"}});
     // Send some more S0 events
     SendEvent(EVENTS_S0[3], env);
     theEvent = env.Listener("s0").AssertOneGetNewAndReset();
     CompareEvent(theEvent, 103, "3", 203, "3");
     EPAssertionUtil.AssertPropsPerRowAnyOrder(
         env.GetEnumerator("s0"),
         FIELDS,
         new[] {new object[] {102, "2", 202, "2"}, new object[] {103, "3", 203, "3"}});
     // Send some more S0 events
     SendEvent(EVENTS_S0[4], env);
     Assert.IsFalse(env.Listener("s0").IsInvoked);
     EPAssertionUtil.AssertPropsPerRowAnyOrder(
         env.GetEnumerator("s0"),
         FIELDS,
         new[] {new object[] {102, "2", 202, "2"}, new object[] {103, "3", 203, "3"}});
     // Push S0[2] out of the window
     SendEvent(EVENTS_S0[5], env);
     theEvent = env.Listener("s0").AssertOneGetOldAndReset();
     CompareEvent(theEvent, 102, "2", 202, "2");
     EPAssertionUtil.AssertPropsPerRowAnyOrder(
         env.GetEnumerator("s0"),
         FIELDS,
         new[] {new object[] {null, null, 202, "2"}, new object[] {103, "3", 203, "3"}});
     // Some more S1 events
     SendEvent(EVENTS_S1[6], env);
     CompareEvent(env.Listener("s0").AssertOneGetNewAndReset(), null, null, 206, "6");
     SendEvent(EVENTS_S1[7], env);
     CompareEvent(env.Listener("s0").AssertOneGetNewAndReset(), null, null, 207, "7");
     SendEvent(EVENTS_S1[8], env);
     CompareEvent(env.Listener("s0").AssertOneGetNewAndReset(), null, null, 208, "8");
     EPAssertionUtil.AssertPropsPerRowAnyOrder(
         env.GetEnumerator("s0"),
         FIELDS,
         new[] {
             new object[] {null, null, 202, "2"}, new object[] {103, "3", 203, "3"}, new object[] {null, null, 206, "6"},
             new object[] {null, null, 207, "7"}, new object[] {null, null, 208, "8"}
         });
     // Push S1[2] out of the window
     SendEvent(EVENTS_S1[9], env);
     var oldEvent = env.Listener("s0").LastOldData[0];
     var newEvent = env.Listener("s0").LastNewData[0];
     CompareEvent(oldEvent, null, null, 202, "2");
     CompareEvent(newEvent, null, null, 209, "9");
     EPAssertionUtil.AssertPropsPerRowAnyOrder(
         env.GetEnumerator("s0"),
         FIELDS,
         new[] {
             new object[] {103, "3", 203, "3"}, new object[] {null, null, 206, "6"}, new object[] {null, null, 207, "7"},
             new object[] {null, null, 208, "8"}, new object[] {null, null, 209, "9"}
         });
     env.UndeployAll();
 }
Ejemplo n.º 23
0
        private void RunAssertionDeleteCondition(EPServiceProvider epService, bool isNamedWindow)
        {
            // create infra
            string stmtTextCreate = isNamedWindow ?
                                    "create window MyInfra#keepall as select TheString as a, IntPrimitive as b from SupportBean" :
                                    "create table MyInfra (a string primary key, b int)";
            EPStatement stmtCreate    = epService.EPAdministrator.CreateEPL(stmtTextCreate);
            var         listenerInfra = new SupportUpdateListener();

            stmtCreate.Events += listenerInfra.Update;

            // create delete stmt
            string stmtTextDelete = "on SupportBean_A delete from MyInfra where 'X' || a || 'X' = id";

            epService.EPAdministrator.CreateEPL(stmtTextDelete);

            // create delete stmt
            stmtTextDelete = "on SupportBean_B delete from MyInfra where b < 5";
            epService.EPAdministrator.CreateEPL(stmtTextDelete);

            // create insert into
            string stmtTextInsertOne = "insert into MyInfra select TheString as a, IntPrimitive as b from SupportBean";

            epService.EPAdministrator.CreateEPL(stmtTextInsertOne);

            // send 3 event
            SendSupportBean(epService, "E1", 1);
            SendSupportBean(epService, "E2", 2);
            SendSupportBean(epService, "E3", 3);
            Assert.AreEqual(3, GetCount(epService, "MyInfra"));
            listenerInfra.Reset();
            var fields = new string[] { "a", "b" };

            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E1", 1 }, new object[] { "E2", 2 }, new object[] { "E3", 3 } });

            // delete E2
            SendSupportBean_A(epService, "XE2X");
            if (isNamedWindow)
            {
                Assert.AreEqual(1, listenerInfra.LastOldData.Length);
                EPAssertionUtil.AssertProps(listenerInfra.LastOldData[0], fields, new object[] { "E2", 2 });
            }
            listenerInfra.Reset();
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E1", 1 }, new object[] { "E3", 3 } });
            Assert.AreEqual(2, GetCount(epService, "MyInfra"));

            SendSupportBean(epService, "E7", 7);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E1", 1 }, new object[] { "E3", 3 }, new object[] { "E7", 7 } });
            Assert.AreEqual(3, GetCount(epService, "MyInfra"));

            // delete all under 5
            SendSupportBean_B(epService, "B1");
            if (isNamedWindow)
            {
                Assert.AreEqual(2, listenerInfra.LastOldData.Length);
                EPAssertionUtil.AssertProps(listenerInfra.LastOldData[0], fields, new object[] { "E1", 1 });
                EPAssertionUtil.AssertProps(listenerInfra.LastOldData[1], fields, new object[] { "E3", 3 });
            }
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E7", 7 } });
            Assert.AreEqual(1, GetCount(epService, "MyInfra"));

            epService.EPAdministrator.DestroyAllStatements();
            epService.EPAdministrator.Configuration.RemoveEventType("MyInfra", false);
        }
Ejemplo n.º 24
0
 public void Run(RegressionEnvironment env)
 {
     SetupStatement(env, "left");
     // Send S1 events, no events expected
     SendEvent(EVENTS_S1[0], env);
     SendEvent(EVENTS_S1[1], env);
     SendEvent(EVENTS_S1[3], env);
     Assert.IsNull(env.Listener("s0").LastNewData); // No events expected
     EPAssertionUtil.AssertPropsPerRowAnyOrder(env.GetEnumerator("s0"), FIELDS, null);
     // Send S0 event, expect event back from outer join
     SendEvent(EVENTS_S0[2], env);
     var theEvent = env.Listener("s0").AssertOneGetNewAndReset();
     CompareEvent(theEvent, 102, "2", null, null);
     EPAssertionUtil.AssertPropsPerRowAnyOrder(env.GetEnumerator("s0"), FIELDS, new[] {new object[] {102, "2", null, null}});
     // Send S1 event matching S0, expect event back
     SendEvent(EVENTS_S1[2], env);
     theEvent = env.Listener("s0").AssertOneGetNewAndReset();
     CompareEvent(theEvent, 102, "2", 202, "2");
     EPAssertionUtil.AssertPropsPerRowAnyOrder(env.GetEnumerator("s0"), FIELDS, new[] {new object[] {102, "2", 202, "2"}});
     // Send some more unmatched events
     SendEvent(EVENTS_S1[4], env);
     SendEvent(EVENTS_S1[5], env);
     SendEvent(EVENTS_S1[6], env);
     Assert.IsNull(env.Listener("s0").LastNewData); // No events expected
     EPAssertionUtil.AssertPropsPerRowAnyOrder(env.GetEnumerator("s0"), FIELDS, new[] {new object[] {102, "2", 202, "2"}});
     // Send event, expect a join result
     SendEvent(EVENTS_S0[5], env);
     theEvent = env.Listener("s0").AssertOneGetNewAndReset();
     CompareEvent(theEvent, 105, "5", 205, "5");
     EPAssertionUtil.AssertPropsPerRowAnyOrder(
         env.GetEnumerator("s0"),
         FIELDS,
         new[] {new object[] {102, "2", 202, "2"}, new object[] {105, "5", 205, "5"}});
     // Let S1[2] go out of the window (lenght 5), expected old join event
     SendEvent(EVENTS_S1[7], env);
     SendEvent(EVENTS_S1[8], env);
     theEvent = env.Listener("s0").AssertOneGetOldAndReset();
     CompareEvent(theEvent, 102, "2", 202, "2");
     EPAssertionUtil.AssertPropsPerRowAnyOrder(
         env.GetEnumerator("s0"),
         FIELDS,
         new[] {new object[] {102, "2", null, null}, new object[] {105, "5", 205, "5"}});
     // S0[9] should generate an outer join event
     SendEvent(EVENTS_S0[9], env);
     theEvent = env.Listener("s0").AssertOneGetNewAndReset();
     CompareEvent(theEvent, 109, "9", null, null);
     EPAssertionUtil.AssertPropsPerRowAnyOrder(
         env.GetEnumerator("s0"),
         FIELDS,
         new[] {new object[] {102, "2", null, null}, new object[] {109, "9", null, null}, new object[] {105, "5", 205, "5"}});
     // S0[2] Should leave the window (length 3), should get OLD and NEW event
     SendEvent(EVENTS_S0[10], env);
     var oldEvent = env.Listener("s0").LastOldData[0];
     var newEvent = env.Listener("s0").LastNewData[0];
     CompareEvent(oldEvent, 102, "2", null, null); // S1[2] has left the window already
     CompareEvent(newEvent, 110, "10", null, null);
     EPAssertionUtil.AssertPropsPerRowAnyOrder(
         env.GetEnumerator("s0"),
         FIELDS,
         new[] {new object[] {110, "10", null, null}, new object[] {109, "9", null, null}, new object[] {105, "5", 205, "5"}});
     env.UndeployAll();
 }
Ejemplo n.º 25
0
        public void TestBatchWindow()
        {
            String[] fields = new String[]
            {
                "TheString", "IntPrimitive"
            }
            ;
            String      statementText = "select distinct TheString, IntPrimitive from SupportBean.win:length_batch(3)";
            EPStatement stmt          = _epService.EPAdministrator.CreateEPL(
                statementText);

            stmt.Events += _listener.Update;

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields,
                                                      new Object[][] {
                new Object[] {
                    "E1", 1
                }
            }
                                                      );
            Assert.IsFalse(_listener.IsInvoked);

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

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

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

            stmt.Dispose();

            // test batch window with aggregation
            _epService.EPRuntime.SendEvent(new CurrentTimeEvent(0));
            String[] fieldsTwo = new String[] {
                "c1", "c2"
            }
            ;
            String      epl     = "insert into ABC select distinct TheString as c1, First(IntPrimitive) as c2 from SupportBean.win:time_batch(1 second)";
            EPStatement stmtTwo = _epService.EPAdministrator.CreateEPL(epl);

            stmtTwo.Events += _listener.Update;

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            _epService.EPRuntime.SendEvent(new SupportBean("E2", 2));

            _epService.EPRuntime.SendEvent(new CurrentTimeEvent(1000));
            EPAssertionUtil.AssertPropsPerRow(_listener.GetAndResetLastNewData(),
                                              fieldsTwo, new Object[][] {
                new Object[] {
                    "E1", 1
                }
                ,
                new Object[] {
                    "E2", 1
                }
            }
                                              );

            _epService.EPRuntime.SendEvent(new CurrentTimeEvent(2000));
            Assert.IsFalse(_listener.IsInvoked);
        }
Ejemplo n.º 26
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                SendCurrentTime(env, "2002-02-01T09:00:00.000");

                env.CompileDeploy(
                    "create context MyTermByTimeout partition by TheString from SupportBean terminated (*, *, *, *, *)",
                    path);
                env.CompileDeploy(
                    "@Name('s0') context MyTermByTimeout select TheString, count(*) as cnt from SupportBean output last when terminated",
                    path);
                env.AddListener("s0");

                env.SendEventBean(new SupportBean("A", 0));

                env.Milestone(0);

                SendCurrentTime(env, "2002-02-01T09:00:05.000");

                env.SendEventBean(new SupportBean("B", 0));

                env.Milestone(1);

                env.SendEventBean(new SupportBean("A", 0));

                SendCurrentTime(env, "2002-02-01T09:00:59.999");

                env.Milestone(2);

                env.SendEventBean(new SupportBean("B", 0));
                env.SendEventBean(new SupportBean("A", 0));
                Assert.IsFalse(env.Listener("s0").IsInvoked);

                SendCurrentTime(env, "2002-02-01T09:01:00.000");
                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    env.Listener("s0").GetAndResetLastNewData(),
                    new [] { "TheString","cnt" },
                    new[] {new object[] {"A", 3L}, new object[] {"B", 2L}});

                env.Milestone(3);

                env.SendEventBean(new SupportBean("C", 0));
                env.SendEventBean(new SupportBean("A", 0));
                SendCurrentTime(env, "2002-02-01T09:01:30.000");
                env.SendEventBean(new SupportBean("D", 0));

                env.Milestone(4);

                env.SendEventBean(new SupportBean("C", 0));

                SendCurrentTime(env, "2002-02-01T09:02:00.000");
                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    env.Listener("s0").GetAndResetLastNewData(),
                    new [] { "TheString","cnt" },
                    new[] {new object[] {"A", 1L}, new object[] {"C", 2L}, new object[] {"D", 1L}});

                SendCurrentTime(env, "2002-02-01T09:03:00.000");
                Assert.IsFalse(env.Listener("s0").IsInvoked);

                env.UndeployAll();
            }
Ejemplo n.º 27
0
        private void RunAssertionSnapshotColumn(EPStatement stmt, String[] fields)
        {
            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields,
                                                      new Object[][] {
                new Object[] {
                    "E1", 1
                }
            }
                                                      );
            Assert.IsFalse(_listener.IsInvoked);

            _epService.EPRuntime.SendEvent(new SupportBean("E2", 2));
            EPAssertionUtil.AssertPropsPerRow(_listener.LastNewData, fields,
                                              new Object[][] {
                new Object[] {
                    "E1", 1
                }
                ,
                new Object[] {
                    "E2", 2
                }
            }
                                              );
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields,
                                                      new Object[][] {
                new Object[] {
                    "E1", 1
                }
                ,
                new Object[] {
                    "E2", 2
                }
            }
                                                      );

            _epService.EPRuntime.SendEvent(new SupportBean("E2", 2));
            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            _epService.EPRuntime.SendEvent(new SupportBean("E2", 2));
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields,
                                                      new Object[][] {
                new Object[] {
                    "E1", 1
                }
                ,
                new Object[] {
                    "E2", 2
                }
            }
                                                      );
            EPAssertionUtil.AssertPropsPerRow(_listener.LastNewData, fields,
                                              new Object[][] {
                new Object[] {
                    "E1", 1
                }
                ,
                new Object[] {
                    "E2", 2
                }
            }
                                              );
            _listener.Reset();

            _epService.EPRuntime.SendEvent(new SupportBean("E3", 3));
            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            _epService.EPRuntime.SendEvent(new SupportBean("E2", 2));
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields,
                                                      new Object[][] {
                new Object[] {
                    "E1", 1
                }
                ,
                new Object[] {
                    "E2", 2
                }
                ,
                new Object[] {
                    "E3", 3
                }
            }
                                                      );
            EPAssertionUtil.AssertPropsPerRow(_listener.LastNewData, fields,
                                              new Object[][] {
                new Object[] {
                    "E1", 1
                }
                ,
                new Object[] {
                    "E2", 2
                }
                ,
                new Object[] {
                    "E3", 3
                }
            }
                                              );
            _listener.Reset();
        }
Ejemplo n.º 28
0
        private void AssertValuesIterate(string[] fields, object[][] objects)
        {
            var result = _epService.EPRuntime.ExecuteQuery("select * from MyTable");

            EPAssertionUtil.AssertPropsPerRowAnyOrder(result.Array, fields, objects);
        }
Ejemplo n.º 29
0
        private void RunAssertsFullJoin_2sides(EPStatement joinView)
        {
            // Test s0 outer join to 2 streams, 2 results for each (cartesian product)
            //
            Object[] s1Events = SupportBean_S1.MakeS1("A", new String[] { "A-s1-1", "A-s1-2" });
            SendEvent(s1Events);
            EPAssertionUtil.AssertSameAnyOrder(new Object[][] { new Object[] { null, s1Events[1], null } }, GetAndResetNewEvents());
            EPAssertionUtil.AssertPropsPerRowAnyOrder(joinView.GetEnumerator(), Fields,
                                                      new Object[][] { new Object[] { null, null, "A", "A-s1-1", null, null },
                                                                       new Object[] { null, null, "A", "A-s1-2", null, null } });

            Object[] s2Events = SupportBean_S2.MakeS2("A", new String[] { "A-s2-1", "A-s2-2" });
            SendEvent(s2Events);
            EPAssertionUtil.AssertSameAnyOrder(new Object[][] { new Object[] { null, null, s2Events[1] } }, GetAndResetNewEvents());
            EPAssertionUtil.AssertPropsPerRowAnyOrder(joinView.GetEnumerator(), Fields,
                                                      new Object[][] { new Object[] { null, null, "A", "A-s1-1", null, null },
                                                                       new Object[] { null, null, "A", "A-s1-2", null, null },
                                                                       new Object[] { null, null, null, null, "A", "A-s2-1" },
                                                                       new Object[] { null, null, null, null, "A", "A-s2-2" } });

            Object[] s0Events = SupportBean_S0.MakeS0("A", new String[] { "A-s0-1" });
            SendEvent(s0Events);
            Object[][] expected = new Object[][] {
                new Object[] { s0Events[0], s1Events[0], s2Events[0] },
                new Object[] { s0Events[0], s1Events[1], s2Events[0] },
                new Object[] { s0Events[0], s1Events[0], s2Events[1] },
                new Object[] { s0Events[0], s1Events[1], s2Events[1] },
            };
            EPAssertionUtil.AssertSameAnyOrder(expected, GetAndResetNewEvents());
            EPAssertionUtil.AssertPropsPerRowAnyOrder(joinView.GetEnumerator(), Fields,
                                                      new Object[][] { new Object[] { "A", "A-s0-1", "A", "A-s1-1", "A", "A-s2-1" },
                                                                       new Object[] { "A", "A-s0-1", "A", "A-s1-2", "A", "A-s2-1" },
                                                                       new Object[] { "A", "A-s0-1", "A", "A-s1-1", "A", "A-s2-2" },
                                                                       new Object[] { "A", "A-s0-1", "A", "A-s1-2", "A", "A-s2-2" } });

            // Test s0 outer join to s1 and s2, no results for each s1 and s2
            //
            s0Events = SupportBean_S0.MakeS0("B", new String[] { "B-s0-1" });
            SendEvent(s0Events);
            EPAssertionUtil.AssertSameAnyOrder(new Object[][] { new Object[] { s0Events[0], null, null } }, GetAndResetNewEvents());
            EPAssertionUtil.AssertPropsPerRowAnyOrder(joinView.GetEnumerator(), Fields,
                                                      new Object[][] { new Object[] { "A", "A-s0-1", "A", "A-s1-1", "A", "A-s2-1" },
                                                                       new Object[] { "A", "A-s0-1", "A", "A-s1-2", "A", "A-s2-1" },
                                                                       new Object[] { "A", "A-s0-1", "A", "A-s1-1", "A", "A-s2-2" },
                                                                       new Object[] { "A", "A-s0-1", "A", "A-s1-2", "A", "A-s2-2" },
                                                                       new Object[] { "B", "B-s0-1", null, null, null, null } });

            s0Events = SupportBean_S0.MakeS0("B", new String[] { "B-s0-2" });
            SendEvent(s0Events);
            EPAssertionUtil.AssertSameAnyOrder(new Object[][] { new Object[] { s0Events[0], null, null } }, GetAndResetNewEvents());
            EPAssertionUtil.AssertPropsPerRowAnyOrder(joinView.GetEnumerator(), Fields,
                                                      new Object[][] { new Object[] { "A", "A-s0-1", "A", "A-s1-1", "A", "A-s2-1" },
                                                                       new Object[] { "A", "A-s0-1", "A", "A-s1-2", "A", "A-s2-1" },
                                                                       new Object[] { "A", "A-s0-1", "A", "A-s1-1", "A", "A-s2-2" },
                                                                       new Object[] { "A", "A-s0-1", "A", "A-s1-2", "A", "A-s2-2" },
                                                                       new Object[] { "B", "B-s0-1", null, null, null, null },
                                                                       new Object[] { "B", "B-s0-2", null, null, null, null } });

            // Test s0 outer join to s1 and s2, one row for s1 and no results for s2
            //
            s1Events = SupportBean_S1.MakeS1("C", new String[] { "C-s1-1" });
            SendEventsAndReset(s1Events);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(joinView.GetEnumerator(), Fields,
                                                      new Object[][] { new Object[] { "A", "A-s0-1", "A", "A-s1-1", "A", "A-s2-1" },
                                                                       new Object[] { "A", "A-s0-1", "A", "A-s1-2", "A", "A-s2-1" },
                                                                       new Object[] { "A", "A-s0-1", "A", "A-s1-1", "A", "A-s2-2" },
                                                                       new Object[] { "A", "A-s0-1", "A", "A-s1-2", "A", "A-s2-2" },
                                                                       new Object[] { "B", "B-s0-1", null, null, null, null },
                                                                       new Object[] { "B", "B-s0-2", null, null, null, null },
                                                                       new Object[] { null, null, "C", "C-s1-1", null, null } });

            s0Events = SupportBean_S0.MakeS0("C", new String[] { "C-s0-1" });
            SendEvent(s0Events);
            EPAssertionUtil.AssertSameAnyOrder(new Object[][] { new Object[] { s0Events[0], s1Events[0], null } }, GetAndResetNewEvents());
            EPAssertionUtil.AssertPropsPerRowAnyOrder(joinView.GetEnumerator(), Fields,
                                                      new Object[][] { new Object[] { "A", "A-s0-1", "A", "A-s1-1", "A", "A-s2-1" },
                                                                       new Object[] { "A", "A-s0-1", "A", "A-s1-2", "A", "A-s2-1" },
                                                                       new Object[] { "A", "A-s0-1", "A", "A-s1-1", "A", "A-s2-2" },
                                                                       new Object[] { "A", "A-s0-1", "A", "A-s1-2", "A", "A-s2-2" },
                                                                       new Object[] { "B", "B-s0-1", null, null, null, null },
                                                                       new Object[] { "B", "B-s0-2", null, null, null, null },
                                                                       new Object[] { "C", "C-s0-1", "C", "C-s1-1", null, null } });

            // Test s0 outer join to s1 and s2, two rows for s1 and no results for s2
            //
            s1Events = SupportBean_S1.MakeS1("D", new String[] { "D-s1-1", "D-s1-2" });
            SendEventsAndReset(s1Events);

            s0Events = SupportBean_S0.MakeS0("D", new String[] { "D-s0-1" });
            SendEvent(s0Events);
            EPAssertionUtil.AssertSameAnyOrder(new Object[][] {
                new Object[] { s0Events[0], s1Events[0], null },
                new Object[] { s0Events[0], s1Events[1], null }
            }, GetAndResetNewEvents());

            // Test s0 outer join to s1 and s2, one row for s2 and no results for s1
            //
            s2Events = SupportBean_S2.MakeS2("E", new String[] { "E-s2-1" });
            SendEventsAndReset(s2Events);

            s0Events = SupportBean_S0.MakeS0("E", new String[] { "E-s0-1" });
            SendEvent(s0Events);
            EPAssertionUtil.AssertSameAnyOrder(new Object[][] { new Object[] { s0Events[0], null, s2Events[0] } }, GetAndResetNewEvents());

            // Test s0 outer join to s1 and s2, two rows for s2 and no results for s1
            //
            s2Events = SupportBean_S2.MakeS2("F", new String[] { "F-s2-1", "F-s2-2" });
            SendEventsAndReset(s2Events);

            s0Events = SupportBean_S0.MakeS0("F", new String[] { "F-s0-1" });
            SendEvent(s0Events);
            EPAssertionUtil.AssertSameAnyOrder(new Object[][] {
                new Object[] { s0Events[0], null, s2Events[0] },
                new Object[] { s0Events[0], null, s2Events[1] }
            }, GetAndResetNewEvents());

            // Test s0 outer join to s1 and s2, one row for s1 and two rows s2
            //
            s1Events = SupportBean_S1.MakeS1("G", new String[] { "G-s1-1" });
            SendEventsAndReset(s1Events);

            s2Events = SupportBean_S2.MakeS2("G", new String[] { "G-s2-1", "G-s2-2" });
            SendEventsAndReset(s2Events);

            s0Events = SupportBean_S0.MakeS0("G", new String[] { "G-s0-2" });
            SendEvent(s0Events);
            expected = new Object[][] {
                new Object[] { s0Events[0], s1Events[0], s2Events[0] },
                new Object[] { s0Events[0], s1Events[0], s2Events[1] },
            };
            EPAssertionUtil.AssertSameAnyOrder(expected, GetAndResetNewEvents());

            // Test s0 outer join to s1 and s2, one row for s2 and two rows s1
            //
            s1Events = SupportBean_S1.MakeS1("H", new String[] { "H-s1-1", "H-s1-2" });
            SendEventsAndReset(s1Events);

            s2Events = SupportBean_S2.MakeS2("H", new String[] { "H-s2-1" });
            SendEventsAndReset(s2Events);

            s0Events = SupportBean_S0.MakeS0("H", new String[] { "H-s0-2" });
            SendEvent(s0Events);
            expected = new Object[][] {
                new Object[] { s0Events[0], s1Events[0], s2Events[0] },
                new Object[] { s0Events[0], s1Events[1], s2Events[0] },
            };
            EPAssertionUtil.AssertSameAnyOrder(expected, GetAndResetNewEvents());

            // Test s0 outer join to s1 and s2, one row for each s1 and s2
            //
            s1Events = SupportBean_S1.MakeS1("I", new String[] { "I-s1-1" });
            SendEventsAndReset(s1Events);

            s2Events = SupportBean_S2.MakeS2("I", new String[] { "I-s2-1" });
            SendEventsAndReset(s2Events);

            s0Events = SupportBean_S0.MakeS0("I", new String[] { "I-s0-2" });
            SendEvent(s0Events);
            expected = new Object[][] {
                new Object[] { s0Events[0], s1Events[0], s2Events[0] },
            };
            EPAssertionUtil.AssertSameAnyOrder(expected, GetAndResetNewEvents());

            // Test s1 inner join to s0 and outer to s2:  s0 with 1 rows, s2 with 2 rows
            //
            s0Events = SupportBean_S0.MakeS0("Q", new String[] { "Q-s0-1" });
            SendEvent(s0Events);
            EPAssertionUtil.AssertSameAnyOrder(new Object[][] { new Object[] { s0Events[0], null, null } }, GetAndResetNewEvents());

            s2Events = SupportBean_S2.MakeS2("Q", new String[] { "Q-s2-1", "Q-s2-2" });
            SendEvent(s2Events[0]);
            EPAssertionUtil.AssertSameAnyOrder(new Object[][] { new Object[] { s0Events[0], null, s2Events[0] } }, GetAndResetNewEvents());
            SendEvent(s2Events[1]);
            EPAssertionUtil.AssertSameAnyOrder(new Object[][] { new Object[] { s0Events[0], null, s2Events[1] } }, GetAndResetNewEvents());

            s1Events = SupportBean_S1.MakeS1("Q", new String[] { "Q-s1-1" });
            SendEvent(s1Events);
            expected = new Object[][] {
                new Object[] { s0Events[0], s1Events[0], s2Events[0] },
                new Object[] { s0Events[0], s1Events[0], s2Events[1] },
            };
            EPAssertionUtil.AssertSameAnyOrder(expected, GetAndResetNewEvents());

            // Test s1 inner join to s0 and outer to s2:  s0 with 0 rows, s2 with 2 rows
            //
            s2Events = SupportBean_S2.MakeS2("R", new String[] { "R-s2-1", "R-s2-2" });
            SendEvent(s2Events);
            EPAssertionUtil.AssertSameAnyOrder(new Object[][] { new Object[] { null, null, s2Events[1] } }, GetAndResetNewEvents());

            s1Events = SupportBean_S1.MakeS1("R", new String[] { "R-s1-1" });
            SendEvent(s1Events);
            EPAssertionUtil.AssertSameAnyOrder(new Object[][] { new Object[] { null, s1Events[0], null } }, GetAndResetNewEvents());

            // Test s1 inner join to s0 and outer to s2:  s0 with 1 rows, s2 with 0 rows
            //
            s0Events = SupportBean_S0.MakeS0("S", new String[] { "S-s0-1" });
            SendEvent(s0Events);
            EPAssertionUtil.AssertSameAnyOrder(new Object[][] { new Object[] { s0Events[0], null, null } }, GetAndResetNewEvents());

            s1Events = SupportBean_S1.MakeS1("S", new String[] { "S-s1-1" });
            SendEvent(s1Events);
            EPAssertionUtil.AssertSameAnyOrder(new Object[][] { new Object[] { s0Events[0], s1Events[0], null } }, GetAndResetNewEvents());

            // Test s1 inner join to s0 and outer to s2:  s0 with 1 rows, s2 with 1 rows
            //
            s0Events = SupportBean_S0.MakeS0("T", new String[] { "T-s0-1" });
            SendEvent(s0Events);
            EPAssertionUtil.AssertSameAnyOrder(new Object[][] { new Object[] { s0Events[0], null, null } }, GetAndResetNewEvents());

            s2Events = SupportBean_S2.MakeS2("T", new String[] { "T-s2-1" });
            SendEventsAndReset(s2Events);

            s1Events = SupportBean_S1.MakeS1("T", new String[] { "T-s1-1" });
            SendEvent(s1Events);
            EPAssertionUtil.AssertSameAnyOrder(new Object[][] { new Object[] { s0Events[0], s1Events[0], s2Events[0] } }, GetAndResetNewEvents());

            // Test s1 inner join to s0 and outer to s2:  s0 with 2 rows, s2 with 0 rows
            //
            s0Events = SupportBean_S0.MakeS0("U", new String[] { "U-s0-1", "U-s0-1" });
            SendEventsAndReset(s0Events);

            s1Events = SupportBean_S1.MakeS1("U", new String[] { "U-s1-1" });
            SendEvent(s1Events);
            expected = new Object[][] {
                new Object[] { s0Events[0], s1Events[0], null },
                new Object[] { s0Events[1], s1Events[0], null },
            };
            EPAssertionUtil.AssertSameAnyOrder(expected, GetAndResetNewEvents());

            // Test s1 inner join to s0 and outer to s2:  s0 with 2 rows, s2 with 1 rows
            //
            s0Events = SupportBean_S0.MakeS0("V", new String[] { "V-s0-1", "V-s0-1" });
            SendEventsAndReset(s0Events);

            s2Events = SupportBean_S2.MakeS2("V", new String[] { "V-s2-1" });
            SendEventsAndReset(s2Events);

            s1Events = SupportBean_S1.MakeS1("V", new String[] { "V-s1-1" });
            SendEvent(s1Events);
            expected = new Object[][] {
                new Object[] { s0Events[0], s1Events[0], s2Events[0] },
                new Object[] { s0Events[1], s1Events[0], s2Events[0] },
            };
            EPAssertionUtil.AssertSameAnyOrder(expected, GetAndResetNewEvents());

            // Test s1 inner join to s0 and outer to s2:  s0 with 2 rows, s2 with 2 rows
            //
            s0Events = SupportBean_S0.MakeS0("W", new String[] { "W-s0-1", "W-s0-2" });
            SendEventsAndReset(s0Events);

            s2Events = SupportBean_S2.MakeS2("W", new String[] { "W-s2-1", "W-s2-2" });
            SendEventsAndReset(s2Events);

            s1Events = SupportBean_S1.MakeS1("W", new String[] { "W-s1-1" });
            SendEvent(s1Events);
            expected = new Object[][] {
                new Object[] { s0Events[0], s1Events[0], s2Events[0] },
                new Object[] { s0Events[1], s1Events[0], s2Events[0] },
                new Object[] { s0Events[0], s1Events[0], s2Events[1] },
                new Object[] { s0Events[1], s1Events[0], s2Events[1] },
            };
            EPAssertionUtil.AssertSameAnyOrder(expected, GetAndResetNewEvents());

            // Test s2 inner join to s0 and outer to s1:  s0 with 1 rows, s1 with 2 rows
            //
            s0Events = SupportBean_S0.MakeS0("J", new String[] { "J-s0-1" });
            SendEventsAndReset(s0Events);

            s1Events = SupportBean_S1.MakeS1("J", new String[] { "J-s1-1", "J-s1-2" });
            SendEventsAndReset(s1Events);

            s2Events = SupportBean_S2.MakeS2("J", new String[] { "J-s2-1" });
            SendEvent(s2Events);
            expected = new Object[][] {
                new Object[] { s0Events[0], s1Events[0], s2Events[0] },
                new Object[] { s0Events[0], s1Events[1], s2Events[0] },
            };
            EPAssertionUtil.AssertSameAnyOrder(expected, GetAndResetNewEvents());

            // Test s2 inner join to s0 and outer to s1:  s0 with 0 rows, s1 with 2 rows
            //
            s1Events = SupportBean_S1.MakeS1("K", new String[] { "K-s1-1", "K-s1-2" });
            SendEventsAndReset(s2Events);

            s2Events = SupportBean_S2.MakeS2("K", new String[] { "K-s2-1" });
            SendEventsAndReset(s2Events);

            // Test s2 inner join to s0 and outer to s1:  s0 with 1 rows, s1 with 0 rows
            //
            s0Events = SupportBean_S0.MakeS0("L", new String[] { "L-s0-1" });
            SendEventsAndReset(s0Events);

            s2Events = SupportBean_S2.MakeS2("L", new String[] { "L-s2-1" });
            SendEvent(s2Events);
            EPAssertionUtil.AssertSameAnyOrder(new Object[][] { new Object[] { s0Events[0], null, s2Events[0] } }, GetAndResetNewEvents());

            // Test s2 inner join to s0 and outer to s1:  s0 with 1 rows, s1 with 1 rows
            //
            s0Events = SupportBean_S0.MakeS0("M", new String[] { "M-s0-1" });
            SendEventsAndReset(s0Events);

            s1Events = SupportBean_S1.MakeS1("M", new String[] { "M-s1-1" });
            SendEventsAndReset(s1Events);

            s2Events = SupportBean_S2.MakeS2("M", new String[] { "M-s2-1" });
            SendEvent(s2Events);
            EPAssertionUtil.AssertSameAnyOrder(new Object[][] { new Object[] { s0Events[0], s1Events[0], s2Events[0] } }, GetAndResetNewEvents());

            // Test s2 inner join to s0 and outer to s1:  s0 with 2 rows, s1 with 0 rows
            //
            s0Events = SupportBean_S0.MakeS0("Count", new String[] { "Count-s0-1", "Count-s0-1" });
            SendEventsAndReset(s0Events);

            s2Events = SupportBean_S2.MakeS2("Count", new String[] { "Count-s2-1" });
            SendEvent(s2Events);
            expected = new Object[][] {
                new Object[] { s0Events[0], null, s2Events[0] },
                new Object[] { s0Events[1], null, s2Events[0] },
            };
            EPAssertionUtil.AssertSameAnyOrder(expected, GetAndResetNewEvents());

            // Test s2 inner join to s0 and outer to s1:  s0 with 2 rows, s1 with 1 rows
            //
            s0Events = SupportBean_S0.MakeS0("O", new String[] { "O-s0-1", "O-s0-1" });
            SendEventsAndReset(s0Events);

            s1Events = SupportBean_S1.MakeS1("O", new String[] { "O-s1-1" });
            SendEventsAndReset(s1Events);

            s2Events = SupportBean_S2.MakeS2("O", new String[] { "O-s2-1" });
            SendEvent(s2Events);
            expected = new Object[][] {
                new Object[] { s0Events[0], s1Events[0], s2Events[0] },
                new Object[] { s0Events[1], s1Events[0], s2Events[0] },
            };
            EPAssertionUtil.AssertSameAnyOrder(expected, GetAndResetNewEvents());

            // Test s2 inner join to s0 and outer to s1:  s0 with 2 rows, s1 with 2 rows
            //
            s0Events = SupportBean_S0.MakeS0("P", new String[] { "P-s0-1", "P-s0-2" });
            SendEventsAndReset(s0Events);

            s1Events = SupportBean_S1.MakeS1("P", new String[] { "P-s1-1", "P-s1-2" });
            SendEventsAndReset(s1Events);

            s2Events = SupportBean_S2.MakeS2("P", new String[] { "P-s2-1" });
            SendEvent(s2Events);
            expected = new Object[][] {
                new Object[] { s0Events[0], s1Events[0], s2Events[0] },
                new Object[] { s0Events[1], s1Events[0], s2Events[0] },
                new Object[] { s0Events[0], s1Events[1], s2Events[0] },
                new Object[] { s0Events[1], s1Events[1], s2Events[0] },
            };
            EPAssertionUtil.AssertSameAnyOrder(expected, GetAndResetNewEvents());
        }
        private void RunAssertion_A_Bstar(bool allMatches)
        {
            EPServiceProviderIsolated isolated = _epService.GetEPServiceIsolated("I1");

            SendTimer(isolated, 0);

            String[] fields = "a,b0,b1,b2".Split(',');
            String   text   = "select * from MyEvent.win:keepall() " +
                              "match_recognize (" +
                              " measures A.TheString as a, B[0].TheString as b0, B[1].TheString as b1, B[2].TheString as b2" +
                              (allMatches ? " all matches" : "") +
                              " pattern (A B*)" +
                              " interval 10 seconds or terminated" +
                              " define" +
                              " A as A.TheString like \"A%\"," +
                              " B as B.TheString like \"B%\"" +
                              ")";

            EPStatement stmt = isolated.EPAdministrator.CreateEPL(text, "stmt1", null);

            stmt.Events += _listener.Update;

            // test output by terminated because of misfit event
            isolated.EPRuntime.SendEvent(new SupportRecogBean("A1"));
            isolated.EPRuntime.SendEvent(new SupportRecogBean("B1"));
            Assert.IsFalse(_listener.IsInvoked);
            isolated.EPRuntime.SendEvent(new SupportRecogBean("X1"));
            if (!allMatches)
            {
                EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { "A1", "B1", null, null });
            }
            else
            {
                EPAssertionUtil.AssertPropsPerRowAnyOrder(_listener.GetAndResetLastNewData(), fields,
                                                          new Object[][] { new Object[] { "A1", "B1", null, null }, new Object[] { "A1", null, null, null } });
            }

            SendTimer(isolated, 20000);
            Assert.IsFalse(_listener.IsInvoked);

            // test output by timer expiry
            isolated.EPRuntime.SendEvent(new SupportRecogBean("A2"));
            isolated.EPRuntime.SendEvent(new SupportRecogBean("B2"));
            Assert.IsFalse(_listener.IsInvoked);
            SendTimer(isolated, 29999);

            SendTimer(isolated, 30000);
            if (!allMatches)
            {
                EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { "A2", "B2", null, null });
            }
            else
            {
                EPAssertionUtil.AssertPropsPerRowAnyOrder(_listener.GetAndResetLastNewData(), fields,
                                                          new Object[][] { new Object[] { "A2", "B2", null, null }, new Object[] { "A2", null, null, null } });
            }

            // destroy
            stmt.Dispose();
            isolated.Dispose();

            EPStatement stmtFromModel = SupportModelHelper.CompileCreate(_epService, text);

            stmtFromModel.Dispose();
        }