コード例 #1
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                var stmtTextOne =
                    "insert into MyStreamTE select a, b from AEventTE#keepall as a, BEventTE#keepall as b";
                env.CompileDeploy(stmtTextOne, path);

                var stmtTextTwo = "@Name('s0') select a.Id, b.Id from MyStreamTE";
                env.CompileDeploy(stmtTextTwo, path).AddListener("s0");

                var eventOne = MakeMap(new[] {new object[] {"Id", "A1"}});
                var eventTwo = MakeMap(new[] {new object[] {"Id", "B1"}});
                env.SendEventMap(eventOne, "AEventTE");
                env.SendEventMap(eventTwo, "BEventTE");

                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    new[] {"a.Id", "b.Id"},
                    new object[] {"A1", "B1"});

                env.UndeployAll();
            }
コード例 #2
0
        private static RegressionPath PreloadData(
            RegressionEnvironment env,
            bool indexShare)
        {
            var path = new RegressionPath();
            var createEpl = "create window AWindow#keepall as SupportCountAccessEvent";
            if (indexShare) {
                createEpl = "@Hint('enable_window_subquery_indexshare') " + createEpl;
            }

            env.CompileDeploy(createEpl, path);
            env.CompileDeploy("insert into AWindow select * from SupportCountAccessEvent", path);
            env.CompileDeploy("create index I1 on AWindow(P00)", path);
            SupportCountAccessEvent.GetAndResetCountGetterCalled();
            for (var i = 0; i < 100; i++) {
                env.SendEventBean(new SupportCountAccessEvent(i, "E" + i));
            }

            env.SendEventBean(new SupportCountAccessEvent(-1, "x"));
            Assert.AreEqual(101, SupportCountAccessEvent.GetAndResetCountGetterCalled());
            return path;
        }
コード例 #3
0
ファイル: EPLVariablesCreate.cs プロジェクト: lanicon/nesper
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();

                var text = "create variable long var1CSS";
                env.EplToModelCompileDeploy(text, path);

                text = "create variable string var2CSS = \"abc\"";
                env.EplToModelCompileDeploy(text, path);

                var stmtTextSelect = "@Name('s0') select var1CSS, var2CSS from SupportBean";
                env.CompileDeploy(stmtTextSelect, path).AddListener("s0");

                string[] fieldsVar = {"var1CSS", "var2CSS"};
                SendSupportBean(env, "E1", 10);
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsVar,
                    new object[] {null, "abc"});

                // ESPER-545
                var createText = "@Name('create') create variable int FOO = 0";
                env.CompileDeploy(createText, path);
                env.CompileDeploy("on pattern [every SupportBean] set FOO = FOO + 1", path);
                env.SendEventBean(new SupportBean());
                Assert.AreEqual(1, env.Runtime.VariableService.GetVariableValue(env.DeploymentId("create"), "FOO"));

                env.UndeployAll();

                env.CompileDeploy(createText);
                Assert.AreEqual(0, env.Runtime.VariableService.GetVariableValue(env.DeploymentId("create"), "FOO"));

                // cleanup of variable when statement exception occurs
                env.CompileDeploy("create variable int x = 123");
                TryInvalidCompile(env, "select missingScript(x) from SupportBean", "skip");
                env.CompileDeploy("create variable int x = 123");

                env.UndeployAll();
            }
コード例 #4
0
        private static void TryAssertion(
            RegressionEnvironment env,
            RegressionPath path,
            string epl)
        {
            env.CompileDeploy(epl, path).AddListener("s0");

            // Repeat
            log.Info("Querying");
            var startTime = PerformanceObserver.MilliTime;
            for (var i = 0; i < 1000; i++) {
                env.SendEventBean(new SupportBeanRange("R", "G", 100, 101));
                Assert.AreEqual(4, env.Listener("s0").GetAndResetLastNewData().Length);
            }

            log.Info("Done Querying");
            var endTime = PerformanceObserver.MilliTime;
            log.Info("delta=" + (endTime - startTime));

            Assert.That(endTime - startTime, Is.LessThan(500));
            env.UndeployModuleContaining("s0");
        }
コード例 #5
0
        public void Run(RegressionEnvironment env)
        {
            var path = new RegressionPath();
            env.CompileDeploy(
                "@Name('window') create window MyWindow#keepall as select TheString, LongPrimitive from SupportBean",
                path);
            var listenerWindow = new SupportMTUpdateListener();
            env.Statement("window").AddListener(listenerWindow);

            env.CompileDeploy(
                "insert into MyWindow(TheString, LongPrimitive) " +
                " select Symbol, Volume \n" +
                " from SupportMarketDataBean",
                path);

            var stmtTextDelete = "on SupportBean_A as S0 delete from MyWindow as win where win.TheString = S0.Id";
            env.CompileDeploy(stmtTextDelete, path);

            TrySend(env, path, listenerWindow, 4, 1000, 8);

            env.UndeployAll();
        }
