Beispiel #1
0
            public void Run(RegressionEnvironment env)
            {
                EPStatementObjectModel model = new EPStatementObjectModel();
                model.SetInsertInto(InsertIntoClause.Create("ReadyStreamAvg", "line", "avgAge"));
                model.SetSelect(SelectClause.Create().Add("line").Add(Expressions.Avg("age"), "avgAge"));
                Filter filter = Filter.Create(typeof(SupportBean).FullName, Expressions.In("line", 1, 8, 10));
                model.SetFrom(FromClause.Create(FilterStream.Create(filter, "RS").AddView("time", Expressions.Constant(10))));
                model.SetWhere(Expressions.IsNotNull("waverId"));
                model.SetGroupBy(GroupByClause.Create("line"));
                model.SetHaving(Expressions.Lt(Expressions.Avg("age"), Expressions.Constant(0)));
                model.SetOutputLimit(OutputLimitClause.Create(Expressions.TimePeriod(null, null, null, 10, null)));
                model.SetOrderBy(OrderByClause.Create("line"));

                Assert.AreEqual(
                    "insert into ReadyStreamAvg(line, avgAge) select line, avg(age) as avgAge from " +
                    typeof(SupportBean).CleanName() +
                    "(line in (1,8,10))#time(10) as RS where waverId is not null group by line having avg(age)<0 output every 10.0d seconds order by line",
                    model.ToEPL());
                SerializableObjectCopier.CopyMayFail(env.Container, model);
            }
