Пример #1
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                var stmtOrigText = "@Name('split') on SupportBean " +
                                   "insert into AStream2SP select * where IntPrimitive=1 " +
                                   "insert into BStream2SP select * where IntPrimitive=1 or IntPrimitive=2";
                env.CompileDeploy(stmtOrigText, path).AddListener("split");
                TryAssertion(env, path);
                path.Clear();

                // statement object model
                var model = new EPStatementObjectModel();
                model.Annotations = Collections.SingletonList(new AnnotationPart("Audit"));
                model.FromClause = FromClause.Create(FilterStream.Create("SupportBean"));
                model.InsertInto = InsertIntoClause.Create("AStream2SP");
                model.SelectClause = SelectClause.CreateWildcard();
                model.WhereClause = Expressions.Eq("IntPrimitive", 1);
                var clause = OnClause.CreateOnInsertSplitStream();
                model.OnExpr = clause;
                var item = OnInsertSplitStreamItem.Create(
                    InsertIntoClause.Create("BStream2SP"),
                    SelectClause.CreateWildcard(),
                    Expressions.Or(Expressions.Eq("IntPrimitive", 1), Expressions.Eq("IntPrimitive", 2)));
                clause.AddItem(item);
                model.Annotations = Collections.SingletonList(AnnotationPart.NameAnnotation("split"));
                Assert.AreEqual(stmtOrigText, model.ToEPL());
                env.CompileDeploy(model, path).AddListener("split");
                TryAssertion(env, path);
                path.Clear();

                env.EplToModelCompileDeploy(stmtOrigText, path).AddListener("split");
                TryAssertion(env, path);
            }
Пример #2
0
        private void RunAssertionJoinUniquePerIdOM(EPServiceProvider epService)
        {
            var model = new EPStatementObjectModel();

            model.SelectClause = SelectClause.CreateWildcard();
            FromClause fromClause = FromClause.Create(
                FilterStream.Create(EVENT_A, "streamA").AddView(View.Create("length", Expressions.Constant(3))),
                FilterStream.Create(EVENT_B, "streamB").AddView(View.Create("length", Expressions.Constant(3))),
                FilterStream.Create(EVENT_C, "streamC").AddView(View.Create("length", Expressions.Constant(3))));

            model.FromClause  = fromClause;
            model.WhereClause = Expressions.And(
                Expressions.EqProperty("streamA.id", "streamB.id"),
                Expressions.EqProperty("streamB.id", "streamC.id"),
                Expressions.EqProperty("streamA.id", "streamC.id"));
            model = (EPStatementObjectModel)SerializableObjectCopier.Copy(epService.Container, model);

            string epl = "select * from " +
                         EVENT_A + "#length(3) as streamA, " +
                         EVENT_B + "#length(3) as streamB, " +
                         EVENT_C + "#length(3) as streamC " +
                         "where streamA.id=streamB.id " +
                         "and streamB.id=streamC.id " +
                         "and streamA.id=streamC.id";

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

            stmt.Events += updateListener.Update;
            Assert.AreEqual(epl, model.ToEPL());

            RunJoinUniquePerId(epService, updateListener);

            stmt.Dispose();
        }
Пример #3
0
            public void Run(RegressionEnvironment env)
            {
                var model = new EPStatementObjectModel();
                model.SelectClause = SelectClause.CreateWildcard()
                    .Add(Expressions.Concat("MyString", "MyString"), "concat");
                model.FromClause =
                    FromClause.Create(
                        FilterStream.Create("SupportBeanSimple")
                            .AddView(View.Create("length", Expressions.Constant(5))));
                model = env.CopyMayFail(model);

                var text = "select *, MyString||MyString as concat from SupportBeanSimple#length(5)";
                Assert.AreEqual(text, model.ToEPL());
                model.Annotations = Collections.SingletonList(AnnotationPart.NameAnnotation("s0"));
                env.CompileDeploy(model).AddListener("s0");

                AssertSimple(env);

                CollectionAssert.AreEquivalent(
                    new EventPropertyDescriptor[] {
                        new EventPropertyDescriptor("MyString", typeof(string), typeof(char), false, false, true, false, false),
                        new EventPropertyDescriptor("MyInt", typeof(int), null, false, false, false, false, false),
                        new EventPropertyDescriptor("concat", typeof(string), typeof(char), false, false, true, false, false)
                    },
                    env.Statement("s0").EventType.PropertyDescriptors);

                env.UndeployAll();
            }