コード例 #6
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                var epl = "create window SBR#keepall as SupportBeanRange;\n" +
                          "@Name('I1') insert into SBR select * from SupportBeanRange;\n" +
                          "create window ST1#keepall as SupportBean_ST1;\n" +
                          "@Name('I2') insert into ST1 select * from SupportBean_ST1;\n";
                env.CompileDeploy(epl, path).Milestone(0);

                // Preload
                log.Info("Preloading events");
                env.SendEventBean(new SupportBeanRange("ST1", "G", 4000, 4004));
                for (var i = 0; i < 10000; i++) {
                    env.SendEventBean(new SupportBean_ST1("ST1", "G", i));
                }

                log.Info("Done preloading");

                var eplQuery = "@Name('s0') select * from SupportBean_ST0 st0 unidirectional, SBR a, ST1 st1 " +
                               "where st0.Key0 = a.Key and st1.Key1 = a.Key and " +
                               "st1.P10 between RangeStart and RangeEnd";
                env.CompileDeploy(eplQuery, path).AddListener("s0").Milestone(1);

                // Repeat
                log.Info("Querying");
                var startTime = PerformanceObserver.MilliTime;
                for (var i = 0; i < 500; i++) {
                    env.SendEventBean(new SupportBean_ST0("ST0", "G", -1));
                    Assert.AreEqual(5, env.Listener("s0").GetAndResetLastNewData().Length);
                }

                log.Info("Done Querying");
                var delta = PerformanceObserver.MilliTime - startTime;
                log.Info("delta=" + delta);

                // This works best with a nested iteration join (and not a cardinal join)
                Assert.That(delta, Is.LessThan(500), "delta=" + delta);
                env.UndeployAll();
            }
コード例 #7
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                var eplCreate = namedWindow
                    ? "create window MyInfraIKW#keepall as SupportBean"
                    : "create table MyInfraIKW (TheString string primary key)";
                env.CompileDeploy(eplCreate, path);
                env.CompileDeploy("create index Idx on MyInfraIKW(TheString)", path);
                env.CompileDeploy("insert into MyInfraIKW select TheString from SupportBean", path);

                var eventCount = 10;
                for (var i = 0; i < eventCount; i++) {
                    env.SendEventBean(new SupportBean("E" + i, 0));
                }

                InvocationCounter.Count = 0;
                var fafEPL = "select * from MyInfraIKW as mw where justCount(mw) and TheString in ('notfound')";
                env.CompileExecuteFAF(fafEPL, path);
                Assert.AreEqual(0, InvocationCounter.Count);

                env.UndeployAll();
            }
コード例 #8
0
            public void Run(RegressionEnvironment env)
            {
                RegressionPath path = new RegressionPath();
                string epl = namedWindow
                    ? "@public create window MyInfra#keepall as (Id string, ArrayOne string[], ArrayTwo string[]);\n"
                    : "@public create table MyInfra(Id string primary key, ArrayOne string[], ArrayTwo string[]);\n";
                epl += "insert into MyInfra select Id, StringOne as ArrayOne, StringTwo as ArrayTwo from SupportEventWithManyArray;\n" +
                       "create index MyInfraIndex on MyInfra(ArrayOne, ArrayTwo);\n";
                env.CompileDeploy(epl, path);

                SendManyArray(env, "E1", new string[] {"a", "b"}, new string[] {"c", "d"});
                SendManyArray(env, "E2", new string[] {"a"}, new string[] {"b"});

                env.Milestone(0);

                AssertFAF(env, path, "ArrayOne = {'a', 'b'} and ArrayTwo = {'c', 'd'}", "E1");
                AssertFAF(env, path, "ArrayOne = {'a'} and ArrayTwo = {'b'}", "E2");
                AssertFAFNot(env, path, "ArrayOne = {'a', 'b', 'c'} and ArrayTwo = {'c', 'd'}");
                AssertFAFNot(env, path, "ArrayOne = {'a', 'b'} and ArrayTwo = {'c', 'c'}");

                env.UndeployAll();
            }
