Пример #1
0
 public static object MakeEnd(
     this SupportDateTimeFieldType enumValue,
     string time,
     long duration)
 {
     return FromEndDate(enumValue, SupportTimeStartEndA.Make(null, time, duration));
 }
Пример #2
0
        public void Run(RegressionEnvironment env)
        {
            var path = new RegressionPath();
            env.CompileDeploy("create window AWindow#keepall as A", path);
            env.CompileDeploy("insert into AWindow select * from A", path);

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

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

            var epl =
                "@Name('s0') select a.Key as c0 from SupportDateTime unidirectional, AWindow as a where LongDate.between(LongdateStart, LongdateEnd, false, true)";
            env.CompileDeploy(epl, path).AddListener("s0");

            // query
            var startTime = PerformanceObserver.MilliTime;
            for (var i = 0; i < 1000; i++) {
                env.SendEventBean(SupportDateTime.Make("2002-05-30T08:00:00.050"));
                Assert.AreEqual("AEarlier", env.Listener("s0").AssertOneGetNewAndReset().Get("c0"));
            }

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

            env.SendEventBean(SupportDateTime.Make("2002-05-30T10:00:00.050"));
            Assert.AreEqual("ALater", env.Listener("s0").AssertOneGetNewAndReset().Get("c0"));

            env.UndeployAll();
        }
Пример #3
0
            public void Run(RegressionEnvironment env)
            {
                var fields = new [] { "val0", "val1", "val2", "val3" };
                var epl = "@Name('s0') select " +
                          "DateTimeEx.get('month') as val0," +
                          "DateTimeOffset.get('month') as val1," +
                          "DateTime.get('month') as val2," +
                          "LongDate.get('month') as val3" +
                          " from SupportDateTime";
                env.CompileDeploy(epl).AddListener("s0");
                LambdaAssertionUtil.AssertTypes(
                    env.Statement("s0").EventType,
                    fields,
                    new[] {
                        typeof(int?),
                        typeof(int?),
                        typeof(int?),
                        typeof(int?)
                    });

                var startTime = "2002-05-30T09:00:00.000";
                env.SendEventBean(SupportDateTime.Make(startTime));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {
                        5, 5, 5, 5
                    });

                env.UndeployAll();

                // try event as input
                epl = "@Name('s0') select abc.Get('month') as val0 from SupportTimeStartEndA as abc";
                env.CompileDeployAddListenerMile(epl, "s0", 1);

                env.SendEventBean(SupportTimeStartEndA.Make("A0", startTime, 0));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    new [] { "val0" },
                    new object[] { 5 });

                env.UndeployAll();

                // test "Get" method on object is preferred
                epl = "@Name('s0') select e.Get() as c0, e.Get('abc') as c1 from SupportEventWithJustGet as e";
                env.CompileDeployAddListenerMile(epl, "s0", 1);
                env.SendEventBean(new SupportEventWithJustGet());
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    new [] { "c0", "c1" },
                    new object[] {1, 2});

                env.UndeployAll();
            }
Пример #4
0
        private void TryRun(String condition, String tsa, String tsb, bool isInvoked)
        {
            EPStatement stmt = _epService.EPAdministrator.CreateEPL("select * from pattern [a=A -> b=B] as abc where " + condition);

            stmt.Events += _listener.Update;

            _epService.EPRuntime.SendEvent(SupportTimeStartEndA.Make("E1", tsa, 0));
            _epService.EPRuntime.SendEvent(SupportTimeStartEndB.Make("E2", tsb, 0));
            Assert.AreEqual(isInvoked, _listener.GetAndClearIsInvoked());

            stmt.Dispose();
        }
Пример #5
0
        private void TryRun(
            RegressionEnvironment env,
            string condition,
            string tsa,
            string tsb,
            bool IsInvoked,
            AtomicLong milestone)
        {
            var epl = "@Name('s0') select * from pattern [a=A -> b=B] as abc where " + condition;
            env.CompileDeploy(epl).AddListener("s0").MilestoneInc(milestone);

            env.SendEventBean(SupportTimeStartEndA.Make("E1", tsa, 0), "A");
            env.SendEventBean(SupportTimeStartEndB.Make("E2", tsb, 0), "B");
            Assert.AreEqual(IsInvoked, env.Listener("s0").GetAndClearIsInvoked());

            env.UndeployAll();
        }