Пример #4
0
        private void RunAssertionBeanEventWildcardSODA(EPServiceProvider epService)
        {
            var         fields        = new string[] { "id" };
            string      statementText = "select distinct * from SupportBean_A#keepall";
            EPStatement stmt          = epService.EPAdministrator.CreateEPL(statementText);
            var         listener      = new SupportUpdateListener();

            stmt.Events += listener.Update;

            epService.EPRuntime.SendEvent(new SupportBean_A("E1"));
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1" } });

            epService.EPRuntime.SendEvent(new SupportBean_A("E2"));
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1" }, new object[] { "E2" } });

            epService.EPRuntime.SendEvent(new SupportBean_A("E1"));
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1" }, new object[] { "E2" } });

            EPStatementObjectModel model = epService.EPAdministrator.CompileEPL(statementText);

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

            model = new EPStatementObjectModel();
            model.SelectClause = SelectClause.CreateWildcard().Distinct(true);
            model.FromClause   = FromClause.Create(FilterStream.Create("SupportBean_A"));
            Assert.AreEqual("select distinct * from SupportBean_A", model.ToEPL());

            stmt.Dispose();
        }
Пример #5
0
            public void Run(RegressionEnvironment env)
            {
                var model = new EPStatementObjectModel();
                model.SelectClause = SelectClause.CreateWildcard();
                var fromClause = FromClause.Create(
                    FilterStream.Create("SupportBean_A", "streamA")
                        .AddView(View.Create("length", Expressions.Constant(3))),
                    FilterStream.Create("SupportBean_B", "streamB")
                        .AddView(View.Create("length", Expressions.Constant(3))),
                    FilterStream.Create("SupportBean_C", "streamC")
                        .AddView(View.Create("length", Expressions.Constant(3))));
                model.FromClause = fromClause;
                model.WhereClause = Expressions.And(
                    Expressions.EqProperty("streamA.Id", "streamB.Id"),
                    Expressions.EqProperty("streamB.Id", "streamC.Id"),
                    Expressions.EqProperty("streamA.Id", "streamC.Id"));
                model = env.CopyMayFail(model);

                var epl = "select * from " +
                          "SupportBean_A#length(3) as streamA, " +
                          "SupportBean_B#length(3) as streamB, " +
                          "SupportBean_C#length(3) as streamC " +
                          "where streamA.Id=streamB.Id " +
                          "and streamB.Id=streamC.Id " +
                          "and streamA.Id=streamC.Id";
                Assert.AreEqual(epl, model.ToEPL());

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

                RunJoinUniquePerId(env);

                env.UndeployAll();
            }
Пример #6
0
        public void TestOutputCrontabAtOMCreate()
        {
            // every 15 minutes 8am to 5pm
            SendTimeEvent(1, 17, 10, 0, 0);
            var expression = "select * from MarketData.std:lastevent() output at (*/15, 8:17, *, *, *)";

            var model = new EPStatementObjectModel();

            model.SelectClause = SelectClause.CreateWildcard();
            model.FromClause   = FromClause.Create(FilterStream.Create("MarketData").AddView("std", "lastevent"));
            var crontabParams = new Expression[] {
                Expressions.CrontabScheduleFrequency(15),
                Expressions.CrontabScheduleRange(8, 17),
                Expressions.CrontabScheduleWildcard(),
                Expressions.CrontabScheduleWildcard(),
                Expressions.CrontabScheduleWildcard()
            };

            model.OutputLimitClause = OutputLimitClause.CreateSchedule(crontabParams);

            var epl = model.ToEPL();

            Assert.AreEqual(expression, epl);
            var stmt = _epService.EPAdministrator.Create(model);

            stmt.AddListener(_listener);
            RunAssertionCrontab(1, stmt);
        }
Пример #7
0
        public void TestNotExists_OM()
        {
            EPStatementObjectModel subquery = new EPStatementObjectModel();

            subquery.SelectClause = SelectClause.CreateWildcard();
            subquery.FromClause   = FromClause.Create(FilterStream.Create("S1").AddView("win", "length", Expressions.Constant(1000)));

            EPStatementObjectModel model = new EPStatementObjectModel();

            model.SelectClause = SelectClause.Create("id");
            model.FromClause   = FromClause.Create(FilterStream.Create("S0"));
            model.WhereClause  = Expressions.Not(Expressions.SubqueryExists(subquery));
            model = (EPStatementObjectModel)SerializableObjectCopier.Copy(model);

            String stmtText = "select id from S0 where not exists (select * from S1.win:length(1000))";

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

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

            stmt.Events += listener.Update;

            epService.EPRuntime.SendEvent(new SupportBean_S0(2));
            Assert.AreEqual(2, listener.AssertOneGetNewAndReset().Get("id"));

            epService.EPRuntime.SendEvent(new SupportBean_S1(-1));
            epService.EPRuntime.SendEvent(new SupportBean_S0(1));
            Assert.IsFalse(listener.IsInvoked);

            epService.EPRuntime.SendEvent(new SupportBean_S1(-2));
            epService.EPRuntime.SendEvent(new SupportBean_S0(3));
            Assert.IsFalse(listener.IsInvoked);
        }
