Example #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();
            }
Example #2
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                var stmtCreateTextOne = "@Name('create-one') create variable long var1SAI = null";
                env.CompileDeploy(stmtCreateTextOne, path);
                Assert.AreEqual(
                    StatementType.CREATE_VARIABLE,
                    env.Statement("create-one").GetProperty(StatementProperty.STATEMENTTYPE));
                Assert.AreEqual(
                    "var1SAI", env.Statement("create-one").GetProperty(StatementProperty.CREATEOBJECTNAME));

                env.AddListener("create-one");

                string[] fieldsVar1 = {"var1SAI"};
                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("create-one"),
                    fieldsVar1,
                    new[] {new object[] {null}});
                Assert.IsFalse(env.Listener("create-one").IsInvoked);

                var typeCreateOne = env.Statement("create-one").EventType;
                Assert.AreEqual(typeof(long?), typeCreateOne.GetPropertyType("var1SAI"));
                Assert.AreEqual(typeof(IDictionary<string, object>), typeCreateOne.UnderlyingType);
                CollectionAssert.AreEquivalent(new[] {"var1SAI"}, typeCreateOne.PropertyNames);

                var stmtCreateTextTwo = "@Name('create-two') create variable long var2SAI = 20";
                env.CompileDeploy(stmtCreateTextTwo, path).AddListener("create-two");
                string[] fieldsVar2 = {"var2SAI"};
                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("create-two"),
                    fieldsVar2,
                    new[] {new object[] {20L}});
                Assert.IsFalse(env.Listener("create-two").IsInvoked);

                var stmtTextSet = "@Name('set') on SupportBean set var1SAI = IntPrimitive * 2, var2SAI = var1SAI + 1";
                env.CompileDeploy(stmtTextSet, path);

                SendSupportBean(env, "E1", 100);
                EPAssertionUtil.AssertProps(
                    env.Listener("create-one").LastNewData[0],
                    fieldsVar1,
                    new object[] {200L});
                EPAssertionUtil.AssertProps(
                    env.Listener("create-one").LastOldData[0],
                    fieldsVar1,
                    new object[] {null});
                env.Listener("create-one").Reset();
                EPAssertionUtil.AssertProps(
                    env.Listener("create-two").LastNewData[0],
                    fieldsVar2,
                    new object[] {201L});
                EPAssertionUtil.AssertProps(
                    env.Listener("create-two").LastOldData[0],
                    fieldsVar2,
                    new object[] {20L});
                env.Listener("create-one").Reset();
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("create-one").GetEnumerator(),
                    fieldsVar1,
                    new[] {new object[] {200L}});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("create-two").GetEnumerator(),
                    fieldsVar2,
                    new[] {new object[] {201L}});

                env.Milestone(0);

                SendSupportBean(env, "E2", 200);
                EPAssertionUtil.AssertProps(
                    env.Listener("create-one").LastNewData[0],
                    fieldsVar1,
                    new object[] {400L});
                EPAssertionUtil.AssertProps(
                    env.Listener("create-one").LastOldData[0],
                    fieldsVar1,
                    new object[] {200L});
                env.Listener("create-one").Reset();
                EPAssertionUtil.AssertProps(
                    env.Listener("create-two").LastNewData[0],
                    fieldsVar2,
                    new object[] {401L});
                EPAssertionUtil.AssertProps(
                    env.Listener("create-two").LastOldData[0],
                    fieldsVar2,
                    new object[] {201L});
                env.Listener("create-one").Reset();
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("create-one").GetEnumerator(),
                    fieldsVar1,
                    new[] {new object[] {400L}});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("create-two").GetEnumerator(),
                    fieldsVar2,
                    new[] {new object[] {401L}});

                env.UndeployModuleContaining("set");
                env.UndeployModuleContaining("create-two");
                env.CompileDeploy(stmtCreateTextTwo);

                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("create-one").GetEnumerator(),
                    fieldsVar1,
                    new[] {new object[] {400L}});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("create-two").GetEnumerator(),
                    fieldsVar2,
                    new[] {new object[] {20L}});
                env.UndeployAll();
            }