Пример #6
0
        private void RunAssertionInput(EPServiceProvider epService)
        {
            string[] fields = "val0,val1".Split(',');
            string   epl    = "select " +
                              "utildate.Get('month') as val0," +
                              "longdate.Get('month') as val1 " +
                              " from SupportDateTime";
            EPStatement stmt     = epService.EPAdministrator.CreateEPL(epl);
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;
            LambdaAssertionUtil.AssertTypes(stmt.EventType, fields, new Type[] {
                typeof(int?), typeof(int?)
            });

            string startTime = "2002-05-30T09:00:00.000";

            epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { 5, 5 });

            // try event as input
            var configBean = new ConfigurationEventTypeLegacy();

            configBean.StartTimestampPropertyName = "longdateStart";
            configBean.EndTimestampPropertyName   = "longdateEnd";
            epService.EPAdministrator.Configuration.AddEventType("SupportTimeStartEndA", typeof(SupportTimeStartEndA), configBean);

            stmt.Dispose();
            epl          = "select abc.Get('month') as val0 from SupportTimeStartEndA as abc";
            stmt         = epService.EPAdministrator.CreateEPL(epl);
            stmt.Events += listener.Update;

            epService.EPRuntime.SendEvent(SupportTimeStartEndA.Make("A0", startTime, 0));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), "val0".Split(','), new object[] { 5 });

            // test "get" method on object is preferred
            epService.EPAdministrator.Configuration.AddEventType(typeof(MyEvent));
            epService.EPAdministrator.CreateEPL("select e.Get() as c0, e.Get('abc') as c1 from MyEvent as e").Events += listener.Update;
            epService.EPRuntime.SendEvent(new MyEvent());
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), "c0,c1".Split(','), new object[] { 1, 2 });

            stmt.Dispose();
        }
Пример #7
0
        public override void Run(EPServiceProvider epService)
        {
            epService.EPAdministrator.Configuration.AddEventType("A", typeof(SupportTimeStartEndA));
            epService.EPAdministrator.Configuration.AddEventType("SupportDateTime", typeof(SupportDateTime));

            epService.EPAdministrator.CreateEPL("create window AWindow#keepall as A");
            epService.EPAdministrator.CreateEPL("insert into AWindow select * from A");

            // preload
            for (int i = 0; i < 10000; i++)
            {
                epService.EPRuntime.SendEvent(SupportTimeStartEndA.Make("A" + i, "2002-05-30T09:00:00.000", 100));
            }
            epService.EPRuntime.SendEvent(SupportTimeStartEndA.Make("AEarlier", "2002-05-30T08:00:00.000", 100));
            epService.EPRuntime.SendEvent(SupportTimeStartEndA.Make("ALater", "2002-05-30T10:00:00.000", 100));

            string      epl      = "select a.key as c0 from SupportDateTime unidirectional, AWindow as a where Longdate.between(longdateStart, longdateEnd, false, true)";
            EPStatement stmt     = epService.EPAdministrator.CreateEPL(epl);
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            // query
            long startTime = DateTimeHelper.CurrentTimeMillis;

            for (int i = 0; i < 1000; i++)
            {
                epService.EPRuntime.SendEvent(SupportDateTime.Make("2002-05-30T08:00:00.050"));
                Assert.AreEqual("AEarlier", listener.AssertOneGetNewAndReset().Get("c0"));
            }
            long endTime = DateTimeHelper.CurrentTimeMillis;
            long delta   = endTime - startTime;

            Assert.IsTrue(delta < 500, "Delta=" + delta / 1000d);

            epService.EPRuntime.SendEvent(SupportDateTime.Make("2002-05-30T10:00:00.050"));
            Assert.AreEqual("ALater", listener.AssertOneGetNewAndReset().Get("c0"));

            stmt.Dispose();
        }
Пример #8
0
        public void TestPerf()
        {
            _epService.EPAdministrator.Configuration.AddEventType("A", typeof(SupportTimeStartEndA).FullName);
            _epService.EPAdministrator.Configuration.AddEventType("SupportDateTime", typeof(SupportDateTime).FullName);

            _epService.EPAdministrator.CreateEPL("create window AWindow.win:keepall() as A");
            _epService.EPAdministrator.CreateEPL("insert into AWindow select * from A");

            // preload
            for (int i = 0; i < 10000; i++)
            {
                _epService.EPRuntime.SendEvent(SupportTimeStartEndA.Make("A" + i, "2002-05-30 9:00:00.000", 100));
            }
            _epService.EPRuntime.SendEvent(SupportTimeStartEndA.Make("AEarlier", "2002-05-30 8:00:00.000", 100));
            _epService.EPRuntime.SendEvent(SupportTimeStartEndA.Make("ALater", "2002-05-30 10:00:00.000", 100));

            String      epl  = "select a.key as c0 from SupportDateTime unidirectional, AWindow as a where msecdate.Between(msecdateStart, msecdateEnd, false, true)";
            EPStatement stmt = _epService.EPAdministrator.CreateEPL(epl);

            stmt.Events += _listener.Update;

            // query
            long startTime = Environment.TickCount;

            for (int i = 0; i < 1000; i++)
            {
                _epService.EPRuntime.SendEvent(SupportDateTime.Make("2002-05-30 8:00:00.050"));
                Assert.AreEqual("AEarlier", _listener.AssertOneGetNewAndReset().Get("c0"));
            }
            long endTime = Environment.TickCount;
            long delta   = endTime - startTime;

            Assert.IsTrue(delta < 500, "Delta=" + delta / 1000d);

            _epService.EPRuntime.SendEvent(SupportDateTime.Make("2002-05-30 10:00:00.050"));
            Assert.AreEqual("ALater", _listener.AssertOneGetNewAndReset().Get("c0"));

            stmt.Dispose();
        }
