Exemple #1
0
            public void Run(RegressionEnvironment env)
            {
                var joinStatement = "@Name('s0') select * from " +
                                    "SupportMarketDataBean(Symbol='IBM')#length(3) S0, " +
                                    "SupportMarketDataBean(Symbol='CSCO')#length(3) S1" +
                                    " where S0.Volume=S1.Volume";
                env.CompileDeployAddListenerMileZero(joinStatement, "s0");

                var setOne = new object[5];
                var setTwo = new object[5];
                long[] volumesOne = {10, 20, 20, 40, 50};
                long[] volumesTwo = {10, 20, 30, 40, 50};
                for (var i = 0; i < setOne.Length; i++) {
                    setOne[i] = new SupportMarketDataBean("IBM", volumesOne[i], i, "");
                    setTwo[i] = new SupportMarketDataBean("CSCO", volumesTwo[i], i, "");
                }

                SendEvent(env, setOne[0]);
                SendEvent(env, setTwo[0]);
                Assert.IsNotNull(env.Listener("s0").LastNewData);
                env.Listener("s0").Reset();

                var listener = env.Listener("s0");
                env.UndeployAll();
                SendEvent(env, setOne[1]);
                SendEvent(env, setTwo[1]);
                Assert.IsFalse(listener.IsInvoked);

                env.CompileDeploy(joinStatement).AddListener("s0");
                SendEvent(env, setOne[2]);
                Assert.IsFalse(env.Listener("s0").IsInvoked);

                env.UndeployAll();
                SendEvent(env, setOne[3]);
                SendEvent(env, setOne[4]);
                SendEvent(env, setTwo[3]);

                env.CompileDeploy(joinStatement).AddListener("s0");
                SendEvent(env, setTwo[4]);
                Assert.IsFalse(env.Listener("s0").IsInvoked);

                env.UndeployAll();
            }
            public void Run(RegressionEnvironment env)
            {
                var epl =
                    "@Name('s0') select (select S0.Id + max(S1.Id) from SupportBean_S1#length(3) as S1) as value from SupportBean_S0 as S0";
                env.CompileDeployAddListenerMileZero(epl, "s0");

                SendEventS0(env, 1);
                Assert.AreEqual(null, env.Listener("s0").AssertOneGetNewAndReset().Get("value"));

                SendEventS1(env, 100);
                SendEventS0(env, 2);
                Assert.AreEqual(102, env.Listener("s0").AssertOneGetNewAndReset().Get("value"));

                SendEventS1(env, 30);
                SendEventS0(env, 3);
                Assert.AreEqual(103, env.Listener("s0").AssertOneGetNewAndReset().Get("value"));

                env.UndeployAll();
            }
