Пример #1
0
            public void Run(RegressionEnvironment env)
            {
                RegressionPath path = new RegressionPath();
                string epl = namedWindow
                    ? "@public create window MyInfra#keepall as (Id string, ArrayOne string[], Value int);\n"
                    : "@public create table MyInfra(Id string primary key, ArrayOne string[], Value int);\n";
                epl += "insert into MyInfra select Id, StringOne as ArrayOne, Value from SupportEventWithManyArray;\n" +
                       "create index MyInfraIndex on MyInfra(ArrayOne, Value btree);\n";
                env.CompileDeploy(epl, path);

                SendManyArray(env, "E1", new string[] {"a", "b"}, 100);
                SendManyArray(env, "E2", new string[] {"a", "b"}, 200);
                SendManyArray(env, "E3", new string[] {"a"}, 300);

                env.Milestone(0);

                AssertFAF(env, path, "ArrayOne = {'a', 'b'} and Value < 150", "E1");
                AssertFAF(env, path, "ArrayOne = {'a', 'b'} and Value > 150", "E2");
                AssertFAF(env, path, "ArrayOne = {'a'} and Value > 200", "E3");
                AssertFAFNot(env, path, "ArrayOne = {'a'} and Value > 400");
                AssertFAFNot(env, path, "ArrayOne = {'a', 'c'} and Value < 150");

                env.UndeployAll();
            }
Пример #2
0
            public void Run(RegressionEnvironment env)
            {
                var epl = "@Name('s0') select case TheString " +
                          " when null then true " +
                          " when '' then false end as p1" +
                          " from SupportBean#length(100)";

                env.CompileDeploy(epl).AddListener("s0");
                Assert.AreEqual(typeof(bool?), env.Statement("s0").EventType.GetPropertyType("p1"));

                SendSupportBeanEvent(env, "x");
                Assert.AreEqual(null, env.Listener("s0").AssertOneGetNewAndReset().Get("p1"));

                SendSupportBeanEvent(env, "null");
                Assert.AreEqual(null, env.Listener("s0").AssertOneGetNewAndReset().Get("p1"));

                SendSupportBeanEvent(env, null);
                Assert.AreEqual(true, env.Listener("s0").AssertOneGetNewAndReset().Get("p1"));

                SendSupportBeanEvent(env, "");
                Assert.AreEqual(false, env.Listener("s0").AssertOneGetNewAndReset().Get("p1"));

                env.UndeployAll();
            }
Пример #3
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                var epl = "create window MyWindow#keepall as (key string, anint int);\n" +
                          "insert into MyWindow(key, anint) select Id, Value from SupportIdAndValueEvent;\n" +
                          "@Name('s0') select exists (select sum(anint) from MyWindow group by key having sum(anint) < 15) as c0," +
                          "not exists (select sum(anint) from MyWindow group by key having sum(anint) < 15) as c1 from SupportValueEvent";
                var fields = new[] {"c0", "c1"};
                env.CompileDeploy(epl, path).AddListener("s0");

                SendVEAndAssert(
                    env,
                    fields,
                    new object[] {false, true});

                env.SendEventBean(new SupportIdAndValueEvent("E1", 19));
                SendVEAndAssert(
                    env,
                    fields,
                    new object[] {false, true});

                env.SendEventBean(new SupportIdAndValueEvent("E2", 12));
                SendVEAndAssert(
                    env,
                    fields,
                    new object[] {true, false});

                env.CompileExecuteFAF("delete from MyWindow", path);

                SendVEAndAssert(
                    env,
                    fields,
                    new object[] {false, true});

                env.UndeployAll();
            }
Пример #4
0
            public void Run(RegressionEnvironment env)
            {
                var epl = "@Name('context') create context NineToFive as start (0, 9, *, *, *) end (0, 17, *, *, *)";
                Assert.AreEqual(0, SupportContextMgmtHelper.GetContextCount(env));
                Assert.AreEqual(0, SupportScheduleHelper.ScheduleCountOverall(env));

                // create and destroy
                env.CompileDeploy(epl);
                Assert.AreEqual(1, SupportContextMgmtHelper.GetContextCount(env));
                Assert.AreEqual(0, SupportScheduleHelper.ScheduleCountOverall(env));

                env.UndeployModuleContaining("context");
                Assert.AreEqual(0, SupportContextMgmtHelper.GetContextCount(env));

                // create context, create statement, destroy statement, destroy context
                var path = new RegressionPath();
                env.CompileDeploy(epl, path);
                Assert.AreEqual(1, SupportContextMgmtHelper.GetContextCount(env));

                env.CompileDeploy("@Name('s0') context NineToFive select * from SupportBean", path);
                Assert.AreEqual(1, SupportScheduleHelper.ScheduleCountOverall(env));

                env.UndeployModuleContaining("s0");
                Assert.AreEqual(0, SupportScheduleHelper.ScheduleCountOverall(env));

                env.UndeployModuleContaining("context");
                Assert.AreEqual(0, SupportContextMgmtHelper.GetContextCount(env));

                // create same context
                path.Clear();
                env.CompileDeploy(epl, path);
                env.CompileDeploy("@Name('C') context NineToFive select * from SupportBean", path);
                env.CompileDeploy("@Name('D') context NineToFive select * from SupportBean", path);

                Assert.AreEqual(1, SupportScheduleHelper.ScheduleCountOverall(env));

                env.UndeployAll();
                Assert.AreEqual(0, SupportContextMgmtHelper.GetContextCount(env));
                Assert.AreEqual(0, SupportScheduleHelper.ScheduleCountOverall(env));

                env.UndeployAll();
            }
Пример #5
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                // widen to long
                var stmtTextCreate = namedWindow
                    ? "create window MyInfraW#keepall as (f1 long, f2 string)"
                    : "create table MyInfraW as (f1 long primary key, f2 string primary key)";
                env.CompileDeploy(stmtTextCreate, path);
                env.CompileDeploy(
                    "insert into MyInfraW(f1, f2) select LongPrimitive, TheString from SupportBean",
                    path);
                env.CompileDeploy("create index MyInfraWIndex1 on MyInfraW(f1)", path);
                var fields = new [] { "f1","f2" };

                SendEventLong(env, "E1", 10L);

                var result = env.CompileExecuteFAF("select * from MyInfraW where f1=10", path);
                EPAssertionUtil.AssertPropsPerRow(
                    result.Array,
                    fields,
                    new[] {new object[] {10L, "E1"}});

                // coerce to short
                stmtTextCreate = namedWindow
                    ? "create window MyInfraWTwo#keepall as (f1 short, f2 string)"
                    : "create table MyInfraWTwo as (f1 short primary key, f2 string primary key)";
                env.CompileDeploy(stmtTextCreate, path);
                env.CompileDeploy(
                    "insert into MyInfraWTwo(f1, f2) select ShortPrimitive, TheString from SupportBean",
                    path);
                env.CompileDeploy("create index MyInfraWTwoIndex1 on MyInfraWTwo(f1)", path);

                SendEventShort(env, "E1", 2);

                result = env.CompileExecuteFAF("select * from MyInfraWTwo where f1=2", path);
                EPAssertionUtil.AssertPropsPerRow(
                    result.Array,
                    fields,
                    new[] {new object[] {(short) 2, "E1"}});

                env.UndeployAll();
            }
            public void Run(RegressionEnvironment env)
            {
                SendTimer(0, env);
                var listener = env.ListenerNew();
                env.CompileDeploy("@Name('s1') @Priority(1) select 1 as prio from pattern [every timer:interval(10)]");
                env.CompileDeploy("@Name('s3') @Priority(3) select 3 as prio from pattern [every timer:interval(10)]");
                env.CompileDeploy("@Name('s2') @Priority(2) select 2 as prio from pattern [every timer:interval(10)]");
                env.CompileDeploy("@Name('s4') @Priority(4) select 4 as prio from pattern [every timer:interval(10)]");
                env.Statement("s1").AddListener(listener);
                env.Statement("s2").AddListener(listener);
                env.Statement("s3").AddListener(listener);
                env.Statement("s4").AddListener(listener);

                SendTimer(10000, env);
                AssertPrio(listener, null, new[] {4, 3, 2, 1});

                env.UndeployModuleContaining("s2");
                env.CompileDeploy("@Name('s0') select 0 as prio from pattern [every timer:interval(10)]");
                env.Statement("s0").AddListener(listener);

                SendTimer(20000, env);
                AssertPrio(listener, null, new[] {4, 3, 1, 0});

                env.CompileDeploy("@Name('s2') @Priority(2) select 2 as prio from pattern [every timer:interval(10)]");
                env.Statement("s2").AddListener(listener);

                SendTimer(30000, env);
                AssertPrio(listener, null, new[] {4, 3, 2, 1, 0});

                env.CompileDeploy("@Name('s5') @Priority(3) select 3 as prio from pattern [every timer:interval(10)]");
                env.Statement("s5").AddListener(listener);

                SendTimer(40000, env);
                AssertPrio(listener, null, new[] {4, 3, 3, 2, 1, 0});

                env.UndeployAll();
            }
            public void Run(RegressionEnvironment env)
            {
                var pathA = new RegressionPath();

                env.CompileDeploy("module A;\n @name('createA') @protected create window MyWindow#keepall as SupportBean", pathA);

                var pathB = new RegressionPath();

                env.CompileDeploy("module B;\n @name('createB') @protected create window MyWindow#keepall as SupportBean", pathB);

                env.CompileDeploy("@Name('B1') select * from MyWindow", pathB);
                env.CompileDeploy("@Name('A1') select * from MyWindow", pathA);
                env.CompileDeploy("@Name('A2') select * from MyWindow", pathA);
                env.CompileDeploy("@Name('B2') select * from MyWindow", pathB);

                AssertProvided(
                    env,
                    env.DeploymentId("createA"),
                    MakeProvided(EPObjectType.NAMEDWINDOW, "MyWindow", env.DeploymentId("A1"), env.DeploymentId("A2")));
                AssertProvided(
                    env,
                    env.DeploymentId("createB"),
                    MakeProvided(EPObjectType.NAMEDWINDOW, "MyWindow", env.DeploymentId("B1"), env.DeploymentId("B2")));
                foreach (var name in new string[] { "A1", "A2" })
                {
                    AssertConsumed(
                        env,
                        env.DeploymentId(name),
                        new EPDeploymentDependencyConsumed.Item(env.DeploymentId("createA"), EPObjectType.NAMEDWINDOW, "MyWindow"));
                }

                foreach (var name in new string[] { "B1", "B2" })
                {
                    AssertConsumed(
                        env,
                        env.DeploymentId(name),
                        new EPDeploymentDependencyConsumed.Item(env.DeploymentId("createB"), EPObjectType.NAMEDWINDOW, "MyWindow"));
                }

                env.UndeployAll();
            }