コード例 #9
0
            public void Run(RegressionEnvironment env)
            {
                RegressionPath path = new RegressionPath();
                string namespc = NamespaceGenerator.Create();
                string objects = "@public create variable string MYVARIABLE_NONCONSTANT = 'abc';\n" +
                                 "@public create table MyTable(tablecol string);\n" +
                                 "@public create window MyWindow#keepall as SupportBean;\n" +
                                 "@public create inlined_class \"\"\"\n" +
                                 "namespace " +
                                 namespc +
                                 " {\n" +
                                 "  public class Helper {\n" +
                                 "    public static string Doit(object param) {\n" +
                                 "      return null;\n" +
                                 "    }\n" +
                                 "  }\n" +
                                 "}\n" +
                                 "\"\"\";\n" +
                                 "@public create expression MyDeclaredExpr { (select TheString from MyWindow) };\n" +
                                 "@public create expression MyHandThrough {v => v};\n" +
                                 "@public create expression string js:MyJavaScript(param) [\"a\"];\n";
                env.Compile(objects, path);

                AssertDisqualified(env, path, "SupportBean", "TheString=Convert.ToString(IntPrimitive)");
                AssertDisqualified(env, path, "SupportBean", "TheString=MYVARIABLE_NONCONSTANT");
                AssertDisqualified(env, path, "SupportBean", "TheString=MyTable.tablecol");
                AssertDisqualified(env, path, "SupportBean", "TheString=(select TheString from MyWindow)");
                AssertDisqualified(env, path, "SupportBeanArrayCollMap", "Id = SetOfString.where(v => v=Id).firstOf()");
                AssertDisqualified(env, path, "SupportBean", $"TheString={namespc}.Helper.Doit(*)");
                AssertDisqualified(env, path, "SupportBean", $"TheString={namespc}.Helper.Doit(me)");
                AssertDisqualified(env, path, "SupportBean", "BoolPrimitive=event_identity_equals(me, me)");
                AssertDisqualified(env, path, "SupportBean", "TheString=MyDeclaredExpr()");
                AssertDisqualified(env, path, "SupportBean", "IntPrimitive=me.TheString.Length");
                AssertDisqualified(env, path, "SupportBean", "IntPrimitive = funcOne('hello')");
                AssertDisqualified(env, path, "SupportBean", "BoolPrimitive = exists(TheString)");
                AssertDisqualified(env, path, "SupportBean", "TheString = MyJavaScript('a')");
                AssertDisqualified(env, path, "SupportBean", "TheString = MyHandThrough('a')");
            }
コード例 #10
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                var epl  =
                    "@public create window WinS0#keepall as SupportBean_S0;\n" +
                    "@public create window WinSB#unique(IntPrimitive) as SupportBean;\n" +
                    "insert into WinS0 select * from SupportBean_S0;\n" +
                    "insert into WinSB select * from SupportBean;\n";

                env.CompileDeploy(epl, path);

                SendS0(env, 1, "a");
                SendS0(env, 2, "b");
                SendS0(env, 3, "c");

                SendSB(env, "X", 2);
                SendSB(env, "Y", 1);
                SendSB(env, "Z", 3);

                var update = "update WinS0 as wins0 set P00 = (select TheString from WinSB winsb where winsb.IntPrimitive = wins0.Id)";

                CompileExecute(env, path, update);

                var query = "select * from WinS0";

                AssertQueryMultirowAnyOrder(
                    env,
                    path,
                    query,
                    "Id,P00",
                    new object[][] {
                    new object[] { 1, "Y" },
                    new object[] { 2, "X" },
                    new object[] { 3, "Z" }
                });

                env.UndeployAll();
            }
コード例 #11
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                var stmtTextOne =
                    "@Name('i1') insert into MyStreamABMap select a, b from pattern [a=AEventMap -> b=BEventMap]";
                env.CompileDeploy(stmtTextOne, path).AddListener("i1");
                Assert.AreEqual(
                    typeof(IDictionary<string, object>),
                    env.Statement("i1").EventType.GetPropertyType("a"));
                Assert.AreEqual(
                    typeof(IDictionary<string, object>),
                    env.Statement("i1").EventType.GetPropertyType("b"));

                var stmtTextTwo = "@Name('s0') select a.Id, b.Id from MyStreamABMap";
                env.CompileDeploy(stmtTextTwo, path).AddListener("s0");
                Assert.AreEqual(typeof(string), env.Statement("s0").EventType.GetPropertyType("a.Id"));
                Assert.AreEqual(typeof(string), env.Statement("s0").EventType.GetPropertyType("b.Id"));

                var eventOne = MakeMap(new[] {new object[] {"Id", "A1"}});
                var eventTwo = MakeMap(new[] {new object[] {"Id", "B1"}});

                env.SendEventMap(eventOne, "AEventMap");
                env.SendEventMap(eventTwo, "BEventMap");

                var theEvent = env.Listener("s0").AssertOneGetNewAndReset();
                EPAssertionUtil.AssertProps(
                    theEvent,
                    new[] {"a.Id", "b.Id"},
                    new object[] {"A1", "B1"});

                theEvent = env.Listener("i1").AssertOneGetNewAndReset();
                EPAssertionUtil.AssertProps(
                    theEvent,
                    new[] {"a", "b"},
                    new object[] {eventOne, eventTwo});

                env.UndeployAll();
            }