Beispiel #2
0
            public void Run(RegressionEnvironment env)
            {
                var events       = EventCollectionFactory.GetEventSetOne(0, 1000);
                var testCaseList = new CaseList();
                EventExpressionCase testCase;

                // The wait is done when 2 seconds passed
                testCase = new EventExpressionCase("timer:interval(1999 msec)");
                testCase.Add("B1");
                testCaseList.AddTest(testCase);

                var text  = "select * from pattern [timer:interval(1.999d)]";
                var model = new EPStatementObjectModel();

                model.SetSelect(SelectClause.CreateWildcard());
                PatternExpr pattern = Patterns.TimerInterval(1.999d);

                model.SetFrom(FromClause.Create(PatternStream.Create(pattern)));
                model = env.CopyMayFail(model);
                Assert.AreEqual(text, model.ToEPL());
                testCase = new EventExpressionCase(model);
                testCase.Add("B1");
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("timer:interval(2 sec)");
                testCase.Add("B1");
                testCaseList.AddTest(testCase);

                // 3 seconds (>2001 microseconds) passed
                testCase = new EventExpressionCase("timer:interval(2.001)");
                testCase.Add("C1");
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("timer:interval(2999 milliseconds)");
                testCase.Add("C1");
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("timer:interval(3 seconds)");
                testCase.Add("C1");
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("timer:interval(3.001 seconds)");
                testCase.Add("B2");
                testCaseList.AddTest(testCase);

                // Try with an all ... repeated timer every 3 seconds
                testCase = new EventExpressionCase("every timer:interval(3.001 sec)");
                testCase.Add("B2");
                testCase.Add("F1");
                testCase.Add("D3");
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("every timer:interval(5000 msec)");
                testCase.Add("A2");
                testCase.Add("B3");
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("timer:interval(3.999 second) -> b=SupportBean_B");
                testCase.Add("B2", "b", events.GetEvent("B2"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("timer:interval(4 sec) -> b=SupportBean_B");
                testCase.Add("B2", "b", events.GetEvent("B2"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("timer:interval(4.001 sec) -> b=SupportBean_B");
                testCase.Add("B3", "b", events.GetEvent("B3"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("timer:interval(0) -> b=SupportBean_B");
                testCase.Add("B1", "b", events.GetEvent("B1"));
                testCaseList.AddTest(testCase);

                // Try with an followed-by as a second argument
                testCase = new EventExpressionCase("b=SupportBean_B -> timer:interval(0.001)");
                testCase.Add("C1", "b", events.GetEvent("B1"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("b=SupportBean_B -> timer:interval(0)");
                testCase.Add("B1", "b", events.GetEvent("B1"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("b=SupportBean_B -> timer:interval(1 sec)");
                testCase.Add("C1", "b", events.GetEvent("B1"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("b=SupportBean_B -> timer:interval(1.001)");
                testCase.Add("B2", "b", events.GetEvent("B1"));
                testCaseList.AddTest(testCase);

                // Try in a 3-way followed by
                testCase = new EventExpressionCase("b=SupportBean_B() -> timer:interval(6.000) -> d=SupportBean_D");
                testCase.Add("D2", "b", events.GetEvent("B1"), "d", events.GetEvent("D2"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase(
                    "every (b=SupportBean_B() -> timer:interval(2.001) -> d=SupportBean_D())");
                testCase.Add("D1", "b", events.GetEvent("B1"), "d", events.GetEvent("D1"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase(
                    "every (b=SupportBean_B() -> timer:interval(2.000) -> d=SupportBean_D())");
                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);

                // Try with an "or"
                testCase = new EventExpressionCase("b=SupportBean_B() or timer:interval(1.001)");
                testCase.Add("B1");
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("b=SupportBean_B() or timer:interval(2.001)");
                testCase.Add("B1", "b", events.GetEvent("B1"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("b=SupportBean_B(Id='B3') or timer:interval(8.500)");
                testCase.Add("D2");
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("timer:interval(8.500) or timer:interval(7.500)");
                testCase.Add("F1");
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("timer:interval(999999 msec) or g=SupportBean_G");
                testCase.Add("G1", "g", events.GetEvent("G1"));
                testCaseList.AddTest(testCase);

                // Try with an "and"
                testCase = new EventExpressionCase("b=SupportBean_B() and timer:interval(4000 msec)");
                testCase.Add("B2", "b", events.GetEvent("B1"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("b=SupportBean_B() and timer:interval(4001 msec)");
                testCase.Add("A2", "b", events.GetEvent("B1"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("timer:interval(9999999 msec) and b=SupportBean_B");
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("timer:interval(1 msec) and b=SupportBean_B(Id='B2')");
                testCase.Add("B2", "b", events.GetEvent("B2"));
                testCaseList.AddTest(testCase);

                // Try with an "within"
                testCase = new EventExpressionCase("timer:interval(3.000) where timer:within(2.000)");
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("timer:interval(3.000) where timer:within (3.000)");
                testCaseList.AddTest(testCase);

                // Run all tests
                var util = new PatternTestHarness(events, testCaseList, GetType());

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

                testCase = new EventExpressionCase("b=SupportBean_B(Id='B1') where timer:within(2 sec)");
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("b=SupportBean_B(Id='B1') where timer:within(2001 msec)");
                testCase.Add("B1", "b", events.GetEvent("B1"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("b=SupportBean_B(Id='B1') where timer:within(1999 msec)");
                testCaseList.AddTest(testCase);

                var text  = "select * from pattern [b=SupportBean_B(Id=\"B3\") where timer:within(10.001d)]";
                var model = new EPStatementObjectModel();

                model.SetSelect(SelectClause.CreateWildcard());
                model = env.CopyMayFail(model);
                Expression  filter  = Expressions.Eq("Id", "B3");
                PatternExpr pattern = Patterns.TimerWithin(
                    10.001,
                    Patterns.Filter(Filter.Create("SupportBean_B", filter), "b"));

                model.SetFrom(FromClause.Create(PatternStream.Create(pattern)));
                Assert.AreEqual(text, model.ToEPL());
                testCase = new EventExpressionCase(model);
                testCase.Add("B3", "b", events.GetEvent("B3"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("b=SupportBean_B(Id='B3') where timer:within(10001 msec)");
                testCase.Add("B3", "b", events.GetEvent("B3"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("b=SupportBean_B(Id='B3') where timer:within(10 sec)");
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("b=SupportBean_B(Id='B3') where timer:within(9.999)");
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("(every b=SupportBean_B) where timer:within(2.001)");
                testCase.Add("B1", "b", events.GetEvent("B1"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("(every b=SupportBean_B) where timer:within(4.001)");
                testCase.Add("B1", "b", events.GetEvent("B1"));
                testCase.Add("B2", "b", events.GetEvent("B2"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("every b=SupportBean_B where timer:within(2.001)");
                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 where timer:within(2001 msec))");
                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 ((every b=SupportBean_B) where timer:within(2.001))");
                testCase.Add("B1", "b", events.GetEvent("B1"));
                testCase.Add("B2", "b", events.GetEvent("B2"));
                testCase.Add("B2", "b", events.GetEvent("B2"));
                testCase.Add("B3", "b", events.GetEvent("B3"));
                testCase.Add("B3", "b", events.GetEvent("B3"));
                testCase.Add("B3", "b", events.GetEvent("B3"));
                testCase.Add("B3", "b", events.GetEvent("B3"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("every ((every b=SupportBean_B) where timer:within(6.001))");
                testCase.Add("B1", "b", events.GetEvent("B1"));
                testCase.Add("B2", "b", events.GetEvent("B2"));
                testCase.Add("B2", "b", events.GetEvent("B2"));
                testCase.Add("B3", "b", events.GetEvent("B3"));
                testCase.Add("B3", "b", events.GetEvent("B3"));
                testCase.Add("B3", "b", events.GetEvent("B3"));
                testCase.Add("B3", "b", events.GetEvent("B3"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("(every b=SupportBean_B) where timer:within(11.001)");
                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) where timer:within(4001 milliseconds)");
                testCase.Add("B1", "b", events.GetEvent("B1"));
                testCase.Add("B2", "b", events.GetEvent("B2"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("every (b=SupportBean_B) where timer:within(6.001)");
                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(
                    "b=SupportBean_B -> d=SupportBean_D where timer:within(4001 milliseconds)");
                testCase.Add("D1", "b", events.GetEvent("B1"), "d", events.GetEvent("D1"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("b=SupportBean_B() -> d=SupportBean_D() where timer:within(4 sec)");
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase(
                    "every (b=SupportBean_B() where timer:within (4.001) and d=SupportBean_D() where timer:within(6.001))");
                testCase.Add("D1", "b", events.GetEvent("B1"), "d", events.GetEvent("D1"));
                testCase.Add("B3", "b", events.GetEvent("B3"), "d", events.GetEvent("D2"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase(
                    "b=SupportBean_B() where timer:within (2001 msec) and d=SupportBean_D() where timer:within(6001 msec)");
                testCase.Add("D1", "b", events.GetEvent("B1"), "d", events.GetEvent("D1"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase(
                    "b=SupportBean_B() where timer:within (2001 msec) and d=SupportBean_D() where timer:within(6000 msec)");
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase(
                    "b=SupportBean_B() where timer:within (2000 msec) and d=SupportBean_D() where timer:within(6001 msec)");
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase(
                    "every b=SupportBean_B -> d=SupportBean_D where timer:within(4000 msec)");
                testCase.Add("D1", "b", events.GetEvent("B2"), "d", events.GetEvent("D1"));
                testCase.Add("D3", "b", events.GetEvent("B3"), "d", events.GetEvent("D3"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase(
                    "every b=SupportBean_B() -> every d=SupportBean_D where timer:within(4000 msec)");
                testCase.Add("D1", "b", events.GetEvent("B1"), "d", events.GetEvent("D1"));
                testCase.Add("D1", "b", events.GetEvent("B2"), "d", events.GetEvent("D1"));
                testCase.Add("D2", "b", events.GetEvent("B1"), "d", events.GetEvent("D2"));
                testCase.Add("D2", "b", events.GetEvent("B2"), "d", events.GetEvent("D2"));
                testCase.Add("D3", "b", events.GetEvent("B1"), "d", events.GetEvent("D3"));
                testCase.Add("D3", "b", events.GetEvent("B2"), "d", events.GetEvent("D3"));
                testCase.Add("D3", "b", events.GetEvent("B3"), "d", events.GetEvent("D3"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase(
                    "b=SupportBean_B() -> d=SupportBean_D() where timer:within(3999 msec)");
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase(
                    "every b=SupportBean_B() -> (every d=SupportBean_D) where timer:within(2001 msec)");
                testCase.Add("D1", "b", events.GetEvent("B2"), "d", events.GetEvent("D1"));
                testCase.Add("D3", "b", events.GetEvent("B3"), "d", events.GetEvent("D3"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase(
                    "every (b=SupportBean_B() -> d=SupportBean_D()) where timer:within(6001 msec)");
                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);

                testCase = new EventExpressionCase(
                    "b=SupportBean_B() where timer:within (2000 msec) or d=SupportBean_D() where timer:within(6000 msec)");
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase(
                    "(b=SupportBean_B() where timer:within (2000 msec) or d=SupportBean_D() where timer:within(6000 msec)) where timer:within (1999 msec)");
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase(
                    "every (b=SupportBean_B() where timer:within (2001 msec) and d=SupportBean_D() where timer:within(6001 msec))");
                testCase.Add("D1", "b", events.GetEvent("B1"), "d", events.GetEvent("D1"));
                testCase.Add("B3", "b", events.GetEvent("B3"), "d", events.GetEvent("D2"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase(
                    "b=SupportBean_B() where timer:within (2001 msec) or d=SupportBean_D() where timer:within(6001 msec)");
                testCase.Add("B1", "b", events.GetEvent("B1"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase(
                    "b=SupportBean_B() where timer:within (2000 msec) or d=SupportBean_D() where timer:within(6001 msec)");
                testCase.Add("D1", "d", events.GetEvent("D1"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase(
                    "every b=SupportBean_B() where timer:within (2001 msec) and every d=SupportBean_D() where timer:within(6001 msec)");
                testCase.Add("D1", "b", events.GetEvent("B1"), "d", events.GetEvent("D1"));
                testCase.Add("D1", "b", events.GetEvent("B2"), "d", events.GetEvent("D1"));
                testCase.Add("D2", "b", events.GetEvent("B1"), "d", events.GetEvent("D2"));
                testCase.Add("D2", "b", events.GetEvent("B2"), "d", events.GetEvent("D2"));
                testCase.Add("B3", "b", events.GetEvent("B3"), "d", events.GetEvent("D1"));
                testCase.Add("B3", "b", events.GetEvent("B3"), "d", events.GetEvent("D2"));
                testCase.Add("D3", "b", events.GetEvent("B1"), "d", events.GetEvent("D3"));
                testCase.Add("D3", "b", events.GetEvent("B2"), "d", events.GetEvent("D3"));
                testCase.Add("D3", "b", events.GetEvent("B3"), "d", events.GetEvent("D3"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase(
                    "(every b=SupportBean_B) where timer:within (2000 msec) and every d=SupportBean_D() where timer:within(6001 msec)");
                testCaseList.AddTest(testCase);

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

                util.RunTest(env);
            }