Пример #9
0
        public void TestPerf()
        {
            var config = new ConfigurationEventTypeLegacy();

            config.StartTimestampPropertyName = "LongdateStart";
            config.EndTimestampPropertyName   = "LongdateEnd";
            _epService.EPAdministrator.Configuration.AddEventType("A", typeof(SupportTimeStartEndA).FullName, config);
            _epService.EPAdministrator.Configuration.AddEventType("B", typeof(SupportTimeStartEndB).FullName, config);

            _epService.EPAdministrator.CreateEPL("create window AWindow#keepall as A");
            _epService.EPAdministrator.CreateEPL("insert into AWindow select * from A");

            // preload
            for (int i = 0; i < 10000; i++)
            {
                _epService.EPRuntime.SendEvent(SupportTimeStartEndA.Make("A" + i, "2002-05-30 9:00:00.000", 100));
            }
            _epService.EPRuntime.SendEvent(SupportTimeStartEndA.Make("AEarlier", "2002-05-30 8:00:00.000", 100));
            _epService.EPRuntime.SendEvent(SupportTimeStartEndA.Make("ALater", "2002-05-30 10:00:00.000", 100));

            // assert BEFORE
            String eplBefore = "select a.Key as c0 from AWindow as a, B b unidirectional where a.before(b)";

            RunAssertion(eplBefore, "2002-05-30 9:00:00.000", 0, "AEarlier");

            String eplBeforeLong = "select a.Key as c0 from AWindow as a, B b unidirectional where a.LongdateEnd.before(b.LongdateStart)";

            RunAssertion(eplBeforeLong, "2002-05-30 9:00:00.000", 0, "AEarlier");

            String eplBeforeLongMix1 = "select a.Key as c0 from AWindow as a, B b unidirectional where a.LongdateEnd.before(b)";

            RunAssertion(eplBeforeLongMix1, "2002-05-30 9:00:00.000", 0, "AEarlier");

            String eplBeforeLongMix2 = "select a.Key as c0 from AWindow as a, B b unidirectional where a.before(b.LongdateStart)";

            RunAssertion(eplBeforeLongMix2, "2002-05-30 9:00:00.000", 0, "AEarlier");

            // assert AFTER
            String eplAfter = "select a.Key as c0 from AWindow as a, B b unidirectional where a.after(b)";

            RunAssertion(eplAfter, "2002-05-30 9:00:00.000", 0, "ALater");

            // assert COINCIDES
            String eplCoincides = "select a.Key as c0 from AWindow as a, B b unidirectional where a.coincides(b)";

            RunAssertion(eplCoincides, "2002-05-30 8:00:00.000", 100, "AEarlier");

            // assert DURING
            String eplDuring = "select a.Key as c0 from AWindow as a, B b unidirectional where a.during(b)";

            RunAssertion(eplDuring, "2002-05-30 7:59:59.000", 2000, "AEarlier");

            // assert FINISHES
            String eplFinishes = "select a.Key as c0 from AWindow as a, B b unidirectional where a.finishes(b)";

            RunAssertion(eplFinishes, "2002-05-30 7:59:59.950", 150, "AEarlier");

            // assert FINISHED-BY
            String eplFinishedBy = "select a.Key as c0 from AWindow as a, B b unidirectional where a.finishedBy(b)";

            RunAssertion(eplFinishedBy, "2002-05-30 8:00:00.050", 50, "AEarlier");

            // assert INCLUDES
            String eplIncludes = "select a.Key as c0 from AWindow as a, B b unidirectional where a.includes(b)";

            RunAssertion(eplIncludes, "2002-05-30 8:00:00.050", 20, "AEarlier");

            // assert MEETS
            String eplMeets = "select a.Key as c0 from AWindow as a, B b unidirectional where a.meets(b)";

            RunAssertion(eplMeets, "2002-05-30 8:00:00.100", 0, "AEarlier");

            // assert METBY
            String eplMetBy = "select a.Key as c0 from AWindow as a, B b unidirectional where a.metBy(b)";

            RunAssertion(eplMetBy, "2002-05-30 7:59:59.950", 50, "AEarlier");

            // assert OVERLAPS
            String eplOverlaps = "select a.Key as c0 from AWindow as a, B b unidirectional where a.overlaps(b)";

            RunAssertion(eplOverlaps, "2002-05-30 8:00:00.050", 100, "AEarlier");

            // assert OVERLAPPEDY
            String eplOverlappedBy = "select a.Key as c0 from AWindow as a, B b unidirectional where a.overlappedBy(b)";

            RunAssertion(eplOverlappedBy, "2002-05-30 9:59:59.950", 100, "ALater");
            RunAssertion(eplOverlappedBy, "2002-05-30 7:59:59.950", 100, "AEarlier");

            // assert STARTS
            String eplStarts = "select a.Key as c0 from AWindow as a, B b unidirectional where a.starts(b)";

            RunAssertion(eplStarts, "2002-05-30 8:00:00.000", 150, "AEarlier");

            // assert STARTEDBY
            String eplEnds = "select a.Key as c0 from AWindow as a, B b unidirectional where a.startedBy(b)";

            RunAssertion(eplEnds, "2002-05-30 8:00:00.000", 50, "AEarlier");
        }