Exemple #3
0
            public void Run(RegressionEnvironment env)
            {
                var epl = "@Name('s0') select * from SupportBean_A as a unidirectional " +
                          "full outer join SupportBean_B as b unidirectional " +
                          "full outer join SupportBean_C as c unidirectional " +
                          "full outer join SupportBean_D as d unidirectional " +
                          "where coalesce(a.Id,b.Id,c.Id,d.Id) in ('YES')";
                env.CompileDeployAddListenerMileZero(epl, "s0");

                SendAssert(env, new SupportBean_A("A1"), false);
                SendAssert(env, new SupportBean_A("YES"), true);
                SendAssert(env, new SupportBean_C("YES"), true);
                SendAssert(env, new SupportBean_C("C1"), false);
                SendAssert(env, new SupportBean_D("YES"), true);
                SendAssert(env, new SupportBean_B("YES"), true);
                SendAssert(env, new SupportBean_B("B1"), false);

                env.UndeployAll();
            }
            public void Run(RegressionEnvironment env)
            {
                // Test for Esper-122
                var joinStatement =
                    "@Name('s0') select S0.Id, S1.Id, S0.P00, S1.P00 from MapS0#keepall as S0, MapS1#keepall as S1" +
                    " where S0.Id = S1.Id";
                env.CompileDeployAddListenerMileZero(joinStatement, "s0");

                for (var i = 0; i < 100; i++) {
                    if (i % 2 == 1) {
                        SendMapEvent(env, "MapS0", "a", 1);
                    }
                    else {
                        SendMapEvent(env, "MapS1", "a", 1);
                    }
                }

                env.UndeployAll();
            }
            public void Run(RegressionEnvironment env)
            {
                var epl =
                    "@Name('s0') @Name('s0')select (select TheString from SupportBean#keepall group by TheString having sum(IntPrimitive) = S0.Id) as c0 from SupportBean_S0 as S0";
                env.CompileDeployAddListenerMileZero(epl, "s0");

                SendSB(env, "E1", 100);
                SendSB(env, "E2", 5);
                SendSB(env, "E3", 20);
                SendEventS0Assert(env, 1, null);
                SendEventS0Assert(env, 5, "E2");

                SendSB(env, "E2", 3);
                SendEventS0Assert(env, 5, null);
                SendEventS0Assert(env, 8, "E2");
                SendEventS0Assert(env, 20, "E3");

                env.UndeployAll();
            }
        public void Run(RegressionEnvironment env)
        {
            var epl = "@Name('s0') select * from SupportMarketDataBean(Symbol='" +
                      SYMBOL +
                      "')#time(3.0)#weighted_avg(Price, Volume, Symbol, Feed)";
            env.CompileDeployAddListenerMileZero(epl, "s0");

            Assert.AreEqual(typeof(double?), env.Statement("s0").EventType.GetPropertyType("average"));

            // Send 2 events, E1 and E2 at +0sec
            env.SendEventBean(MakeBean(SYMBOL, 10, 500));
            CheckValue(env, 10);

            env.SendEventBean(MakeBean(SYMBOL, 11, 500));
            CheckValue(env, 10.5);

            // Sleep for 1.5 seconds
            Sleep(1500);

            // Send 2 more events, E3 and E4 at +1.5sec
            env.SendEventBean(MakeBean(SYMBOL, 10, 1000));
            CheckValue(env, 10.25);
            env.SendEventBean(MakeBean(SYMBOL, 10.5, 2000));
            CheckValue(env, 10.375);

            // Sleep for 2 seconds, E1 and E2 should have left the window
            Sleep(2000);
            CheckValue(env, 10.333333333);

            // Send another event, E5 at +3.5sec
            env.SendEventBean(MakeBean(SYMBOL, 10.2, 1000));
            CheckValue(env, 10.3);

            // Sleep for 2.5 seconds, E3 and E4 should expire
            Sleep(2500);
            CheckValue(env, 10.2);

            // Sleep for 1 seconds, E5 should have expired
            Sleep(1000);
            CheckValue(env, double.NaN);

            env.UndeployAll();
        }
            public void Run(RegressionEnvironment env)
            {
                var fieldName = "subq";
                var fields = new[] {"c0", "c1"};

                var epl =
                    "create context MyCtx partition by TheString from SupportBean, P00 from SupportBean_S0;\n" +
                    "@Name('s0') context MyCtx select " +
                    "(select TheString as c0, sum(IntPrimitive) as c1 " +
                    " from SupportBean#keepall " +
                    " group by TheString) as subq " +
                    "from SupportBean_S0 as S0";
                env.CompileDeployAddListenerMileZero(epl, "s0");

                env.SendEventBean(new SupportBean("P1", 100));
                env.SendEventBean(new SupportBean_S0(1, "P1"));
                AssertMapFieldAndReset(
                    env,
                    fieldName,
                    fields,
                    new object[] {"P1", 100});

                env.SendEventBean(new SupportBean_S0(2, "P2"));
                AssertMapFieldAndReset(env, fieldName, fields, null);

                env.SendEventBean(new SupportBean("P2", 200));
                env.SendEventBean(new SupportBean_S0(3, "P2"));
                AssertMapFieldAndReset(
                    env,
                    fieldName,
                    fields,
                    new object[] {"P2", 200});

                env.SendEventBean(new SupportBean("P2", 205));
                env.SendEventBean(new SupportBean_S0(4, "P2"));
                AssertMapFieldAndReset(
                    env,
                    fieldName,
                    fields,
                    new object[] {"P2", 405});

                env.UndeployAll();
            }