Пример #8
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();

                // test dispatch between named windows
                env.CompileDeploy("@Name('A') create window A#unique(Id) as (Id int)", path);
                env.CompileDeploy("@Name('B') create window B#unique(Id) as (Id int)", path);
                env.CompileDeploy(
                    "@Name('C') on A merge B when not matched then insert select 1 as Id when matched then insert select 1 as Id",
                    path);

                env.CompileDeploy("@Name('D') select * from B", path).AddListener("D");
                env.CompileDeploy("@Name('E') insert into A select IntPrimitive as Id from SupportBean", path);

                env.SendEventBean(new SupportBean("E1", 1));
                Assert.IsTrue(env.Listener("D").IsInvoked);
                env.UndeployAll();

                // test insert-stream only, no remove stream
                var fields = new[] {"c0", "c1"};
                var epl = "create window W1#lastevent as SupportBean;\n" +
                          "insert into W1 select * from SupportBean;\n" +
                          "create window W2#lastevent as SupportBean;\n" +
                          "on W1 as a merge W2 as b when not matched then insert into OutStream select a.TheString as c0, istream() as c1;\n" +
                          "@Name('s0') select * from OutStream;\n";
                env.CompileDeploy(epl).AddListener("s0");

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

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

                env.UndeployAll();
            }
Пример #9
0
            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();
            }
Пример #10
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeploy(
                    "@Name('context') create context SegmentedByString partition by TheString from SupportBean",
                    path);

                var fieldsOne = new [] { "IntPrimitive","count(*)" };
                env.CompileDeploy(
                    "@Name('s0') context SegmentedByString select IntPrimitive, count(*) from SupportBean group by IntPrimitive",
                    path);
                env.AddListener("s0");

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

                env.SendEventBean(new SupportBean("G2", 200));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsOne,
                    new object[] {200, 1L});

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

                env.SendEventBean(new SupportBean("G1", 11));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsOne,
                    new object[] {11, 1L});

                env.SendEventBean(new SupportBean("G2", 200));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsOne,
                    new object[] {200, 2L});

                env.SendEventBean(new SupportBean("G2", 10));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsOne,
                    new object[] {10, 1L});

                env.UndeployModuleContaining("s0");

                // add "string" : a context property
                var fieldsTwo = new [] { "TheString","IntPrimitive","count(*)" };
                env.CompileDeploy(
                    "@Name('s0') context SegmentedByString select TheString, IntPrimitive, count(*) from SupportBean group by IntPrimitive",
                    path);
                env.AddListener("s0");

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

                env.SendEventBean(new SupportBean("G2", 200));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsTwo,
                    new object[] {"G2", 200, 1L});

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

                env.SendEventBean(new SupportBean("G1", 11));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsTwo,
                    new object[] {"G1", 11, 1L});

                env.SendEventBean(new SupportBean("G2", 200));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsTwo,
                    new object[] {"G2", 200, 2L});

                env.SendEventBean(new SupportBean("G2", 10));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsTwo,
                    new object[] {"G2", 10, 1L});

                env.UndeployAll();
            }
Пример #11
0
            public void Run(RegressionEnvironment env)
            {
                var fields = new[] {"TheString", "mysum"};
                var epl = "create window MyWindow.win:keepall() as select * from SupportBean;\n" +
                          "insert into MyWindow select * from SupportBean;\n" +
                          "on SupportBean_A a delete from MyWindow w where w.TheString = a.Id;\n" +
                          "on SupportBean_B delete from MyWindow;\n" +
                          "@Name('s0') select TheString, sum(IntPrimitive) as mysum from MyWindow group by TheString order by TheString";
                env.CompileDeploy(epl).AddListener("s0");

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

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

                env.Milestone(0);

                env.SendEventBean(new SupportBean("A", 101));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"A", 201});

                env.Milestone(1);

                env.SendEventBean(new SupportBean("B", 21));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"B", 41});
                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"A", 201}, new object[] {"B", 41}});

                env.Milestone(2);

                env.SendEventBean(new SupportBean_A("A"));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"A", null});
                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"B", 41}});

                env.Milestone(3);

                env.SendEventBean(new SupportBean("A", 102));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"A", 102});
                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"A", 102}, new object[] {"B", 41}});

                env.Milestone(4);

                env.SendEventBean(new SupportBean_A("B"));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"B", null});
                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"A", 102}});

                env.Milestone(5);

                env.SendEventBean(new SupportBean("B", 22));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"B", 22});
                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"A", 102}, new object[] {"B", 22}});

                env.UndeployAll();
            }
Пример #12
0
            public void Run(RegressionEnvironment env)
            {
                env.CompileDeploy("select current_timestamp.toDateTimeEx().AddDays(1) from SupportBean");

                var startTime = "2002-05-30T09:00:00.000";
                env.AdvanceTime(DateTimeParsingFunctions.ParseDefaultMSec(startTime));

                string[] fields = {
                    "val1a", "val1b", "val1c", "val1d", "val1e",
                    "val2a", "val2b", "val2c", "val2d", "val2e",
                    "val3a", "val3b", "val3c", "val3d", "val3e",
                    "val4a", "val4b", "val4c", "val4d", "val4e",
                };

                var eplFragment =
                    "@Name('s0') select " +

                    "current_timestamp.toDateTime() as val1a," +
                    "LongDate.toDateTime() as val1b," +
                    "DateTimeEx.toDateTime() as val1c," +
                    "DateTimeOffset.toDateTime() as val1d," +
                    "DateTimeEx.toDateTime() as val1e," +

                    "current_timestamp.toDateTimeOffset() as val2a," +
                    "LongDate.toDateTimeOffset() as val2b," +
                    "DateTime.toDateTimeOffset() as val2c," +
                    "DateTimeOffset.toDateTimeOffset() as val2d," +
                    "DateTimeEx.toDateTimeOffset() as val2e," +

                    "current_timestamp.toDateTimeEx() as val3a," +
                    "LongDate.toDateTimeEx() as val3b," +
                    "DateTime.toDateTimeEx() as val3c," +
                    "DateTimeOffset.toDateTimeEx() as val3d," +
                    "DateTimeEx.toDateTimeEx() as val3e," +

                    "current_timestamp.toMillisec() as val4a," +
                    "LongDate.toMillisec() as val4b," +
                    "DateTime.toMillisec() as val4c," +
                    "DateTimeOffset.toMillisec() as val4d," +
                    "DateTimeEx.toMillisec() as val4e" +

                    " from SupportDateTime";

                env.CompileDeploy(eplFragment).AddListener("s0");
                LambdaAssertionUtil.AssertTypes(
                    env.Statement("s0").EventType,
                    fields,
                    new[] {
                        typeof(DateTime?),
                        typeof(DateTime?),
                        typeof(DateTime?),
                        typeof(DateTime?),
                        typeof(DateTime?),

                        typeof(DateTimeOffset?),
                        typeof(DateTimeOffset?),
                        typeof(DateTimeOffset?),
                        typeof(DateTimeOffset?),
                        typeof(DateTimeOffset?),

                        typeof(DateTimeEx),
                        typeof(DateTimeEx),
                        typeof(DateTimeEx),
                        typeof(DateTimeEx),
                        typeof(DateTimeEx),

                        typeof(long?),
                        typeof(long?),
                        typeof(long?),
                        typeof(long?),
                        typeof(long?)
                    });

                env.SendEventBean(SupportDateTime.Make(startTime));

                var expected = EPAssertionUtil.ConcatenateArray(
                    SupportDateTime.GetArrayCoerced(startTime, "date".Repeat(5)),
                    SupportDateTime.GetArrayCoerced(startTime, "dto".Repeat(5)),
                    SupportDateTime.GetArrayCoerced(startTime, "dtx".Repeat(5)),
                    SupportDateTime.GetArrayCoerced(startTime, "long".Repeat(5)));

                EPAssertionUtil.AssertProps(env.Listener("s0").AssertOneGetNewAndReset(), fields, expected);

                env.SendEventBean(SupportDateTime.Make(null));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new[] {
                        SupportDateTime.GetValueCoerced(startTime, "date"), null, null, null, null,
                        SupportDateTime.GetValueCoerced(startTime, "dto"), null, null, null, null,
                        SupportDateTime.GetValueCoerced(startTime, "dtx"), null, null, null, null,
                        SupportDateTime.GetValueCoerced(startTime, "long"), null, null, null, null
                    });

                env.UndeployAll();
            }