Пример #10
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();
        }
Пример #11
0
        public void TestIncludeEndpoints()
        {
            String startTime = "2002-05-30 09:00:00.000";

            _epService.EPRuntime.SendEvent(new CurrentTimeEvent(DateTimeParser.ParseDefaultMSec(startTime)));

            String[] fieldsCurrentTs = "val0,val1,val2,val3,val4,val5,val6".Split(',');
            String   eplCurrentTS    = "select " +
                                       "current_timestamp.After(msecdateStart) as val0, " +
                                       "current_timestamp.Between(msecdateStart, msecdateEnd) as val1, " +
                                       "current_timestamp.Between(utildateStart, caldateEnd) as val2, " +
                                       "current_timestamp.Between(caldateStart, utildateEnd) as val3, " +
                                       "current_timestamp.Between(utildateStart, utildateEnd) as val4, " +
                                       "current_timestamp.Between(caldateStart, caldateEnd) as val5, " +
                                       "current_timestamp.Between(caldateEnd, caldateStart) as val6 " +
                                       "from SupportTimeStartEndA";
            EPStatement stmtCurrentTs = _epService.EPAdministrator.CreateEPL(eplCurrentTS);

            stmtCurrentTs.Events += _listener.Update;
            LambdaAssertionUtil.AssertTypesAllSame(stmtCurrentTs.EventType, fieldsCurrentTs, typeof(bool?));

            _epService.EPRuntime.SendEvent(SupportTimeStartEndA.Make("E1", "2002-05-30 08:59:59.999", 0));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fieldsCurrentTs, new Object[] { true, false, false, false, false, false, false });

            _epService.EPRuntime.SendEvent(SupportTimeStartEndA.Make("E1", "2002-05-30 08:59:59.999", 1));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fieldsCurrentTs, new Object[] { true, true, true, true, true, true, true });

            _epService.EPRuntime.SendEvent(SupportTimeStartEndA.Make("E1", "2002-05-30 08:59:59.999", 100));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fieldsCurrentTs, new Object[] { true, true, true, true, true, true, true });

            _epService.EPRuntime.SendEvent(SupportTimeStartEndA.Make("E1", "2002-05-30 09:00:00.000", 0));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fieldsCurrentTs, new Object[] { false, true, true, true, true, true, true });

            _epService.EPRuntime.SendEvent(SupportTimeStartEndA.Make("E1", "2002-05-30 09:00:00.000", 100));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fieldsCurrentTs, new Object[] { false, true, true, true, true, true, true });

            _epService.EPRuntime.SendEvent(SupportTimeStartEndA.Make("E1", "2002-05-30 09:00:00.001", 100));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fieldsCurrentTs, new Object[] { false, false, false, false, false, false, false });
            stmtCurrentTs.Dispose();

            // test calendar field and constants
            _epService.EPAdministrator.Configuration.AddImport(typeof(DateTimeParser));
            String[] fieldsConstants = "val0,val1,val2,val3".Split(',');
            String   eplConstants    = "select " +
                                       "msecdateStart.between(DateTimeParser.ParseDefault('2002-05-30 09:00:00.000'), DateTimeParser.ParseDefault('2002-05-30 09:01:00.000')) as val0, " +
                                       "utildateStart.between(DateTimeParser.ParseDefault('2002-05-30 09:00:00.000'), DateTimeParser.ParseDefault('2002-05-30 09:01:00.000')) as val1, " +
                                       "caldateStart.between(DateTimeParser.ParseDefault('2002-05-30 09:00:00.000'), DateTimeParser.ParseDefault('2002-05-30 09:01:00.000')) as val2, " +
                                       "msecdateStart.between(DateTimeParser.ParseDefault('2002-05-30 09:01:00.000'), DateTimeParser.ParseDefault('2002-05-30 09:00:00.000')) as val3 " +
                                       "from SupportTimeStartEndA";
            EPStatement stmtConstants = _epService.EPAdministrator.CreateEPL(eplConstants);

            stmtConstants.Events += _listener.Update;
            LambdaAssertionUtil.AssertTypesAllSame(stmtConstants.EventType, fieldsConstants, typeof(bool?));

            _epService.EPRuntime.SendEvent(SupportTimeStartEndA.Make("E1", "2002-05-30 8:59:59.999", 0));
            EPAssertionUtil.AssertPropsAllValuesSame(_listener.AssertOneGetNewAndReset(), fieldsConstants, false);

            _epService.EPRuntime.SendEvent(SupportTimeStartEndA.Make("E2", "2002-05-30 9:00:00.000", 0));
            EPAssertionUtil.AssertPropsAllValuesSame(_listener.AssertOneGetNewAndReset(), fieldsConstants, true);

            _epService.EPRuntime.SendEvent(SupportTimeStartEndA.Make("E2", "2002-05-30 9:00:05.000", 0));
            EPAssertionUtil.AssertPropsAllValuesSame(_listener.AssertOneGetNewAndReset(), fieldsConstants, true);

            _epService.EPRuntime.SendEvent(SupportTimeStartEndA.Make("E2", "2002-05-30 9:00:59.999", 0));
            EPAssertionUtil.AssertPropsAllValuesSame(_listener.AssertOneGetNewAndReset(), fieldsConstants, true);

            _epService.EPRuntime.SendEvent(SupportTimeStartEndA.Make("E2", "2002-05-30 9:01:00.000", 0));
            EPAssertionUtil.AssertPropsAllValuesSame(_listener.AssertOneGetNewAndReset(), fieldsConstants, true);

            _epService.EPRuntime.SendEvent(SupportTimeStartEndA.Make("E2", "2002-05-30 9:01:00.001", 0));
            EPAssertionUtil.AssertPropsAllValuesSame(_listener.AssertOneGetNewAndReset(), fieldsConstants, false);

            stmtConstants.Dispose();
        }