Exemple #8
0
            public void Run(RegressionEnvironment env)
            {
                var stmtText =
                    "@Name('s0') select Id from SupportBean_S0 where not exists (select * from SupportBean_S1#length(1000))";
                env.CompileDeployAddListenerMileZero(stmtText, "s0");

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

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

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

                env.UndeployAll();
            }
Exemple #9
0
            public void Run(RegressionEnvironment env)
            {
                var stmtText = "@Name('s0') select * from " +
                               "SupportBeanRange#keepall sbr " +
                               " left outer join " +
                               "SupportBean_ST0#keepall S0 on S0.Key0=sbr.Key" +
                               " left outer join " +
                               "SupportBean_ST1#keepall S1 on S1.Key1=S0.Key0" +
                               " where S0.P00 between sbr.RangeStartLong and sbr.RangeEndLong";
                env.CompileDeployAddListenerMileZero(stmtText, "s0");

                // preload
                log.Info("Preload");
                for (var i = 0; i < 10; i++) {
                    env.SendEventBean(new SupportBean_ST1("ST1_" + i, "K", i));
                }

                for (var i = 0; i < 10000; i++) {
                    env.SendEventBean(new SupportBean_ST0("ST0_" + i, "K", i));
                }

                log.Info("Preload done");

                var startTime = PerformanceObserver.MilliTime;
                for (var i = 0; i < 100; i++) {
                    long index = 5000 + i;
                    env.SendEventBean(SupportBeanRange.MakeLong("R", "K", index, index + 2));
                    Assert.AreEqual(30, env.Listener("s0").GetAndResetLastNewData().Length);
                }

                var endTime = PerformanceObserver.MilliTime;
                var delta = endTime - startTime;

                env.SendEventBean(new SupportBean_ST0("ST0X", "K", 5000));
                Assert.AreEqual(10, env.Listener("s0").GetAndResetLastNewData().Length);

                env.SendEventBean(new SupportBean_ST1("ST1X", "K", 5004));
                Assert.AreEqual(301, env.Listener("s0").GetAndResetLastNewData().Length);

                Assert.That(delta, Is.LessThan(500), "Failed perf test, delta=" + delta);
                env.UndeployAll();
            }
Exemple #10
0
            public void Run(RegressionEnvironment env)
            {
                var epl = "@Name('s0') select a.Id as aId, b.Id as bId from SupportBean_A as a unidirectional " +
                          "full outer join SupportBean_B as b unidirectional";
                env.CompileDeployAddListenerMileZero(epl, "s0");

                env.SendEventBean(new SupportBean_A("A1"));
                AssertReceived2Stream(env, "A1", null);

                env.SendEventBean(new SupportBean_B("B1"));
                AssertReceived2Stream(env, null, "B1");

                env.SendEventBean(new SupportBean_B("B2"));
                AssertReceived2Stream(env, null, "B2");

                env.SendEventBean(new SupportBean_A("A2"));
                AssertReceived2Stream(env, "A2", null);

                env.UndeployAll();
            }
Exemple #11
0
            public void Run(RegressionEnvironment env)
            {
                string[] fields = {"val0"};
                var epl =
                    "@Name('s0') select prev(1, TheString) as val0 from SupportBean#expr_batch(current_count > 2)";
                env.CompileDeployAddListenerMileZero(epl, "s0");

                env.SendEventBean(new SupportBean("E1", 1));
                env.SendEventBean(new SupportBean("E2", 2));
                Assert.IsFalse(env.Listener("s0").IsInvoked);

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

                env.UndeployAll();
            }