Пример #8
0
        public void TestSingleOM()
        {
            String eventName = typeof(SupportBeanSimple).FullName;

            EPStatementObjectModel model = new EPStatementObjectModel();

            model.SelectClause = SelectClause.CreateWildcard().Add(Expressions.Concat("MyString", "MyString"), "concat");
            model.FromClause   = FromClause.Create(FilterStream.Create(eventName).AddView(View.Create("win", "length", Expressions.Constant(5))));
            model = (EPStatementObjectModel)SerializableObjectCopier.Copy(model);

            String text = "select *, MyString||MyString as concat from " + eventName + ".win:length(5)";

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

            EPStatement statement = _epService.EPAdministrator.Create(model);

            statement.Events += _listener.Update;
            AssertSimple();

            EPAssertionUtil.AssertEqualsAnyOrder(new[] {
                new EventPropertyDescriptor("MyString", typeof(string), typeof(char), false, false, true, false, false),
                new EventPropertyDescriptor("MyInt", typeof(int), null, false, false, false, false, false),
                new EventPropertyDescriptor("concat", typeof(string), typeof(char), false, false, true, false, false),
            }, statement.EventType.PropertyDescriptors);
        }
Пример #9
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();
            }
        }
Пример #10
0
            public void Run(RegressionEnvironment env)
            {
                // every 15 minutes 8am to 5pm
                SendTimeEvent(env, 1, 17, 10, 0, 0);
                var expression = "select * from SupportMarketDataBean#lastevent output at (*/15, 8:17, *, *, *)";

                var model = new EPStatementObjectModel();
                model.SelectClause = SelectClause.CreateWildcard();
                model.FromClause = FromClause.Create(FilterStream.Create("SupportMarketDataBean").AddView("lastevent"));
                Expression[] crontabParams = {
                    Expressions.CrontabScheduleFrequency(15),
                    Expressions.CrontabScheduleRange(8, 17),
                    Expressions.CrontabScheduleWildcard(),
                    Expressions.CrontabScheduleWildcard(),
                    Expressions.CrontabScheduleWildcard()
                };
                model.OutputLimitClause = OutputLimitClause.CreateSchedule(crontabParams);

                var epl = model.ToEPL();
                Assert.AreEqual(expression, epl);

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

                TryAssertionCrontab(env, 1);
            }
Пример #11
0
            public void Run(RegressionEnvironment env)
            {
                var subquery = new EPStatementObjectModel();
                subquery.SelectClause = SelectClause.CreateWildcard();
                subquery.FromClause = FromClause.Create(
                    FilterStream.Create("SupportBean_S1").AddView("length", Expressions.Constant(1000)));

                var model = new EPStatementObjectModel();
                model.SelectClause = SelectClause.Create("Id");
                model.FromClause = FromClause.Create(FilterStream.Create("SupportBean_S0"));
                model.WhereClause = Expressions.Not(Expressions.SubqueryExists(subquery));
                model = env.CopyMayFail(model);

                var stmtText =
                    "select Id from SupportBean_S0 where not exists (select * from SupportBean_S1#length(1000))";
                Assert.AreEqual(stmtText, model.ToEPL());

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

                env.SendEventBean(new SupportBean_S0(2));
                Assert.AreEqual(2, env.Listener("s0").AssertOneGetNewAndReset().Get("Id"));

                env.SendEventBean(new SupportBean_S1(-1));
                env.SendEventBean(new SupportBean_S0(1));
                Assert.IsFalse(env.Listener("s0").IsInvoked);

                env.SendEventBean(new SupportBean_S1(-2));
                env.SendEventBean(new SupportBean_S0(3));
                Assert.IsFalse(env.Listener("s0").IsInvoked);

                env.UndeployAll();
            }
Пример #12
0
        private void RunAssertionBatchOffsetNoOrderOM(EPServiceProvider epService)
        {
            var model = new EPStatementObjectModel();

            model.SelectClause = SelectClause.CreateWildcard();
            model.SelectClause.StreamSelector = StreamSelector.RSTREAM_ISTREAM_BOTH;
            model.FromClause     = FromClause.Create(FilterStream.Create("SupportBean").AddView("length_batch", Expressions.Constant(3)));
            model.RowLimitClause = RowLimitClause.Create(1);

            string statementString = "select irstream * from SupportBean#length_batch(3) limit 1";

            Assert.AreEqual(statementString, model.ToEPL());
            EPStatement stmt     = epService.EPAdministrator.Create(model);
            var         listener = new SupportUpdateListener();

            TryAssertion(epService, stmt, listener);
            stmt.Dispose();
            listener.Reset();

            model = epService.EPAdministrator.CompileEPL(statementString);
            Assert.AreEqual(statementString, model.ToEPL());
            stmt = epService.EPAdministrator.Create(model);
            TryAssertion(epService, stmt, listener);
            stmt.Dispose();
        }
