示例#1
0
            public void Run(RegressionEnvironment env)
            {
                // Test substitution parameter and inheritance in key matching
                var path = new RegressionPath();
                var types =
                    "create schema MyEventOne as " +
                    typeof(MyEventOne).MaskTypeName() +
                    ";\n" +
                    "create schema MyEventTwo as " +
                    typeof(MyEventTwo).MaskTypeName() +
                    ";\n";
                env.CompileDeployWBusPublicType(types, path);

                var epl = "select * from MyEventOne(Key = ?::IKey)";
                var compiled = env.Compile(epl, path);
                var lKey = new MyObjectKeyInterface();
                DeployWithResolver(env, compiled, "s0", prepared => prepared.SetObject(1, lKey));
                env.AddListener("s0");

                env.SendEventBean(new MyEventOne(lKey));
                Assert.IsTrue(env.Listener("s0").GetAndClearIsInvoked());

                // Test substitution parameter and concrete subclass in key matching
                epl = "select * from MyEventTwo where Key = ?::MyObjectKeyConcrete";
                compiled = env.Compile(epl, path);
                var cKey = new MyObjectKeyConcrete();
                DeployWithResolver(env, compiled, "s1", prepared => prepared.SetObject(1, cKey));
                env.AddListener("s1");

                env.SendEventBean(new MyEventTwo(cKey));
                Assert.IsTrue(env.Listener("s1").GetAndClearIsInvoked());

                env.UndeployAll();
            }
示例#2
0
            public void Run(RegressionEnvironment env)
            {
                env.CompileDeploy("insert into MyVariantStreamFour select * from SupportBeanVariantStream");
                env.CompileDeploy("insert into MyVariantStreamFour select * from SupportBean");

                // test pattern
                env.CompileDeploy("@Name('s0') select * from pattern [a=MyVariantStreamFour -> b=MyVariantStreamFour]");
                env.AddListener("s0");
                object[] events = {new SupportBean("E1", -1), new SupportBeanVariantStream("E2")};
                env.SendEventBean(events[0]);
                env.SendEventBean(events[1]);
                EPAssertionUtil.AssertProps(env.Listener("s0").AssertOneGetNewAndReset(), new [] { "a","b" }, events);
                env.UndeployModuleContaining("s0");

                // test subquery
                env.CompileDeploy(
                    "@Name('s0') select * from SupportBean_A as a where exists(select * from MyVariantStreamFour#lastevent as b where b.TheString=a.Id)");
                env.AddListener("s0");
                events = new object[]
                    {new SupportBean("E1", -1), new SupportBeanVariantStream("E2"), new SupportBean_A("E2")};

                env.SendEventBean(events[0]);
                env.SendEventBean(events[2]);
                Assert.IsFalse(env.Listener("s0").IsInvoked);

                env.SendEventBean(events[1]);
                env.SendEventBean(events[2]);
                Assert.IsTrue(env.Listener("s0").IsInvoked);

                env.UndeployAll();
            }
示例#3
0
            public void Run(RegressionEnvironment env)
            {
                // test named-map at the second level of a nested map
                env.CompileDeploy(
                    "@Name('s0') select " +
                    "outer.p0.n0 as a, " +
                    "outer.p1[0].n0 as b, " +
                    "outer.p1[1].n0 as c, " +
                    "outer.p0 as d, " +
                    "outer.p1 as e " +
                    "from MyObjectArrayMapOuter");
                env.AddListener("s0");

                var n0Bean1 = MakeMap(
                    new[] {
                        new object[] {"n0", 1}
                    });
                var n0Bean21 = MakeMap(
                    new[] {
                        new object[] {"n0", 2}
                    });
                var n0Bean22 = MakeMap(
                    new[] {
                        new object[] {"n0", 3}
                    });
                IDictionary<string, object>[] n0Bean2 = {n0Bean21, n0Bean22};
                var theEvent = MakeMap(
                    new[] {
                        new object[] {"p0", n0Bean1},
                        new object[] {"p1", n0Bean2}
                    });
                env.SendEventObjectArray(new object[] {theEvent}, "MyObjectArrayMapOuter");

                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    new [] { "a","b","c","d","e" },
                    new object[] {1, 2, 3, n0Bean1, n0Bean2});
                var eventType = env.Statement("s0").EventType;
                Assert.AreEqual(typeof(int?), eventType.GetPropertyType("a"));
                Assert.AreEqual(typeof(int?), eventType.GetPropertyType("b"));
                Assert.AreEqual(typeof(int?), eventType.GetPropertyType("c"));
                Assert.AreEqual(typeof(IDictionary<string, object>), eventType.GetPropertyType("d"));
                Assert.AreEqual(typeof(IDictionary<string, object>[]), eventType.GetPropertyType("e"));

                env.UndeployAll();
                env.CompileDeploy(
                    "@Name('s0') select outer.p0.n0? as a, outer.p1[0].n0? as b, outer.p1[1]?.n0 as c, outer.p0? as d, outer.p1? as e from MyObjectArrayMapOuter");
                env.AddListener("s0");

                env.SendEventObjectArray(new object[] {theEvent}, "MyObjectArrayMapOuter");

                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    new [] { "a","b","c","d","e" },
                    new object[] {1, 2, 3, n0Bean1, n0Bean2});
                Assert.AreEqual(typeof(int?), env.Statement("s0").EventType.GetPropertyType("a"));

                env.UndeployAll();
            }