Example #3
0
            public void Run(RegressionEnvironment env)
            {
                // create window
                var stmtTextCreate = namedWindow
                    ? "@Name('CreateInfra') create window MyInfra#keepall as select TheString as a, IntPrimitive as b from SupportBean"
                    : "@Name('CreateInfra') create table MyInfra (a string primary key, b int)";
                var path = new RegressionPath();
                env.CompileDeploy(stmtTextCreate, path).AddListener("CreateInfra");

                // create delete stmt
                var stmtTextDelete = "@Name('OnDelete') on SupportBean_A delete from MyInfra";
                env.CompileDeploy(stmtTextDelete, path).AddListener("OnDelete");
                EPAssertionUtil.AssertEqualsAnyOrder(
                    env.Statement("OnDelete").EventType.PropertyNames,
                    new[] {"a", "b"});

                // create insert into
                var stmtTextInsertOne =
                    "@Name('Insert') insert into MyInfra select TheString as a, IntPrimitive as b from SupportBean";
                env.CompileDeploy(stmtTextInsertOne, path);

                // create consumer
                string[] fields = {"a", "b"};
                var stmtTextSelect = "@Name('Select') select irstream MyInfra.a as a, b from MyInfra as S1";
                env.CompileDeploy(stmtTextSelect, path).AddListener("Select");

                // Delete all events, no result expected
                SendSupportBean_A(env, "A1");
                Assert.IsFalse(env.Listener("CreateInfra").IsInvoked);
                Assert.IsFalse(env.Listener("Select").IsInvoked);
                Assert.IsFalse(env.Listener("OnDelete").IsInvoked);
                Assert.AreEqual(0, GetCount(env, path, "MyInfra"));

                // send 1 event
                SendSupportBean(env, "E1", 1);
                if (namedWindow) {
                    EPAssertionUtil.AssertProps(
                        env.Listener("CreateInfra").AssertOneGetNewAndReset(),
                        fields,
                        new object[] {"E1", 1});
                    EPAssertionUtil.AssertProps(
                        env.Listener("Select").AssertOneGetNewAndReset(),
                        fields,
                        new object[] {"E1", 1});
                }
                else {
                    Assert.IsFalse(env.Listener("CreateInfra").IsInvoked);
                    Assert.IsFalse(env.Listener("Select").IsInvoked);
                }

                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("CreateInfra"),
                    fields,
                    new[] {new object[] {"E1", 1}});
                EPAssertionUtil.AssertPropsPerRow(env.GetEnumerator("OnDelete"), fields, null);
                Assert.AreEqual(1, GetCount(env, path, "MyInfra"));

                env.Milestone(0);

                // Delete all events, 1 row expected
                SendSupportBean_A(env, "A2");
                if (namedWindow) {
                    EPAssertionUtil.AssertProps(
                        env.Listener("CreateInfra").AssertOneGetOldAndReset(),
                        fields,
                        new object[] {"E1", 1});
                    EPAssertionUtil.AssertProps(
                        env.Listener("Select").AssertOneGetOldAndReset(),
                        fields,
                        new object[] {"E1", 1});
                    EPAssertionUtil.AssertPropsPerRow(env.GetEnumerator("OnDelete"), fields, new object[0][]);
                }

                EPAssertionUtil.AssertPropsPerRow(env.GetEnumerator("CreateInfra"), fields, null);
                EPAssertionUtil.AssertProps(
                    env.Listener("OnDelete").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E1", 1});
                Assert.AreEqual(0, GetCount(env, path, "MyInfra"));

                // send 2 events
                SendSupportBean(env, "E2", 2);
                SendSupportBean(env, "E3", 3);
                env.Listener("CreateInfra").Reset();
                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("CreateInfra"),
                    fields,
                    new[] {new object[] {"E2", 2}, new object[] {"E3", 3}});
                Assert.IsFalse(env.Listener("OnDelete").IsInvoked);
                Assert.AreEqual(2, GetCount(env, path, "MyInfra"));

                env.Milestone(1);

                // Delete all events, 2 rows expected
                SendSupportBean_A(env, "A2");
                if (namedWindow) {
                    EPAssertionUtil.AssertProps(
                        env.Listener("CreateInfra").LastOldData[0],
                        fields,
                        new object[] {"E2", 2});
                    EPAssertionUtil.AssertProps(
                        env.Listener("CreateInfra").LastOldData[1],
                        fields,
                        new object[] {"E3", 3});
                    EPAssertionUtil.AssertPropsPerRow(env.GetEnumerator("OnDelete"), fields, new object[0][]);
                }

                EPAssertionUtil.AssertPropsPerRow(env.GetEnumerator("CreateInfra"), fields, null);
                Assert.AreEqual(2, env.Listener("OnDelete").LastNewData.Length);
                EPAssertionUtil.AssertProps(
                    env.Listener("OnDelete").LastNewData[0],
                    fields,
                    new object[] {"E2", 2});
                EPAssertionUtil.AssertProps(
                    env.Listener("OnDelete").LastNewData[1],
                    fields,
                    new object[] {"E3", 3});
                Assert.AreEqual(0, GetCount(env, path, "MyInfra"));

                env.UndeployAll();
            }
        private static void RunAssertion(
            RegressionEnvironment env,
            String eventTypeName,
            RegressionPath path)
        {
            env.CompileDeploy("@Name('s0') insert into MyNestedStream select nested1 from " + eventTypeName + "#lastevent", path);

            CollectionAssert.AreEquivalent(
                new[] {
                    new EventPropertyDescriptor("nested1", typeof(XmlNode), null, false, false, false, false, true)
                },
                env.Statement("s0").EventType.PropertyDescriptors);
            SupportEventTypeAssertionUtil.AssertConsistency(env.Statement("s0").EventType);

            env.CompileDeploy(
                "@Name('s1') select nested1.attr1 as attr1, nested1.prop1 as prop1, nested1.prop2 as prop2, nested1.nested2.prop3 as prop3, nested1.nested2.prop3[0] as prop3_0, nested1.nested2 as nested2 from MyNestedStream#lastevent",
                path);
            CollectionAssert.AreEquivalent(
                new EventPropertyDescriptor[] {
                    new EventPropertyDescriptor("prop1", typeof(string), typeof(char), false, false, true, false, false),
                    new EventPropertyDescriptor("prop2", typeof(bool?), null, false, false, false, false, false),
                    new EventPropertyDescriptor("attr1", typeof(string), typeof(char), false, false, true, false, false),
                    new EventPropertyDescriptor(
                        "prop3",
                        typeof(int?[]),
                        typeof(int?),
                        false,
                        false,
                        true,
                        false,
                        false),
                    new EventPropertyDescriptor("prop3_0", typeof(int?), null, false, false, false, false, false),
                    new EventPropertyDescriptor("nested2", typeof(XmlNode), null, false, false, false, false, true)
                },
                env.Statement("s1").EventType.PropertyDescriptors);
            SupportEventTypeAssertionUtil.AssertConsistency(env.Statement("s1").EventType);

            env.CompileDeploy("@Name('sw') select * from MyNestedStream", path);
            CollectionAssert.AreEquivalent(
                new EventPropertyDescriptor[] {
                    new EventPropertyDescriptor("nested1", typeof(XmlNode), null, false, false, false, false, true)
                },
                env.Statement("sw").EventType.PropertyDescriptors);
            SupportEventTypeAssertionUtil.AssertConsistency(env.Statement("sw").EventType);

            env.CompileDeploy(
                "@Name('iw') insert into MyNestedStreamTwo select nested1.* from " + eventTypeName + "#lastevent",
                path);
            CollectionAssert.AreEquivalent(
                new EventPropertyDescriptor[] {
                    new EventPropertyDescriptor("prop1", typeof(string), typeof(char), false, false, true, false, false),
                    new EventPropertyDescriptor("prop2", typeof(bool?), null, false, false, false, false, false),
                    new EventPropertyDescriptor("attr1", typeof(string), typeof(char), false, false, true, false, false),
                    new EventPropertyDescriptor("nested2", typeof(XmlNode), null, false, false, false, false, true)
                },
                env.Statement("iw").EventType.PropertyDescriptors);
            SupportEventTypeAssertionUtil.AssertConsistency(env.Statement("iw").EventType);

            SupportXML.SendDefaultEvent(env.EventService, "test", eventTypeName);
            var stmtInsertWildcardBean = env.GetEnumerator("iw").Advance();
            EPAssertionUtil.AssertProps(
                stmtInsertWildcardBean,
                new[] {"prop1", "prop2", "attr1"},
                new object[] {"SAMPLE_V1", true, "SAMPLE_ATTR1"});

            SupportEventTypeAssertionUtil.AssertConsistency(env.GetEnumerator("s0").Advance());
            var stmtInsertBean = env.GetEnumerator("s0").Advance();
            SupportEventTypeAssertionUtil.AssertConsistency(env.GetEnumerator("iw").Advance());
            SupportEventTypeAssertionUtil.AssertConsistency(env.GetEnumerator("sw").Advance());

            var fragmentNested1 = (EventBean) stmtInsertBean.GetFragment("nested1");
            Assert.AreEqual(5, fragmentNested1.Get("nested2.prop3[2]"));
            Assert.AreEqual(eventTypeName + ".nested1", fragmentNested1.EventType.Name);

            var fragmentNested2 = (EventBean) stmtInsertWildcardBean.GetFragment("nested2");
            Assert.AreEqual(4, fragmentNested2.Get("prop3[1]"));
            Assert.AreEqual(eventTypeName + ".nested1.nested2", fragmentNested2.EventType.Name);

            env.UndeployAll();
        }