コード例 #12
0
        // test Map event with ObjectArrayType and ObjectArrayType[] properties
        private void RunAssertionMapWithObjectArray(RegressionEnvironment env)
        {
            var path = new RegressionPath();
            var schema = "create objectarray schema OATypeInMap(p0 string, p1 int);\n" +
                         "create map schema MapTypeWOA(oa1 OATypeInMap, oa2 OATypeInMap[]);\n";
            env.CompileDeployWBusPublicType(schema, path);

            env.CompileDeploy(
                "@Name('s0') select oa1.p0 as c0, oa1.p1 as c1, oa2[0].p0 as c2, oa2[1].p1 as c3 from MapTypeWOA",
                path);
            env.AddListener("s0");

            IDictionary<string, object> data = new Dictionary<string, object>();
            data.Put(
                "oa1",
                new object[] {"A", 100});
            data.Put(
                "oa2",
                new[] {
                    new object[] {"B", 200}, new object[] {"C", 300}
                });
            env.SendEventMap(data, "MapTypeWOA");
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                new [] { "c0", "c1", "c2", "c3" },
                new object[] {"A", 100, "B", 300});
            env.UndeployModuleContaining("s0");

            // test inserting from map to array
            env.CompileDeploy("@Name('s0') insert into OATypeInMap select 'a' as p0, 1 as p1 from MapTypeWOA", path)
                .AddListener("s0");
            env.SendEventMap(data, "MapTypeWOA");
            Assert.IsTrue(env.Listener("s0").AssertOneGetNew() is ObjectArrayBackedEventBean);
            Assert.AreEqual("a", env.Listener("s0").AssertOneGetNew().Get("p0"));
            Assert.AreEqual(1, env.Listener("s0").AssertOneGetNewAndReset().Get("p1"));

            env.UndeployAll();
        }
コード例 #13
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeploy(
                    "@Audit @Name('ctx') create context MyTermByUnrelated partition by TheString from SupportBean(IntPrimitive=0) terminated by SupportBean(IntPrimitive=1)",
                    path);
                env.CompileDeploy(
                    "@Name('s0') context MyTermByUnrelated select TheString, count(*) as cnt from SupportBean output last when terminated",
                    path);
                env.AddListener("s0");
                var fields = new [] { "TheString","cnt" };

                env.Milestone(0);

                env.SendEventBean(new SupportBean("A", 2));
                env.SendEventBean(new SupportBean("B", 1));

                env.Milestone(1);

                env.SendEventBean(new SupportBean("B", 0));
                env.SendEventBean(new SupportBean("B", 2));
                Assert.IsFalse(env.Listener("s0").IsInvoked);

                env.Milestone(2);

                env.SendEventBean(new SupportBean("B", 1));
                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    env.Listener("s0").GetAndResetLastNewData(),
                    fields,
                    new[] {new object[] {"B", 1L}});

                env.Milestone(3);

                env.SendEventBean(new SupportBean("A", 0));
                env.UndeployModuleContaining("s0");
                AssertFilterSvcCount(env, 0, "ctx");
                env.UndeployAll();
            }
コード例 #14
0
        private static void RunAssertion(
            RegressionEnvironment env,
            string eventTypeName,
            RegressionPath path)
        {
            env.CompileDeploy("@Name('s0') select countTags, countTagsInt, idarray, tagArray, tagOne from " + eventTypeName, path);
            env.CompileDeploy("@Name('e0') insert into TagOneStream select tagOne.* from " + eventTypeName, path);
            env.CompileDeploy("@Name('e1') select ID from TagOneStream", path);
            env.CompileDeploy("@Name('e2') insert into TagArrayStream select tagArray as mytags from " + eventTypeName, path);
            env.CompileDeploy("@Name('e3') select mytags[1].ID from TagArrayStream", path);

            var doc = SupportXML.GetDocument(OBSERVATION_XML);
            env.SendEventXMLDOM(doc, eventTypeName);

            SupportEventTypeAssertionUtil.AssertConsistency(env.GetEnumerator("s0").Advance());
            SupportEventTypeAssertionUtil.AssertConsistency(env.GetEnumerator("e0").Advance());
            SupportEventTypeAssertionUtil.AssertConsistency(env.GetEnumerator("e1").Advance());
            SupportEventTypeAssertionUtil.AssertConsistency(env.GetEnumerator("e2").Advance());
            SupportEventTypeAssertionUtil.AssertConsistency(env.GetEnumerator("e3").Advance());

            var resultEnumerator = env.GetEnumerator("s0");
            Assert.That(resultEnumerator, Is.Not.Null);
            Assert.That(resultEnumerator.MoveNext(), Is.True);
            Assert.That(resultEnumerator.Current, Is.Not.Null);

            var resultArray = resultEnumerator.Current.Get("idarray");
            EPAssertionUtil.AssertEqualsExactOrder(
                (object[]) resultArray,
                new[] {"urn:epc:1:2.24.400", "urn:epc:1:2.24.401"});
            EPAssertionUtil.AssertProps(
                env.GetEnumerator("s0").Advance(),
                new[] {"countTags", "countTagsInt"},
                new object[] {2d, 2});
            Assert.AreEqual("urn:epc:1:2.24.400", env.GetEnumerator("e1").Advance().Get("ID"));
            Assert.AreEqual("urn:epc:1:2.24.401", env.GetEnumerator("e3").Advance().Get("mytags[1].ID"));

            env.UndeployAll();
        }