Пример #13
0
            public void Run(RegressionEnvironment env)
            {
                string[] fields = {"TheString"};
                var epl = "@Name('s0') select irstream TheString from SupportBean#expr(sum(IntPrimitive) < 10)";
                env.CompileDeploy(epl).AddListener("s0");

                env.SendEventBean(new SupportBean("E1", 1));
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E1"}});
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E1"});

                env.Milestone(0);

                env.SendEventBean(new SupportBean("E2", 9));
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E2"}});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").GetAndResetDataListsFlattened(),
                    fields,
                    new[] {new object[] {"E2"}},
                    new[] {new object[] {"E1"}});

                env.SendEventBean(new SupportBean("E3", 11));
                EPAssertionUtil.AssertPropsPerRow(env.Statement("s0").GetEnumerator(), fields, null);
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").GetAndResetDataListsFlattened(),
                    fields,
                    new[] {new object[] {"E3"}},
                    new[] {new object[] {"E2"}, new object[] {"E3"}});

                env.Milestone(1);

                env.SendEventBean(new SupportBean("E4", 12));
                EPAssertionUtil.AssertPropsPerRow(env.Statement("s0").GetEnumerator(), fields, null);
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").GetAndResetDataListsFlattened(),
                    fields,
                    new[] {new object[] {"E4"}},
                    new[] {new object[] {"E4"}});

                env.SendEventBean(new SupportBean("E5", 1));
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E5"}});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").GetAndResetDataListsFlattened(),
                    fields,
                    new[] {new object[] {"E5"}},
                    null);

                env.Milestone(2);

                env.SendEventBean(new SupportBean("E6", 2));
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E5"}, new object[] {"E6"}});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").GetAndResetDataListsFlattened(),
                    fields,
                    new[] {new object[] {"E6"}},
                    null);

                env.SendEventBean(new SupportBean("E7", 3));
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E5"}, new object[] {"E6"}, new object[] {"E7"}});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").GetAndResetDataListsFlattened(),
                    fields,
                    new[] {new object[] {"E7"}},
                    null);

                env.Milestone(3);

                env.SendEventBean(new SupportBean("E8", 6));
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E7"}, new object[] {"E8"}});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").GetAndResetDataListsFlattened(),
                    fields,
                    new[] {new object[] {"E8"}},
                    new[] {new object[] {"E5"}, new object[] {"E6"}});

                env.SendEventBean(new SupportBean("E9", 9));
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E9"}});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").GetAndResetDataListsFlattened(),
                    fields,
                    new[] {new object[] {"E9"}},
                    new[] {new object[] {"E7"}, new object[] {"E8"}});

                env.UndeployAll();
            }
Пример #14
0
            public void Run(RegressionEnvironment env)
            {
                env.AdvanceTime(0);

                string[] fields = {"TheString"};
                var epl =
                    "@Name('s0') select irstream * from SupportBean#expr(oldest_timestamp > newest_timestamp - 2000)";
                env.CompileDeploy(epl).AddListener("s0");

                env.AdvanceTime(1000);
                env.SendEventBean(new SupportBean("E1", 1));
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E1"}});
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E1"});

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

                env.Milestone(0);

                env.SendEventBean(new SupportBean("E3", 3));
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E1"}, new object[] {"E2"}, new object[] {"E3"}});
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E3"});

                env.AdvanceTime(2500);
                env.SendEventBean(new SupportBean("E4", 4));
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E1"}, new object[] {"E2"}, new object[] {"E3"}, new object[] {"E4"}});

                env.AdvanceTime(3000);
                env.SendEventBean(new SupportBean("E5", 5));
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E2"}, new object[] {"E3"}, new object[] {"E4"}, new object[] {"E5"}});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").LastNewData,
                    fields,
                    new[] {new object[] {"E5"}});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").LastOldData,
                    fields,
                    new[] {new object[] {"E1"}});
                env.Listener("s0").Reset();

                env.AdvanceTime(3499);
                env.SendEventBean(new SupportBean("E6", 6));
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {
                        new object[] {"E2"}, new object[] {"E3"}, new object[] {"E4"}, new object[] {"E5"},
                        new object[] {"E6"}
                    });

                env.Milestone(1);

                env.AdvanceTime(3500);
                env.SendEventBean(new SupportBean("E7", 7));
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E4"}, new object[] {"E5"}, new object[] {"E6"}, new object[] {"E7"}});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").LastNewData,
                    fields,
                    new[] {new object[] {"E7"}});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").LastOldData,
                    fields,
                    new[] {new object[] {"E2"}, new object[] {"E3"}});
                env.Listener("s0").Reset();

                env.AdvanceTime(10000);
                env.SendEventBean(new SupportBean("E8", 8));
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E8"}});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").LastNewData,
                    fields,
                    new[] {new object[] {"E8"}});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").LastOldData,
                    fields,
                    new[] {new object[] {"E4"}, new object[] {"E5"}, new object[] {"E6"}, new object[] {"E7"}});
                env.Listener("s0").Reset();

                env.UndeployAll();
            }
Пример #15
0
            public void Run(RegressionEnvironment env)
            {
                var fields = new[] {"c0"};
                env.AdvanceTime(0);

                var epl =
                    "@Name('s0') select irstream TheString as c0 from SupportBean#expr(newest_timestamp - oldest_timestamp < 1000)";
                env.CompileDeploy(epl).AddListener("s0").Milestone(0);

                env.AdvanceTime(1000);
                EPAssertionUtil.AssertPropsPerRow(env.GetEnumerator("s0"), fields, new object[0][]);
                SendSupportBean(env, "E1");
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E1"});

                env.Milestone(1);

                env.AdvanceTime(1500);
                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"E1"}});
                SendSupportBean(env, "E2");
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E2"});

                env.Milestone(2);

                env.AdvanceTime(2000);
                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"E1"}, new object[] {"E2"}});
                SendSupportBean(env, "E3");
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertGetAndResetIRPair(),
                    fields,
                    new object[] {"E3"},
                    new object[] {"E1"});

                env.Milestone(3);

                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"E2"}, new object[] {"E3"}});
                env.AdvanceTime(2499);

                env.Milestone(4);

                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"E2"}, new object[] {"E3"}});
                SendSupportBean(env, "E4");
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E4"});

                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"E2"}, new object[] {"E3"}, new object[] {"E4"}});
                env.AdvanceTime(2500);

                env.Milestone(5);

                env.Milestone(6);

                EPAssertionUtil.AssertPropsPerRowAnyOrder(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"E2"}, new object[] {"E3"}, new object[] {"E4"}});
                SendSupportBean(env, "E5");
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertGetAndResetIRPair(),
                    fields,
                    new object[] {"E5"},
                    new object[] {"E2"});
                env.AdvanceTime(10000);
                SendSupportBean(env, "E6");
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").GetAndResetIRPair(),
                    fields,
                    new[] {new object[] {"E6"}},
                    new[] {new object[] {"E3"}, new object[] {"E4"}, new object[] {"E5"}});

                env.UndeployAll();
            }