Пример #12
0
        private static void TryAssertionExcludeEndpoints(
            RegressionEnvironment env,
            RegressionPath path,
            string fields,
            AtomicLong milestone)
        {
            var fieldsCurrentTs = new [] { "val0","val1","val2","val3","val4","val5","val6","val7" };
            var eplCurrentTS = "@Name('s0') select " +
                               "current_timestamp.between(" + fields + ", true, true) as val0, " +
                               "current_timestamp.between(" + fields + ", true, false) as val1, " +
                               "current_timestamp.between(" + fields + ", false, true) as val2, " + 
                               "current_timestamp.between(" + fields + ", false, false) as val3, " +
                               "current_timestamp.between(" + fields + ", VAR_TRUE, VAR_TRUE) as val4, " +
                               "current_timestamp.between(" + fields + ", VAR_TRUE, VAR_FALSE) as val5, " +
                               "current_timestamp.between(" + fields + ", VAR_FALSE, VAR_TRUE) as val6, " +
                               "current_timestamp.between(" + fields + ", VAR_FALSE, VAR_FALSE) as val7 " +
                               "from SupportTimeStartEndA";
            env.CompileDeploy(eplCurrentTS, path).AddListener("s0");
            LambdaAssertionUtil.AssertTypesAllSame(env.Statement("s0").EventType, fieldsCurrentTs, typeof(bool?));

            env.SendEventBean(SupportTimeStartEndA.Make("E1", "2002-05-30T08:59:59.999", 0));
            EPAssertionUtil.AssertPropsAllValuesSame(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fieldsCurrentTs,
                false);

            env.SendEventBean(SupportTimeStartEndA.Make("E1", "2002-05-30T08:59:59.999", 1));
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fieldsCurrentTs,
                new object[] {true, false, true, false, true, false, true, false});

            env.MilestoneInc(milestone);

            env.SendEventBean(SupportTimeStartEndA.Make("E1", "2002-05-30T08:59:59.999", 2));
            EPAssertionUtil.AssertPropsAllValuesSame(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fieldsCurrentTs,
                true);

            env.SendEventBean(SupportTimeStartEndA.Make("E1", "2002-05-30T09:00:00.000", 1));
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fieldsCurrentTs,
                new object[] {true, true, false, false, true, true, false, false});

            env.UndeployModuleContaining("s0");

            // test calendar field and constants
            var fieldsConstants = new [] { "val0","val1","val2","val3" };
            var eplConstants = "@Name('s0') select " +
                               "LongdateStart.between(DateTimeParsingFunctions.ParseDefaultEx('2002-05-30T09:00:00.000'), DateTimeParsingFunctions.ParseDefaultEx('2002-05-30T09:01:00.000'), true, true) as val0, " +
                               "LongdateStart.between(DateTimeParsingFunctions.ParseDefaultEx('2002-05-30T09:00:00.000'), DateTimeParsingFunctions.ParseDefaultEx('2002-05-30T09:01:00.000'), true, false) as val1, " +
                               "LongdateStart.between(DateTimeParsingFunctions.ParseDefaultEx('2002-05-30T09:00:00.000'), DateTimeParsingFunctions.ParseDefaultEx('2002-05-30T09:01:00.000'), false, true) as val2, " +
                               "LongdateStart.between(DateTimeParsingFunctions.ParseDefaultEx('2002-05-30T09:00:00.000'), DateTimeParsingFunctions.ParseDefaultEx('2002-05-30T09:01:00.000'), false, false) as val3 " +
                               "from SupportTimeStartEndA";
            env.CompileDeploy(eplConstants).AddListener("s0");
            LambdaAssertionUtil.AssertTypesAllSame(env.Statement("s0").EventType, fieldsConstants, typeof(bool?));

            env.SendEventBean(SupportTimeStartEndA.Make("E1", "2002-05-30T08:59:59.999", 0));
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fieldsConstants,
                new object[] {false, false, false, false});

            env.SendEventBean(SupportTimeStartEndA.Make("E2", "2002-05-30T09:00:00.000", 0));
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fieldsConstants,
                new object[] {true, true, false, false});

            env.SendEventBean(SupportTimeStartEndA.Make("E2", "2002-05-30T09:00:05.000", 0));
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fieldsConstants,
                new object[] {true, true, true, true});

            env.MilestoneInc(milestone);

            env.SendEventBean(SupportTimeStartEndA.Make("E2", "2002-05-30T09:00:59.999", 0));
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fieldsConstants,
                new object[] {true, true, true, true});

            env.SendEventBean(SupportTimeStartEndA.Make("E2", "2002-05-30T09:01:00.000", 0));
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fieldsConstants,
                new object[] {true, false, true, false});

            env.SendEventBean(SupportTimeStartEndA.Make("E2", "2002-05-30T09:01:00.001", 0));
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fieldsConstants,
                new object[] {false, false, false, false});

            env.UndeployModuleContaining("s0");
        }