示例#4
0
            public void Run(RegressionEnvironment env)
            {
                // test map containing first-level property that is an array of primitive or Class
                env.CompileDeploy("@Name('s0') select P0('k1') as a from MyMappedPropertyMap");
                env.AddListener("s0");

                IDictionary<string, object> eventVal = new Dictionary<string, object>();
                eventVal.Put("k1", "v1");
                var theEvent = MakeMap(
                    new[] {
                        new object[] {"P0", eventVal}
                    });
                env.SendEventMap(theEvent, "MyMappedPropertyMap");

                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    new [] { "a" },
                    new object[] {"v1"});
                Assert.AreEqual(typeof(object), env.Statement("s0").EventType.GetPropertyType("a"));
                env.UndeployAll();

                // test map at the second level of a nested map that is an array of primitive or Class
                env.CompileDeploy("@Name('s0') select outer.P0('k1') as a from MyMappedPropertyMapOuter");
                env.AddListener("s0");

                var eventOuter = MakeMap(
                    new[] {
                        new object[] {"outer", theEvent}
                    });
                env.SendEventMap(eventOuter, "MyMappedPropertyMapOuter");

                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    new[] {"a"},
                    new object[] {"v1"}
                );
                Assert.AreEqual(typeof(object), env.Statement("s0").EventType.GetPropertyType("a"));
                env.UndeployModuleContaining("s0");

                // test map that contains a bean which has a map property
                env.CompileDeploy(
                        "@Name('s0') select outerTwo.MapProperty('xOne') as a from MyMappedPropertyMapOuterTwo")
                    .AddListener("s0");

                var eventOuterTwo = MakeMap(
                    new[] {
                        new object[] {"outerTwo", SupportBeanComplexProps.MakeDefaultBean()}
                    });
                env.SendEventMap(eventOuterTwo, "MyMappedPropertyMapOuterTwo");

                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    new [] { "a" },
                    new object[] {"yOne"});
                Assert.AreEqual(typeof(object), env.Statement("s0").EventType.GetPropertyType("a"));

                env.UndeployAll();
            }
示例#5
0
            public void Run(RegressionEnvironment env)
            {
                env.CompileDeploy(
                    "@Name('s0') select outer.P0.n0 as a, outer.P1[0].n0 as b, outer.P1[1].n0 as c, outer.P0 as d, outer.P1 as e from MyArrayMapTwo");
                env.AddListener("s0");

                var n0Bean1 = EventMapCore.MakeMap(
                    new[] {
                        new object[] {"n0", 1}
                    });
                var n0Bean21 = EventMapCore.MakeMap(
                    new[] {
                        new object[] {"n0", 2}
                    });
                var n0Bean22 = EventMapCore.MakeMap(
                    new[] {
                        new object[] {"n0", 3}
                    });
                IDictionary<string, object>[] n0Bean2 = {n0Bean21, n0Bean22};
                var theEvent = EventMapCore.MakeMap(
                    new[] {
                        new object[] {"P0", n0Bean1}, new object[] {"P1", n0Bean2}
                    });
                var eventOuter = EventMapCore.MakeMap(
                    new[] {
                        new object[] {"outer", theEvent}
                    });
                env.SendEventMap(eventOuter, "MyArrayMapTwo");

                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    new [] { "a","b","c","d","e" },
                    new object[] {1, 2, 3, n0Bean1, n0Bean2});
                var eventType = env.Statement("s0").EventType;
                Assert.AreEqual(typeof(int?), eventType.GetPropertyType("a"));
                Assert.AreEqual(typeof(int?), eventType.GetPropertyType("b"));
                Assert.AreEqual(typeof(int?), eventType.GetPropertyType("c"));
                Assert.AreEqual(typeof(IDictionary<string, object>), eventType.GetPropertyType("d"));
                Assert.AreEqual(typeof(IDictionary<string, object>[]), eventType.GetPropertyType("e"));

                env.UndeployAll();
                env.CompileDeploy(
                    "@Name('s0') select outer.P0.n0? as a, outer.P1[0].n0? as b, outer.P1[1]?.n0 as c, outer.P0? as d, outer.P1? as e from MyArrayMapTwo");
                env.AddListener("s0");

                env.SendEventMap(eventOuter, "MyArrayMapTwo");

                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    new [] { "a","b","c","d","e" },
                    new object[] {1, 2, 3, n0Bean1, n0Bean2});
                Assert.AreEqual(typeof(int?), env.Statement("s0").EventType.GetPropertyType("a"));

                env.UndeployAll();
            }