Example #5
0
            public void Run(RegressionEnvironment env)
            {
                var fields = new[] {"TheString", "IntPrimitive", "LongPrimitive"};
                var epl = "@Name('s0') select irstream * from SupportBean.ext:rank(TheString, 3, IntPrimitive)";
                env.CompileDeployAddListenerMileZero(epl, "s0");

                EPAssertionUtil.AssertPropsPerRow(env.GetEnumerator("s0"), fields, null);

                SendSupportBean(env, "A", 10, 100L);
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"A", 10, 100L});

                env.Milestone(1);

                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"A", 10, 100L}});
                SendSupportBean(env, "B", 20, 101L);
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"B", 20, 101L});

                env.Milestone(2);

                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"A", 10, 100L}, new object[] {"B", 20, 101L}});
                SendSupportBean(env, "A", 8, 102L); // replace A
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertGetAndResetIRPair(),
                    fields,
                    new object[] {"A", 8, 102L},
                    new object[] {"A", 10, 100L});

                env.Milestone(3);

                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"A", 8, 102L}, new object[] {"B", 20, 101L}});
                SendSupportBean(env, "C", 15, 103L);
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"C", 15, 103L});

                env.Milestone(4);

                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"A", 8, 102L}, new object[] {"C", 15, 103L}, new object[] {"B", 20, 101L}});
                SendSupportBean(env, "D", 21, 104L);
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertGetAndResetIRPair(),
                    fields,
                    new object[] {"D", 21, 104L},
                    new object[] {"D", 21, 104L});

                env.Milestone(5);

                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"A", 8, 102L}, new object[] {"C", 15, 103L}, new object[] {"B", 20, 101L}});
                SendSupportBean(env, "A", 16, 105L);
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertGetAndResetIRPair(),
                    fields,
                    new object[] {"A", 16, 105L},
                    new object[] {"A", 8, 102L});

                env.Milestone(6);

                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"C", 15, 103L}, new object[] {"A", 16, 105L}, new object[] {"B", 20, 101L}});
                SendSupportBean(env, "C", 16, 106L);
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertGetAndResetIRPair(),
                    fields,
                    new object[] {"C", 16, 106L},
                    new object[] {"C", 15, 103L});

                env.Milestone(7);

                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"A", 16, 105L}, new object[] {"C", 16, 106L}, new object[] {"B", 20, 101L}});
                SendSupportBean(env, "C", 16, 107L);
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertGetAndResetIRPair(),
                    fields,
                    new object[] {"C", 16, 107L},
                    new object[] {"C", 16, 106L});
                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"A", 16, 105L}, new object[] {"C", 16, 107L}, new object[] {"B", 20, 101L}});
                SendSupportBean(env, "E", 1, 108L);
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertGetAndResetIRPair(),
                    fields,
                    new object[] {"E", 1, 108L},
                    new object[] {"B", 20, 101L});
                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"E", 1, 108L}, new object[] {"A", 16, 105L}, new object[] {"C", 16, 107L}});

                env.UndeployAll();
            }
Example #6
0
            public void Run(RegressionEnvironment env)
            {
                // create infra
                var stmtTextCreate = namedWindow
                    ? "@Name('CreateInfra') create window MyInfra#keepall as select TheString as a, IntPrimitive as b from SupportBean"
                    : "@Name('CreateInfra') create table MyInfra(a string primary key, b int)";
                var path = new RegressionPath();
                env.CompileDeploy(stmtTextCreate, path).AddListener("CreateInfra");

                // create delete stmt
                var stmtTextDelete =
                    "@Name('OnDelete') on pattern [every ea=SupportBean_A or every eb=SupportBean_B] delete from MyInfra";
                env.CompileDeploy(stmtTextDelete, path).AddListener("OnDelete");

                // create insert into
                var stmtTextInsertOne = "insert into MyInfra select TheString as a, IntPrimitive as b from SupportBean";
                env.CompileDeploy(stmtTextInsertOne, path);

                // send 1 event
                string[] fields = {"a", "b"};
                SendSupportBean(env, "E1", 1);
                if (namedWindow) {
                    EPAssertionUtil.AssertProps(
                        env.Listener("CreateInfra").AssertOneGetNewAndReset(),
                        fields,
                        new object[] {"E1", 1});
                    EPAssertionUtil.AssertPropsPerRow(env.GetEnumerator("OnDelete"), fields, null);
                }

                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("CreateInfra"),
                    fields,
                    new[] {new object[] {"E1", 1}});
                Assert.AreEqual(1, GetCount(env, path, "MyInfra"));

                // Delete all events using A, 1 row expected
                SendSupportBean_A(env, "A1");
                if (namedWindow) {
                    EPAssertionUtil.AssertProps(
                        env.Listener("CreateInfra").AssertOneGetOldAndReset(),
                        fields,
                        new object[] {"E1", 1});
                }

                EPAssertionUtil.AssertPropsPerRow(env.GetEnumerator("CreateInfra"), fields, null);
                EPAssertionUtil.AssertProps(
                    env.Listener("OnDelete").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E1", 1});
                Assert.AreEqual(0, GetCount(env, path, "MyInfra"));

                env.Milestone(0);

                // send 1 event
                SendSupportBean(env, "E2", 2);
                if (namedWindow) {
                    EPAssertionUtil.AssertProps(
                        env.Listener("CreateInfra").AssertOneGetNewAndReset(),
                        fields,
                        new object[] {"E2", 2});
                }

                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("CreateInfra"),
                    fields,
                    new[] {new object[] {"E2", 2}});
                Assert.AreEqual(1, GetCount(env, path, "MyInfra"));

                // Delete all events using B, 1 row expected
                SendSupportBean_B(env, "B1");
                if (namedWindow) {
                    EPAssertionUtil.AssertProps(
                        env.Listener("CreateInfra").AssertOneGetOldAndReset(),
                        fields,
                        new object[] {"E2", 2});
                }

                EPAssertionUtil.AssertPropsPerRow(env.GetEnumerator("CreateInfra"), fields, null);
                EPAssertionUtil.AssertProps(
                    env.Listener("OnDelete").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E2", 2});
                Assert.AreEqual(0, GetCount(env, path, "MyInfra"));

                env.UndeployAll();
            }