Пример #13
0
            public void Run(RegressionEnvironment env)
            {
                var startTime = "2002-05-30T09:00:00.000";
                env.AdvanceTime(DateTimeParsingFunctions.ParseDefaultMSec(startTime));

                var fieldsCurrentTs = new [] { "val0","val1","val2","val3","val4","val5","val6","val7" };
                var eplCurrentTS = "@Name('s0') select " +
                                   "current_timestamp.after(LongdateStart) as val0, " +
                                   "current_timestamp.between(LongdateStart, LongdateEnd) as val1, " +
                                   "current_timestamp.between(DateTimeStart, DateTimeExEnd) as val2, " +
                                   "current_timestamp.between(DateTimeExStart, DateTimeEnd) as val3, " +
                                   "current_timestamp.between(DateTimeStart, DateTimeEnd) as val4, " +
                                   "current_timestamp.between(DateTimeExStart, DateTimeExEnd) as val5, " +
                                   "current_timestamp.between(DateTimeExEnd, DateTimeExStart) as val6, " +
                                   "current_timestamp.between(DateTimeOffsetStart, DateTimeOffsetEnd) as val7 " +
                                   "from SupportTimeStartEndA";
                env.CompileDeploy(eplCurrentTS).AddListener("s0");
                LambdaAssertionUtil.AssertTypesAllSame(env.Statement("s0").EventType, fieldsCurrentTs, typeof(bool?));

                env.SendEventBean(SupportTimeStartEndA.Make("E1", "2002-05-30T08:59:59.999", 0));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsCurrentTs,
                    new object[] {
                        true,  // LongdateStart (val0)
                        false, // LongdateStart - LongdateEnd
                        false, // DateTimeStart - DateTimeExEnd
                        false, // DateTimeExStart - DateTimeEnd
                        false, // DateTimeStart - DateTimeEnd
                        false, // DateTimeExStart - DateTimeExEnd
                        false, // DateTimeExEnd - DateTimeExStart
                        false  // DateTimeOffsetStart - DateTimeOffsetEnd
                    });

                env.SendEventBean(SupportTimeStartEndA.Make("E1", "2002-05-30T08:59:59.999", 1));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsCurrentTs,
                    new object[] {
                        true, // LongdateStart (val0)
                        true, // LongdateStart - LongdateEnd
                        true, // DateTimeStart - DateTimeExEnd
                        true, // DateTimeExStart - DateTimeEnd
                        true, // DateTimeStart - DateTimeEnd
                        true, // DateTimeExStart - DateTimeExEnd
                        true, // DateTimeExEnd - DateTimeExStart
                        true  // DateTimeOffsetStart - DateTimeOffsetEnd
                    });

                env.SendEventBean(SupportTimeStartEndA.Make("E1", "2002-05-30T08:59:59.999", 100));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsCurrentTs,
                    new object[] {
                        true, // LongdateStart (val0)
                        true, // LongdateStart - LongdateEnd
                        true, // DateTimeStart - DateTimeExEnd
                        true, // DateTimeExStart - DateTimeEnd
                        true, // DateTimeStart - DateTimeEnd
                        true, // DateTimeExStart - DateTimeExEnd
                        true, // DateTimeExEnd - DateTimeExStart
                        true  // DateTimeOffsetStart - DateTimeOffsetEnd
                    });

                env.SendEventBean(SupportTimeStartEndA.Make("E1", "2002-05-30T09:00:00.000", 0));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsCurrentTs,
                    new object[] {
                        false, // LongdateStart (val0)
                        true, // LongdateStart - LongdateEnd
                        true, // DateTimeStart - DateTimeExEnd
                        true, // DateTimeExStart - DateTimeEnd
                        true, // DateTimeStart - DateTimeEnd
                        true, // DateTimeExStart - DateTimeExEnd
                        true, // DateTimeExEnd - DateTimeExStart
                        true  // DateTimeOffsetStart - DateTimeOffsetEnd
                    });

                env.SendEventBean(SupportTimeStartEndA.Make("E1", "2002-05-30T09:00:00.000", 100));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsCurrentTs,
                    new object[] {
                        false, // LongdateStart (val0)
                        true, // LongdateStart - LongdateEnd
                        true, // DateTimeStart - DateTimeExEnd
                        true, // DateTimeExStart - DateTimeEnd
                        true, // DateTimeStart - DateTimeEnd
                        true, // DateTimeExStart - DateTimeExEnd
                        true, // DateTimeExEnd - DateTimeExStart
                        true  // DateTimeOffsetStart - DateTimeOffsetEnd
                    });

                env.SendEventBean(SupportTimeStartEndA.Make("E1", "2002-05-30T09:00:00.001", 100));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsCurrentTs,
                    new object[] {
                        false, // LongdateStart (val0)
                        false, // LongdateStart - LongdateEnd
                        false, // DateTimeStart - DateTimeExEnd
                        false, // DateTimeExStart - DateTimeEnd
                        false, // DateTimeStart - DateTimeEnd
                        false, // DateTimeExStart - DateTimeExEnd
                        false, // DateTimeExEnd - DateTimeExStart
                        false  // DateTimeOffsetStart - DateTimeOffsetEnd
                    });
                env.UndeployAll();

                // test calendar field and constants
                var fieldsConstants = new [] { "val0","val1","val2","val3","val4" };
                var eplConstants = "@Name('s0') select " +
                                   "LongdateStart.between(DateTimeParsingFunctions.ParseDefaultEx('2002-05-30T09:00:00.000'), DateTimeParsingFunctions.ParseDefaultEx('2002-05-30T09:01:00.000')) as val0, " +
                                   "DateTimeStart.between(DateTimeParsingFunctions.ParseDefaultEx('2002-05-30T09:00:00.000'), DateTimeParsingFunctions.ParseDefaultEx('2002-05-30T09:01:00.000')) as val1, " +
                                   "DateTimeExStart.between(DateTimeParsingFunctions.ParseDefaultEx('2002-05-30T09:00:00.000'), DateTimeParsingFunctions.ParseDefaultEx('2002-05-30T09:01:00.000')) as val2, " +
                                   "DateTimeOffsetStart.between(DateTimeParsingFunctions.ParseDefaultEx('2002-05-30T09:00:00.000'), DateTimeParsingFunctions.ParseDefaultEx('2002-05-30T09:01:00.000')) as val3, " +
                                   "LongdateStart.between(DateTimeParsingFunctions.ParseDefaultEx('2002-05-30T09:01:00.000'), DateTimeParsingFunctions.ParseDefaultEx('2002-05-30T09:00:00.000')) as val4 " +
                                   "from SupportTimeStartEndA";
                env.CompileDeployAddListenerMile(eplConstants, "s0", 1);
                LambdaAssertionUtil.AssertTypesAllSame(env.Statement("s0").EventType, fieldsConstants, typeof(bool?));

                env.SendEventBean(SupportTimeStartEndA.Make("E1", "2002-05-30T08:59:59.999", 0));
                EPAssertionUtil.AssertPropsAllValuesSame(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsConstants,
                    false);

                env.SendEventBean(SupportTimeStartEndA.Make("E2", "2002-05-30T09:00:00.000", 0));
                EPAssertionUtil.AssertPropsAllValuesSame(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsConstants,
                    true);

                env.SendEventBean(SupportTimeStartEndA.Make("E2", "2002-05-30T09:00:05.000", 0));
                EPAssertionUtil.AssertPropsAllValuesSame(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsConstants,
                    true);

                env.SendEventBean(SupportTimeStartEndA.Make("E2", "2002-05-30T09:00:59.999", 0));
                EPAssertionUtil.AssertPropsAllValuesSame(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsConstants,
                    true);

                env.SendEventBean(SupportTimeStartEndA.Make("E2", "2002-05-30T09:01:00.000", 0));
                EPAssertionUtil.AssertPropsAllValuesSame(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsConstants,
                    true);

                env.SendEventBean(SupportTimeStartEndA.Make("E2", "2002-05-30T09:01:00.001", 0));
                EPAssertionUtil.AssertPropsAllValuesSame(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fieldsConstants,
                    false);

                env.UndeployAll();
            }