コード例 #15
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                string text;

                // Table
                env.CompileDeploy("@Name('infra') create table MyTable(col1 string primary key, col2 string)", path);
                env.Compile(
                    "@Name('infra') create index MyIndexForTable on MyTable(col2)",
                    path); // Note: not deploying, just adding to path

                text = "dependency index 'MyIndexForTable'";
                TryInvalidDeploy(
                    env,
                    path,
                    "select * from SupportBean as sb, MyTable as mt where mt.col2 = sb.TheString",
                    text);
                TryInvalidDeploy(
                    env,
                    path,
                    "select * from SupportBean as sb where exists (select * from MyTable as mt where mt.col2 = sb.TheString)",
                    text);

                // Named Window
                env.CompileDeploy("@Name('infra') create window MyWindow#keepall as SupportBean", path);
                env.Compile(
                    "@Name('infra') create index MyIndexForNW on MyWindow(IntPrimitive)",
                    path); // Note: not deploying, just adding to path

                text = "dependency index 'MyIndexForNW'";
                TryInvalidDeploy(
                    env,
                    path,
                    "on SupportBean_S0 as sb update MyWindow as mw set TheString='a' where sb.Id = mw.IntPrimitive",
                    text);

                env.UndeployAll();
            }
コード例 #16
0
        private static void RunAssertion(
            RegressionEnvironment env,
            String eventTypeName,
            RegressionPath path)
        {
            var stmtText = "@Name('s0') select type?,dyn[1]?,nested.nes2?,map('a')? from " + eventTypeName;
            env.CompileDeploy(stmtText, path).AddListener("s0");

            CollectionAssert.AreEquivalent(
                new EventPropertyDescriptor[] {
                    new EventPropertyDescriptor("type?", typeof(XmlNode), null, false, false, false, false, false),
                    new EventPropertyDescriptor("dyn[1]?", typeof(XmlNode), null, false, false, false, false, false),
                    new EventPropertyDescriptor(
                        "nested.nes2?",
                        typeof(XmlNode),
                        null,
                        false,
                        false,
                        false,
                        false,
                        false),
                    new EventPropertyDescriptor("map('a')?", typeof(XmlNode), null, false, false, false, false, false)
                },
                env.Statement("s0").EventType.PropertyDescriptors);
            SupportEventTypeAssertionUtil.AssertConsistency(env.Statement("s0").EventType);

            var sender = env.EventService.GetEventSender("MyEventWithPrefix");
            var root = SupportXML.SendEvent(sender, SCHEMA_XML);

            var theEvent = env.Listener("s0").AssertOneGetNewAndReset();
            Assert.AreSame(root.DocumentElement.ChildNodes.Item(0), theEvent.Get("type?"));
            Assert.AreSame(root.DocumentElement.ChildNodes.Item(2), theEvent.Get("dyn[1]?"));
            Assert.AreSame(root.DocumentElement.ChildNodes.Item(3).ChildNodes.Item(0), theEvent.Get("nested.nes2?"));
            Assert.AreSame(root.DocumentElement.ChildNodes.Item(4), theEvent.Get("map('a')?"));
            SupportEventTypeAssertionUtil.AssertConsistency(theEvent);

            env.UndeployAll();
        }
コード例 #17
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                var epl  =
                    "@public create window WinSB#lastevent as SupportBean;\n" +
                    "insert into WinSB select * from SupportBean;\n";

                if (namedWindow)
                {
                    epl +=
                        "@public create window InfraS0#lastevent as SupportBean_S0;\n" +
                        "insert into InfraS0 select * from SupportBean_S0;\n";
                }
                else
                {
                    epl +=
                        "@public create table InfraS0(Id int primary key, P00 string);\n" +
                        "on SupportBean_S0 as s0 merge InfraS0 as is0 where s0.Id = is0.Id" +
                        "  when not matched then insert select Id, P00 when matched then update set is0.P00=s0.P00;\n";
                }

                var query = "select (select P00 from InfraS0) as c0 from WinSB";

                env.CompileDeploy(epl, path);

                AssertQueryNoRows(env, path, query, typeof(string));

                SendSB(env, "E1", 1);
                AssertQuerySingle(env, path, query, null);

                SendS0(env, 1, "a");
                AssertQuerySingle(env, path, query, "a");

                SendS0(env, 1, "b");
                AssertQuerySingle(env, path, query, "b");

                env.UndeployAll();
            }