示例#6
0
        private static void RunSimpleTwoParameter(
            RegressionEnvironment env,
            string stmtText,
            string statementName,
            bool compareText)
        {
            var compiled = env.Compile(stmtText);

            DeployWithResolver(
                env,
                compiled,
                statementName,
                prepared => {
                    prepared.SetObject(1, "e1");
                    prepared.SetObject(2, 1);
                });
            env.AddListener(statementName);
            if (compareText) {
                Assert.AreEqual(
                    "select * from SupportBean(TheString=?::string,IntPrimitive=?::int)",
                    env.Statement(statementName).GetProperty(StatementProperty.EPL));
            }

            DeployWithResolver(
                env,
                compiled,
                statementName + "__1",
                prepared => {
                    prepared.SetObject(1, "e2");
                    prepared.SetObject(2, 2);
                });
            env.AddListener(statementName + "__1");
            if (compareText) {
                Assert.AreEqual(
                    "select * from SupportBean(TheString=?::string,IntPrimitive=?::int)",
                    env.Statement(statementName + "__1").GetProperty(StatementProperty.EPL));
            }

            env.SendEventBean(new SupportBean("e2", 2));
            Assert.IsFalse(env.Listener(statementName).IsInvoked);
            Assert.IsTrue(env.Listener(statementName + "__1").GetAndClearIsInvoked());

            env.SendEventBean(new SupportBean("e1", 1));
            Assert.IsFalse(env.Listener(statementName + "__1").IsInvoked);
            Assert.IsTrue(env.Listener(statementName).GetAndClearIsInvoked());

            env.SendEventBean(new SupportBean("e1", 2));
            Assert.IsFalse(env.Listener(statementName).IsInvoked);
            Assert.IsFalse(env.Listener(statementName + "__1").IsInvoked);

            env.UndeployAll();
        }
示例#7
0
        public void Run(RegressionEnvironment env)
        {
            var path = new RegressionPath();
            env.CompileDeploy("create window MyWindow#keepall as SupportBean", path);
            env.CompileDeploy("insert into MyWindow select * from SupportBean", path);
            env.CompileDeploy("create const variable String MYCONST = 'E331'", path);

            for (var i = 0; i < 10000; i++) {
                env.SendEventBean(new SupportBean("E" + i, i * -1));
            }

            // test join
            env.CompileDeploy(
                "@Name('s0') select * from SupportBean_S0 S0 unidirectional, MyWindow sb where TheString = MYCONST",
                path);
            env.AddListener("s0");

            var listener = env.Listener("s0");
            var start = PerformanceObserver.MilliTime;
            for (var i = 0; i < 10000; i++) {
                env.SendEventBean(new SupportBean_S0(i, "E" + i));
                EPAssertionUtil.AssertProps(
                    listener.AssertOneGetNewAndReset(),
                    new [] { "sb.TheString","sb.IntPrimitive" },
                    new object[] {"E331", -331});
            }

            var delta = PerformanceObserver.MilliTime - start;
            Assert.That(delta, Is.LessThan(500), "delta=" + delta);
            env.UndeployModuleContaining("s0");

            // test subquery
            env.CompileDeploy(
                "@Name('s0') select * from SupportBean_S0 where exists (select * from MyWindow where TheString = MYCONST)",
                path);
            env.AddListener("s0");
            listener = env.Listener("s0");

            start = PerformanceObserver.MilliTime;
            for (var i = 0; i < 10000; i++) {
                env.SendEventBean(new SupportBean_S0(i, "E" + i));
                Assert.IsTrue(listener.GetAndClearIsInvoked());
            }

            delta = PerformanceObserver.MilliTime - start;
            Assert.That(delta, Is.LessThan(500), "delta=" + delta);

            env.UndeployModuleContaining("s0");
            env.UndeployAll();
        }
示例#8
0
            public void Run(RegressionEnvironment env)
            {
                // test map containing first-level property that is an array of primitive or Class
                env.CompileDeploy(
                    "@Name('s0') select P0[0] as a, P0[1] as b, P1[0].IntPrimitive as c, P1[1] as d, P0 as e from MyArrayOA");
                env.AddListener("s0");

                int[] p0 = {1, 2, 3};
                SupportBean[] beans = {new SupportBean("e1", 5), new SupportBean("e2", 6)};
                object[] eventData = {p0, beans};
                env.SendEventObjectArray(eventData, "MyArrayOA");

                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    new [] { "a","b","c","d","e" },
                    new object[] {1, 2, 5, beans[1], p0});
                var eventType = env.Statement("s0").EventType;
                Assert.AreEqual(typeof(int?), eventType.GetPropertyType("a"));
                Assert.AreEqual(typeof(int?), eventType.GetPropertyType("b"));
                Assert.AreEqual(typeof(int?), eventType.GetPropertyType("c"));
                Assert.AreEqual(typeof(SupportBean), eventType.GetPropertyType("d"));
                Assert.AreEqual(typeof(int[]), eventType.GetPropertyType("e"));
                env.UndeployAll();

                // test map at the second level of a nested map that is an array of primitive or Class
                env.CompileDeploy(
                    "@Name('s0') select " +
                    "outer.P0[0] as a, " +
                    "outer.P0[1] as b, " +
                    "outer.P1[0].IntPrimitive as c, " +
                    "outer.P1[1] as d, " +
                    "outer.P0 as e " +
                    "from MyArrayOAMapOuter");
                env.AddListener("s0");

                env.SendEventObjectArray(new object[] {eventData}, "MyArrayOAMapOuter");

                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    new [] { "a","b","c","d" },
                    new object[] {1, 2, 5, beans[1]});
                eventType = env.Statement("s0").EventType;
                Assert.AreEqual(typeof(int?), eventType.GetPropertyType("a"));
                Assert.AreEqual(typeof(int?), eventType.GetPropertyType("b"));
                Assert.AreEqual(typeof(int?), eventType.GetPropertyType("c"));
                Assert.AreEqual(typeof(SupportBean), eventType.GetPropertyType("d"));
                Assert.AreEqual(typeof(int[]), eventType.GetPropertyType("e"));

                env.UndeployAll();
            }