Пример #13
0
        public void TestRStreamOnly_OM()
        {
            _epService = EPServiceProviderManager.GetDefaultProvider(SupportConfigFactory.GetConfiguration());
            _epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(_epService, this.GetType(), this.GetType().FullName);
            }

            string stmtText = "select rstream * from " + typeof(SupportBean).FullName + ".win:length(3)";
            EPStatementObjectModel model = new EPStatementObjectModel();

            model.SelectClause = SelectClause.CreateWildcard(StreamSelector.RSTREAM_ONLY);
            FromClause fromClause = FromClause.Create(FilterStream.Create(typeof(SupportBean).FullName).AddView(View.Create("win", "length", Expressions.Constant(3))));

            model.FromClause = fromClause;
            model            = (EPStatementObjectModel)SerializableObjectCopier.Copy(model);

            Assert.AreEqual(stmtText, model.ToEPL());
            EPStatement statement = _epService.EPAdministrator.Create(model);

            statement.AddListener(_testListener);

            object theEvent = SendEvent("a");

            Assert.IsFalse(_testListener.IsInvoked);

            SendEvents(new string[] { "a", "b" });
            Assert.IsFalse(_testListener.IsInvoked);

            SendEvent("d");
            Assert.AreSame(theEvent, _testListener.LastNewData[0].Underlying); // receive 'a' as new data
            Assert.IsNull(_testListener.LastOldData);                          // receive no more old data
            _testListener.Reset();
        }
Пример #14
0
        private void RunAssertionRStreamOnly_OM(EPServiceProvider epService)
        {
            string stmtText = "select rstream * from " + typeof(SupportBean).FullName + "#length(3)";
            var    model    = new EPStatementObjectModel();

            model.SelectClause = SelectClause.CreateWildcard(StreamSelector.RSTREAM_ONLY);
            FromClause fromClause = FromClause.Create(FilterStream.Create(typeof(SupportBean).FullName).AddView(View.Create("length", Expressions.Constant(3))));

            model.FromClause = fromClause;
            model            = (EPStatementObjectModel)SerializableObjectCopier.Copy(epService.Container, model);

            Assert.AreEqual(stmtText, model.ToEPL());
            EPStatement statement    = epService.EPAdministrator.Create(model);
            var         testListener = new SupportUpdateListener();

            statement.Events += testListener.Update;

            Object theEvent = SendEvent(epService, "a", 2);

            Assert.IsFalse(testListener.IsInvoked);

            SendEvents(epService, new string[] { "a", "b" });
            Assert.IsFalse(testListener.IsInvoked);

            SendEvent(epService, "d", 2);
            Assert.AreSame(theEvent, testListener.LastNewData[0].Underlying); // receive 'a' as new data
            Assert.IsNull(testListener.LastOldData);                          // receive no more old data

            statement.Dispose();
        }
Пример #15
0
        public void TestSameEventOM()
        {
            EPStatementObjectModel subquery = new EPStatementObjectModel();

            subquery.SelectClause = SelectClause.CreateWildcard();
            subquery.FromClause   = FromClause.Create(FilterStream.Create("S1").AddView(View.Create("win", "length", Expressions.Constant(1000))));

            EPStatementObjectModel model = new EPStatementObjectModel();

            model.FromClause   = FromClause.Create(FilterStream.Create("S1"));
            model.SelectClause = SelectClause.Create().Add(Expressions.Subquery(subquery), "events1");
            model = (EPStatementObjectModel)SerializableObjectCopier.Copy(model);

            String stmtText = "select (select * from S1.win:length(1000)) as events1 from S1";

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

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

            stmt.Events += _listener.Update;

            EventType type = stmt.EventType;

            Assert.AreEqual(typeof(SupportBean_S1), type.GetPropertyType("events1"));

            Object theEvent = new SupportBean_S1(-1, "Y");

            _epService.EPRuntime.SendEvent(theEvent);
            EventBean result = _listener.AssertOneGetNewAndReset();

            Assert.AreSame(theEvent, result.Get("events1"));
        }
Пример #16
0
        private void RunAssertionExistsInSelectOM(EPServiceProvider epService)
        {
            var subquery = new EPStatementObjectModel();

            subquery.SelectClause = SelectClause.CreateWildcard();
            subquery.FromClause   = FromClause.Create(FilterStream.Create("S1")
                                                      .AddView(View.Create("length", Expressions.Constant(1000))));

            var model = new EPStatementObjectModel();

            model.FromClause   = FromClause.Create(FilterStream.Create("S0"));
            model.SelectClause = SelectClause.Create()
                                 .Add(Expressions.SubqueryExists(subquery), "value");
            model = (EPStatementObjectModel)SerializableObjectCopier.Copy(epService.Container, model);

            string stmtText = "select exists (select * from S1#length(1000)) as value from S0";

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

            EPStatement stmt     = epService.EPAdministrator.Create(model);
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            RunTestExistsInSelect(epService, listener);

            stmt.Dispose();
        }