コード例 #18
0
ファイル: EPLOtherSplitStream.cs プロジェクト: lanicon/nesper
        private static void TryAssertionFromClauseAsMultiple(
            RegressionEnvironment env,
            bool soda)
        {
            var path = new RegressionPath();
            var epl = "on OrderBean as oe " +
                      "insert into StartEvent select oe.OrderDetail.OrderId as oi " +
                      "insert into ThenEvent select * from [select oe.OrderDetail.OrderId as oi, ItemId from OrderDetail.Items] as item " +
                      "insert into MoreEvent select oe.OrderDetail.OrderId as oi, item.ItemId as ItemId from [select oe, * from OrderDetail.Items] as item " +
                      "output all";
            env.CompileDeploy(soda, epl, path);

            var listeners = GetListeners(env);
            env.CompileDeploy("@Name('s0') select * from StartEvent", path).AddListener("s0", listeners[0]);
            env.CompileDeploy("@Name('s1') select * from ThenEvent", path).AddListener("s1", listeners[1]);
            env.CompileDeploy("@Name('s2') select * from MoreEvent", path).AddListener("s2", listeners[2]);

            env.SendEventBean(OrderBeanFactory.MakeEventOne());
            var fieldsOrderId = new[] {"oi"};
            var fieldsItems = new[] {"oi", "ItemId"};
            EPAssertionUtil.AssertProps(
                listeners[0].AssertOneGetNewAndReset(),
                fieldsOrderId,
                new object[] {"PO200901"});
            object[][] expected = {
                new object[] {"PO200901", "A001"}, new object[] {"PO200901", "A002"}, new object[] {"PO200901", "A003"}
            };
            EPAssertionUtil.AssertPropsPerRow(
                listeners[1].GetAndResetDataListsFlattened().First,
                fieldsItems,
                expected);
            EPAssertionUtil.AssertPropsPerRow(
                listeners[2].GetAndResetDataListsFlattened().First,
                fieldsItems,
                expected);

            env.UndeployAll();
        }
コード例 #19
0
ファイル: ClientRuntimeItself.cs プロジェクト: lanicon/nesper
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeploy("create window SomeWindow#keepall as SupportBean", path);

                var compiledFAF = env.CompileFAF("select * from SomeWindow", path);
                var compiledModule = env.Compile("select * from SomeWindow", path);

                var msgInvalidDeployFAF =
                    "Cannot deploy EPL that was compiled as a fire-and-forget query, make sure to use the 'compile' method of the compiler";
                try {
                    env.Runtime.DeploymentService.Deploy(compiledFAF);
                    Assert.Fail();
                }
                catch (EPDeployException ex) {
                    Assert.AreEqual(msgInvalidDeployFAF, ex.Message);
                }

                try {
                    env.Runtime.DeploymentService.Rollout(Collections.SingletonList(new EPDeploymentRolloutCompiled(compiledFAF)));
                    Assert.Fail();
                }
                catch (EPDeployException ex) {
                    Assert.AreEqual(msgInvalidDeployFAF, ex.Message);
                }

                try {
                    env.Runtime.FireAndForgetService.ExecuteQuery(compiledModule);
                    Assert.Fail();
                }
                catch (EPException ex) {
                    Assert.AreEqual(
                        "Cannot execute a fire-and-forget query that was compiled as module EPL, make sure to use the 'compileQuery' method of the compiler",
                        ex.Message);
                }

                env.UndeployAll();
            }
コード例 #20
0
        private static void TryAssertionTypableSubquerySingleMayFilter(
            RegressionEnvironment env,
            string typeType,
            bool filter)
        {
            var path = new RegressionPath();
            env.CompileDeploy("create " + typeType + " schema EventZero(e0_0 string, e0_1 string)", path);
            env.CompileDeploy("create " + typeType + " schema EventOne(ez EventZero)", path);

            var fields = new[] {"ez.e0_0", "ez.e0_1"};
            env.CompileDeploy(
                    "@Name('s0') insert into EventOne select " +
                    "(select P00 as e0_0, P01 as e0_1 from SupportBean_S0#lastevent" +
                    (filter ? " where Id >= 100" : "") +
                    ") as ez " +
                    "from SupportBean",
                    path)
                .AddListener("s0");

            env.SendEventBean(new SupportBean_S0(1, "x1", "y1"));
            env.SendEventBean(new SupportBean("E1", 1));
            var expected = filter ? new object[] {null, null} : new object[] {"x1", "y1"};
            EPAssertionUtil.AssertProps(env.Listener("s0").AssertOneGetNewAndReset(), fields, expected);

            env.SendEventBean(new SupportBean_S0(100, "x2", "y2"));
            env.SendEventBean(new SupportBean("E2", 2));
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fields,
                new object[] {"x2", "y2"});

            env.SendEventBean(new SupportBean_S0(2, "x3", "y3"));
            env.SendEventBean(new SupportBean("E3", 3));
            expected = filter ? new object[] {null, null} : new object[] {"x3", "y3"};
            EPAssertionUtil.AssertProps(env.Listener("s0").AssertOneGetNewAndReset(), fields, expected);

            env.UndeployAll();
        }