Пример #16
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                var eplContext =
                    "@Name('CTX') create context SegmentedByString partition by TheString from SupportBean";
                env.CompileDeploy(eplContext, path);

                var fields = new [] { "TheString","IntPrimitive","col1" };
                var eplGrouped =
                    "@Name('S1') context SegmentedByString select TheString,IntPrimitive,sum(LongPrimitive) as col1 from SupportBean group by IntPrimitive";
                env.CompileDeploy(eplGrouped, path).AddListener("S1");

                var eplGroupedAccess =
                    "@Name('S2') context SegmentedByString select TheString,IntPrimitive,window(LongPrimitive) as col1 from SupportBean.win:keepall() sb group by IntPrimitive";
                env.CompileDeploy(eplGroupedAccess, path).AddListener("S2");

                var eplGroupedDistinct =
                    "@Name('S3') context SegmentedByString select TheString,IntPrimitive,sum(distinct LongPrimitive) as col1 from SupportBean.win:keepall() sb group by IntPrimitive";
                env.CompileDeploy(eplGroupedDistinct, path).AddListener("S3");

                env.SendEventBean(MakeEvent("G1", 1, 10L));
                EPAssertionUtil.AssertProps(
                    env.Listener("S1").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"G1", 1, 10L});
                EPAssertionUtil.AssertProps(
                    env.Listener("S2").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {
                        "G1", 1,
                        new long[] {10L}
                    });
                EPAssertionUtil.AssertProps(
                    env.Listener("S3").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"G1", 1, 10L});

                env.Milestone(0);

                env.SendEventBean(MakeEvent("G2", 1, 25L));
                EPAssertionUtil.AssertProps(
                    env.Listener("S1").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"G2", 1, 25L});
                EPAssertionUtil.AssertProps(
                    env.Listener("S2").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {
                        "G2", 1,
                        new long[] {25L}
                    });
                EPAssertionUtil.AssertProps(
                    env.Listener("S3").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"G2", 1, 25L});

                env.Milestone(1);

                env.SendEventBean(MakeEvent("G1", 2, 2L));
                EPAssertionUtil.AssertProps(
                    env.Listener("S1").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"G1", 2, 2L});
                EPAssertionUtil.AssertProps(
                    env.Listener("S2").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {
                        "G1", 2,
                        new long[] {2L}
                    });
                EPAssertionUtil.AssertProps(
                    env.Listener("S3").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"G1", 2, 2L});

                env.Milestone(2);

                env.SendEventBean(MakeEvent("G2", 2, 100L));
                EPAssertionUtil.AssertProps(
                    env.Listener("S1").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"G2", 2, 100L});
                EPAssertionUtil.AssertProps(
                    env.Listener("S2").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {
                        "G2", 2,
                        new long[] {100L}
                    });
                EPAssertionUtil.AssertProps(
                    env.Listener("S3").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"G2", 2, 100L});

                env.Milestone(3);

                env.SendEventBean(MakeEvent("G1", 1, 10L));
                EPAssertionUtil.AssertProps(
                    env.Listener("S1").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"G1", 1, 20L});
                EPAssertionUtil.AssertProps(
                    env.Listener("S2").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {
                        "G1", 1,
                        new long[] {10L, 10L}
                    });
                EPAssertionUtil.AssertProps(
                    env.Listener("S3").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"G1", 1, 10L});

                env.Milestone(4);

                env.SendEventBean(MakeEvent("G1", 2, 3L));
                EPAssertionUtil.AssertProps(
                    env.Listener("S1").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"G1", 2, 5L});
                EPAssertionUtil.AssertProps(
                    env.Listener("S2").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {
                        "G1", 2,
                        new long[] {2L, 3L}
                    });
                EPAssertionUtil.AssertProps(
                    env.Listener("S3").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"G1", 2, 5L});

                env.Milestone(5);

                env.SendEventBean(MakeEvent("G2", 2, 101L));
                EPAssertionUtil.AssertProps(
                    env.Listener("S1").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"G2", 2, 201L});
                EPAssertionUtil.AssertProps(
                    env.Listener("S2").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {
                        "G2", 2,
                        new long[] {100L, 101L}
                    });
                EPAssertionUtil.AssertProps(
                    env.Listener("S3").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"G2", 2, 201L});

                env.Milestone(6);

                env.SendEventBean(MakeEvent("G3", 1, -1L));
                EPAssertionUtil.AssertProps(
                    env.Listener("S1").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"G3", 1, -1L});
                EPAssertionUtil.AssertProps(
                    env.Listener("S2").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {
                        "G3", 1,
                        new long[] {-1L}
                    });
                EPAssertionUtil.AssertProps(
                    env.Listener("S3").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"G3", 1, -1L});

                env.Milestone(7);

                env.SendEventBean(MakeEvent("G3", 2, -2L));
                EPAssertionUtil.AssertProps(
                    env.Listener("S1").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"G3", 2, -2L});
                EPAssertionUtil.AssertProps(
                    env.Listener("S2").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {
                        "G3", 2,
                        new long[] {-2L}
                    });
                EPAssertionUtil.AssertProps(
                    env.Listener("S3").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"G3", 2, -2L});

                env.Milestone(8);

                env.SendEventBean(MakeEvent("G3", 1, -3L));
                EPAssertionUtil.AssertProps(
                    env.Listener("S1").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"G3", 1, -4L});
                EPAssertionUtil.AssertProps(
                    env.Listener("S2").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {
                        "G3", 1,
                        new long[] {-1L, -3L}
                    });
                EPAssertionUtil.AssertProps(
                    env.Listener("S3").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"G3", 1, -4L});

                env.Milestone(9);

                env.SendEventBean(MakeEvent("G1", 2, 3L));
                EPAssertionUtil.AssertProps(
                    env.Listener("S1").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"G1", 2, 8L});
                EPAssertionUtil.AssertProps(
                    env.Listener("S2").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {
                        "G1", 2,
                        new long[] {2L, 3L, 3L}
                    });
                EPAssertionUtil.AssertProps(
                    env.Listener("S3").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"G1", 2, 5L});

                env.UndeployAll();
            }
Пример #17
0
            public void Run(RegressionEnvironment env)
            {
                string[] fields = {"Symbol", "sumVol"};
                var stmtText = "@Name('s0') select Symbol, sum(Volume) as sumVol " +
                               "from SupportMarketDataBean#length(5) " +
                               "group by Symbol";
                env.CompileDeploy(stmtText).AddListener("s0");

                Assert.IsFalse(env.Statement("s0").GetEnumerator().MoveNext());

                SendEvent(env, "SYM", 100);
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"SYM", 100L}});

                SendEvent(env, "SYM", 10);
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"SYM", 110L}});

                env.Milestone(0);

                SendEvent(env, "TAC", 1);
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"SYM", 110L}, new object[] {"TAC", 1L}});

                SendEvent(env, "SYM", 11);
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"SYM", 121L}, new object[] {"TAC", 1L}});

                env.Milestone(1);

                SendEvent(env, "TAC", 2);
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"SYM", 121L}, new object[] {"TAC", 3L}});

                SendEvent(env, "OCC", 55);
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"SYM", 21L}, new object[] {"TAC", 3L}, new object[] {"OCC", 55L}});

                env.Milestone(2);

                SendEvent(env, "OCC", 4);
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"TAC", 3L}, new object[] {"SYM", 11L}, new object[] {"OCC", 59L}});

                SendEvent(env, "OCC", 3);
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"SYM", 11L}, new object[] {"TAC", 2L}, new object[] {"OCC", 62L}});

                env.UndeployAll();
            }
Пример #18
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeploy(
                    "@Name('context') create context SegmentedByString partition by TheString from SupportBean",
                    path);

                var fieldsOne = new [] { "IntPrimitive","col1" };
                env.CompileDeploy(
                    "@Name('s0') context SegmentedByString " +
                    "select IntPrimitive, count(*) as col1 " +
                    "from SupportBean unidirectional, SupportBean_S0#keepall " +
                    "group by IntPrimitive order by IntPrimitive asc",
                    path);
                env.AddListener("s0");

                env.SendEventBean(new SupportBean("G1", 10));
                env.SendEventBean(new SupportBean_S0(1));
                env.SendEventBean(new SupportBean_S0(2));
                Assert.IsFalse(env.Listener("s0").IsInvoked);

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

                env.Milestone(0);

                env.SendEventBean(new SupportBean_S0(3));

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

                env.Milestone(1);

                env.SendEventBean(new SupportBean("G2", 20));
                env.SendEventBean(new SupportBean_S0(4));
                Assert.IsFalse(env.Listener("s0").IsInvoked);

                env.SendEventBean(new SupportBean("G2", 20));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsOne,
                    new object[] {20, 1L});

                env.SendEventBean(new SupportBean_S0(5));

                env.Milestone(2);

                env.SendEventBean(new SupportBean("G2", 20));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsOne,
                    new object[] {20, 2L});

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

                env.UndeployModuleContaining("s0");
                env.UndeployAll();
            }