Example #7
0
            public void Run(RegressionEnvironment env)
            {
                var text =
                    "@Name('s0') select irstream Symbol, Feed, Price from  SupportMarketDataBean#unique(Symbol, Feed) order by Symbol, Feed";
                if (optionalAnnotation != null) {
                    text = optionalAnnotation + text;
                }

                env.CompileDeployAddListenerMileZero(text, "s0");

                env.SendEventBean(MakeMarketDataEvent("S1", "F1", 100));
                env.Listener("s0")
                    .AssertNewOldData(
                        new[] {
                            new object[] {"Symbol", "S1"},
                            new object[] {"Feed", "F1"},
                            new object[] {"Price", 100.0}
                        },
                        null);

                env.Milestone(1);

                env.SendEventBean(MakeMarketDataEvent("S2", "F1", 5));
                env.Listener("s0")
                    .AssertNewOldData(
                        new[] {
                            new object[] {"Symbol", "S2"},
                            new object[] {"Feed", "F1"},
                            new object[] {"Price", 5.0}
                        },
                        null);

                env.Milestone(2);

                env.SendEventBean(MakeMarketDataEvent("S1", "F1", 101));
                env.Listener("s0")
                    .AssertNewOldData(
                        new[] {
                            new object[] {"Symbol", "S1"},
                            new object[] {"Feed", "F1"},
                            new object[] {"Price", 101.0}
                        },
                        new[] {
                            new object[] {"Symbol", "S1"}, new object[] {"Feed", "F1"}, new object[] {"Price", 100.0}
                        });

                env.Milestone(3);

                env.SendEventBean(MakeMarketDataEvent("S2", "F1", 102));
                env.Listener("s0")
                    .AssertNewOldData(
                        new[] {
                            new object[] {"Symbol", "S2"},
                            new object[] {"Feed", "F1"},
                            new object[] {"Price", 102.0}
                        },
                        new[] {
                            new object[] {"Symbol", "S2"}, new object[] {"Feed", "F1"}, new object[] {"Price", 5.0}
                        });

                // test iterator
                var events = EPAssertionUtil.EnumeratorToArray(env.GetEnumerator("s0"));
                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    events,
                    new[] {"Price"},
                    new[] {new object[] {101.0}, new object[] {102.0}});

                env.Milestone(4);

                env.SendEventBean(MakeMarketDataEvent("S1", "F2", 6));
                env.Listener("s0")
                    .AssertNewOldData(
                        new[] {
                            new object[] {"Symbol", "S1"},
                            new object[] {"Feed", "F2"},
                            new object[] {"Price", 6.0}
                        },
                        null);

                // test iterator
                events = EPAssertionUtil.EnumeratorToArray(env.GetEnumerator("s0"));
                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    events,
                    new[] {"Price"},
                    new[] {new object[] {101.0}, new object[] {6.0}, new object[] {102.0}});

                env.UndeployAll();
            }
Example #8
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();
 }
Example #9
0
            public void Run(RegressionEnvironment env)
            {
                var fields = new[] {"TheString"};

                env.Milestone(0);

                var epl = "@Name('s0') select irstream * from SupportBean#length(2)";
                env.CompileDeployAddListenerMile(epl, "s0", 1);

                EPAssertionUtil.AssertPropsPerRow(env.GetEnumerator("s0"), fields, null);

                SendSupportBean(env, "E1");
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E1"});

                env.Milestone(2);
                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"E1"}});

                SendSupportBean(env, "E2");
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E2"});

                env.Milestone(3);
                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"E1"}, new object[] {"E2"}});

                SendSupportBean(env, "E3");
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertGetAndResetIRPair(),
                    fields,
                    new object[] {"E3"},
                    new object[] {"E1"});

                env.Milestone(4);
                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"E2"}, new object[] {"E3"}});

                env.Milestone(5);
                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"E2"}, new object[] {"E3"}});

                SendSupportBean(env, "E4");
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertGetAndResetIRPair(),
                    fields,
                    new object[] {"E4"},
                    new object[] {"E2"});
                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"E3"}, new object[] {"E4"}});

                env.UndeployAll();
            }