Exemple #12
0
            public void Run(RegressionEnvironment env)
            {
                var fields = new[] {"c0", "c1"};
                var epl = "@Name('s0') select exists (select sum(IntPrimitive) from SupportBean) as c0," +
                          "not exists (select sum(IntPrimitive) from SupportBean) as c1 from SupportValueEvent";
                env.CompileDeployAddListenerMileZero(epl, "s0");

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

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

                env.UndeployAll();
            }
            public void Run(RegressionEnvironment env)
            {
                var epl =
                    "@Name('s0') select (select sum(IntPrimitive) from SupportBean#keepall where TheString = S0.P00 having sum(IntPrimitive) > 10) as c0 from SupportBean_S0 as S0";
                env.CompileDeployAddListenerMileZero(epl, "s0");

                SendEventS0Assert(env, "G1", null);

                SendSB(env, "G1", 10);
                SendEventS0Assert(env, "G1", null);

                SendSB(env, "G2", 11);
                SendEventS0Assert(env, "G1", null);
                SendEventS0Assert(env, "G2", 11);

                SendSB(env, "G1", 12);
                SendEventS0Assert(env, "G1", 22);

                env.UndeployAll();
            }
            public void Run(RegressionEnvironment env)
            {
                /// <summary>
                /// Query:
                /// -&gt; s2
                /// -&gt; s3
                /// -&gt; s4
                /// </summary>
                var epl = "@Name('s0') select * from " +
                          "SupportBean_S4#length(1000) as S4 " +
                          " right outer join SupportBean_S1#length(1000) as S1 on S1.P10 = S4.P40 " +
                          " left outer join " +
                          "SupportBean_S0#length(1000) as S0 on S0.P00 = S1.P10 " +
                          " left outer join SupportBean_S2#length(1000) as S2 on S1.P10 = S2.P20 " +
                          " left outer join SupportBean_S3#length(1000) as S3 on S1.P10 = S3.P30 ";

                env.CompileDeployAddListenerMileZero(epl, "s0");

                TryAssertion(env);
            }
Exemple #15
0
            public void Run(RegressionEnvironment env)
            {
                var stmtText =
                    "@Name('s0') select S0.AnyObject in (select * from SupportBean_S1#length(1000)) as value from SupportBeanArrayCollMap S0";
                env.CompileDeployAddListenerMileZero(stmtText, "s0");

                var s1 = new SupportBean_S1(100);
                var arrayBean = new SupportBeanArrayCollMap(s1);
                env.SendEventBean(s1);
                env.SendEventBean(arrayBean);
                Assert.AreEqual(true, env.Listener("s0").AssertOneGetNewAndReset().Get("value"));

                var s2 = new SupportBean_S2(100);
                arrayBean.AnyObject = s2;
                env.SendEventBean(s2);
                env.SendEventBean(arrayBean);
                Assert.AreEqual(false, env.Listener("s0").AssertOneGetNewAndReset().Get("value"));

                env.UndeployAll();
            }
Exemple #16
0
            public void Run(RegressionEnvironment env)
            {
                SendCurrentTime(env, "2002-02-01T09:00:00.000");
                var epl = "@Name('s0') select rstream * from SupportBean#time_accum(1 month)";
                env.CompileDeployAddListenerMileZero(epl, "s0");

                env.SendEventBean(new SupportBean("E1", 1));
                env.SendEventBean(new SupportBean("E2", 2));

                SendCurrentTimeWithMinus(env, "2002-03-01T09:00:00.000", 1);
                Assert.IsFalse(env.Listener("s0").IsInvoked);

                SendCurrentTime(env, "2002-03-01T09:00:00.000");
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").GetAndResetLastNewData(),
                    new[] {"TheString"},
                    new[] {new object[] {"E1"}, new object[] {"E2"}});

                env.UndeployAll();
            }