Пример #17
0
        public void TestJoinUniquePerIdOM()
        {
            var model = new EPStatementObjectModel();

            model.SelectClause = SelectClause.CreateWildcard();
            model.FromClause   = FromClause.Create(
                FilterStream.Create(_eventA, "streamA").AddView(View.Create("win", "length", Expressions.Constant(3))),
                FilterStream.Create(_eventB, "streamB").AddView(View.Create("win", "length", Expressions.Constant(3))),
                FilterStream.Create(_eventC, "streamC").AddView(View.Create("win", "length", Expressions.Constant(3))));
            model.WhereClause = Expressions.And(
                Expressions.EqProperty("streamA.id", "streamB.id"),
                Expressions.EqProperty("streamB.id", "streamC.id"),
                Expressions.EqProperty("streamA.id", "streamC.id"));
            model = (EPStatementObjectModel)SerializableObjectCopier.Copy(model);

            String joinStatement = "select * from " +
                                   _eventA + ".win:length(3) as streamA, " +
                                   _eventB + ".win:length(3) as streamB, " +
                                   _eventC + ".win:length(3) as streamC " +
                                   "where streamA.id=streamB.id " +
                                   "and streamB.id=streamC.id " +
                                   "and streamA.id=streamC.id";

            EPStatement joinView = _epService.EPAdministrator.Create(model);

            joinView.Events += _updateListener.Update;
            Assert.AreEqual(joinStatement, model.ToEPL());

            RunJoinUniquePerId();
        }
            public void Run(RegressionEnvironment env)
            {
                var stmtText = "select rstream * from SupportBean#length(3)";
                var model = new EPStatementObjectModel();
                model.SelectClause = SelectClause.CreateWildcard(StreamSelector.RSTREAM_ONLY);
                var fromClause = FromClause.Create(
                    FilterStream.Create("SupportBean").AddView(View.Create("length", Expressions.Constant(3))));
                model.FromClause = fromClause;
                model = env.CopyMayFail(model);

                Assert.AreEqual(stmtText, model.ToEPL());
                model.Annotations = Collections.SingletonList(AnnotationPart.NameAnnotation("s0"));
                env.CompileDeploy(model).AddListener("s0");

                var theEvent = SendEvent(env, "a", 2);
                Assert.IsFalse(env.Listener("s0").IsInvoked);

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

                SendEvent(env, "d", 2);
                Assert.AreSame(theEvent, env.Listener("s0").LastNewData[0].Underlying); // receive 'a' as new data
                Assert.IsNull(env.Listener("s0").LastOldData); // receive no more old data

                env.UndeployAll();
            }
Пример #19
0
        private void RunAssertionOutputCrontabAtOMCreate(EPServiceProvider epService)
        {
            // every 15 minutes 8am to 5pm
            SendTimeEvent(epService, 1, 17, 10, 0, 0);
            string expression = "select * from MarketData#lastevent output at (*/15, 8:17, *, *, *)";

            var model = new EPStatementObjectModel();

            model.SelectClause = SelectClause.CreateWildcard();
            model.FromClause   = FromClause.Create(FilterStream.Create("MarketData")
                                                   .AddView("lastevent"));
            var crontabParams = new Expression[] {
                Expressions.CrontabScheduleFrequency(15),
                Expressions.CrontabScheduleRange(8, 17),
                Expressions.CrontabScheduleWildcard(),
                Expressions.CrontabScheduleWildcard(),
                Expressions.CrontabScheduleWildcard()
            };

            model.OutputLimitClause = OutputLimitClause.CreateSchedule(crontabParams);

            string epl = model.ToEPL();

            Assert.AreEqual(expression, epl);
            EPStatement stmt     = epService.EPAdministrator.Create(model);
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;
            TryAssertionCrontab(epService, 1, stmt, listener);
        }
Пример #20
0
        public void TestBeanEventWildcardSODA()
        {
            var fields        = new string[] { "id" };
            var statementText = "select distinct * from SupportBean_A#keepall";
            var stmt          = _epService.EPAdministrator.CreateEPL(statementText);

            stmt.AddListener(_listener);

            _epService.EPRuntime.SendEvent(new SupportBean_A("E1"));
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1" } });

            _epService.EPRuntime.SendEvent(new SupportBean_A("E2"));
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1" }, new object[] { "E2" } });

            _epService.EPRuntime.SendEvent(new SupportBean_A("E1"));
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1" }, new object[] { "E2" } });

            var model = _epService.EPAdministrator.CompileEPL(statementText);

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

            model = new EPStatementObjectModel();
            model.SelectClause = SelectClause.CreateWildcard().Distinct(true);
            model.FromClause   = FromClause.Create(FilterStream.Create("SupportBean_A"));
            Assert.AreEqual("select distinct * from SupportBean_A", model.ToEPL());
        }
Пример #21
0
 public void Run(RegressionEnvironment env)
 {
     var model = new EPStatementObjectModel();
     model.SelectClause = SelectClause.CreateWildcard();
     model.FromClause = FromClause.Create(FilterStream.Create(typeof(SupportBean).Name));
     model.Annotations = Collections.SingletonList(AnnotationPart.NameAnnotation("s0"));
     SerializableObjectCopier.CopyMayFail(env.Container, model);
 }