Example #10
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeploy(
                    "@Name('create') create table MyTableEUIV as (pKey0 string primary key, pkey1 int primary key, thecnt count(*))",
                    path);
                env.CompileDeploy(
                    "into table MyTableEUIV select count(*) as thecnt from SupportBean group by TheString, IntPrimitive",
                    path);
                env.SendEventBean(new SupportBean("E1", 10));
                env.SendEventBean(new SupportBean("E1", 20));

                // invalid index being created
                try {
                    var compiled = env.Compile("create unique index SecIndex on MyTableEUIV(pKey0)", path);
                    env.Runtime.DeploymentService.Deploy(compiled);
                    Assert.Fail();
                }
                catch (EPDeployException ex) {
                    SupportMessageAssertUtil.AssertMessage(
                        ex.Message,
                        "Failed to deploy: Unique index violation, index 'SecIndex' is a unique index and key 'E1' already exists");
                }

                // try fire-and-forget update of primary key to non-unique value
                try {
                    env.CompileExecuteFAF("update MyTableEUIV set pkey1 = 0", path);
                    Assert.Fail();
                }
                catch (EPException ex) {
                    SupportMessageAssertUtil.AssertMessage(
                        ex,
                        "Unique index violation, index 'MyTableEUIV' is a unique index and key 'MultiKey<E1,0>' already exists");
                    // assert events are unchanged - no update actually performed
                    EPAssertionUtil.AssertPropsPerRowAnyOrder(
                        env.GetEnumerator("create"),
                        new[] {"pKey0", "pkey1"},
                        new[] {new object[] {"E1", 10}, new object[] {"E1", 20}});
                }

                // try on-update unique index violation
                env.CompileDeploy("@Name('on-update') on SupportBean_S1 update MyTableEUIV set pkey1 = 0", path);
                try {
                    env.SendEventBean(new SupportBean_S1(0));
                    Assert.Fail();
                }
                catch (EPException ex) {
                    SupportMessageAssertUtil.AssertMessage(
                        ex,
                        "Unexpected exception in statement 'on-update': Unique index violation, index 'MyTableEUIV' is a unique index and key 'MultiKey<E1,0>' already exists");
                    // assert events are unchanged - no update actually performed
                    EPAssertionUtil.AssertPropsPerRowAnyOrder(
                        env.Statement("create").GetEnumerator(),
                        new[] {"pKey0", "pkey1"},
                        new[] {new object[] {"E1", 10}, new object[] {"E1", 20}});
                }

                // disallow on-merge unique key updates
                try {
                    env.CompileWCheckedEx(
                        "@Name('on-merge') on SupportBean_S1 merge MyTableEUIV when matched then update set pkey1 = 0",
                        path);
                    Assert.Fail();
                }
                catch (EPCompileException ex) {
                    SupportMessageAssertUtil.AssertMessage(
                        ex.InnerException,
                        "Validation failed in when-matched (clause 1): On-merge statements may not update unique keys of tables");
                }

                env.UndeployAll();
            }
Example #11
0
            public void Run(RegressionEnvironment env)
            {
                var text = "@Name('s0') select irstream Symbol, " +
                           "prev(1, Symbol) as prev1, " +
                           "prior(1, Symbol) as prio1, " +
                           "prevtail(Symbol) as prevtail0, " +
                           "prevcount(Symbol) as prevCountSym, " +
                           "prevwindow(Symbol) as prevWindowSym " +
                           "from SupportMarketDataBean.win:length(2)";
                env.CompileDeployAddListenerMileZero(text, "s0");
                string[] fields = {"Symbol", "prev1", "prio1", "prevtail0", "prevCountSym", "prevWindowSym"};

                env.SendEventBean(MakeMarketDataEvent("E1"));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {
                        "E1", null, null, "E1", 1L,
                        new object[] {"E1"}
                    });

                env.Milestone(1);

                env.SendEventBean(MakeMarketDataEvent("E2"));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {
                        "E2", "E1", "E1", "E1", 2L,
                        new object[] {"E2", "E1"}
                    });

                env.Milestone(2);

                for (var i = 3; i < 10; i++) {
                    env.SendEventBean(MakeMarketDataEvent("E" + i));

                    env.Listener("s0")
                        .AssertNewOldData(
                            new[] {
                                new object[] {"Symbol", "E" + i}, new object[] {"prev1", "E" + (i - 1)},
                                new object[] {"prio1", "E" + (i - 1)}, new object[] {"prevtail0", "E" + (i - 1)}
                            }, // new data
                            new[] {
                                new object[] {"Symbol", "E" + (i - 2)}, new object[] {"prev1", null},
                                new object[] {"prevtail0", null}
                            } //  old data
                        );

                    env.Milestone(i);
                }

                // Lets try the iterator
                var events = env.GetEnumerator("s0");
                for (var i = 8; i < 10; i++) {
                    var @event = events.Advance();
                    Assert.AreEqual("E" + i, @event.Get("Symbol"));
                }

                env.UndeployAll();
            }