Exemple #17
0
            public void Run(RegressionEnvironment env)
            {
                long startTime = 1000;
                SendTimer(env, startTime);

                var epl =
                    "@Name('s0') select sum(Price) " +
                    "from SupportMarketDataBean#time_length_batch(10 sec, 3, 'force_update')";
                env.CompileDeployAddListenerMileZero(epl, "s0");

                // No batch as we are not start eager
                SendTimer(env, startTime + 10000);
                Assert.IsFalse(env.Listener("s0").IsInvoked);

                // No batch as we are not start eager
                SendTimer(env, startTime + 20000);
                Assert.IsFalse(env.Listener("s0").IsInvoked);

                env.UndeployAll();
            }
            public void Run(RegressionEnvironment env)
            {
                var epl =
                    "@Name('s0') @Name('s0')select * from SupportBean(IntPrimitive<10) where IntPrimitive not in (select IntPrimitive from SupportBean#unique(IntPrimitive))";
                env.CompileDeployAddListenerMileZero(epl, "s0");

                env.SendEventBean(new SupportBean("E1", 5));
                Assert.IsFalse(env.Listener("s0").GetAndClearIsInvoked());

                env.UndeployAll();

                var eplTwo =
                    "@Name('s0') select * from SupportBean where IntPrimitive not in (select IntPrimitive from SupportBean(IntPrimitive<10)#unique(IntPrimitive))";
                env.CompileDeployAddListenerMile(eplTwo, "s0", 1);

                env.SendEventBean(new SupportBean("E1", 5));
                Assert.IsFalse(env.Listener("s0").GetAndClearIsInvoked());

                env.UndeployAll();
            }
Exemple #19
0
            public void Run(RegressionEnvironment env)
            {
                var text = "@Name('s0') select irstream * from  SupportMarketDataBean#size()";
                env.CompileDeployAddListenerMileZero(text, "s0");

                env.SendEventBean(MakeMarketDataEvent("E1"));
                env.Listener("s0")
                    .AssertNewOldData(
                        new[] {new object[] {"size", 1L}},
                        new[] {new object[] {"size", 0L}});

                env.Milestone(1);

                env.SendEventBean(MakeMarketDataEvent("E2"));
                env.Listener("s0")
                    .AssertNewOldData(
                        new[] {new object[] {"size", 2L}},
                        new[] {new object[] {"size", 1L}});

                env.Milestone(2);

                for (var i = 3; i < 10; i++) {
                    env.SendEventBean(MakeMarketDataEvent("E" + i));
                    env.Listener("s0")
                        .AssertNewOldData(
                            new[] {new object[] {"size", (long) i}}, // new data
                            new[] {new object[] {"size", (long) i - 1}} //  old data
                        );

                    env.Milestone(i);
                }

                // test iterator
                var events = EPAssertionUtil.EnumeratorToArray(env.GetEnumerator("s0"));
                EPAssertionUtil.AssertPropsPerRow(
                    events,
                    new[] {"size"},
                    new[] {new object[] {9L}});

                env.UndeployAll();
            }
Exemple #20
0
            public void Run(RegressionEnvironment env)
            {
                var fields = new[] {"TheString", "col"};
                var epl =
                    "@Name('s0') select TheString, (select P00 from SupportBean_S0#lastevent()) as col from SupportBean";
                env.CompileDeployAddListenerMileZero(epl, "s0");

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

                env.Milestone(1);

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

                env.Milestone(2);

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

                env.Milestone(3);

                env.SendEventBean(new SupportBean_S0(12, "S02"));
                env.SendEventBean(new SupportBean("E4", 4));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E4", "S02"});

                env.UndeployAll();
            }
Exemple #21
0
            public void Run(RegressionEnvironment env)
            {
                var text = "@Name('s0') select irstream * from  SupportMarketDataBean#firstlength(3)";
                env.CompileDeployAddListenerMileZero(text, "s0");

                env.SendEventBean(MakeMarketDataEvent("E1"));
                env.Listener("s0").AssertNewOldData(new[] {new object[] {"Symbol", "E1"}}, null);
                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("s0"),
                    new[] {"Symbol"},
                    new[] {new object[] {"E1"}});

                env.Milestone(1);

                env.SendEventBean(MakeMarketDataEvent("E2"));
                env.Listener("s0").AssertNewOldData(new[] {new object[] {"Symbol", "E2"}}, null);
                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("s0"),
                    new[] {"Symbol"},
                    new[] {new object[] {"E1"}, new object[] {"E2"}});

                env.Milestone(2);

                env.SendEventBean(MakeMarketDataEvent("E3"));
                env.Listener("s0").AssertNewOldData(new[] {new object[] {"Symbol", "E3"}}, null);
                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("s0"),
                    new[] {"Symbol"},
                    new[] {new object[] {"E1"}, new object[] {"E2"}, new object[] {"E3"}});

                env.Milestone(3);

                env.SendEventBean(MakeMarketDataEvent("E4"));
                Assert.IsFalse(env.Listener("s0").IsInvoked);
                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("s0"),
                    new[] {"Symbol"},
                    new[] {new object[] {"E1"}, new object[] {"E2"}, new object[] {"E3"}});

                env.UndeployAll();
            }