Пример #19
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeploy(
                    "@Name('context') create context SegmentedByString partition by TheString from SupportBean",
                    path);

                var fieldsOne = new [] { "IntPrimitive","count(*)" };
                env.CompileDeploy(
                    "@Name('s0') context SegmentedByString select IntPrimitive, count(*) from SupportBean#length_batch(2) group by IntPrimitive order by IntPrimitive asc",
                    path);
                env.AddListener("s0");

                env.SendEventBean(new SupportBean("G1", 10));
                env.SendEventBean(new SupportBean("G2", 200));
                Assert.IsFalse(env.Listener("s0").IsInvoked);

                env.Milestone(0);

                env.SendEventBean(new SupportBean("G1", 11));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").LastNewData[0],
                    fieldsOne,
                    new object[] {10, 1L});
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").GetAndResetLastNewData()[1],
                    fieldsOne,
                    new object[] {11, 1L});

                env.Milestone(1);

                env.SendEventBean(new SupportBean("G1", 10));
                Assert.IsFalse(env.Listener("s0").IsInvoked);

                env.Milestone(2);

                env.SendEventBean(new SupportBean("G2", 200));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsOne,
                    new object[] {200, 2L});

                env.Milestone(3);

                env.SendEventBean(new SupportBean("G1", 10));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").LastNewData[0],
                    fieldsOne,
                    new object[] {10, 2L});
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").GetAndResetLastNewData()[1],
                    fieldsOne,
                    new object[] {11, 0L});

                env.Milestone(4);

                env.SendEventBean(new SupportBean("G2", 10));
                env.SendEventBean(new SupportBean("G2", 10));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").LastNewData[0],
                    fieldsOne,
                    new object[] {10, 2L});
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").GetAndResetLastNewData()[1],
                    fieldsOne,
                    new object[] {200, 0L});

                env.UndeployModuleContaining("s0");

                // add "string" : add context property
                var fieldsTwo = new [] { "TheString","IntPrimitive","count(*)" };
                env.CompileDeploy(
                    "@Name('s0') context SegmentedByString select TheString, IntPrimitive, count(*) from SupportBean#length_batch(2) group by IntPrimitive order by TheString, IntPrimitive asc",
                    path);
                env.AddListener("s0");

                env.SendEventBean(new SupportBean("G1", 10));
                env.SendEventBean(new SupportBean("G2", 200));
                Assert.IsFalse(env.Listener("s0").IsInvoked);

                env.Milestone(5);

                env.SendEventBean(new SupportBean("G1", 11));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").LastNewData[0],
                    fieldsTwo,
                    new object[] {"G1", 10, 1L});
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").GetAndResetLastNewData()[1],
                    fieldsTwo,
                    new object[] {"G1", 11, 1L});

                env.SendEventBean(new SupportBean("G1", 10));
                Assert.IsFalse(env.Listener("s0").IsInvoked);

                env.Milestone(6);

                env.SendEventBean(new SupportBean("G2", 200));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsTwo,
                    new object[] {"G2", 200, 2L});

                env.SendEventBean(new SupportBean("G1", 10));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").LastNewData[0],
                    fieldsTwo,
                    new object[] {"G1", 10, 2L});
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").GetAndResetLastNewData()[1],
                    fieldsTwo,
                    new object[] {"G1", 11, 0L});

                env.Milestone(7);

                env.SendEventBean(new SupportBean("G2", 10));
                env.SendEventBean(new SupportBean("G2", 10));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").LastNewData[0],
                    fieldsTwo,
                    new object[] {"G2", 10, 2L});
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").GetAndResetLastNewData()[1],
                    fieldsTwo,
                    new object[] {"G2", 200, 0L});

                env.UndeployAll();
            }
Пример #20
0
        private static void TryAssertionDocExample(
            RegressionEnvironment env,
            EventRepresentationChoice eventRepresentationEnum)
        {
            var path = new RegressionPath();
            var baseModuleEPL = eventRepresentationEnum.GetAnnotationTextWJsonProvided<MyLocalJsonProvidedOrderEvent>() +
                                " create schema OrderEvent as (OrderId string, ProductId string, Price double, Quantity int, DeletedFlag boolean)";
            env.CompileDeployWBusPublicType(baseModuleEPL, path);

            var appModuleOne = eventRepresentationEnum.GetAnnotationTextWJsonProvided<MyLocalJsonProvidedProductTotalRec>() +
                               " create schema ProductTotalRec as (ProductId string, TotalPrice double);" +
                               "" +
                               "@Name('nwProd') create window ProductWindow#unique(ProductId) as ProductTotalRec;" +
                               "" +
                               "on OrderEvent oe\n" +
                               "merge ProductWindow pw\n" +
                               "where pw.ProductId = oe.ProductId\n" +
                               "when matched\n" +
                               "then update set TotalPrice = TotalPrice + oe.Price\n" +
                               "when not matched\n" +
                               "then insert select ProductId, Price as TotalPrice;";
            env.CompileDeploy(appModuleOne, path);

            var appModuleTwo =
                " @Name('nwOrd') create window OrderWindow#keepall as OrderEvent;" +
                "" +
                "on OrderEvent oe\n" +
                "  merge OrderWindow pw\n" +
                "  where pw.OrderId = oe.OrderId\n" +
                "  when not matched \n" +
                "    then insert select *\n" +
                "  when matched and oe.DeletedFlag=true\n" +
                "    then delete\n" +
                "  when matched\n" +
                "    then update set pw.Quantity = oe.Quantity, pw.Price = oe.Price";

            env.CompileDeploy(appModuleTwo, path);

            SendOrderEvent(env, eventRepresentationEnum, "O1", "P1", 10, 100, false);
            SendOrderEvent(env, eventRepresentationEnum, "O1", "P1", 11, 200, false);
            SendOrderEvent(env, eventRepresentationEnum, "O2", "P2", 3, 300, false);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(
                env.Statement("nwProd").GetEnumerator(),
                new[] {"ProductId", "TotalPrice"},
                new[] {new object[] {"P1", 21d}, new object[] {"P2", 3d}});
            EPAssertionUtil.AssertPropsPerRowAnyOrder(
                env.Statement("nwOrd").GetEnumerator(),
                new[] {"OrderId", "Quantity"},
                new[] {new object[] {"O1", 200}, new object[] {"O2", 300}});

            var module = "create schema StreetCarCountSchema (streetId string, carcount int);" +
                         "    create schema StreetChangeEvent (streetId string, action string);" +
                         "    create window StreetCarCountWindow#unique(streetId) as StreetCarCountSchema;" +
                         "    on StreetChangeEvent ce merge StreetCarCountWindow w where ce.streetId = w.streetId\n" +
                         "    when not matched and ce.action = 'ENTER' then insert select streetId, 1 as carcount\n" +
                         "    when matched and ce.action = 'ENTER' then update set StreetCarCountWindow.carcount = carcount + 1\n" +
                         "    when matched and ce.action = 'LEAVE' then update set StreetCarCountWindow.carcount = carcount - 1;" +
                         "    select * from StreetCarCountWindow;";
            env.CompileDeploy(module, path);

            env.UndeployAll();
        }