Пример #22
0
            private void TryAssertionInsertWhereOMStaggered(
                RegressionEnvironment env,
                EventRepresentationChoice eventRepresentationEnum)
            {
                var path = new RegressionPath();
                var stmtTextCreateOne = eventRepresentationEnum.GetAnnotationTextWJsonProvided<MyLocalJsonProvidedMyWindowIWOM>() +
                                        " @Name('window') create window MyWindowIWOM#keepall as select a, b from MyMapAB";
                env.CompileDeploy(stmtTextCreateOne, path);
                Assert.IsTrue(eventRepresentationEnum.MatchesClass(env.Statement("window").EventType.UnderlyingType));
                env.AddListener("window");

                // create insert into
                var stmtTextInsertOne = "insert into MyWindowIWOM select a, b from MyMapAB";
                env.CompileDeploy(stmtTextInsertOne, path);

                // populate some data
                env.SendEventMap(BuildMap(new[] {new object[] {"a", "E1"}, new object[] {"b", 2}}), "MyMapAB");
                env.SendEventMap(BuildMap(new[] {new object[] {"a", "E2"}, new object[] {"b", 10}}), "MyMapAB");
                env.SendEventMap(BuildMap(new[] {new object[] {"a", "E3"}, new object[] {"b", 10}}), "MyMapAB");

                // create window with keep-all using OM
                var model = new EPStatementObjectModel();
                eventRepresentationEnum.AddAnnotationForNonMap(model);
                Expression where = Expressions.Eq("b", 10);
                model.CreateWindow =
                    CreateWindowClause.Create("MyWindowIWOMTwo", View.Create("keepall"))
                        .WithInsert(true)
                        .WithInsertWhereClause(where)
                        .WithAsEventTypeName("MyWindowIWOM");
                model.SelectClause = SelectClause.CreateWildcard();
                var text = eventRepresentationEnum.GetAnnotationTextForNonMap() +
                           " create window MyWindowIWOMTwo#keepall as select * from MyWindowIWOM insert where b=10";
                Assert.AreEqual(text.Trim(), model.ToEPL());

                var modelTwo = env.EplToModel(text);
                Assert.AreEqual(text.Trim(), modelTwo.ToEPL());
                modelTwo.Annotations = Collections.SingletonList(AnnotationPart.NameAnnotation("windowTwo"));
                env.CompileDeploy(modelTwo, path).AddListener("windowTwo");

                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("windowTwo"),
                    new[] {"a", "b"},
                    new[] {new object[] {"E2", 10}, new object[] {"E3", 10}});

                // test select individual fields and from an insert-from named window
                env.CompileDeploy(
                    eventRepresentationEnum.GetAnnotationTextWJsonProvided<MyLocalJsonProvidedMyWindowIWOMThree>() +
                    " @Name('windowThree') create window MyWindowIWOMThree#keepall as select a from MyWindowIWOMTwo insert where a = 'E2'",
                    path);
                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("windowThree"),
                    new[] {"a"},
                    new[] {new object[] {"E2"}});

                env.UndeployAll();
            }
Пример #23
0
        private void TryAssertionInsertWhereOMStaggered(EPServiceProvider epService, EventRepresentationChoice eventRepresentationEnum)
        {
            IDictionary <string, object> dataType = MakeMap(new[] { new object[] { "a", typeof(string) }, new object[] { "b", typeof(int) } });

            epService.EPAdministrator.Configuration.AddEventType("MyMap", dataType);

            string      stmtTextCreateOne = eventRepresentationEnum.GetAnnotationText() + " create window MyWindowIWOM#keepall as select a, b from MyMap";
            EPStatement stmtCreateOne     = epService.EPAdministrator.CreateEPL(stmtTextCreateOne);

            Assert.IsTrue(eventRepresentationEnum.MatchesClass(stmtCreateOne.EventType.UnderlyingType));
            var listener = new SupportUpdateListener();

            stmtCreateOne.Events += listener.Update;

            // create insert into
            string stmtTextInsertOne = "insert into MyWindowIWOM select a, b from MyMap";

            epService.EPAdministrator.CreateEPL(stmtTextInsertOne);

            // populate some data
            epService.EPRuntime.SendEvent(MakeMap(new[] { new object[] { "a", "E1" }, new object[] { "b", 2 } }), "MyMap");
            epService.EPRuntime.SendEvent(MakeMap(new[] { new object[] { "a", "E2" }, new object[] { "b", 10 } }), "MyMap");
            epService.EPRuntime.SendEvent(MakeMap(new[] { new object[] { "a", "E3" }, new object[] { "b", 10 } }), "MyMap");

            // create window with keep-all using OM
            var model = new EPStatementObjectModel();

            eventRepresentationEnum.AddAnnotationForNonMap(model);
            Expression where   = Expressions.Eq("b", 10);
            model.CreateWindow = CreateWindowClause.Create("MyWindowIWOMTwo", View.Create("keepall"))
                                 .SetIsInsert(true)
                                 .SetInsertWhereClause(where);
            model.SelectClause = SelectClause.CreateWildcard();
            model.FromClause   = FromClause.Create(FilterStream.Create("MyWindowIWOM"));
            string text = eventRepresentationEnum.GetAnnotationTextForNonMap() + " create window MyWindowIWOMTwo#keepall as select * from MyWindowIWOM insert where b=10";

            Assert.AreEqual(text.Trim(), model.ToEPL());

            EPStatementObjectModel modelTwo = epService.EPAdministrator.CompileEPL(text);

            Assert.AreEqual(text.Trim(), modelTwo.ToEPL());

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

            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), "a,b".Split(','), new[] { new object[] { "E2", 10 }, new object[] { "E3", 10 } });

            // test select individual fields and from an insert-from named window
            stmt = epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create window MyWindowIWOMThree#keepall as select a from MyWindowIWOMTwo insert where a = 'E2'");
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), "a".Split(','), new[] { new object[] { "E2" } });

            epService.EPAdministrator.DestroyAllStatements();
            epService.EPAdministrator.Configuration.RemoveEventType("MyWindowIWOM", true);
            epService.EPAdministrator.Configuration.RemoveEventType("MyWindowIWOMTwo", true);
            epService.EPAdministrator.Configuration.RemoveEventType("MyWindowIWOMThree", true);
        }