示例#9
0
            public void Run(RegressionEnvironment env)
            {
                env.CompileDeploy(
                    "@Name('s0') select P0[0] as a, P0[1] as b, P1[0].IntPrimitive as c, P1[1] as d, P0 as e from MyArrayMap");
                env.AddListener("s0");

                int[] p0 = {1, 2, 3};
                SupportBean[] beans = {new SupportBean("e1", 5), new SupportBean("e2", 6)};
                var theEvent = EventMapCore.MakeMap(new[] {new object[] { "P0", p0}, new object[] {"P1", beans}});
                env.SendEventMap(theEvent, "MyArrayMap");

                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    new [] { "a","b","c","d","e" },
                    new object[] {1, 2, 5, beans[1], p0});
                var eventType = env.Statement("s0").EventType;
                Assert.AreEqual(typeof(int?), eventType.GetPropertyType("a"));
                Assert.AreEqual(typeof(int?), eventType.GetPropertyType("b"));
                Assert.AreEqual(typeof(int?), eventType.GetPropertyType("c"));
                Assert.AreEqual(typeof(SupportBean), eventType.GetPropertyType("d"));
                Assert.AreEqual(typeof(int[]), eventType.GetPropertyType("e"));
                env.UndeployAll();

                env.CompileDeploy(
                    "@Name('s0') select" +
                    " outer.P0[0] as a," +
                    " outer.P0[1] as b," +
                    " outer.P1[0].IntPrimitive as c," +
                    " outer.P1[1] as d," +
                    " outer.P0 as e" +
                    " from MyArrayMapOuter");
                env.AddListener("s0");

                var eventOuter = EventMapCore.MakeMap(new[] {new object[] {"outer", theEvent}});
                env.SendEventMap(eventOuter, "MyArrayMapOuter");

                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    new [] { "a","b","c","d" },
                    new object[] {1, 2, 5, beans[1]});
                eventType = env.Statement("s0").EventType;
                Assert.AreEqual(typeof(int?), eventType.GetPropertyType("a"));
                Assert.AreEqual(typeof(int?), eventType.GetPropertyType("b"));
                Assert.AreEqual(typeof(int?), eventType.GetPropertyType("c"));
                Assert.AreEqual(typeof(SupportBean), eventType.GetPropertyType("d"));
                Assert.AreEqual(typeof(int[]), eventType.GetPropertyType("e"));

                env.UndeployAll();
            }
示例#10
0
            public void Run(RegressionEnvironment env)
            {
                var epl = "@Name('s0') select * from SupportBean(IntPrimitive in (1, 10))";
                env.CompileDeployAddListenerMile(epl, "s0", 0);

                SendBeanInt(env, 10);
                Assert.IsTrue(env.Listener("s0").GetAndClearIsInvoked());
                SendBeanInt(env, 11);
                Assert.IsFalse(env.Listener("s0").GetAndClearIsInvoked());
                SendBeanInt(env, 1);
                Assert.IsTrue(env.Listener("s0").GetAndClearIsInvoked());

                env.UndeployAll();

                // try enum collection with substitution param
                ISet<SupportEnum> types = new HashSet<SupportEnum>();
                types.Add(SupportEnum.ENUM_VALUE_2);
                var collectionType = typeof(ICollection<SupportEnum>).CleanName();
                var compiled = env.Compile(
                    "@Name('s0') select * from SupportBean ev " + "where ev.EnumValue in (?::`" + collectionType + "`)");
                env.Deploy(
                    compiled,
                    new DeploymentOptions().WithStatementSubstitutionParameter(
                        prepared => prepared.SetObject(1, types)));
                env.AddListener("s0");

                var theEvent = new SupportBean();
                theEvent.EnumValue = SupportEnum.ENUM_VALUE_2;
                env.SendEventBean(theEvent);

                Assert.IsTrue(env.Listener("s0").IsInvoked);

                env.UndeployAll();
            }
示例#11
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                var milestone = new AtomicLong();
                var ctx = "CategorizedContext";
                var eplCtx = "@Name('context') create context " +
                             ctx +
                             " as " +
                             "group IntPrimitive<10 as cat1 " +
                             "from SupportBean";
                env.CompileDeploy(eplCtx, path);

                var eplStmt =
                    "@Name('s0') context CategorizedContext select context.name as c0, context.label as c1, prior(1,IntPrimitive) as c2 from SupportBean";
                env.CompileDeploy(eplStmt, path).AddListener("s0");

                RunAssertion(env, ctx, milestone);

                // test SODA
                path.Clear();
                env.EplToModelCompileDeploy(eplCtx, path);
                env.EplToModelCompileDeploy(eplStmt, path);
                env.AddListener("s0");

                RunAssertion(env, ctx, milestone);
            }
        private static void TryAssertionReturnTypeIsEvents(
            RegressionEnvironment env,
            string methodName,
            AtomicLong milestone)
        {
            var path = new RegressionPath();
            var compiled = env.CompileWBusPublicType("create schema MyItem(Id string)");
            env.Deploy(compiled);
            path.Add(compiled);

            env.CompileDeploy(
                "@Name('s0') select " +
                methodName +
                "(TheString).where(v -> v.Id in ('id1', 'id3')) as c0 from SupportBean",
                path);
            env.AddListener("s0");

            env.SendEventBean(new SupportBean("id0,id1,id2,id3,id4", 0));
            var real = env.Listener("s0").AssertOneGetNewAndReset().Get("c0");
            var coll = real.Unwrap<IDictionary<string, object>>();
            EPAssertionUtil.AssertPropsPerRow(
                coll.ToArray(),
                new [] { "Id" },
                new[] {
                    new object[] {"id1"},
                    new object[] {"id3"}
                });

            env.UndeployAll();
        }