Пример #21
0
        public void Run(RegressionEnvironment env)
        {
            var path = new RegressionPath();
            env.CompileDeploy("@Name('create') create window AWindow#keepall as SupportTimeStartEndA", path);
            env.CompileDeploy("insert into AWindow select * from SupportTimeStartEndA", path);

            var eventTypeNW = env.Statement("create").EventType;
            Assert.AreEqual("LongdateStart", eventTypeNW.StartTimestampPropertyName);
            Assert.AreEqual("LongdateEnd", eventTypeNW.EndTimestampPropertyName);

            // preload
            for (var i = 0; i < 10000; i++) {
                env.SendEventBean(SupportTimeStartEndA.Make("A" + i, "2002-05-30T09:00:00.000", 100));
            }

            env.SendEventBean(SupportTimeStartEndA.Make("AEarlier", "2002-05-30T08:00:00.000", 100));
            env.SendEventBean(SupportTimeStartEndA.Make("ALater", "2002-05-30T10:00:00.000", 100));

            // assert BEFORE
            var eplBefore =
                "select a.Key as c0 from AWindow as a, SupportTimeStartEndB b unidirectional where a.before(b)";
            RunAssertion(env, path, eplBefore, "2002-05-30T09:00:00.000", 0, "AEarlier");

            var eplBeforeMSec =
                "select a.Key as c0 from AWindow as a, SupportTimeStartEndB b unidirectional where a.LongdateEnd.before(b.LongdateStart)";
            RunAssertion(env, path, eplBeforeMSec, "2002-05-30T09:00:00.000", 0, "AEarlier");

            var eplBeforeMSecMix1 =
                "select a.Key as c0 from AWindow as a, SupportTimeStartEndB b unidirectional where a.LongdateEnd.before(b)";
            RunAssertion(env, path, eplBeforeMSecMix1, "2002-05-30T09:00:00.000", 0, "AEarlier");

            var eplBeforeMSecMix2 =
                "select a.Key as c0 from AWindow as a, SupportTimeStartEndB b unidirectional where a.before(b.LongdateStart)";
            RunAssertion(env, path, eplBeforeMSecMix2, "2002-05-30T09:00:00.000", 0, "AEarlier");

            // assert AFTER
            var eplAfter =
                "select a.Key as c0 from AWindow as a, SupportTimeStartEndB b unidirectional where a.after(b)";
            RunAssertion(env, path, eplAfter, "2002-05-30T09:00:00.000", 0, "ALater");

            // assert COINCIDES
            var eplCoincides =
                "select a.Key as c0 from AWindow as a, SupportTimeStartEndB b unidirectional where a.coincides(b)";
            RunAssertion(env, path, eplCoincides, "2002-05-30T08:00:00.000", 100, "AEarlier");

            // assert DURING
            var eplDuring =
                "select a.Key as c0 from AWindow as a, SupportTimeStartEndB b unidirectional where a.during(b)";
            RunAssertion(env, path, eplDuring, "2002-05-30T07:59:59.000", 2000, "AEarlier");

            // assert FINISHES
            var eplFinishes =
                "select a.Key as c0 from AWindow as a, SupportTimeStartEndB b unidirectional where a.finishes(b)";
            RunAssertion(env, path, eplFinishes, "2002-05-30T07:59:59.950", 150, "AEarlier");

            // assert FINISHED-BY
            var eplFinishedBy =
                "select a.Key as c0 from AWindow as a, SupportTimeStartEndB b unidirectional where a.finishedBy(b)";
            RunAssertion(env, path, eplFinishedBy, "2002-05-30T08:00:00.050", 50, "AEarlier");

            // assert INCLUDES
            var eplIncludes =
                "select a.Key as c0 from AWindow as a, SupportTimeStartEndB b unidirectional where a.includes(b)";
            RunAssertion(env, path, eplIncludes, "2002-05-30T08:00:00.050", 20, "AEarlier");

            // assert MEETS
            var eplMeets =
                "select a.Key as c0 from AWindow as a, SupportTimeStartEndB b unidirectional where a.meets(b)";
            RunAssertion(env, path, eplMeets, "2002-05-30T08:00:00.100", 0, "AEarlier");

            // assert METBY
            var eplMetBy =
                "select a.Key as c0 from AWindow as a, SupportTimeStartEndB b unidirectional where a.metBy(b)";
            RunAssertion(env, path, eplMetBy, "2002-05-30T07:59:59.950", 50, "AEarlier");

            // assert OVERLAPS
            var eplOverlaps =
                "select a.Key as c0 from AWindow as a, SupportTimeStartEndB b unidirectional where a.overlaps(b)";
            RunAssertion(env, path, eplOverlaps, "2002-05-30T08:00:00.050", 100, "AEarlier");

            // assert OVERLAPPEDY
            var eplOverlappedBy =
                "select a.Key as c0 from AWindow as a, SupportTimeStartEndB b unidirectional where a.overlappedBy(b)";
            RunAssertion(env, path, eplOverlappedBy, "2002-05-30T09:59:59.950", 100, "ALater");
            RunAssertion(env, path, eplOverlappedBy, "2002-05-30T07:59:59.950", 100, "AEarlier");

            // assert STARTS
            var eplStarts =
                "select a.Key as c0 from AWindow as a, SupportTimeStartEndB b unidirectional where a.starts(b)";
            RunAssertion(env, path, eplStarts, "2002-05-30T08:00:00.000", 150, "AEarlier");

            // assert STARTEDBY
            var eplEnds =
                "select a.Key as c0 from AWindow as a, SupportTimeStartEndB b unidirectional where a.startedBy(b)";
            RunAssertion(env, path, eplEnds, "2002-05-30T08:00:00.000", 50, "AEarlier");

            env.UndeployAll();
        }
Пример #22
0
            public void Run(RegressionEnvironment env)
            {
                var fields = new [] { "a_string" };
                var text = "@Name('s0') select * from SupportRecogBean#keepall " +
                           "match_recognize (" +
                           "  measures A.TheString as a_string" +
                           "  all matches pattern (A) " +
                           "  define A as (A.Value > PREV(A.Value))" +
                           ") " +
                           "order by a_string";
                env.CompileDeploy(text).AddListener("s0");

                env.SendEventBean(new SupportRecogBean("E1", 5));
                env.SendEventBean(new SupportRecogBean("E2", 3));
                Assert.IsFalse(env.Listener("s0").IsInvoked);
                Assert.IsFalse(env.Statement("s0").GetEnumerator().MoveNext());

                env.Milestone(0);

                env.SendEventBean(new SupportRecogBean("E3", 6));
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").GetAndResetLastNewData(),
                    fields,
                    new[] {new object[] {"E3"}});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E3"}});

                env.Milestone(1);

                env.SendEventBean(new SupportRecogBean("E4", 4));
                Assert.IsFalse(env.Listener("s0").IsInvoked);
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E3"}});

                env.Milestone(2);

                env.SendEventBean(new SupportRecogBean("E5", 6));
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").GetAndResetLastNewData(),
                    fields,
                    new[] {new object[] {"E5"}});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E3"}, new object[] {"E5"}});

                env.Milestone(3);

                env.SendEventBean(new SupportRecogBean("E6", 10));
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").GetAndResetLastNewData(),
                    fields,
                    new[] {new object[] {"E6"}});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E3"}, new object[] {"E5"}, new object[] {"E6"}});

                env.Milestone(4);

                env.SendEventBean(new SupportRecogBean("E7", 9));

                env.Milestone(5);

                env.SendEventBean(new SupportRecogBean("E8", 4));
                Assert.IsFalse(env.Listener("s0").IsInvoked);
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E3"}, new object[] {"E5"}, new object[] {"E6"}});

                env.UndeployModuleContaining("s0");

                text = "@Name('s0') select * from SupportRecogBean#keepall " +
                       "match_recognize (" +
                       "  measures A.TheString as a_string" +
                       "  all matches pattern (A) " +
                       "  define A as (PREV(A.Value, 2) = 5)" +
                       ") " +
                       "order by a_string";

                env.CompileDeploy(text).AddListener("s0");

                env.SendEventBean(new SupportRecogBean("E1", 5));
                env.SendEventBean(new SupportRecogBean("E2", 4));
                Assert.IsFalse(env.Listener("s0").IsInvoked);
                Assert.IsFalse(env.Statement("s0").GetEnumerator().MoveNext());

                env.Milestone(6);

                env.SendEventBean(new SupportRecogBean("E3", 6));
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").GetAndResetLastNewData(),
                    fields,
                    new[] {new object[] {"E3"}});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E3"}});

                env.Milestone(7);

                env.SendEventBean(new SupportRecogBean("E4", 3));
                env.SendEventBean(new SupportRecogBean("E5", 3));
                env.SendEventBean(new SupportRecogBean("E5", 5));
                env.SendEventBean(new SupportRecogBean("E6", 5));
                Assert.IsFalse(env.Listener("s0").IsInvoked);
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E3"}});

                env.Milestone(8);

                env.SendEventBean(new SupportRecogBean("E7", 6));
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").GetAndResetLastNewData(),
                    fields,
                    new[] {new object[] {"E7"}});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E3"}, new object[] {"E7"}});

                env.Milestone(9);

                env.SendEventBean(new SupportRecogBean("E8", 6));
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").GetAndResetLastNewData(),
                    fields,
                    new[] {new object[] {"E8"}});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E3"}, new object[] {"E7"}, new object[] {"E8"}});

                env.UndeployAll();
            }