Пример #14
0
 private static object FromEndDate(this SupportDateTimeFieldType enumValue, SupportTimeStartEndA holder)
 {
     return(GetEndDateTimeProvider(enumValue).Invoke(holder));
 }
Пример #15
0
 public static object MakeStart(this SupportDateTimeFieldType enumValue, string time)
 {
     return(FromEndDate(enumValue, SupportTimeStartEndA.Make(null, time, 0)));
 }
Пример #16
0
        private void RunAssertionIncludeEndpoints(EPServiceProvider epService)
        {
            string startTime = "2002-05-30T09:00:00.000";

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(DateTimeParser.ParseDefaultMSec(startTime)));

            string[] fieldsCurrentTs = "val0,val1,val2,val3,val4,val5,val6".Split(',');
            string   eplCurrentTS    = "select " +
                                       "current_timestamp.after(longdateStart) as val0, " +
                                       "current_timestamp.between(longdateStart, longdateEnd) as val1, " +
                                       "current_timestamp.between(utildateStart, caldateEnd) as val2, " +
                                       "current_timestamp.between(caldateStart, utildateEnd) as val3, " +
                                       "current_timestamp.between(utildateStart, utildateEnd) as val4, " +
                                       "current_timestamp.between(caldateStart, caldateEnd) as val5, " +
                                       "current_timestamp.between(caldateEnd, caldateStart) as val6 " +
                                       "from SupportTimeStartEndA";
            EPStatement stmtCurrentTs = epService.EPAdministrator.CreateEPL(eplCurrentTS);
            var         listener      = new SupportUpdateListener();

            stmtCurrentTs.Events += listener.Update;
            LambdaAssertionUtil.AssertTypesAllSame(stmtCurrentTs.EventType, fieldsCurrentTs, typeof(bool?));

            epService.EPRuntime.SendEvent(SupportTimeStartEndA.Make("E1", "2002-05-30T08:59:59.999", 0));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fieldsCurrentTs, new object[] {
                true, false, false, false, false, false, false
            });

            epService.EPRuntime.SendEvent(SupportTimeStartEndA.Make("E1", "2002-05-30T08:59:59.999", 1));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fieldsCurrentTs, new object[] {
                true, true, true, true, true, true, true
            });

            epService.EPRuntime.SendEvent(SupportTimeStartEndA.Make("E1", "2002-05-30T08:59:59.999", 100));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fieldsCurrentTs, new object[] {
                true, true, true, true, true, true, true
            });

            epService.EPRuntime.SendEvent(SupportTimeStartEndA.Make("E1", "2002-05-30T09:00:00.000", 0));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fieldsCurrentTs, new object[] {
                false, true, true, true, true, true, true
            });

            epService.EPRuntime.SendEvent(SupportTimeStartEndA.Make("E1", "2002-05-30T09:00:00.000", 100));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fieldsCurrentTs, new object[] {
                false, true, true, true, true, true, true
            });

            epService.EPRuntime.SendEvent(SupportTimeStartEndA.Make("E1", "2002-05-30T09:00:00.001", 100));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fieldsCurrentTs, new object[] {
                false, false, false, false, false, false, false
            });
            stmtCurrentTs.Dispose();

            // test calendar field and constants
            epService.EPAdministrator.Configuration.AddImport(typeof(DateTime));
            string[] fieldsConstants = "val0,val1,val2,val5".Split(',');
            string   eplConstants    = "select " +
                                       "longdateStart.between(DateTimeParser.ParseDefault('2002-05-30T09:00:00.000'), DateTimeParser.ParseDefault('2002-05-30T09:01:00.000')) as val0, " +
                                       "utildateStart.between(DateTimeParser.ParseDefault('2002-05-30T09:00:00.000'), DateTimeParser.ParseDefault('2002-05-30T09:01:00.000')) as val1, " +
                                       "caldateStart.between(DateTimeParser.ParseDefault('2002-05-30T09:00:00.000'), DateTimeParser.ParseDefault('2002-05-30T09:01:00.000')) as val2, " +
                                       "longdateStart.between(DateTimeParser.ParseDefault('2002-05-30T09:01:00.000'), DateTimeParser.ParseDefault('2002-05-30T09:00:00.000')) as val5 " +
                                       "from SupportTimeStartEndA";
            EPStatement stmtConstants = epService.EPAdministrator.CreateEPL(eplConstants);

            stmtConstants.Events += listener.Update;
            LambdaAssertionUtil.AssertTypesAllSame(stmtConstants.EventType, fieldsConstants, typeof(bool?));

            epService.EPRuntime.SendEvent(SupportTimeStartEndA.Make("E1", "2002-05-30T08:59:59.999", 0));
            EPAssertionUtil.AssertPropsAllValuesSame(listener.AssertOneGetNewAndReset(), fieldsConstants, false);

            epService.EPRuntime.SendEvent(SupportTimeStartEndA.Make("E2", "2002-05-30T09:00:00.000", 0));
            EPAssertionUtil.AssertPropsAllValuesSame(listener.AssertOneGetNewAndReset(), fieldsConstants, true);

            epService.EPRuntime.SendEvent(SupportTimeStartEndA.Make("E2", "2002-05-30T09:00:05.000", 0));
            EPAssertionUtil.AssertPropsAllValuesSame(listener.AssertOneGetNewAndReset(), fieldsConstants, true);

            epService.EPRuntime.SendEvent(SupportTimeStartEndA.Make("E2", "2002-05-30T09:00:59.999", 0));
            EPAssertionUtil.AssertPropsAllValuesSame(listener.AssertOneGetNewAndReset(), fieldsConstants, true);

            epService.EPRuntime.SendEvent(SupportTimeStartEndA.Make("E2", "2002-05-30T09:01:00.000", 0));
            EPAssertionUtil.AssertPropsAllValuesSame(listener.AssertOneGetNewAndReset(), fieldsConstants, true);

            epService.EPRuntime.SendEvent(SupportTimeStartEndA.Make("E2", "2002-05-30T09:01:00.001", 0));
            EPAssertionUtil.AssertPropsAllValuesSame(listener.AssertOneGetNewAndReset(), fieldsConstants, false);

            stmtConstants.Dispose();
        }