Beispiel #1
0
        public void TestIndexedValuePropOM()
        {
            var epService = EPServiceProviderManager.GetDefaultProvider(SupportConfigFactory.GetConfiguration());

            epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(epService, GetType(), GetType().FullName);
            }

            var type = typeof(SupportBeanComplexProps).FullName;

            var model = new EPStatementObjectModel();

            model.SelectClause = SelectClause.CreateWildcard();
            PatternExpr pattern = Patterns.FollowedBy(Patterns.EveryFilter(type, "a"),
                                                      Patterns.Filter(Filter.Create(type, Expressions.EqProperty("Indexed[0]", "a.Indexed[0]")), "b"));

            model.FromClause = FromClause.Create(PatternStream.Create(pattern));
            model            = (EPStatementObjectModel)SerializableObjectCopier.Copy(model);

            var patternText = "select * from pattern [every a=" + type + " -> b=" + type + "(Indexed[0]=a.Indexed[0])]";

            Assert.AreEqual(patternText, model.ToEPL());

            var stmt = epService.EPAdministrator.Create(model);

            RunIndexedValueProp(epService, stmt);

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.EndTest();
            }
        }
Beispiel #2
0
        private void RunAssertionWhere_OM(EPServiceProvider epService)
        {
            var model = new EPStatementObjectModel();

            model.SelectClause = SelectClause.Create()
                                 .AddWithAsProvidedName("s0.id", "idS0").AddWithAsProvidedName("s1.id", "idS1");
            PatternExpr pattern = Patterns.Or()
                                  .Add(Patterns.EveryFilter(typeof(SupportBean_S0).FullName, "s0"))
                                  .Add(Patterns.EveryFilter(typeof(SupportBean_S1).FullName, "s1")
                                       );

            model.FromClause  = FromClause.Create(PatternStream.Create(pattern));
            model.WhereClause = Expressions.Or()
                                .Add(Expressions.And()
                                     .Add(Expressions.IsNotNull("s0.id"))
                                     .Add(Expressions.Lt("s0.id", 100))
                                     )
                                .Add(Expressions.And()
                                     .Add(Expressions.IsNotNull("s1.id"))
                                     .Add(Expressions.Ge("s1.id", 100))
                                     );
            model = (EPStatementObjectModel)SerializableObjectCopier.Copy(epService.Container, model);

            string reverse  = model.ToEPL();
            string stmtText = "select s0.id as idS0, s1.id as idS1 " +
                              "from pattern [every s0=" + typeof(SupportBean_S0).FullName +
                              " or every s1=" + typeof(SupportBean_S1).FullName + "] " +
                              "where s0.id is not null and s0.id<100 or s1.id is not null and s1.id>=100";

            Assert.AreEqual(stmtText, reverse);

            EPStatement statement      = epService.EPAdministrator.Create(model);
            var         updateListener = new SupportUpdateListener();

            statement.Events += updateListener.Update;

            SendEventS0(epService, 1);
            AssertEventIds(updateListener, 1, null);

            SendEventS0(epService, 101);
            Assert.IsFalse(updateListener.IsInvoked);

            SendEventS1(epService, 1);
            Assert.IsFalse(updateListener.IsInvoked);

            SendEventS1(epService, 100);
            AssertEventIds(updateListener, null, 100);

            statement.Dispose();
        }