Example #12
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeploy("@Name('v0') create variable Object varobject = null", path);
                env.CompileDeploy(
                    "@Name('v1') create variable " + typeof(SupportBean_A).FullName + " varbean = null",
                    path);
                env.CompileDeploy("@Name('v2') create variable SupportBean_S0 vartype = null", path);
                var depIdVarobject = env.DeploymentId("v0");
                var depIdVarbean = env.DeploymentId("v1");
                var depIdVartype = env.DeploymentId("v2");

                var fields = new [] { "varobject","varbean","varbean.Id","vartype","vartype.Id" };
                env.CompileDeploy(
                    "@Name('s0') select varobject, varbean, varbean.Id, vartype, vartype.Id from SupportBean",
                    path);
                env.AddListener("s0");

                // test null
                env.SendEventBean(new SupportBean());
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {null, null, null, null, null});

                env.Milestone(0);

                // test objects
                var a1objectOne = new SupportBean_A("A1");
                var s0objectOne = new SupportBean_S0(1);
                env.Runtime.VariableService.SetVariableValue(depIdVarobject, "varobject", "abc");
                env.Runtime.VariableService.SetVariableValue(depIdVarbean, "varbean", a1objectOne);
                env.Runtime.VariableService.SetVariableValue(depIdVartype, "vartype", s0objectOne);

                env.Milestone(1);

                env.SendEventBean(new SupportBean());
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"abc", a1objectOne, a1objectOne.Id, s0objectOne, s0objectOne.Id});

                // test on-set for Object and EventType
                var fieldsTop = new [] { "varobject","vartype","varbean" };
                env.CompileDeploy(
                    "@Name('set') on SupportBean_S0(P00='X') arrival set varobject=1, vartype=arrival, varbean=null",
                    path);
                env.AddListener("set");

                var s0objectTwo = new SupportBean_S0(2, "X");
                env.SendEventBean(s0objectTwo);
                Assert.AreEqual(1, env.Runtime.VariableService.GetVariableValue(depIdVarobject, "varobject"));
                Assert.AreEqual(s0objectTwo, env.Runtime.VariableService.GetVariableValue(depIdVartype, "vartype"));
                Assert.AreEqual(
                    s0objectTwo,
                    env.Runtime
                        .VariableService.GetVariableValue(
                            Collections.SingletonSet(new DeploymentIdNamePair(depIdVartype, "vartype")))
                        .Get(new DeploymentIdNamePair(depIdVartype, "vartype")));
                EPAssertionUtil.AssertProps(
                    env.Listener("set").AssertOneGetNewAndReset(),
                    fieldsTop,
                    new object[] {1, s0objectTwo, null});
                EPAssertionUtil.AssertProps(
                    env.GetEnumerator("set").Advance(),
                    fieldsTop,
                    new object[] {1, s0objectTwo, null});

                // set via API to null
                IDictionary<DeploymentIdNamePair, object> newValues = new Dictionary<DeploymentIdNamePair, object>();
                newValues.Put(new DeploymentIdNamePair(depIdVarobject, "varobject"), null);
                newValues.Put(new DeploymentIdNamePair(depIdVartype, "vartype"), null);
                newValues.Put(new DeploymentIdNamePair(depIdVarbean, "varbean"), null);
                env.Runtime.VariableService.SetVariableValue(newValues);
                env.SendEventBean(new SupportBean());
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {null, null, null, null, null});

                // set via API to values
                newValues.Put(new DeploymentIdNamePair(depIdVarobject, "varobject"), 10L);
                newValues.Put(new DeploymentIdNamePair(depIdVartype, "vartype"), s0objectTwo);
                newValues.Put(new DeploymentIdNamePair(depIdVarbean, "varbean"), a1objectOne);
                env.Runtime.VariableService.SetVariableValue(newValues);
                env.SendEventBean(new SupportBean());
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {10L, a1objectOne, a1objectOne.Id, s0objectTwo, s0objectTwo.Id});

                // test on-set for Bean class
                env.CompileDeploy(
                    "@Name('set-two') on SupportBean_A(Id='Y') arrival set varobject=null, vartype=null, varbean=arrival",
                    path);
                env.AddListener("set-two");
                var a1objectTwo = new SupportBean_A("Y");
                env.SendEventBean(new SupportBean_A("Y"));
                Assert.AreEqual(null, env.Runtime.VariableService.GetVariableValue(depIdVarobject, "varobject"));
                Assert.AreEqual(null, env.Runtime.VariableService.GetVariableValue(depIdVartype, "vartype"));
                Assert.AreEqual(
                    a1objectTwo,
                    env.Runtime
                        .VariableService.GetVariableValue(
                            Collections.SingletonSet(new DeploymentIdNamePair(depIdVarbean, "varbean")))
                        .Get(new DeploymentIdNamePair(depIdVarbean, "varbean")));
                EPAssertionUtil.AssertProps(
                    env.Listener("set-two").AssertOneGetNewAndReset(),
                    fieldsTop,
                    new object[] {null, null, a1objectTwo});
                EPAssertionUtil.AssertProps(
                    env.GetEnumerator("set-two").Advance(),
                    fieldsTop,
                    new object[] {null, null, a1objectTwo});

                env.UndeployAll();
            }
Example #13
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeploy("@Name('create') create variable SupportBean varbean", path);

                var fields = new [] { "varbean.TheString","varbean.IntPrimitive","varbean.GetTheString()" };
                env.CompileDeploy(
                    "@Name('s0') select varbean.TheString,varbean.IntPrimitive,varbean.GetTheString() from SupportBean_S0",
                    path);
                env.AddListener("s0");

                env.SendEventBean(new SupportBean_S0(1));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {null, null, null});

                env.CompileDeploy(
                    "@Name('set') on SupportBean_A set varbean.TheString = 'A', varbean.IntPrimitive = 1",
                    path);
                env.AddListener("set");
                env.SendEventBean(new SupportBean_A("E1"));
                env.Listener("set").Reset();

                env.Milestone(0);

                env.SendEventBean(new SupportBean_S0(2));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {null, null, null});

                var setBean = new SupportBean();
                env.Runtime.VariableService.SetVariableValue(env.DeploymentId("create"), "varbean", setBean);
                env.SendEventBean(new SupportBean_A("E2"));
                EPAssertionUtil.AssertProps(
                    env.Listener("set").AssertOneGetNewAndReset(),
                    new [] { "varbean.TheString","varbean.IntPrimitive" },
                    new object[] {"A", 1});
                EPAssertionUtil.AssertProps(
                    env.GetEnumerator("set").Advance(),
                    new [] { "varbean.TheString","varbean.IntPrimitive" },
                    new object[] {"A", 1});

                env.Milestone(1);

                env.SendEventBean(new SupportBean_S0(3));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"A", 1, "A"});
                Assert.AreNotSame(
                    setBean,
                    env.Runtime.VariableService.GetVariableValue(env.DeploymentId("create"), "varbean"));
                Assert.AreEqual(
                    1,
                    ((SupportBean) env.Runtime.VariableService.GetVariableValue(env.DeploymentId("create"), "varbean"))
                    .IntPrimitive);

                // test self evaluate
                env.UndeployModuleContaining("set");
                env.CompileDeploy(
                    "@Name('set') on SupportBean_A set varbean.TheString = SupportBean_A.Id, varbean.TheString = '>'||varbean.TheString||'<'",
                    path);
                env.AddListener("set");
                env.SendEventBean(new SupportBean_A("E3"));
                Assert.AreEqual(
                    ">E3<",
                    ((SupportBean) env.Runtime.VariableService.GetVariableValue(env.DeploymentId("create"), "varbean"))
                    .TheString);
                env.UndeployModuleContaining("set");

                // test widen
                env.CompileDeploy("@Name('set') on SupportBean_A set varbean.LongPrimitive = 1", path);
                env.AddListener("set");
                env.SendEventBean(new SupportBean_A("E4"));
                Assert.AreEqual(
                    1,
                    ((SupportBean) env.Runtime.VariableService.GetVariableValue(env.DeploymentId("create"), "varbean"))
                    .LongPrimitive);

                env.UndeployAll();
            }