示例#13
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeploy("create window MyWindowUNP#keepall as SupportBean", path);
                env.CompileDeploy("insert into MyWindowUNP select * from SupportBean", path);
                env.CompileDeploy(
                    "@Name('merge') on SupportBean_S0 as sb " +
                    "merge MyWindowUNP as mywin when matched then " +
                    "update set mywin.SetDoublePrimitive(Id), increaseIntCopyDouble(initial, mywin)",
                    path);
                env.AddListener("merge");
                var fields = new[] {"IntPrimitive", "DoublePrimitive", "DoubleBoxed"};

                env.SendEventBean(MakeSupportBean("E1", 10, 2));
                env.SendEventBean(new SupportBean_S0(5, "E1"));
                EPAssertionUtil.AssertProps(
                    env.Listener("merge").GetAndResetLastNewData()[0],
                    fields,
                    new object[] {11, 5d, 5d});

                // try a case-statement
                var eplCase = "on SupportBean_S0 merge MyWindowUNP " +
                              "when matched then update set TheString = " +
                              "case IntPrimitive when 1 then 'a' else 'b' end";
                env.CompileDeploy(eplCase, path);

                env.UndeployAll();
            }
示例#14
0
            public void Run(RegressionEnvironment env)
            {
                string[] fields = {"TheString", "IntPrimitive"};
                env.CompileDeploy(
                    "@Name('s0') select * from SupportBean where TheString in (select distinct Id from SupportBean_A#keepall)");
                env.AddListener("s0");

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

                env.Milestone(0);

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

                env.UndeployAll();
            }
示例#15
0
            public void Run(RegressionEnvironment env)
            {
                var path        = new RegressionPath();
                var eplOne      = "@Name('type') @public @buseventtype create schema MyEvent(p string)";
                var compiledOne = env.Compile(eplOne, path);
                var eplTwo      = "@Name('s0') select * from MyEvent";
                var compiledTwo = env.Compile(eplTwo, path);

                IList <EPDeploymentRolloutCompiled> items = new List <EPDeploymentRolloutCompiled>();

                items.Add(new EPDeploymentRolloutCompiled(compiledOne));
                items.Add(new EPDeploymentRolloutCompiled(compiledTwo));

                var rollout = env.Deployment.Rollout(items);

                env.AddListener("s0");

                Assert.AreEqual(2, rollout.Items.Length);
                AssertDeployment(env, rollout.Items[0].Deployment, "type");
                AssertDeployment(env, rollout.Items[1].Deployment, "s0");

                AssertSendAndReceive(env, "a");

                env.Milestone(0);

                AssertSendAndReceive(env, "b");

                env.UndeployAll();
            }
        private static void TryAssertion2StreamInnerWGroupBy(RegressionEnvironment env)
        {
            var epl = "create objectarray schema E1 (id string, grp string, value int);\n" +
                      "create objectarray schema E2 (id string, value2 int);\n" +
                      "@Name('s0') select count(*) as c0, sum(E1.value) as c1, E1.id as c2 " +
                      "from E1 unidirectional inner join E2#keepall on E1.id = E2.id group by E1.grp";
            env.CompileDeployWBusPublicType(epl, new RegressionPath());
            env.AddListener("s0");
            var fields = new[] {"c0", "c1", "c2"};

            env.SendEventObjectArray(new object[] {"A", 100}, "E2");
            Assert.IsFalse(env.Listener("s0").IsInvoked);

            env.SendEventObjectArray(new object[] {"A", "X", 10}, "E1");
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fields,
                new object[] {1L, 10, "A"});

            env.SendEventObjectArray(new object[] {"A", "Y", 20}, "E1");
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fields,
                new object[] {1L, 20, "A"});

            env.UndeployAll();
        }
示例#17
0
            public void Run(RegressionEnvironment env)
            {
                env.AdvanceTime(0);
                var path = new RegressionPath();
                env.CompileDeploy(
                    "create context MyTermByTimeout partition by TheString from SupportBean terminated after 10 seconds",
                    path);
                env.CompileDeploy(
                    "@Name('s0') context MyTermByTimeout select TheString, count(*) as cnt from SupportBean",
                    path);
                env.AddListener("s0");

                SendAssertSB(1, env, "A");

                env.Milestone(0);

                env.AdvanceTime(1000);

                SendAssertSB(2, env, "A");

                env.Milestone(1);

                SendAssertSB(1, env, "B");

                env.AdvanceTime(9999);

                SendAssertSB(2, env, "B");
                SendAssertSB(3, env, "A");

                env.Milestone(2);

                env.AdvanceTime(10000);

                env.Milestone(3);

                SendAssertSB(3, env, "B");
                SendAssertSB(1, env, "A");

                env.AdvanceTime(10999);

                SendAssertSB(4, env, "B");
                SendAssertSB(2, env, "A");

                env.AdvanceTime(11000);

                SendAssertSB(1, env, "B");

                env.Milestone(4);

                SendAssertSB(3, env, "A");

                env.Milestone(5);

                env.AdvanceTime(99999);

                SendAssertSB(1, env, "B");
                SendAssertSB(1, env, "A");

                env.UndeployAll();
            }