Пример #23
0
            public void Run(RegressionEnvironment env)
            {
                var milestone = new AtomicLong();
                var fieldsOne = new [] { "col1" };
                var path = new RegressionPath();

                var eplCtx =
                    "@Name('context') create context SegmentedByString partition by TheString from SupportBean";
                env.CompileDeploy(eplCtx, path);

                var epl = "@Name('s0') context SegmentedByString select sum(IntPrimitive) as col1 from SupportBean;\n";
                env.CompileDeploy(epl, path).AddListener("s0");

                env.MilestoneInc(milestone);

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

                env.MilestoneInc(milestone);

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

                env.MilestoneInc(milestone);

                env.SendEventBean(new SupportBean("G1", 4));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsOne,
                    new object[] {7});

                env.MilestoneInc(milestone);

                env.SendEventBean(new SupportBean("G2", 1));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsOne,
                    new object[] {3});

                env.MilestoneInc(milestone);

                env.SendEventBean(new SupportBean("G3", -1));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsOne,
                    new object[] {-1});

                env.MilestoneInc(milestone);

                env.UndeployModuleContaining("s0");

                // test mixed with access
                var fieldsTwo = new [] { "col1","col2" };
                env.CompileDeploy(
                    "@Name('s0') context SegmentedByString " +
                    "select sum(IntPrimitive) as col1, toArray(window(*).selectFrom(v->v.IntPrimitive)) as col2 " +
                    "from SupportBean#keepall",
                    path);
                env.AddListener("s0");

                env.SendEventBean(new SupportBean("G1", 8));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsTwo,
                    new object[] {
                        8,
                        new object[] {8}
                    });

                env.SendEventBean(new SupportBean("G2", 5));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsTwo,
                    new object[] {
                        5,
                        new object[] {5}
                    });

                env.SendEventBean(new SupportBean("G1", 1));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsTwo,
                    new object[] {
                        9,
                        new object[] {8, 1}
                    });

                env.SendEventBean(new SupportBean("G2", 2));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsTwo,
                    new object[] {
                        7,
                        new object[] {5, 2}
                    });

                env.UndeployModuleContaining("s0");

                // test only access
                var fieldsThree = new [] { "col1" };
                env.CompileDeploy(
                    "@Name('s0') context SegmentedByString " +
                    "select toArray(window(*).selectFrom(v->v.IntPrimitive)) as col1 " +
                    "from SupportBean#keepall",
                    path);
                env.AddListener("s0");

                env.SendEventBean(new SupportBean("G1", 8));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsThree,
                    new object[] {new object[] {8}});

                env.SendEventBean(new SupportBean("G2", 5));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsThree,
                    new object[] {new object[] {5}});

                env.SendEventBean(new SupportBean("G1", 1));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsThree,
                    new object[] {new object[] {8, 1}});

                env.SendEventBean(new SupportBean("G2", 2));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsThree,
                    new object[] {new object[] {5, 2}});

                env.UndeployModuleContaining("s0");

                // test subscriber
                var stmtFour = env.CompileDeploy(
                        "@Name('s0') context SegmentedByString " +
                        "select count(*) as col1 " +
                        "from SupportBean",
                        path)
                    .Statement("s0");
                var subs = new SupportSubscriber();
                stmtFour.Subscriber = subs;

                env.SendEventBean(new SupportBean("G1", 1));
                Assert.AreEqual(1L, subs.AssertOneGetNewAndReset());

                env.SendEventBean(new SupportBean("G1", 1));
                Assert.AreEqual(2L, subs.AssertOneGetNewAndReset());

                env.SendEventBean(new SupportBean("G2", 2));
                Assert.AreEqual(1L, subs.AssertOneGetNewAndReset());

                env.UndeployAll();
            }
Пример #24
0
 public void Run(RegressionEnvironment env)
 {
     env.CompileDeploy("create window MyWindow#time(30) as (col1 int, col2 string)");
     env.CompileDeploy("create window MyWindow#time(30) as (col1 short, col2 long)");
     env.UndeployAll();
 }
Пример #25
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                var eplContext =
                    "@Name('CTX') create context SegmentedByString partition by TheString from SupportBean";
                env.CompileDeploy(eplContext, path);

                var fields = new [] { "TheString","col1" };
                var eplUngrouped =
                    "@Name('S1') context SegmentedByString select TheString,sum(IntPrimitive) as col1 from SupportBean";
                env.CompileDeploy(eplUngrouped, path).AddListener("S1");

                var eplGroupedAccess =
                    "@Name('S2') context SegmentedByString select TheString,window(IntPrimitive) as col1 from SupportBean#keepall() sb";
                env.CompileDeploy(eplGroupedAccess, path).AddListener("S2");

                env.Milestone(0);

                env.SendEventBean(new SupportBean("G1", 2));
                EPAssertionUtil.AssertProps(
                    env.Listener("S1").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"G1", 2});
                EPAssertionUtil.AssertProps(
                    env.Listener("S2").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {
                        "G1",
                        new int[] {2}
                    });

                env.SendEventBean(new SupportBean("G1", 3));
                EPAssertionUtil.AssertProps(
                    env.Listener("S1").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"G1", 5});
                EPAssertionUtil.AssertProps(
                    env.Listener("S2").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {
                        "G1",
                        new int[] {2, 3}
                    });
                AssertPartitionInfo(env);

                env.Milestone(1);

                AssertPartitionInfo(env);
                env.SendEventBean(new SupportBean("G2", 10));
                EPAssertionUtil.AssertProps(
                    env.Listener("S1").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"G2", 10});
                EPAssertionUtil.AssertProps(
                    env.Listener("S2").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {
                        "G2",
                        new int[] {10}
                    });

                env.Milestone(2);

                env.SendEventBean(new SupportBean("G2", 11));
                EPAssertionUtil.AssertProps(
                    env.Listener("S1").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"G2", 21});
                EPAssertionUtil.AssertProps(
                    env.Listener("S2").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {
                        "G2",
                        new int[] {10, 11}
                    });

                env.Milestone(3);

                env.SendEventBean(new SupportBean("G1", 4));
                EPAssertionUtil.AssertProps(
                    env.Listener("S1").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"G1", 9});
                EPAssertionUtil.AssertProps(
                    env.Listener("S2").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {
                        "G1",
                        new int[] {2, 3, 4}
                    });

                env.Milestone(4);

                env.SendEventBean(new SupportBean("G3", 100));
                EPAssertionUtil.AssertProps(
                    env.Listener("S1").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"G3", 100});
                EPAssertionUtil.AssertProps(
                    env.Listener("S2").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {
                        "G3",
                        new int[] {100}
                    });

                env.Milestone(5);

                env.SendEventBean(new SupportBean("G3", 101));
                EPAssertionUtil.AssertProps(
                    env.Listener("S1").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"G3", 201});
                EPAssertionUtil.AssertProps(
                    env.Listener("S2").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {
                        "G3",
                        new int[] {100, 101}
                    });

                env.UndeployModuleContaining("S1");
                env.UndeployModuleContaining("S2");
                env.UndeployModuleContaining("CTX");
            }
Пример #26
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                var eplCreate = namedWindow
                    ? "create window MyInfra#unique(Key) as SupportMaxAmountEvent"
                    : "create table MyInfra(Key string primary key, MaxAmount double)";
                env.CompileDeploy(eplCreate, path);
                env.CompileDeploy("insert into MyInfra select * from SupportMaxAmountEvent", path);

                var stmtText = "@Name('s0') select TheString as c0, sum(IntPrimitive) as c1 " +
                               "from SupportBean#groupwin(TheString)#length(2) as sb " +
                               "group by TheString " +
                               "having sum(IntPrimitive) > (select MaxAmount from MyInfra as mw where sb.TheString = mw.Key)";
                env.CompileDeploy(stmtText, path).AddListener("s0");

                var fields = new[] {"c0", "c1"};

                // set some amounts
                env.SendEventBean(new SupportMaxAmountEvent("G1", 10));
                env.SendEventBean(new SupportMaxAmountEvent("G2", 20));
                env.SendEventBean(new SupportMaxAmountEvent("G3", 30));

                // send some events
                env.SendEventBean(new SupportBean("G1", 5));
                env.SendEventBean(new SupportBean("G2", 19));
                env.SendEventBean(new SupportBean("G3", 28));
                Assert.IsFalse(env.Listener("s0").IsInvoked);

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

                env.SendEventBean(new SupportBean("G2", 18));
                env.SendEventBean(new SupportBean("G1", 4));
                env.SendEventBean(new SupportBean("G3", 2));
                Assert.IsFalse(env.Listener("s0").IsInvoked);

                env.SendEventBean(new SupportBean("G3", 29));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"G3", 31});

                env.SendEventBean(new SupportBean("G3", 4));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"G3", 33});

                env.SendEventBean(new SupportBean("G1", 6));
                env.SendEventBean(new SupportBean("G2", 2));
                env.SendEventBean(new SupportBean("G3", 26));
                Assert.IsFalse(env.Listener("s0").IsInvoked);

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

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

                env.UndeployAll();
            }