Example #14
0
            public void Run(RegressionEnvironment env)
            {
                var fields = new [] { "Book.BookId","Item.ItemId","Amount" };
                var stmtText = "@Name('s0') select Book.BookId,Item.ItemId,Amount from " +
                               "OrderBean[Books]#firstunique(BookId) Book, " +
                               "OrderBean[OrderDetail.Items]#keepall Item " +
                               "where Book.BookId = Item.ProductId " +
                               "order by Book.BookId, Item.ItemId";
                env.CompileDeploy(stmtText).AddListener("s0");

                env.SendEventBean(MakeEventOne());
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").LastNewData,
                    fields,
                    new[] {
                        new object[] {"10020", "A001", 10}, new object[] {"10020", "A003", 30},
                        new object[] {"10021", "A002", 25}
                    });
                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {
                        new object[] {"10020", "A001", 10}, new object[] {"10020", "A003", 30},
                        new object[] {"10021", "A002", 25}
                    });
                env.Listener("s0").Reset();

                env.SendEventBean(MakeEventTwo());
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").LastNewData,
                    fields,
                    new[] {new object[] {"10022", "B001", 5}});
                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {
                        new object[] {"10020", "A001", 10}, new object[] {"10020", "A003", 30},
                        new object[] {"10021", "A002", 25}, new object[] {"10022", "B001", 5}
                    });
                env.Listener("s0").Reset();

                env.SendEventBean(MakeEventThree());
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").LastNewData,
                    fields,
                    new[] {new object[] {"10021", "C001", 50}});
                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {
                        new object[] {"10020", "A001", 10}, new object[] {"10020", "A003", 30},
                        new object[] {"10021", "A002", 25}, new object[] {"10021", "C001", 50},
                        new object[] {"10022", "B001", 5}
                    });
                env.Listener("s0").Reset();

                env.SendEventBean(MakeEventFour());
                Assert.IsFalse(env.Listener("s0").IsInvoked);

                env.UndeployAll();
            }
Example #15
0
            public void Run(RegressionEnvironment env)
            {
                var fields = new[] {"c0", "c1"};
                var epl =
                    "@Name('s0') select irstream TheString as c0, IntPrimitive as c1 from SupportBean#unique(TheString)";
                if (optionalAnnotations != null) {
                    epl = optionalAnnotations + epl;
                }

                env.CompileDeployAddListenerMileZero(epl, "s0");

                env.Milestone(1);

                EPAssertionUtil.AssertPropsPerRow(env.GetEnumerator("s0"), fields, new object[0][]);
                SendSupportBean(env, "E1", 1);
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E1", 1});

                env.Milestone(2);

                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"E1", 1}});
                SendSupportBean(env, "E2", 20);
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E2", 20});

                env.Milestone(3);

                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"E1", 1}, new object[] {"E2", 20}});
                SendSupportBean(env, "E1", 2);
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertGetAndResetIRPair(),
                    fields,
                    new object[] {"E1", 2},
                    new object[] {"E1", 1});

                env.Milestone(4);

                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"E1", 2}, new object[] {"E2", 20}});
                SendSupportBean(env, "E2", 21);
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertGetAndResetIRPair(),
                    fields,
                    new object[] {"E2", 21},
                    new object[] {"E2", 20});

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

                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"E1", 2}, new object[] {"E2", 21}});
                SendSupportBean(env, "E2", 22);
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertGetAndResetIRPair(),
                    fields,
                    new object[] {"E2", 22},
                    new object[] {"E2", 21});
                SendSupportBean(env, "E1", 3);
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertGetAndResetIRPair(),
                    fields,
                    new object[] {"E1", 3},
                    new object[] {"E1", 2});

                SendSupportBean(env, "E3", 30);
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E3", 30});

                env.UndeployAll();
            }