コード例 #21
0
            public void Run(RegressionEnvironment env)
            {
                var fields = new[] {"TheString"};
                var path = new RegressionPath();
                env.CompileDeploy("@Name('create') create table MyTableIIU(TheString string)", path);
                env.CompileDeploy("@Name('tbl-insert') insert into MyTableIIU select TheString from SupportBean", path);

                EPAssertionUtil.AssertPropsPerRow(env.GetEnumerator("create"), fields, new object[0][]);

                env.SendEventBean(new SupportBean("E1", 0));
                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("create"),
                    fields,
                    new[] {
                        new object[] {"E1"}
                    });

                env.Milestone(0);

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

                try {
                    env.SendEventBean(new SupportBean("E2", 0));
                    Assert.Fail();
                }
                catch (EPException ex) {
                    SupportMessageAssertUtil.AssertMessage(
                        ex,
                        "Unexpected exception in statement 'tbl-insert': Unique index violation, table 'MyTableIIU' is a declared to hold a single un-keyed row");
                }

                env.UndeployAll();
            }
コード例 #22
0
            public void Run(RegressionEnvironment env)
            {
                RunAssertionAllTypes(env, "MyXMLEvent", DefaultSupportGraphEventUtil.GetXMLEvents());
                RunAssertionAllTypes(env, "MyOAEvent", DefaultSupportGraphEventUtil.GetOAEvents());
                RunAssertionAllTypes(env, "MyMapEvent", DefaultSupportGraphEventUtil.GetMapEvents());
                RunAssertionAllTypes(
                    env,
                    DefaultSupportGraphEventUtil.EVENTTYPENAME,
                    DefaultSupportGraphEventUtil.GetPONOEvents());

                // invalid: output stream
                TryInvalidCompile(
                    env,
                    "create dataflow DF1 EventBusSink -> s1 {}",
                    "Failed to obtain operator 'EventBusSink': EventBusSink operator does not provide an output stream");

                var path = new RegressionPath();
                env.CompileDeploy("create schema SampleSchema(tagId string, locX double, locY double)", path);
                var docSmple = "@Name('s0') create dataflow MyDataFlow\n" +
                               "BeaconSource -> instream<SampleSchema> {} // produces sample stream to\n" +
                               "//demonstrate below\n" +
                               "// Send SampleSchema events produced by beacon to the event bus.\n" +
                               "EventBusSink(instream) {}\n" +
                               "\n" +
                               "// Send SampleSchema events produced by beacon to the event bus.\n" +
                               "// With collector that performs transformation.\n" +
                               "EventBusSink(instream) {\n" +
                               "collector : {\n" +
                               "class : '" +
                               typeof(MyTransformToEventBus).MaskTypeName() +
                               "'\n" +
                               "}\n" +
                               "}";
                env.CompileDeploy(docSmple, path);
                env.Runtime.DataFlowService.Instantiate(env.DeploymentId("s0"), "MyDataFlow");

                env.UndeployAll();
            }
コード例 #23
0
            private static void TryAssertionTestExpressionUse(
                RegressionEnvironment env,
                bool namedWindow)
            {
                var path = new RegressionPath();
                env.CompileDeploy("create expression myexpr {(select IntPrimitive from MyInfra)}", path);
                var eplCreate = namedWindow
                    ? "create window MyInfra#keepall as SupportBean"
                    : "create table MyInfra(TheString string, IntPrimitive int)";
                env.CompileDeploy(eplCreate, path);
                env.CompileDeploy("insert into MyInfra select TheString, IntPrimitive from SupportBean", path);
                env.CompileDeploy("@Name('s0') select myexpr() as c0 from SupportBean_S0", path).AddListener("s0");
                AssertStatelessStmt(env, "s0", false);

                env.SendEventBean(new SupportBean("E1", 100));
                env.SendEventBean(new SupportBean_S0(1, "E1"));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    new[] {"c0"},
                    new object[] {100});

                env.UndeployAll();
            }
コード例 #24
0
        private void RunAssertion(
            RegressionEnvironment env,
            RegressionPath path,
            string epl,
            string timestampB,
            long durationB,
            string expectedAKey)
        {
            env.CompileDeploy("@Name('s0') " + epl, path).AddListener("s0");

            // query
            var startTime = PerformanceObserver.MilliTime;
            for (var i = 0; i < 1000; i++) {
                env.SendEventBean(SupportTimeStartEndB.Make("B", timestampB, durationB));
                Assert.AreEqual(expectedAKey, env.Listener("s0").AssertOneGetNewAndReset().Get("c0"));
            }

            var endTime = PerformanceObserver.MilliTime;
            var delta = endTime - startTime;
            Assert.That(delta, Is.LessThan(500), "Delta=" + delta / 1000d);

            env.UndeployModuleContaining("s0");
        }