Beispiel #3
0
            public void Run(RegressionEnvironment env)
            {
                var model = new EPStatementObjectModel();
                model.SelectClause = SelectClause.Create()
                    .AddWithAsProvidedName("S0.Id", "idS0")
                    .AddWithAsProvidedName("S1.Id", "idS1");
                PatternExpr pattern = Patterns.Or()
                    .Add(Patterns.EveryFilter("SupportBean_S0", "S0"))
                    .Add(
                        Patterns.EveryFilter("SupportBean_S1", "S1")
                    );
                model.FromClause = FromClause.Create(PatternStream.Create(pattern));
                model.WhereClause = Expressions.Or()
                    .Add(
                        Expressions.And()
                            .Add(Expressions.IsNotNull("S0.Id"))
                            .Add(Expressions.Lt("S0.Id", 100))
                    )
                    .Add(
                        Expressions.And()
                            .Add(Expressions.IsNotNull("S1.Id"))
                            .Add(Expressions.Ge("S1.Id", 100))
                    );
                model = env.CopyMayFail(model);

                var reverse = model.ToEPL();
                var stmtText = "select S0.Id as idS0, S1.Id as idS1 " +
                               "from pattern [every S0=SupportBean_S0" +
                               " or every S1=SupportBean_S1] " +
                               "where S0.Id is not null and S0.Id<100 or S1.Id is not null and S1.Id>=100";
                Assert.AreEqual(stmtText, reverse);

                model.Annotations = Collections.SingletonList(AnnotationPart.NameAnnotation("s0"));
                env.CompileDeploy(model).AddListener("s0");

                SendEventS0(env, 1);
                AssertEventIds(env, 1, null);

                SendEventS0(env, 101);
                Assert.IsFalse(env.Listener("s0").IsInvoked);

                SendEventS1(env, 1);
                Assert.IsFalse(env.Listener("s0").IsInvoked);

                SendEventS1(env, 100);
                AssertEventIds(env, null, 100);

                env.UndeployAll();
            }
Beispiel #4
0
        private void RunAssertionIndexedValuePropOM(EPServiceProvider epService)
        {
            string type = typeof(SupportBeanComplexProps).FullName;

            var model = new EPStatementObjectModel();

            model.SelectClause = SelectClause.CreateWildcard();
            PatternExpr pattern = Patterns.FollowedBy(Patterns.EveryFilter(type, "a"),
                                                      Patterns.Filter(Filter.Create(type, Expressions.EqProperty("Indexed[0]", "a.Indexed[0]")), "b"));

            model.FromClause = FromClause.Create(PatternStream.Create(pattern));
            model            = (EPStatementObjectModel)SerializableObjectCopier.Copy(epService.Container, model);

            string patternText = "select * from pattern [every a=" + type + " -> b=" + type + "(Indexed[0]=a.Indexed[0])]";

            Assert.AreEqual(patternText, model.ToEPL());

            EPStatement stmt = epService.EPAdministrator.Create(model);

            RunIndexedValueProp(epService, stmt);
            stmt.Dispose();
        }
Beispiel #5
0
            public void Run(RegressionEnvironment env)
            {
                var type = typeof(SupportBeanComplexProps).Name;

                var model = new EPStatementObjectModel();
                model.SelectClause = SelectClause.CreateWildcard();
                PatternExpr pattern = Patterns.FollowedBy(
                    Patterns.EveryFilter(type, "a"),
                    Patterns.Filter(Filter.Create(type, Expressions.EqProperty("Indexed[0]", "a.Indexed[0]")), "b"));
                model.FromClause = FromClause.Create(PatternStream.Create(pattern));
                model = env.CopyMayFail(model);

                var patternText = "select * from pattern [every a=" +
                                  type +
                                  " -> b=" +
                                  type +
                                  "(Indexed[0]=a.Indexed[0])]";
                Assert.AreEqual(patternText, model.ToEPL());

                model.Annotations = Collections.SingletonList(AnnotationPart.NameAnnotation("s0"));
                env.CompileDeploy(model).AddListener("s0");
                RunIndexedValueProp(env);
                env.UndeployAll();
            }