Example #16
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();
 }
            public void Run(RegressionEnvironment env)
            {
                string[] fields = {"TheString"};
                var path = new RegressionPath();

                var epl = "@Name('window') create window MyWindowIWT#keepall as SupportBean;\n" +
                          "insert into MyWindowIWT select * from SupportBean(IntPrimitive > 0);\n";
                env.CompileDeploy(epl, path).AddListener("window");

                env.Milestone(0);

                // populate some data
                Assert.AreEqual(0, GetCount(env, path, "window", "MyWindowIWT"));
                env.SendEventBean(new SupportBean("A1", 1));
                Assert.AreEqual(1, GetCount(env, path, "window", "MyWindowIWT"));
                env.SendEventBean(new SupportBean("B2", 1));

                env.Milestone(1);

                env.SendEventBean(new SupportBean("C3", 1));
                env.SendEventBean(new SupportBean("A4", 4));
                env.SendEventBean(new SupportBean("C5", 4));
                Assert.AreEqual(5, GetCount(env, path, "window", "MyWindowIWT"));
                env.Listener("window").Reset();

                env.Milestone(2);

                // create window with keep-all
                var stmtTextCreateTwo = "@Name('windowTwo') create window MyWindowTwo#keepall as MyWindowIWT insert";
                env.CompileDeploy(stmtTextCreateTwo, path).AddListener("windowTwo");
                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("windowTwo"),
                    fields,
                    new[] {
                        new object[] {"A1"}, new object[] {"B2"}, new object[] {"C3"}, new object[] {"A4"},
                        new object[] {"C5"}
                    });
                var eventTypeTwo = env.GetEnumerator("windowTwo").Advance().EventType;
                Assert.IsFalse(env.Listener("windowTwo").IsInvoked);
                Assert.AreEqual(5, GetCount(env, path, "windowTwo", "MyWindowTwo"));
                Assert.AreEqual(
                    StatementType.CREATE_WINDOW,
                    env.Statement("windowTwo").GetProperty(StatementProperty.STATEMENTTYPE));
                Assert.AreEqual(
                    "MyWindowTwo", 
                    env.Statement("windowTwo").GetProperty(StatementProperty.CREATEOBJECTNAME));

                // create window with keep-all and filter
                var stmtTextCreateThree =
                    "@Name('windowThree') create window MyWindowThree#keepall as MyWindowIWT insert where TheString like 'A%'";
                env.CompileDeploy(stmtTextCreateThree, path).AddListener("windowThree");
                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("windowThree"),
                    fields,
                    new[] {new object[] {"A1"}, new object[] {"A4"}});
                var eventTypeThree = env.GetEnumerator("windowThree").Advance().EventType;
                Assert.IsFalse(env.Listener("windowThree").IsInvoked);

                env.Milestone(3);

                Assert.AreEqual(2, GetCount(env, path, "windowThree", "MyWindowThree"));

                // create window with last-per-id
                var stmtTextCreateFour =
                    "@Name('windowFour') create window MyWindowFour#unique(IntPrimitive) as MyWindowIWT insert";
                env.CompileDeploy(stmtTextCreateFour, path).AddListener("windowFour");
                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("windowFour"),
                    fields,
                    new[] {new object[] {"C3"}, new object[] {"C5"}});
                var eventTypeFour = env.GetEnumerator("windowFour").Advance().EventType;
                Assert.IsFalse(env.Listener("windowFour").IsInvoked);

                env.Milestone(4);

                Assert.AreEqual(2, GetCount(env, path, "windowFour", "MyWindowFour"));

                env.CompileDeploy("insert into MyWindowIWT select * from SupportBean(TheString like 'A%')", path);
                env.CompileDeploy("insert into MyWindowTwo select * from SupportBean(TheString like 'B%')", path);
                env.CompileDeploy("insert into MyWindowThree select * from SupportBean(TheString like 'C%')", path);
                env.CompileDeploy("insert into MyWindowFour select * from SupportBean(TheString like 'D%')", path);
                Assert.IsFalse(
                    env.Listener("window").IsInvoked ||
                    env.Listener("windowTwo").IsInvoked ||
                    env.Listener("windowThree").IsInvoked ||
                    env.Listener("windowFour").IsInvoked);

                env.SendEventBean(new SupportBean("B9", -9));
                var received = env.Listener("windowTwo").AssertOneGetNewAndReset();
                EPAssertionUtil.AssertProps(
                    received,
                    fields,
                    new object[] {"B9"});
                if (!env.IsHA) {
                    Assert.AreSame(eventTypeTwo, received.EventType);
                }

                Assert.IsFalse(
                    env.Listener("window").IsInvoked ||
                    env.Listener("windowThree").IsInvoked ||
                    env.Listener("windowFour").IsInvoked);
                Assert.AreEqual(6, GetCount(env, path, "windowTwo", "MyWindowTwo"));

                env.Milestone(5);

                env.SendEventBean(new SupportBean("A8", -8));
                received = env.Listener("window").AssertOneGetNewAndReset();
                EPAssertionUtil.AssertProps(
                    received,
                    fields,
                    new object[] {"A8"});
                Assert.AreSame(env.Statement("window").EventType, received.EventType);
                Assert.IsFalse(
                    env.Listener("windowTwo").IsInvoked ||
                    env.Listener("windowThree").IsInvoked ||
                    env.Listener("windowFour").IsInvoked);

                env.Milestone(6);

                env.SendEventBean(new SupportBean("C7", -7));
                received = env.Listener("windowThree").AssertOneGetNewAndReset();
                EPAssertionUtil.AssertProps(
                    received,
                    fields,
                    new object[] {"C7"});
                if (!env.IsHA) {
                    Assert.AreSame(eventTypeThree, received.EventType);
                }

                Assert.IsFalse(
                    env.Listener("windowTwo").IsInvoked ||
                    env.Listener("window").IsInvoked ||
                    env.Listener("windowFour").IsInvoked);

                env.SendEventBean(new SupportBean("D6", -6));
                received = env.Listener("windowFour").AssertOneGetNewAndReset();
                EPAssertionUtil.AssertProps(
                    received,
                    fields,
                    new object[] {"D6"});
                if (!env.IsHA) {
                    Assert.AreSame(eventTypeFour, received.EventType);
                }

                Assert.IsFalse(
                    env.Listener("windowTwo").IsInvoked ||
                    env.Listener("window").IsInvoked ||
                    env.Listener("windowThree").IsInvoked);

                env.UndeployAll();
            }
Example #18
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();
 }
Example #19
0
            public void Run(RegressionEnvironment env)
            {
                var fields = new[] {"c0"};

                var epl =
                    "@Name('s0') select irstream TheString as c0 from SupportBean#ext_timed_batch(LongPrimitive, 10 sec)";
                env.CompileDeployAddListenerMileZero(epl, "s0");

                EPAssertionUtil.AssertPropsPerRow(env.GetEnumerator("s0"), fields, new object[0][]);
                SendSupportBeanWLong(env, "E1", 1000); // reference point is 1000, every batch is 11000/21000/31000...
                Assert.IsFalse(env.Listener("s0").IsInvoked);

                env.Milestone(1);

                SendSupportBeanWLong(env, "E2", 5000);
                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"E1"}, new object[] {"E2"}});
                Assert.IsFalse(env.Listener("s0").IsInvoked);

                env.Milestone(2);

                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"E1"}, new object[] {"E2"}});
                SendSupportBeanWLong(env, "E3", 11000);
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").AssertInvokedAndReset(),
                    fields,
                    new[] {new object[] {"E1"}, new object[] {"E2"}},
                    null);

                env.Milestone(3);

                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"E3"}});
                SendSupportBeanWLong(env, "E4", 0);
                Assert.IsFalse(env.Listener("s0").IsInvoked);

                env.Milestone(4);

                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"E3"}, new object[] {"E4"}});
                SendSupportBeanWLong(env, "E5", 21000);
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").AssertInvokedAndReset(),
                    fields,
                    new[] {new object[] {"E3"}, new object[] {"E4"}},
                    new[] {new object[] {"E1"}, new object[] {"E2"}});

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

                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"E5"}});
                SendSupportBeanWLong(env, "E6", 31000);
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").AssertInvokedAndReset(),
                    fields,
                    new[] {new object[] {"E5"}},
                    new[] {new object[] {"E3"}, new object[] {"E4"}});
                SendSupportBeanWLong(env, "E7", 41000);
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").AssertInvokedAndReset(),
                    fields,
                    new[] {new object[] {"E6"}},
                    new[] {new object[] {"E5"}});

                env.UndeployAll();
            }