Exemple #22
0
            public void Run(RegressionEnvironment env)
            {
                SendCurrentTime(env, "2002-02-01T09:00:00.000");
                env.CompileDeployAddListenerMileZero("@Name('s0') select * from SupportBean#firsttime(1 month)", "s0");

                SendCurrentTime(env, "2002-02-15T09:00:00.000");
                env.SendEventBean(new SupportBean("E1", 1));

                SendCurrentTimeWithMinus(env, "2002-03-01T09:00:00.000", 1);
                env.SendEventBean(new SupportBean("E2", 2));

                SendCurrentTime(env, "2002-03-01T09:00:00.000");
                env.SendEventBean(new SupportBean("E3", 3));

                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    new[] {"TheString"},
                    new[] {new object[] {"E1"}, new object[] {"E2"}});

                env.UndeployAll();
            }
            public void Run(RegressionEnvironment env)
            {
                var epl = "select * from SupportTradeEventTwo#lastevent;\n" +
                          "@Name('s0') select window(tl.*) as longItems, " +
                          "       (SELECT window(ts.*) AS shortItems FROM SupportTradeEventTwo#time(20 minutes) as ts WHERE ts.SecurityID=tl.SecurityID) " +
                          "from SupportTradeEventTwo#time(20 minutes) as tl " +
                          "where tl.SecurityID = 1000" +
                          "group by tl.SecurityID";
                env.CompileDeployAddListenerMileZero(epl, "s0");

                env.SendEventBean(new SupportTradeEventTwo(PerformanceObserver.MilliTime, 1000, 50, 1));
                Assert.AreEqual(1, ((object[]) env.Listener("s0").AssertOneGetNew().Get("longItems")).Length);
                Assert.AreEqual(1, ((object[]) env.Listener("s0").AssertOneGetNew().Get("shortItems")).Length);
                env.Listener("s0").Reset();

                env.SendEventBean(new SupportTradeEventTwo(PerformanceObserver.MilliTime + 10, 1000, 50, 1));
                Assert.AreEqual(2, ((object[]) env.Listener("s0").AssertOneGetNew().Get("longItems")).Length);
                Assert.AreEqual(2, ((object[]) env.Listener("s0").AssertOneGetNew().Get("shortItems")).Length);

                env.UndeployAll();
            }
            public void Run(RegressionEnvironment env)
            {
                var epl = "@Name('s0') select irstream Symbol, " +
                          "min(Volume) as minVol," +
                          "max(Volume) as maxVol," +
                          "min(distinct Volume) as minDistVol," +
                          "max(distinct Volume) as maxDistVol" +
                          " from SupportBeanString#length(100) as one, " +
                          "SupportMarketDataBean#length(3) as two " +
                          "where (Symbol='DELL' or Symbol='IBM' or Symbol='GE') " +
                          "  and one.TheString = two.Symbol " +
                          "group by Symbol";
                env.CompileDeployAddListenerMileZero(epl, "s0");

                env.SendEventBean(new SupportBeanString(SYMBOL_DELL));
                env.SendEventBean(new SupportBeanString(SYMBOL_IBM));

                TryAssertionMinMax(env, new AtomicLong());

                env.UndeployAll();
            }