Beispiel #6
0
        private void RunAssertionOp(EPServiceProvider epService)
        {
            EventCollection     events       = EventCollectionFactory.GetEventSetOne(0, 1000);
            var                 testCaseList = new CaseList();
            EventExpressionCase testCase;

            testCase = new EventExpressionCase("b=" + EVENT_B_CLASS + " and not d=" + EVENT_D_CLASS);
            testCase.Add("B1", "b", events.GetEvent("B1"));
            testCaseList.AddTest(testCase);

            string text  = "select * from pattern [every b=" + EVENT_B_CLASS + " and not g=" + EVENT_G_CLASS + "]";
            var    model = new EPStatementObjectModel();

            model.SelectClause = SelectClause.CreateWildcard();
            PatternExpr pattern = Patterns.And()
                                  .Add(Patterns.EveryFilter(EVENT_B_CLASS, "b"))
                                  .Add(Patterns.NotFilter(EVENT_G_CLASS, "g"));

            model.FromClause = FromClause.Create(PatternStream.Create(pattern));
            model            = (EPStatementObjectModel)SerializableObjectCopier.Copy(epService.Container, model);
            Assert.AreEqual(text, model.ToEPL());
            testCase = new EventExpressionCase(model);
            testCase.Add("B1", "b", events.GetEvent("B1"));
            testCase.Add("B2", "b", events.GetEvent("B2"));
            testCase.Add("B3", "b", events.GetEvent("B3"));
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("every b=" + EVENT_B_CLASS + " and not g=" + EVENT_G_CLASS);
            testCase.Add("B1", "b", events.GetEvent("B1"));
            testCase.Add("B2", "b", events.GetEvent("B2"));
            testCase.Add("B3", "b", events.GetEvent("B3"));
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("every b=" + EVENT_B_CLASS + " and not d=" + EVENT_D_CLASS);
            testCase.Add("B1", "b", events.GetEvent("B1"));
            testCase.Add("B2", "b", events.GetEvent("B2"));
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("b=" + EVENT_B_CLASS + " and not a=" + EVENT_A_CLASS + "(id='A1')");
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("b=" + EVENT_B_CLASS + " and not a2=" + EVENT_A_CLASS + "(id='A2')");
            testCase.Add("B1", "b", events.GetEvent("B1"));
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("every (b=" + EVENT_B_CLASS + " and not b3=" + EVENT_B_CLASS + "(id='B3'))");
            testCase.Add("B1", "b", events.GetEvent("B1"));
            testCase.Add("B2", "b", events.GetEvent("B2"));
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("every (b=" + EVENT_B_CLASS + " or not " + EVENT_D_CLASS + "())");
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("every (every b=" + EVENT_B_CLASS + " and not " + EVENT_B_CLASS + "(id='B2'))");
            testCase.Add("B1", "b", events.GetEvent("B1"));
            testCase.Add("B3", "b", events.GetEvent("B3"));
            testCase.Add("B3", "b", events.GetEvent("B3"));
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("every (b=" + EVENT_B_CLASS + " and not " + EVENT_B_CLASS + "(id='B2'))");
            testCase.Add("B1", "b", events.GetEvent("B1"));
            testCase.Add("B3", "b", events.GetEvent("B3"));
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("(b=" + EVENT_B_CLASS + " -> d=" + EVENT_D_CLASS + ") and " +
                                               " not " + EVENT_A_CLASS);
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("(b=" + EVENT_B_CLASS + " -> d=" + EVENT_D_CLASS + ") and " +
                                               " not " + EVENT_G_CLASS);
            testCase.Add("D1", "b", events.GetEvent("B1"), "d", events.GetEvent("D1"));
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("every (b=" + EVENT_B_CLASS + " -> d=" + EVENT_D_CLASS + ") and " +
                                               " not " + EVENT_G_CLASS);
            testCase.Add("D1", "b", events.GetEvent("B1"), "d", events.GetEvent("D1"));
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("every (b=" + EVENT_B_CLASS + " -> d=" + EVENT_D_CLASS + ") and " +
                                               " not " + EVENT_G_CLASS + "(id='x')");
            testCase.Add("D1", "b", events.GetEvent("B1"), "d", events.GetEvent("D1"));
            testCase.Add("D3", "b", events.GetEvent("B3"), "d", events.GetEvent("D3"));
            testCaseList.AddTest(testCase);

            var util = new PatternTestHarness(events, testCaseList, this.GetType());

            util.RunTest(epService);
        }