示例#18
0
            public void Run(RegressionEnvironment env)
            {
                var epl =
                    "@Name('s0') select ?:pint:int as c0 from SupportBean(TheString=?:pstring:string and IntPrimitive=?:pint:int and LongPrimitive=?:plong:long)";
                var compiled = env.Compile(soda, epl, new CompilerArguments(new Configuration()));
                DeployWithResolver(
                    env,
                    compiled,
                    null,
                    prepared => {
                        prepared.SetObject("pstring", "E1");
                        prepared.SetObject("pint", 10);
                        prepared.SetObject("plong", 100L);
                    });
                env.AddListener("s0");

                var @event = new SupportBean("E1", 10);
                @event.LongPrimitive = 100;
                env.SendEventBean(@event);
                EPAssertionUtil.AssertProps(env.Listener("s0").AssertOneGetNewAndReset(), "c0".SplitCsv(), 10);

                env.Milestone(0);

                env.SendEventBean(@event);
                EPAssertionUtil.AssertProps(env.Listener("s0").AssertOneGetNewAndReset(), "c0".SplitCsv(), 10);

                env.UndeployAll();
            }
示例#19
0
            public void Run(RegressionEnvironment env)
            {
                var epl = "@Name('s0') select * from SupportBean_S0(Id=?:subs_1:int);\n" +
                          "@Name('s1') select * from SupportBean_S1(P10=?:subs_2:string);\n";
                var compiled = env.Compile(epl);

                var options = new DeploymentOptions().WithStatementSubstitutionParameter(
                    _ => {
                        if (_.StatementName.Equals("s1")) {
                            _.SetObject("subs_2", "abc");
                        }
                        else {
                            _.SetObject("subs_1", 100);
                        }
                    });

                try {
                    env.Deployment.Deploy(compiled, options);
                }
                catch (EPDeployException e) {
                    throw new EPRuntimeException(e);
                }

                env.AddListener("s0").AddListener("s1");

                env.SendEventBean(new SupportBean_S1(-1, "abc"));
                Assert.IsTrue(env.Listener("s1").IsInvoked);

                env.SendEventBean(new SupportBean_S0(100));
                Assert.IsTrue(env.Listener("s0").IsInvoked);

                env.UndeployAll();
            }
示例#20
0
            public void Run(RegressionEnvironment env)
            {
                // External clocking
                SendTimer(0, env);

                // Set up a timer:within
                env.CompileDeploy(
                    "@Name('s0') select a.TheString as Id from pattern [every a=SupportBean -> timer:interval(IntPrimitive seconds)]");
                env.AddListener("s0");

                SendTimer(10000, env);
                env.SendEventBean(new SupportBean("E1", 3));
                env.SendEventBean(new SupportBean("E2", 2));

                SendTimer(11999, env);
                Assert.IsFalse(env.Listener("s0").IsInvoked);
                SendTimer(12000, env);
                Assert.AreEqual("E2", env.Listener("s0").AssertOneGetNewAndReset().Get("Id"));

                SendTimer(12999, env);
                Assert.IsFalse(env.Listener("s0").IsInvoked);
                SendTimer(13000, env);
                Assert.AreEqual("E1", env.Listener("s0").AssertOneGetNewAndReset().Get("Id"));

                env.UndeployAll();
            }
示例#21
0
            public void Run(RegressionEnvironment env)
            {
                // External clocking
                SendTimer(0, env);

                // Set up a timer:within
                var compiled = env
                               .Compile("@Name('s0') select * from pattern [timer:interval(?::int minute ?::int seconds)]");

                env.Deploy(
                    compiled,
                    new DeploymentOptions().WithStatementSubstitutionParameter(
                        prepared => {
                    prepared.SetObject(1, 1);
                    prepared.SetObject(2, 2);
                }));
                env.AddListener("s0");

                SendTimer(62 * 1000 - 1, env);
                Assert.IsFalse(env.Listener("s0").IsInvoked);

                SendTimer(62 * 1000, env);
                Assert.IsTrue(env.Listener("s0").IsInvoked);

                env.UndeployAll();
            }