Пример #27
0
            public void Run(RegressionEnvironment env)
            {
                string[] fields = {"Symbol", "vol"};
                var stmtText = "@Name('s0') select Symbol, Volume * 10 as vol from SupportMarketDataBean#length(5)" +
                               " where Volume < 0";
                env.CompileDeploy(stmtText).AddListener("s0");

                Assert.IsFalse(env.Statement("s0").GetEnumerator().MoveNext());

                SendEvent(env, "SYM", 100);
                Assert.IsFalse(env.Statement("s0").GetEnumerator().MoveNext());
                EPAssertionUtil.AssertPropsPerRow(env.Statement("s0").GetEnumerator(), fields, null);

                SendEvent(env, "SYM", -1);
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"SYM", -10L}});

                SendEvent(env, "SYM", -6);
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"SYM", -10L}, new object[] {"SYM", -60L}});

                env.Milestone(0);

                SendEvent(env, "SYM", 1);
                SendEvent(env, "SYM", 16);
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"SYM", -10L}, new object[] {"SYM", -60L}});

                SendEvent(env, "SYM", -9);
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"SYM", -10L}, new object[] {"SYM", -60L}, new object[] {"SYM", -90L}});

                env.Milestone(1);

                SendEvent(env, "SYM", 2);
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"SYM", -60L}, new object[] {"SYM", -90L}});

                SendEvent(env, "SYM", 3);
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"SYM", -90L}});

                env.Milestone(2);

                SendEvent(env, "SYM", 4);
                SendEvent(env, "SYM", 5);
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"SYM", -90L}});

                env.Milestone(3);

                SendEvent(env, "SYM", 6);
                Assert.IsFalse(env.Statement("s0").GetEnumerator().MoveNext());

                env.UndeployAll();
            }
Пример #28
0
        public void Run(RegressionEnvironment env)
        {
            var joinStatement = "@Name('s0') select Id, P00, TheString from " +
                                "SupportBean#length(100) as S1, " +
                                " method:SupportStaticMethodInvocations.FetchObjectLog(TheString, IntPrimitive)";
            env.CompileDeploy(joinStatement).AddListener("s0");

            // set sleep off
            SupportStaticMethodInvocations.GetInvocationSizeReset();

            // The LRU cache caches per same keys
            string[] fields = {"Id", "P00", "TheString"};
            SendBeanEvent(env, "E1", 1);
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fields,
                new object[] {1, "|E1|", "E1"});

            SendBeanEvent(env, "E2", 2);
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fields,
                new object[] {2, "|E2|", "E2"});

            SendBeanEvent(env, "E3", 3);
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fields,
                new object[] {3, "|E3|", "E3"});
            Assert.AreEqual(3, SupportStaticMethodInvocations.GetInvocationSizeReset());

            // should be cached
            SendBeanEvent(env, "E3", 3);
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fields,
                new object[] {3, "|E3|", "E3"});
            Assert.AreEqual(0, SupportStaticMethodInvocations.GetInvocationSizeReset());

            // should not be cached
            SendBeanEvent(env, "E4", 4);
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fields,
                new object[] {4, "|E4|", "E4"});
            Assert.AreEqual(1, SupportStaticMethodInvocations.GetInvocationSizeReset());

            // should be cached
            SendBeanEvent(env, "E2", 2);
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fields,
                new object[] {2, "|E2|", "E2"});
            Assert.AreEqual(0, SupportStaticMethodInvocations.GetInvocationSizeReset());

            // should not be cached
            SendBeanEvent(env, "E1", 1);
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fields,
                new object[] {1, "|E1|", "E1"});
            Assert.AreEqual(1, SupportStaticMethodInvocations.GetInvocationSizeReset());

            env.UndeployAll();
        }
Пример #29
0
            public void Run(RegressionEnvironment env)
            {
                string[] fields = {"Symbol", "Price", "sumVol"};
                var stmtText = "@Name('s0') select Symbol, Price, sum(Volume) as sumVol " +
                               "from SupportMarketDataBean#length(5) " +
                               "group by Symbol having sum(Volume) > 20";

                env.CompileDeploy(stmtText).AddListener("s0");
                Assert.IsFalse(env.Statement("s0").GetEnumerator().MoveNext());

                SendEvent(env, "SYM", -1, 100);
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"SYM", -1d, 100L}});

                SendEvent(env, "TAC", -2, 12);
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"SYM", -1d, 100L}});

                env.Milestone(0);

                SendEvent(env, "TAC", -3, 13);
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {
                        new object[] {"SYM", -1d, 100L}, new object[] {"TAC", -2d, 25L}, new object[] {"TAC", -3d, 25L}
                    });

                SendEvent(env, "SYM", -4, 1);
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {
                        new object[] {"SYM", -1d, 101L}, new object[] {"TAC", -2d, 25L}, new object[] {"TAC", -3d, 25L},
                        new object[] {"SYM", -4d, 101L}
                    });

                env.Milestone(1);

                SendEvent(env, "OCC", -5, 99);
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {
                        new object[] {"SYM", -1d, 101L}, new object[] {"TAC", -2d, 25L}, new object[] {"TAC", -3d, 25L},
                        new object[] {"SYM", -4d, 101L}, new object[] {"OCC", -5d, 99L}
                    });

                env.Milestone(2);

                SendEvent(env, "TAC", -6, 2);
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {
                        new object[] {"TAC", -2d, 27L}, new object[] {"TAC", -3d, 27L}, new object[] {"OCC", -5d, 99L},
                        new object[] {"TAC", -6d, 27L}
                    });

                env.UndeployAll();
            }
        public void Run(RegressionEnvironment env)
        {
            var path = new RegressionPath();

            // Bean
            var beanTests = new Pair <object, object>[] {
                new Pair <object, object>(new SupportMarkerImplA("e1"), Exists("e1")),
                new Pair <object, object>(new SupportMarkerImplB(1), Exists(1)),
                new Pair <object, object>(new SupportMarkerImplC(), NotExists())
            };

            RunAssertion(env, nameof(SupportMarkerInterface), FBEAN, null, beanTests, typeof(object), path);

            // Map
            var mapTests = new Pair <object, object>[] {
                new Pair <object, object>(Collections.SingletonMap("somekey", "10"), NotExists()),
                new Pair <object, object>(Collections.SingletonMap("Id", "abc"), Exists("abc")),
                new Pair <object, object>(Collections.SingletonMap("Id", 10), Exists(10)),
            };

            RunAssertion(env, MAP_TYPENAME, FMAP, null, mapTests, typeof(object), path);

            // Object-Array
            var oaTests = new Pair <object, object>[] {
                new Pair <object, object>(new object[] { 1, null }, Exists(null)),
                new Pair <object, object>(new object[] { 2, "abc" }, Exists("abc")),
                new Pair <object, object>(new object[] { 3, 10 }, Exists(10)),
            };

            RunAssertion(env, OA_TYPENAME, FOA, null, oaTests, typeof(object), path);

            // XML
            var xmlTests = new Pair <object, object>[] {
                new Pair <object, object>("", NotExists()),
                new Pair <object, object>("<Id>10</Id>", Exists("10")),
                new Pair <object, object>("<Id>abc</Id>", Exists("abc")),
            };

            RunAssertion(env, XML_TYPENAME, FXML, xmlToValue, xmlTests, typeof(XmlNode), path);

            // Avro
            var avroSchema = AvroSchemaUtil.ResolveAvroSchema(env.Runtime.EventTypeService.GetEventTypePreconfigured(AVRO_TYPENAME)).AsRecordSchema();
            var datumEmpty = new GenericRecord(SchemaBuilder.Record(AVRO_TYPENAME));
            var datumOne   = new GenericRecord(avroSchema);

            datumOne.Put("Id", 101);
            var datumTwo = new GenericRecord(avroSchema);

            datumTwo.Put("Id", null);
            var avroTests = new Pair <object, object>[] {
                new Pair <object, object>(datumEmpty, NotExists()),
                new Pair <object, object>(datumOne, Exists(101)),
                new Pair <object, object>(datumTwo, Exists(null))
            };

            RunAssertion(env, AVRO_TYPENAME, FAVRO, null, avroTests, typeof(object), path);

            // Json
            env.CompileDeploy("@JsonSchema(Dynamic=true) @public @buseventtype create json schema " + JSON_TYPENAME + "()", path);
            var jsonTests = new Pair <object, object>[] {
                new Pair <object, object>("{}", NotExists()),
                new Pair <object, object>("{\"Id\": 10}", Exists(10)),
                new Pair <object, object>("{\"Id\": \"abc\"}", Exists("abc"))
            };

            RunAssertion(env, JSON_TYPENAME, FJSON, null, jsonTests, typeof(object), path);
        }