Beispiel #7
0
            public void Run(RegressionEnvironment env)
            {
                var events = EventCollectionFactory.GetEventSetOne(0, 1000);
                var testCaseList = new CaseList();
                EventExpressionCase testCase;

                testCase = new EventExpressionCase("b=SupportBean_B and not d=SupportBean_D");
                testCase.Add("B1", "b", events.GetEvent("B1"));
                testCaseList.AddTest(testCase);

                var text = "select * from pattern [every b=SupportBean_B and not g=SupportBean_G]";
                var model = new EPStatementObjectModel();
                model.SelectClause = SelectClause.CreateWildcard();
                PatternExpr pattern = Patterns.And()
                    .Add(Patterns.EveryFilter("SupportBean_B", "b"))
                    .Add(Patterns.NotFilter("SupportBean_G", "g"));
                model.FromClause = FromClause.Create(PatternStream.Create(pattern));
                model = env.CopyMayFail(model);
                Assert.AreEqual(text, model.ToEPL());
                testCase = new EventExpressionCase(model);
                testCase.Add("B1", "b", events.GetEvent("B1"));
                testCase.Add("B2", "b", events.GetEvent("B2"));
                testCase.Add("B3", "b", events.GetEvent("B3"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("every b=SupportBean_B and not g=SupportBean_G");
                testCase.Add("B1", "b", events.GetEvent("B1"));
                testCase.Add("B2", "b", events.GetEvent("B2"));
                testCase.Add("B3", "b", events.GetEvent("B3"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("every b=SupportBean_B and not d=SupportBean_D");
                testCase.Add("B1", "b", events.GetEvent("B1"));
                testCase.Add("B2", "b", events.GetEvent("B2"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("b=SupportBean_B and not a=SupportBean_A(Id='A1')");
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("b=SupportBean_B and not a2=SupportBean_A(Id='A2')");
                testCase.Add("B1", "b", events.GetEvent("B1"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("every (b=SupportBean_B and not b3=SupportBean_B(Id='B3'))");
                testCase.Add("B1", "b", events.GetEvent("B1"));
                testCase.Add("B2", "b", events.GetEvent("B2"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("every (b=SupportBean_B or not SupportBean_D())");
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("every (every b=SupportBean_B and not SupportBean_B(Id='B2'))");
                testCase.Add("B1", "b", events.GetEvent("B1"));
                testCase.Add("B3", "b", events.GetEvent("B3"));
                testCase.Add("B3", "b", events.GetEvent("B3"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("every (b=SupportBean_B and not SupportBean_B(Id='B2'))");
                testCase.Add("B1", "b", events.GetEvent("B1"));
                testCase.Add("B3", "b", events.GetEvent("B3"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase(
                    "(b=SupportBean_B -> d=SupportBean_D) and " +
                    " not SupportBean_A");
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase(
                    "(b=SupportBean_B -> d=SupportBean_D) and " +
                    " not SupportBean_G");
                testCase.Add("D1", "b", events.GetEvent("B1"), "d", events.GetEvent("D1"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase(
                    "every (b=SupportBean_B -> d=SupportBean_D) and " +
                    " not SupportBean_G");
                testCase.Add("D1", "b", events.GetEvent("B1"), "d", events.GetEvent("D1"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase(
                    "every (b=SupportBean_B -> d=SupportBean_D) and " +
                    " not SupportBean_G(Id='x')");
                testCase.Add("D1", "b", events.GetEvent("B1"), "d", events.GetEvent("D1"));
                testCase.Add("D3", "b", events.GetEvent("B3"), "d", events.GetEvent("D3"));
                testCaseList.AddTest(testCase);

                var util = new PatternTestHarness(events, testCaseList, GetType());
                util.RunTest(env);
            }