示例#22
0
            public void Run(RegressionEnvironment env)
            {
                var text = "@Name('s0') select A.TheString as TheString from pattern " +
                           "[every A=SupportBean(IntPrimitive=123) -> (timer:interval(30 seconds) and not SupportMarketDataBean(Volume=123, Symbol=A.TheString))]";
                env.CompileDeploy(text);

                env.AddListener("s0");

                SendTimer(0, env);
                env.SendEventBean(new SupportBean("E1", 123));

                SendTimer(10000, env);
                env.SendEventBean(new SupportBean("E2", 123));

                SendTimer(20000, env);
                env.SendEventBean(new SupportMarketDataBean("E1", 0, 123L, ""));

                SendTimer(30000, env);
                env.SendEventBean(new SupportBean("E3", 123));
                Assert.IsFalse(env.Listener("s0").IsInvoked);

                SendTimer(40000, env);
                string[] fields = {"TheString"};
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E2"});

                env.UndeployAll();
            }
            public void Run(RegressionEnvironment env)
            {
                env.CompileDeploy(
                    "@Name('s0') select *, p0simple.p1id + 1 as plusone, p0bean as mybean from WheatRoot");
                env.AddListener("s0");

                env.SendEventObjectArray(
                    new object[] {new object[] {10}, SupportBeanComplexProps.MakeDefaultBean()},
                    "WheatRoot");

                var eventBean = env.Listener("s0").AssertOneGetNewAndReset();
                //  System.out.println(SupportEventTypeAssertionUtil.print(eventBean));    comment me in
                var eventType = eventBean.EventType;
                SupportEventTypeAssertionUtil.AssertConsistency(eventType);

                // resolve property via fragment
                Assert.IsTrue(eventType.GetPropertyDescriptor("p0simple").IsFragment);
                Assert.AreEqual(11, eventBean.Get("plusone"));
                Assert.AreEqual(10, eventBean.Get("p0simple.p1id"));

                var innerSimpleEvent = (EventBean) eventBean.GetFragment("p0simple");
                Assert.AreEqual(10, innerSimpleEvent.Get("p1id"));

                var innerBeanEvent = (EventBean) eventBean.GetFragment("mybean");
                Assert.AreEqual("NestedNestedValue", innerBeanEvent.Get("Nested.NestedNested.NestedNestedValue"));
                Assert.AreEqual(
                    "NestedNestedValue",
                    ((EventBean) eventBean.GetFragment("mybean.Nested.NestedNested")).Get("NestedNestedValue"));

                env.UndeployAll();
            }
示例#24
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();

                // test wildcard
                var stmtOrigText = "@Name('insert') on SupportBean insert into AStream select *";
                env.CompileDeploy(stmtOrigText, path).AddListener("insert");

                var listeners = GetListeners(env);
                env.CompileDeploy("@Name('s0') select * from AStream", path).AddListener("s0", listeners[0]);

                SendSupportBean(env, "E1", 1);
                AssertReceivedSingle(listeners, 0, "E1");
                Assert.IsFalse(env.Listener("insert").IsInvoked);

                // test select
                stmtOrigText = "@Name('s1') on SupportBean insert into BStreamABC select 3*IntPrimitive as value";
                env.CompileDeploy(stmtOrigText, path);

                env.CompileDeploy("@Name('s2') select value from BStreamABC", path);
                env.AddListener("s2", listeners[1]);

                SendSupportBean(env, "E1", 6);
                Assert.AreEqual(18, listeners[1].AssertOneGetNewAndReset().Get("value"));

                // assert type is original type
                Assert.AreEqual(typeof(SupportBean), env.Statement("insert").EventType.UnderlyingType);
                Assert.IsFalse(env.GetEnumerator("insert").MoveNext());

                env.UndeployAll();
            }
示例#25
0
        public void Run(RegressionEnvironment env)
        {
            env.CompileDeploy(
                "@Name('s0') select MYPROPERTY, myproperty, myProperty, MyProperty from SupportBeanDupProperty");
            env.AddListener("s0");

            env.SendEventBean(new SupportBeanDupProperty("lowercamel", "uppercamel", "upper", "lower"));
            var result = env.Listener("s0").AssertOneGetNewAndReset();

            Assert.AreEqual("upper", result.Get("MYPROPERTY"));
            Assert.AreEqual("lower", result.Get("myproperty"));
            Assert.AreEqual("lowercamel", result.Get("myProperty"));
            Assert.AreEqual("uppercamel", result.Get("MyProperty"));

            env.UndeployAll();

            env.CompileDeploy(
                    "@Name('s0') select " +
                    "NESTED.NESTEDVALUE as val1, " +
                    "ARRAYPROPERTY[0] as val2, " +
                    "MAPPED('keyOne') as val3, " +
                    "INDEXED[0] as val4 " +
                    " from SupportBeanComplexProps")
                .AddListener("s0");

            env.SendEventBean(SupportBeanComplexProps.MakeDefaultBean());
            var theEvent = env.Listener("s0").AssertOneGetNewAndReset();
            Assert.AreEqual("NestedValue", theEvent.Get("val1"));
            Assert.AreEqual(10, theEvent.Get("val2"));
            Assert.AreEqual("valueOne", theEvent.Get("val3"));
            Assert.AreEqual(1, theEvent.Get("val4"));

            env.UndeployAll();
        }