コード例 #25
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeploy("create table MyTable(total sum(int))", path);
                env.CompileDeploy("into table MyTable select sum(IntPrimitive) as total from SupportBean", path);
                env.CompileDeploy(
                    "@Name('s0') select (select sum(total) from MyTable having sum(total) > 100) as c0 from SupportBean_S0",
                    path);
                env.AddListener("s0");

                SendEventS0Assert(env, null);

                SendSB(env, "E1", 50);
                SendEventS0Assert(env, null);

                SendSB(env, "E2", 55);
                SendEventS0Assert(env, 105);

                SendSB(env, "E3", -5);
                SendEventS0Assert(env, null);

                env.UndeployAll();
            }
コード例 #26
0
ファイル: EPLScriptExpression.cs プロジェクト: lanicon/nesper
        private static void TryCreateExpressionWArrayAllocate(RegressionEnvironment env)
        {
            var path = new RegressionPath();
            var epl =
                "@Name('first') create expression double js:test(bar) [\n" +
                "function test(bar) {\n" +
                "  var test=[];\n" +
                "  return -1.0;\n" +
                "}\n" +
                "return test(bar);\n" +
                "]\n";
            env.CompileDeploy(epl, path);

            env.CompileDeploy("@Name('s0') select test('a') as c0 from SupportBean_S0", path).AddListener("s0");
            env.Listener("s0").Reset();
            env.SendEventBean(new SupportBean_S0(0));
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                new[] {"c0"},
                new object[] {-1d});

            env.UndeployAll();
        }
コード例 #27
0
        private void RunAssertionBeanNav(
            RegressionEnvironment env,
            string typename,
            FunctionSendEvent4Int send,
            RegressionPath path)
        {
            var epl = "@Name('s0') select * from " + typename;

            env.CompileDeploy(epl, path).AddListener("s0");

            send.Invoke(typename, env, 1, 2, 3, 4);
            var @event = env.Listener("s0").AssertOneGetNewAndReset();

            EPAssertionUtil.AssertProps(@event, "L1.Lvl1,L1.L2.Lvl2,L1.L2.L3.Lvl3,L1.L2.L3.L4.Lvl4".SplitCsv(), new object[] { 1, 2, 3, 4 });
            SupportEventTypeAssertionUtil.AssertConsistency(@event);
            var nativeFragment = typename.Equals(BEAN_TYPENAME) || typename.Equals(JSONPROVIDED_TYPENAME);

            SupportEventTypeAssertionUtil.AssertFragments(@event, nativeFragment, false, "L1.L2");
            SupportEventTypeAssertionUtil.AssertFragments(@event, nativeFragment, false, "L1,L1.L2,L1.L2.L3,L1.L2.L3.L4");
            RunAssertionEventInvalidProp(@event);

            env.UndeployModuleContaining("s0");
        }
コード例 #28
0
            public void Run(RegressionEnvironment env)
            {
                // External clocking
                SendTimer(0, env);

                // Set up a timer:within
                var path = new RegressionPath();

                env.CompileDeploy("create variable double M_isv=1", path);
                env.CompileDeploy("create variable double S_isv=2", path);
                env.CompileDeploy(
                    "@Name('s0') select * from pattern [timer:interval(M_isv minute S_isv seconds)]",
                    path);
                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();
            }
コード例 #29
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeploy("create schema SomeType ()", path);
                env.CompileDeploy(
                    "@Name('flow') create dataflow MyDataFlowOne " +
                    "DefaultSupportSourceOp -> outstream<SomeType> {}" +
                    "DefaultSupportCaptureOp(outstream) {}",
                    path);

                var src = new DefaultSupportSourceOp(new object[] {new MyException("TestException")});
                var output = new DefaultSupportCaptureOp();
                var options =
                    new EPDataFlowInstantiationOptions().WithOperatorProvider(
                        new DefaultSupportGraphOpProvider(src, output));
                var dfOne = env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "MyDataFlowOne", options);

                dfOne.Start();
                Sleep(200);
                Assert.AreEqual(EPDataFlowState.COMPLETE, dfOne.State);
                Assert.AreEqual(0, output.GetAndReset().Count);
                env.UndeployAll();
            }
コード例 #30
0
            public void Run(RegressionEnvironment env)
            {
                // declared via EPL
                var path = new RegressionPath();
                env.CompileDeploy(
                    "create constant variable MySimpleVariableService myService = MySimpleVariableServiceFactory.MakeService()",
                    path);

                // exercise
                var epl = "@Name('s0') select " +
                          "myService.DoSomething() as c0, " +
                          "myInitService.DoSomething() as c1 " +
                          "from SupportBean";
                env.CompileDeploy(epl, path).AddListener("s0");

                env.SendEventBean(new SupportBean("E1", 1));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    new[] {"c0", "c1"},
                    new object[] {"hello", "hello"});

                env.UndeployAll();
            }