Пример #24
0
        public void TestCreateFromOM()
        {
            var model = new EPStatementObjectModel();

            model.SelectClause = SelectClause.CreateWildcard();
            model.FromClause   = FromClause.Create(FilterStream.Create(typeof(SupportBean).FullName));
            SerializableObjectCopier.Copy(model);

            EPStatement stmt = _epService.EPAdministrator.Create(model, "s1");

            stmt.Events += _listener.Update;

            Object theEvent = new SupportBean();

            _epService.EPRuntime.SendEvent(theEvent);
            Assert.AreEqual(theEvent, _listener.AssertOneGetNewAndReset().Underlying);
        }
Пример #25
0
        public void TestOp()
        {
            var events       = EventCollectionFactory.GetEventSetOne(0, 1000);
            var testCaseList = new CaseList();

            var testCase = new EventExpressionCase("a=A -> (every b=B) while(b.Id != 'B2')");

            testCase.Add("B1", "a", events.GetEvent("A1"), "b", events.GetEvent("B1"));
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("a=A -> (every b=B) while(b.Id != 'B3')");
            testCase.Add("B1", "a", events.GetEvent("A1"), "b", events.GetEvent("B1"));
            testCase.Add("B2", "a", events.GetEvent("A1"), "b", events.GetEvent("B2"));
            testCaseList.AddTest(testCase);

            testCase = new EventExpressionCase("(every b=B) while(b.Id != 'B3')");
            testCase.Add("B1", "b", events.GetEvent("B1"));
            testCase.Add("B2", "b", events.GetEvent("B2"));
            testCaseList.AddTest(testCase);

            String text = "select * from pattern [(every b=" + EVENT_B_CLASS + ") while (b.Id!=\"B3\")]";

            var model = new EPStatementObjectModel();

            model.SelectClause = SelectClause.CreateWildcard();
            model = (EPStatementObjectModel)SerializableObjectCopier.Copy(model);
            Expression  guardExpr      = Expressions.Neq("b.Id", "B3");
            PatternExpr every          = Patterns.Every(Patterns.Filter(Filter.Create(EVENT_B_CLASS), "b"));
            PatternExpr patternGuarded = Patterns.WhileGuard(every, guardExpr);

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

            testCase = new EventExpressionCase("(every b=B) while(b.Id != 'B1')");
            testCaseList.AddTest(testCase);

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

            util.RunTest();
        }
Пример #26
0
        // This is a simple EPL only.
        // Each OM/SODA Api is tested in it's respective unit test (i.e. TestInsertInto), including ToEPL()
        //
        private void RunAssertionCreateFromOM(EPServiceProvider epService)
        {
            var model = new EPStatementObjectModel();

            model.SelectClause = SelectClause.CreateWildcard();
            model.FromClause   = FromClause.Create(FilterStream.Create(typeof(SupportBean).FullName));
            SerializableObjectCopier.Copy(epService.Container, model);

            var stmt     = epService.EPAdministrator.Create(model, "s1");
            var listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            var theEvent = new SupportBean();

            epService.EPRuntime.SendEvent(theEvent);
            Assert.AreEqual(theEvent, listener.AssertOneGetNewAndReset().Underlying);

            stmt.Dispose();
        }