Exemple #25
0
            public void Run(RegressionEnvironment env)
            {
                var epl = "@Name('context') create context CategoryContext\n" +
                          "group TheString = 'A' as cat1,\n" +
                          "group TheString = 'B' as cat2 \n" +
                          "from SupportBean;\n" +
                          "@Name('s0') context CategoryContext select count(*) as c0, context.label as c1 from SupportBean;\n";
                env.CompileDeployAddListenerMileZero(epl, "s0");

                var deploymentIdContext = env.DeploymentId("context");
                var statementNames =
                    env.Runtime.ContextPartitionService.GetContextStatementNames(
                        deploymentIdContext,
                        "CategoryContext");
                EPAssertionUtil.AssertEqualsExactOrder(statementNames, new [] { "s0" });
                Assert.AreEqual(
                    1,
                    env.Runtime.ContextPartitionService.GetContextNestingLevel(deploymentIdContext, "CategoryContext"));
                var ids = env.Runtime.ContextPartitionService.GetContextPartitionIds(
                    deploymentIdContext,
                    "CategoryContext",
                    new ContextPartitionSelectorAll());
                EPAssertionUtil.AssertEqualsExactOrder(new[] {0, 1}, ids.ToArray());

                SendAssert(env, "A", 1, "cat1", 1L);
                SendAssert(env, "C", 2, null, null);

                env.Milestone(1);

                SendAssert(env, "B", 3, "cat2", 1L);
                SendAssert(env, "A", 4, "cat1", 2L);

                env.Milestone(2);

                SendAssert(env, "A", 6, "cat1", 3L);
                SendAssert(env, "B", 5, "cat2", 2L);
                SendAssert(env, "C", 7, null, null);

                env.UndeployAll();
            }
Exemple #26
0
            public void Run(RegressionEnvironment env)
            {
                long startTime = 1000;
                SendTimer(env, startTime);
                var events = Get100Events();

                var epl =
                    "@Name('s0') select irstream Price, prev(1, Price) as prevPrice, prior(1, Price) as priorPrice " +
                    "from SupportMarketDataBean#time_accum(10 sec)";
                env.CompileDeployAddListenerMileZero(epl, "s0");

                // 1st event
                SendTimer(env, startTime + 20000);
                env.SendEventBean(events[5]);
                AssertData(env.Listener("s0").AssertOneGetNewAndReset(), 5d, null, null);

                // 2nd event
                SendTimer(env, startTime + 25000);
                env.SendEventBean(events[6]);
                AssertData(env.Listener("s0").AssertOneGetNewAndReset(), 6d, 5d, 5d);

                // 3nd event
                SendTimer(env, startTime + 34000);
                env.SendEventBean(events[7]);
                AssertData(env.Listener("s0").AssertOneGetNewAndReset(), 7d, 6d, 6d);

                SendTimer(env, startTime + 43999);
                Assert.IsFalse(env.Listener("s0").IsInvoked);

                SendTimer(env, startTime + 44000);
                Assert.IsNull(env.Listener("s0").LastNewData);
                Assert.AreEqual(1, env.Listener("s0").OldDataList.Count);
                Assert.AreEqual(3, env.Listener("s0").LastOldData.Length);
                AssertData(env.Listener("s0").LastOldData[0], 5d, null, null);
                AssertData(env.Listener("s0").LastOldData[1], 6d, null, 5d);
                AssertData(env.Listener("s0").LastOldData[2], 7d, null, 6d);
                env.Listener("s0").Reset();

                env.UndeployAll();
            }
            public void Run(RegressionEnvironment env)
            {
                var epl = "@Name('s0') select Val as value from SupportOverrideOne#length(10)";
                env.CompileDeployAddListenerMileZero(epl, "s0");

                env.SendEventBean(new SupportOverrideOneA("valA", "valOne", "valBase"));
                var theEvent = env.Listener("s0").GetAndResetLastNewData()[0];
                Assert.AreEqual("valA", theEvent.Get("value"));

                env.SendEventBean(new SupportOverrideBase("x"));
                Assert.IsFalse(env.Listener("s0").IsInvoked);

                env.SendEventBean(new SupportOverrideOneB("valB", "valTwo", "valBase2"));
                theEvent = env.Listener("s0").GetAndResetLastNewData()[0];
                Assert.AreEqual("valB", theEvent.Get("value"));

                env.SendEventBean(new SupportOverrideOne("valThree", "valBase3"));
                theEvent = env.Listener("s0").GetAndResetLastNewData()[0];
                Assert.AreEqual("valThree", theEvent.Get("value"));

                env.UndeployAll();
            }