示例#26
0
            public void Run(RegressionEnvironment env)
            {
                env.CompileDeploy(
                    "@Name('s0') select rectangle(One.X, One.Y, One.Width, One.Height).intersects(rectangle(Two.X, Two.Y, Two.Width, Two.Height)) as c0 from SupportSpatialDualAABB");
                env.AddListener("s0");

                // For example, in MySQL:
                // SET @g1 = ST_GeomFromText('Polygon((1 1,1 2,2 2,2 1,1 1))');
                // SET @g2 = ST_GeomFromText('Polygon((2 2,2 4,4 4,4 2,2 2))');
                // SELECT MBRIntersects(@g1,@g2), MBRIntersects(@g2,@g1);
                // includes exterior

                SendAssert(env, Rect(1, 1, 5, 5), Rect(2, 2, 2, 2), true);
                SendAssert(env, Rect(1, 1, 1, 1), Rect(2, 2, 2, 2), true);

                env.Milestone(0);

                SendAssert(env, Rect(1, 0.9999, 1, 0.99999), Rect(2, 2, 2, 2), false);
                SendAssert(env, Rect(1, 1, 1, 0.99999), Rect(2, 2, 2, 2), false);
                SendAssert(env, Rect(1, 0.9999, 1, 1), Rect(2, 2, 2, 2), false);

                SendAssert(env, Rect(4, 4, 1, 1), Rect(2, 2, 2, 2), true);
                SendAssert(env, Rect(4.0001, 4, 1, 1), Rect(2, 2, 2, 2), false);
                SendAssert(env, Rect(4, 4.0001, 1, 1), Rect(2, 2, 2, 2), false);

                env.Milestone(1);

                SendAssert(env, Rect(10, 20, 5, 5), Rect(0, 0, 50, 50), true);
                SendAssert(env, Rect(10, 20, 5, 5), Rect(20, 20, 50, 50), false);
                SendAssert(env, Rect(10, 20, 5, 5), Rect(9, 19, 1, 1), true);
                SendAssert(env, Rect(10, 20, 5, 5), Rect(15, 25, 1, 1), true);
                env.UndeployAll();
            }
示例#27
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeploy("create window MyWindow#keepall as (p0 string, p1 int);", path);
                env.CompileDeploy("create unique index MyIndex on MyWindow(p0);", path);
                env.CompileDeploy(
                    INDEX_CALLBACK_HOOK +
                    "@Name('s0') on SupportBean_S0 as S0 select p0, p1 from MyWindow as win where win.p0 = S0.P00;",
                    path);
                env.AddListener("s0");

                SupportQueryPlanIndexHook.AssertOnExprTableAndReset(
                    "MyIndex",
                    "unique hash={p0(string)} btree={} advanced={}");

                env.CompileExecuteFAF("insert into MyWindow select 'a' as p0, 1 as p1", path);

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

                env.UndeployAll();
            }
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeploy(
                    "@Name('s0') insert rstream into NextStream " +
                    "select rstream S0.TheString as TheString from SupportBean#length(3) as S0",
                    path);
                env.AddListener("s0");

                env.CompileDeploy("@Name('ii') select * from NextStream", path).AddListener("ii");

                SendEvent(env, "a", 2);
                Assert.IsFalse(env.Listener("s0").IsInvoked);
                Assert.IsFalse(env.Listener("ii").IsInvoked);

                SendEvents(env, new[] {"b", "c"});
                Assert.IsFalse(env.Listener("s0").IsInvoked);
                Assert.IsFalse(env.Listener("ii").IsInvoked);

                SendEvent(env, "d", 2);
                Assert.AreSame("a", env.Listener("s0").LastNewData[0].Get("TheString")); // receive 'a' as new data
                Assert.IsNull(env.Listener("s0").LastOldData); // receive no more old data
                Assert.AreEqual("a", env.Listener("ii").LastNewData[0].Get("TheString")); // insert into unchanged
                Assert.IsNull(env.Listener("s0").LastOldData); // receive no old data in insert into

                env.UndeployAll();
            }
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeploy(
                    "@Name('context') create context SegmentedByString partition by TheString from SupportBean",
                    path);

                string[] fields = {"TheString", "IntPrimitive", "val0"};
                env.CompileDeploy(
                    "@Name('s0') context SegmentedByString " +
                    "select TheString, IntPrimitive, (select count(*) from SupportBean_S0#keepall as S0 where sb.IntPrimitive = S0.Id) as val0 " +
                    "from SupportBean as sb",
                    path);
                env.AddListener("s0");

                env.SendEventBean(new SupportBean_S0(10, "s1"));

                env.Milestone(0);

                env.SendEventBean(new SupportBean("G1", 10));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"G1", 10, 0L});

                env.UndeployAll();
            }
示例#30
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeployWBusPublicType("create schema Geofence(x double, y double, vin string)", path);

                env.CompileDeploy(
                    "create table Regions(regionId string primary key, rx double, ry double, rwidth double, rheight double)",
                    path);
                env.CompileDeploy(
                    "create index RectangleIndex on Regions((rx, ry, rwidth, rheight) mxcifquadtree(0, 0, 10, 12))",
                    path);
                env.CompileDeploy(
                    "@Name('s0') " +
                    IndexBackingTableInfo.INDEX_CALLBACK_HOOK +
                    "on Geofence as vin insert into VINWithRegion select regionId, vin from Regions where rectangle(rx, ry, rwidth, rheight).intersects(rectangle(vin.x, vin.y, 0, 0))",
                    path);
                env.AddListener("s0");

                SupportQueryPlanIndexHook.AssertOnExprTableAndReset(
                    "RectangleIndex",
                    "non-unique hash={} btree={} advanced={mxcifquadtree(rx,ry,rwidth,rheight)}");

                env.CompileExecuteFAF("insert into Regions values ('R1', 2, 2, 5, 5)", path);
                env.SendEventMap(CollectionUtil.PopulateNameValueMap("x", 3d, "y", 3d, "vin", "V1"), "Geofence");

                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    new[] {"vin", "regionId"},
                    new object[] {"V1", "R1"});

                env.UndeployAll();
            }