Пример #27
0
            public void Run(RegressionEnvironment env)
            {
                var events = EventCollectionFactory.GetEventSetOne(0, 1000);
                var testCaseList = new CaseList();
                EventExpressionCase testCase = null;

                testCase = new EventExpressionCase("a=SupportBean_A -> (every b=SupportBean_B) while(b.Id != 'B2')");
                testCase.Add("B1", "a", events.GetEvent("A1"), "b", events.GetEvent("B1"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("a=SupportBean_A -> (every b=SupportBean_B) while(b.Id != 'B3')");
                testCase.Add("B1", "a", events.GetEvent("A1"), "b", events.GetEvent("B1"));
                testCase.Add("B2", "a", events.GetEvent("A1"), "b", events.GetEvent("B2"));
                testCaseList.AddTest(testCase);

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

                var text = "select * from pattern [(every b=SupportBean_B) while (b.Id!=\"B3\")]";
                var model = new EPStatementObjectModel();
                model.SelectClause = SelectClause.CreateWildcard();
                model = env.CopyMayFail(model);
                Expression guardExpr = Expressions.Neq("b.Id", "B3");
                PatternExpr every = Patterns.Every(Patterns.Filter(Filter.Create("SupportBean_B"), "b"));
                PatternExpr patternGuarded = Patterns.WhileGuard(every, guardExpr);
                model.FromClause = FromClause.Create(PatternStream.Create(patternGuarded));
                Assert.AreEqual(text, model.ToEPL());
                testCase = new EventExpressionCase(model);
                testCase.Add("B1", "b", events.GetEvent("B1"));
                testCase.Add("B2", "b", events.GetEvent("B2"));
                testCaseList.AddTest(testCase);

                testCase = new EventExpressionCase("(every b=SupportBean_B) while(b.Id != 'B1')");
                testCaseList.AddTest(testCase);

                var util = new PatternTestHarness(events, testCaseList, GetType());
                util.RunTest(env);
            }
Пример #28
0
        private void RunAssertion2SplitNoDefaultOutputFirst(EPServiceProvider epService)
        {
            var stmtOrigText = "@Audit on SupportBean " +
                               "insert into AStream2SP select * where IntPrimitive=1 " +
                               "insert into BStream2SP select * where IntPrimitive=1 or IntPrimitive=2";
            var stmtOrig = epService.EPAdministrator.CreateEPL(stmtOrigText);

            TryAssertion(epService, stmtOrig);

            // statement object model
            var model = new EPStatementObjectModel();

            model.Annotations  = Collections.SingletonList(new AnnotationPart("Audit"));
            model.FromClause   = FromClause.Create(FilterStream.Create("SupportBean"));
            model.InsertInto   = InsertIntoClause.Create("AStream2SP");
            model.SelectClause = SelectClause.CreateWildcard();
            model.WhereClause  = Expressions.Eq("IntPrimitive", 1);
            var clause = OnClause.CreateOnInsertSplitStream();

            model.OnExpr = clause;
            var item = OnInsertSplitStreamItem.Create(
                InsertIntoClause.Create("BStream2SP"),
                SelectClause.CreateWildcard(),
                Expressions.Or(Expressions.Eq("IntPrimitive", 1), Expressions.Eq("IntPrimitive", 2)));

            clause.AddItem(item);
            Assert.AreEqual(stmtOrigText, model.ToEPL());
            stmtOrig = epService.EPAdministrator.Create(model);
            TryAssertion(epService, stmtOrig);

            var newModel = epService.EPAdministrator.CompileEPL(stmtOrigText);

            stmtOrig = epService.EPAdministrator.Create(newModel);
            Assert.AreEqual(stmtOrigText, newModel.ToEPL());
            TryAssertion(epService, stmtOrig);

            SupportModelHelper.CompileCreate(epService, stmtOrigText + " output all");

            epService.EPAdministrator.DestroyAllStatements();
        }
Пример #29
0
        public void TestLeftOuterJoin_root_s0_OM()
        {
            EPStatementObjectModel model = new EPStatementObjectModel();

            model.SelectClause = SelectClause.CreateWildcard();
            FromClause fromClause = FromClause.Create(
                FilterStream.Create(EVENT_S0, "s0").AddView("win", "keepall"),
                FilterStream.Create(EVENT_S1, "s1").AddView("win", "keepall"),
                FilterStream.Create(EVENT_S2, "s2").AddView("win", "keepall"));

            fromClause.Add(OuterJoinQualifier.Create("s0.P00", OuterJoinType.LEFT, "s1.p10"));
            fromClause.Add(OuterJoinQualifier.Create("s0.P00", OuterJoinType.LEFT, "s2.p20"));
            model.FromClause = fromClause;
            model            = (EPStatementObjectModel)SerializableObjectCopier.Copy(model);

            Assert.AreEqual("select * from com.espertech.esper.support.bean.SupportBean_S0.win:keepall() as s0 left outer join com.espertech.esper.support.bean.SupportBean_S1.win:keepall() as s1 on s0.P00 = s1.p10 left outer join com.espertech.esper.support.bean.SupportBean_S2.win:keepall() as s2 on s0.P00 = s2.p20", model.ToEPL());
            EPStatement joinView = epService.EPAdministrator.Create(model);

            joinView.Events += updateListener.Update;

            RunAsserts();
        }
Пример #30
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();
        }