Exemple #28
0
            public void Run(RegressionEnvironment env)
            {
                var epl =
                    "@Name('s0') select * from SupportBean#expr_batch(udf(TheString, view_reference, expired_count))";
                env.CompileDeployAddListenerMileZero(epl, "s0");

                ViewExpressionWindow.LocalUDF.Result = true;
                env.SendEventBean(new SupportBean("E1", 0));
                Assert.AreEqual("E1", ViewExpressionWindow.LocalUDF.Key);
                Assert.AreEqual(0, (int) ViewExpressionWindow.LocalUDF.ExpiryCount);
                Assert.IsNotNull(ViewExpressionWindow.LocalUDF.Viewref);

                env.SendEventBean(new SupportBean("E2", 0));

                ViewExpressionWindow.LocalUDF.Result = false;
                env.SendEventBean(new SupportBean("E3", 0));
                Assert.AreEqual("E3", ViewExpressionWindow.LocalUDF.Key);
                Assert.AreEqual(0, (int) ViewExpressionWindow.LocalUDF.ExpiryCount);
                Assert.IsNotNull(ViewExpressionWindow.LocalUDF.Viewref);

                env.UndeployAll();
            }
Exemple #29
0
            public void Run(RegressionEnvironment env)
            {
                var epl = "@Name('s0') select irstream * from SupportBean#unique(IntBoxed)";
                env.CompileDeployAddListenerMileZero(epl, "s0");

                var beanOne = new SupportBean("E1", 1);
                env.SendEventBean(beanOne);
                env.Listener("s0").AssertOneGetNewAndReset();

                var eplTwo = "@Name('s1') select irstream * from SupportBean#unique(IntBoxed)";
                env.CompileDeployAddListenerMile(eplTwo, "s1", 1);

                var beanTwo = new SupportBean("E2", 2);
                env.SendEventBean(beanTwo);

                Assert.AreEqual(beanTwo, env.Listener("s0").LastNewData[0].Underlying);
                Assert.AreEqual(beanOne, env.Listener("s0").LastOldData[0].Underlying);
                Assert.AreEqual(beanTwo, env.Listener("s1").LastNewData[0].Underlying);
                Assert.IsNull(env.Listener("s1").LastOldData);

                env.UndeployAll();
            }
Exemple #30
0
            public void Run(RegressionEnvironment env)
            {
                var stmtText = "@Name('s0') select (select Id+1 as myId from SupportBean_S1#lastevent) as idS1_0, " +
                               "(select Id+2 as myId from SupportBean_S1#lastevent) as idS1_1 from SupportBean_S0";

                env.CompileDeployAddListenerMileZero(stmtText, "s0");

                // check type
                Assert.AreEqual(typeof(int?), env.Statement("s0").EventType.GetPropertyType("idS1_0"));
                Assert.AreEqual(typeof(int?), env.Statement("s0").EventType.GetPropertyType("idS1_1"));

                // test no event, should return null
                env.SendEventBean(new SupportBean_S0(1));
                var theEvent = env.Listener("s0").AssertOneGetNewAndReset();
                Assert.AreEqual(null, theEvent.Get("idS1_0"));
                Assert.AreEqual(null, theEvent.Get("idS1_1"));

                // test one event
                env.SendEventBean(new SupportBean_S1(10));
                env.SendEventBean(new SupportBean_S0(1));
                theEvent = env.Listener("s0").AssertOneGetNewAndReset();
                Assert.AreEqual(11, theEvent.Get("idS1_0"));
                Assert.AreEqual(12, theEvent.Get("idS1_1"));

                // resend event
                env.SendEventBean(new SupportBean_S0(2));
                theEvent = env.Listener("s0").AssertOneGetNewAndReset();
                Assert.AreEqual(11, theEvent.Get("idS1_0"));
                Assert.AreEqual(12, theEvent.Get("idS1_1"));

                // test second event
                env.SendEventBean(new SupportBean_S1(999));
                env.SendEventBean(new SupportBean_S0(3));
                theEvent = env.Listener("s0").AssertOneGetNewAndReset();
                Assert.AreEqual(1000, theEvent.Get("idS1_0"));
                Assert.AreEqual(1001, theEvent.Get("idS1_1"));

                env.UndeployAll();
            }