Exemplo n.º 1
0
            public void Run(RegressionEnvironment env)
            {
                var fields = new [] { "val0","val1","val2","val3","val4","val5","val6","val7" };
                var eplFragment = "@Name('s0') select " +
                                  "DateTimeOffset.get('msec') as val0," +
                                  "DateTimeOffset.get('sec') as val1," +
                                  "DateTimeOffset.get('minutes') as val2," +
                                  "DateTimeOffset.get('hour') as val3," +
                                  "DateTimeOffset.get('day') as val4," +
                                  "DateTimeOffset.get('month') as val5," +
                                  "DateTimeOffset.get('year') as val6," +
                                  "DateTimeOffset.get('week') as val7" +
                                  " from SupportDateTime";
                env.CompileDeploy(eplFragment).AddListener("s0");
                LambdaAssertionUtil.AssertTypes(
                    env.Statement("s0").EventType,
                    fields,
                    new[] {
                        typeof(int?), typeof(int?), typeof(int?), typeof(int?),
                        typeof(int?), typeof(int?), typeof(int?), typeof(int?)
                    });

                var startTime = "2002-05-30T09:01:02.003";
                env.SendEventBean(SupportDateTime.Make(startTime));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {3, 2, 1, 9, 30, 5, 2002, 22});

                env.UndeployAll();
            }
Exemplo n.º 2
0
        private void RunAssertionFormatWString(EPServiceProvider epService)
        {
            string startTime = "2002-05-30T09:00:00.000";

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(DateTimeParser.ParseDefaultMSec(startTime)));
            string sdfPattern = "yyyy.MM.dd G 'at' HH:mm:ss";
            var    sdf        = new SimpleDateFormat(sdfPattern);

            string[] fields      = "val0,val1".Split(',');
            string   eplFragment = "select " +
                                   "longdate.Format(\"" + sdfPattern + "\") as val0," +
                                   "utildate.Format(\"" + sdfPattern + "\") as val1" +
                                   "utildate.Format(SimpleDateFormat.DateInstance) as val5," +
                                   "localdate.Format(java.time.format.DateTimeFormatter.BASIC_ISO_DATE) as val6" +
                                   " from SupportDateTime";
            EPStatement stmtFragment = epService.EPAdministrator.CreateEPL(eplFragment);
            var         listener     = new SupportUpdateListener();

            stmtFragment.Events += listener.Update;
            LambdaAssertionUtil.AssertTypesAllSame(stmtFragment.EventType, fields, typeof(string));

            SupportDateTime sdt = SupportDateTime.Make(startTime);

            epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            var expected = new object[] {
                sdf.Format(sdt.Longdate), sdf.Format(sdt.Utildate),
            };

            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, expected);

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

            stmtFragment.Dispose();
        }
Exemplo n.º 3
0
        public void TestRoundCeil()
        {
            String[] fields      = "val0,val1,val2,val3,val4,val5,val6".Split(',');
            String   eplFragment = "select " +
                                   "utildate.roundCeiling('msec') as val0," +
                                   "utildate.roundCeiling('sec') as val1," +
                                   "utildate.roundCeiling('minutes') as val2," +
                                   "utildate.roundCeiling('hour') as val3," +
                                   "utildate.roundCeiling('day') as val4," +
                                   "utildate.roundCeiling('month') as val5," +
                                   "utildate.roundCeiling('year') as val6" +
                                   " from SupportDateTime";
            EPStatement stmtFragment = _epService.EPAdministrator.CreateEPL(eplFragment);

            stmtFragment.Events += _listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[] { typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?) });

            String[] expected =
            {
                "2002-05-30 09:01:02.003",
                "2002-05-30 09:01:03.000",
                "2002-05-30 09:02:00.000",
                "2002-05-30 10:00:00.000",
                "2002-05-31 00:00:00.000",
                "2002-06-1 00:00:00.000",
                "2003-01-1 00:00:00.000",
            };
            String startTime = "2002-05-30 09:01:02.003";

            _epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, SupportDateTime.GetArrayCoerced(expected, "util"));
        }
Exemplo n.º 4
0
        public void TestFields()
        {
            String[] fields      = "val0,val1,val2,val3,val4,val5,val6,val7".Split(',');
            String   eplFragment = "select " +
                                   "utildate.withMax('msec') as val0," +
                                   "utildate.withMax('sec') as val1," +
                                   "utildate.withMax('minutes') as val2," +
                                   "utildate.withMax('hour') as val3," +
                                   "utildate.withMax('day') as val4," +
                                   "utildate.withMax('month') as val5," +
                                   "utildate.withMax('year') as val6," +
                                   "utildate.withMax('week') as val7" +
                                   " from SupportDateTime";
            EPStatement stmtFragment = _epService.EPAdministrator.CreateEPL(eplFragment);

            stmtFragment.Events += _listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[] { typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?) });

            String[] expected =
            {
                "2002-5-30 09:00:00.999",
                "2002-5-30 09:00:59.000",
                "2002-5-30 09:59:00.000",
                "2002-5-30 23:00:00.000",
                "2002-5-31 09:00:00.000",
                "2002-12-30 09:00:00.000",
                "9999-05-30 09:00:00.000",
                "2002-12-26 09:00:00.000"
            };
            String startTime = "2002-05-30 09:00:00.000";

            _epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, SupportDateTime.GetArrayCoerced(expected, "util"));
        }
Exemplo n.º 5
0
            public void Run(RegressionEnvironment env)
            {
                var startTime = "2002-05-30T09:00:00.000";
                env.AdvanceTime(DateTimeParsingFunctions.ParseDefaultMSec(startTime));
                var sdfPattern = "yyyy.MM.dd G 'at' HH:mm:ss";
                var sdf = new SimpleDateFormat(sdfPattern);

                var fields = new [] { "val0","val1","val2","val3" };
                var eplFragment = "@Name('s0') select " +
                                  "DateTimeEx.format(\"" + sdfPattern + "\") as val0," +
                                  "DateTimeOffset.format(\"" + sdfPattern + "\") as val1," +
                                  "DateTime.format(\"" + sdfPattern + "\") as val2," +
                                  "LongDate.format(\"" + sdfPattern + "\") as val3" +
                                  " from SupportDateTime";
                env.CompileDeploy(eplFragment).AddListener("s0");
                LambdaAssertionUtil.AssertTypesAllSame(env.Statement("s0").EventType, fields, typeof(string));

                var sdt = SupportDateTime.Make(startTime);
                env.SendEventBean(SupportDateTime.Make(startTime));

                var received = env.Listener("s0").AssertOneGetNewAndReset();
                Assert.That(received.Get("val0"), Is.EqualTo(sdf.Format(sdt.DateTimeEx)));
                Assert.That(received.Get("val1"), Is.EqualTo(sdf.Format(sdt.DateTimeOffset)));
                Assert.That(received.Get("val2"), Is.EqualTo(sdf.Format(sdt.DateTime)));
                Assert.That(received.Get("val3"), Is.EqualTo(sdf.Format(sdt.LongDate)));

                env.SendEventBean(SupportDateTime.Make(null));
                received = env.Listener("s0").AssertOneGetNewAndReset();
                Assert.That(received.Get("val0"), Is.Null);
                Assert.That(received.Get("val1"), Is.Null);
                Assert.That(received.Get("val2"), Is.Null);
                Assert.That(received.Get("val3"), Is.Null);

                env.UndeployAll();
            }
Exemplo n.º 6
0
            public void Run(RegressionEnvironment env)
            {
                var epl = "@Name('s0') select " +
                          "LongDate.roll('date', true) as c0, " +
                          "DateTimeEx.roll('date', true) as c1, " +
                          "DateTimeOffset.roll('date', true) as c2, " +
                          "DateTime.roll('date', true) as c3 " +
                          " from SupportDateTime";

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

                var @event       = SupportDateTime.Make("2002-05-30T09:01:02.000");
                var dateExpected = @event.DateTimeEx.Clone();

                dateExpected.AddDays(1);

                env.SendEventBean(@event);
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    "c0,c1,c2,c3".SplitCsv(),
                    new object[] {
                    dateExpected.UtcMillis,
                    dateExpected,
                    dateExpected.DateTime,
                    dateExpected.DateTime.DateTime
                });

                env.UndeployAll();
            }
Exemplo n.º 7
0
        public void TestFormat()
        {
            String startTime = "2002-05-30 09:00:00.000";

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

            String[] fields      = "val0,val1,val2".Split(',');
            String   eplFragment = "select " +
                                   "current_timestamp.format() as val0," +
                                   "utildate.format() as val1," +
                                   "longdate.format() as val2" +
                                   " from SupportDateTime";
            EPStatement stmtFragment = _epService.EPAdministrator.CreateEPL(eplFragment);

            stmtFragment.Events += _listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[] { typeof(string), typeof(string), typeof(string) });

            _epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            Object[] expected = SupportDateTime.GetArrayCoerced(startTime, "str[utc]", "str[utc]", "str[utc]");
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, expected);

            _epService.EPRuntime.SendEvent(SupportDateTime.Make(null));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields,
                                        new Object[] { SupportDateTime.GetValueCoerced(startTime, "str[utc]"), null, null });
        }
Exemplo n.º 8
0
        private static void RunAssertionDateformatNonString(
            RegressionEnvironment env,
            AtomicLong milestone)
        {
            var sdt     = SupportDateTime.Make("2002-05-30T09:00:00.000");
            var sdfDate = sdt.DateTimeEx.DateTime.ToString("s");
            var sdf     = typeof(SimpleDateFormat).FullName;

            var epl = "@Name('s0') select " +
                      $"cast('{sdfDate}',dtx,dateformat:{sdf}.GetInstance()) as c0," +
                      $"cast('{sdfDate}',datetimeoffset,dateformat:{sdf}.GetInstance()) as c1," +
                      $"cast('{sdfDate}',datetime,dateformat:{sdf}.GetInstance()) as c2," +
                      $"cast('{sdfDate}',long,dateformat:{sdf}.GetInstance()) as c3" +
                      " from SupportBean";

            env.CompileDeployAddListenerMile(epl, "s0", milestone.GetAndIncrement());

            env.SendEventBean(new SupportBean());
            var @event = env.Listener("s0").AssertOneGetNewAndReset();

            Assert.That(@event.Get("c0"), Is.EqualTo(sdt.DateTimeEx));
            Assert.That(@event.Get("c1"), Is.EqualTo(sdt.DateTimeEx.DateTime));
            Assert.That(@event.Get("c2"), Is.EqualTo(sdt.DateTimeEx.DateTime.DateTime));
            Assert.That(@event.Get("c3"), Is.EqualTo(sdt.DateTimeEx.UtcMillis));

            env.UndeployAll();
        }
Exemplo n.º 9
0
            public void Run(RegressionEnvironment env)
            {
                var epl = "@Name('s0') select " +
                          "LongDate.asArrayOfString() as c0, " +
                          "DateTimeEx.asArrayOfString() as c1, " +
                          "DateTimeOffset.asArrayOfString() as c2, " +
                          "DateTime.asArrayOfString() as c3 " +
                          " from SupportDateTime";

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

                var @event = SupportDateTime.Make("2002-05-30T09:01:02.000");

                env.SendEventBean(@event);
                var expected = "30,5,2002".SplitCsv();

                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    "c0,c1,c2,c3".SplitCsv(),
                    new object[] {
                    expected,
                    expected,
                    expected,
                    expected
                });

                env.UndeployAll();
            }
Exemplo n.º 10
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();
        }
Exemplo n.º 11
0
            public void Run(RegressionEnvironment env)
            {
                var fields = new [] { "val0","val1","val2", "val3" };
                var eplFragment = "@Name('s0') select " +
                                  "DateTime.withMax('month') as val0," +
                                  "DateTimeOffset.withMax('month') as val1," +
                                  "DateTimeEx.withMax('month') as val2," +
                                  "LongDate.withMax('month') as val3" +
                                  " from SupportDateTime";
                env.CompileDeploy(eplFragment).AddListener("s0");
                LambdaAssertionUtil.AssertTypes(
                    env.Statement("s0").EventType,
                    fields,
                    new[] {
                        typeof(DateTime?),
                        typeof(DateTimeOffset?),
                        typeof(DateTimeEx),
                        typeof(long?)
                    });

                var startTime = "2002-05-30T09:00:00.000";
                var expectedTime = "2002-12-30T09:00:00.000";
                env.SendEventBean(SupportDateTime.Make(startTime));

                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    SupportDateTime.GetArrayCoerced(expectedTime, "datetime", "dto", "dtx", "long"));

                env.UndeployAll();
            }
Exemplo n.º 12
0
        public void TestFields()
        {
            String[] fields      = "val0,val1,val2,val3,val4,val5,val6,val7".Split(',');
            String   eplFragment = "select " +
                                   "utildate.Get('msec') as val0," +
                                   "utildate.Get('sec') as val1," +
                                   "utildate.Get('minutes') as val2," +
                                   "utildate.Get('hour') as val3," +
                                   "utildate.Get('day') as val4," +
                                   "utildate.Get('month') as val5," +
                                   "utildate.Get('year') as val6," +
                                   "utildate.Get('week') as val7" +
                                   " from SupportDateTime";
            EPStatement stmtFragment = _epService.EPAdministrator.CreateEPL(eplFragment);

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

            String startTime = "2002-05-30 09:01:02.003";

            _epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { 3, 2, 1, 9, 30, 5, 2002, 22 });
        }
Exemplo n.º 13
0
        private void RunAssertionFormat(EPServiceProvider epService)
        {
            string startTime = "2002-05-30T09:00:00.000";

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

            string[] fields      = "val0,val1,val2".Split(',');
            string   eplFragment = "select " +
                                   "current_timestamp.Format() as val0," +
                                   "utildate.Format() as val1," +
                                   "longdate.Format() as val2" +
                                   " from SupportDateTime";
            EPStatement stmtFragment = epService.EPAdministrator.CreateEPL(eplFragment);
            var         listener     = new SupportUpdateListener();

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

            epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            object[] expected = SupportDateTime.GetArrayCoerced(startTime,
                                                                "str[utc]", "str[utc]", "str[utc]");
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, expected);

            epService.EPRuntime.SendEvent(SupportDateTime.Make(null));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] {
                SupportDateTime.GetValueCoerced(startTime, "str[utc]"), null, null
            });

            stmtFragment.Dispose();
        }
Exemplo n.º 14
0
        private void RunAssertionInput(EPServiceProvider epService)
        {
            string[] fields      = "val0,val1,val2".Split(',');
            string   eplFragment = "select " +
                                   "utildate.set('month', 1) as val0," +
                                   "longdate.set('month', 1) as val1," +
                                   "caldate.set('month', 1) as val2 " +
                                   " from SupportDateTime";
            EPStatement stmtFragment = epService.EPAdministrator.CreateEPL(eplFragment);
            var         listener     = new SupportUpdateListener();

            stmtFragment.Events += listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[]
            {
                typeof(DateTimeOffset?),
                typeof(long?),
                typeof(DateTimeEx)
            });

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

            epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields,
                                        SupportDateTime.GetArrayCoerced(expectedTime, "util", "long", "cal"));

            stmtFragment.Dispose();
        }
Exemplo n.º 15
0
        public void TestPlusMinusTimePeriod()
        {
            String startTime = "2002-05-30 9:00:00.000";

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

            String[] fields      = "val0,val1,val2,val4,val5,val6".Split(',');
            String   eplFragment = "select " +
                                   "current_timestamp.plus(1 hour 10 sec 20 msec) as val0," +
                                   "utildate.plus(1 hour 10 sec 20 msec) as val1," +
                                   "msecdate.plus(1 hour 10 sec 20 msec) as val2," +
                                   "current_timestamp.minus(1 hour 10 sec 20 msec) as val4," +
                                   "utildate.minus(1 hour 10 sec 20 msec) as val5," +
                                   "msecdate.minus(1 hour 10 sec 20 msec) as val6" +
                                   " from SupportDateTime";
            EPStatement stmtFragment = _epService.EPAdministrator.CreateEPL(eplFragment);

            stmtFragment.Events += _listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[] { typeof(long?), typeof(DateTimeOffset?), typeof(long?), typeof(long?), typeof(DateTimeOffset?), typeof(long?) });

            _epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            Object[] expectedPlus  = SupportDateTime.GetArrayCoerced("2002-05-30 10:00:10.020", "msec", "util", "msec");
            Object[] expectedMinus = SupportDateTime.GetArrayCoerced("2002-05-30 07:59:49.980", "msec", "util", "msec");
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, EPAssertionUtil.ConcatenateArray(expectedPlus, expectedMinus));

            _epService.EPRuntime.SendEvent(SupportDateTime.Make(null));
            expectedPlus  = SupportDateTime.GetArrayCoerced("2002-05-30 10:00:10.020", "msec", "null", "null");
            expectedMinus = SupportDateTime.GetArrayCoerced("2002-05-30 07:59:49.980", "msec", "null", "null");
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, EPAssertionUtil.ConcatenateArray(expectedPlus, expectedMinus));
        }
Exemplo n.º 16
0
            public void Run(RegressionEnvironment env)
            {
                var fields = new [] { "c0", "c1", "c2", "c3" };
                var eplCurrentTS = "@Name('s0') select " +
                                   "LongDate.between(LongPrimitive, LongBoxed) as c0, " +
                                   "DateTimeOffset.between(LongPrimitive, LongBoxed) as c1, " +
                                   "DateTimeEx.between(LongPrimitive, LongBoxed) as c2," +
                                   "DateTime.between(LongPrimitive, LongBoxed) as c3" +
                                   " from SupportDateTime unidirectional, SupportBean#lastevent";
                env.CompileDeploy(eplCurrentTS).AddListener("s0");

                var bean = new SupportBean();
                bean.LongPrimitive = 10;
                bean.LongBoxed = 20L;
                env.SendEventBean(bean);

                env.SendEventBean(SupportDateTime.Make("2002-05-30T09:01:02.003"));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {false, false, false, false});

                bean = new SupportBean();
                bean.LongPrimitive = 0;
                bean.LongBoxed = long.MaxValue;
                env.SendEventBean(bean);

                env.SendEventBean(SupportDateTime.Make("2002-05-30T09:01:02.003"));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {true, true, true, true});

                env.UndeployAll();
            }
Exemplo n.º 17
0
        public void TestCalOps()
        {
            String[] fields      = "val0,val1".Split(',');
            String   eplFragment = "select " +
                                   "utildate.set('hour', 1).set('minute', 2).set('second', 3) as val0," +
                                   "msecdate.set('hour', 1).set('minute', 2).set('second', 3) as val1" +
                                   " from SupportDateTime";
            EPStatement stmtFragment = _epService.EPAdministrator.CreateEPL(eplFragment);

            stmtFragment.Events += _listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[] { typeof(DateTimeOffset?), typeof(long?) });

            String startTime    = "2002-05-30 09:00:00.000";
            String expectedTime = "2002-05-30 1:02:03.000";

            _epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, SupportDateTime.GetArrayCoerced(expectedTime, "util", "msec"));

            stmtFragment.Dispose();
            eplFragment = "select " +
                          "utildate.set('hour', 1).set('minute', 2).set('second', 3).toCalendar() as val0," +
                          "msecdate.set('hour', 1).set('minute', 2).set('second', 3).toCalendar() as val1" +
                          " from SupportDateTime";
            stmtFragment         = _epService.EPAdministrator.CreateEPL(eplFragment);
            stmtFragment.Events += _listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[] { typeof(DateTimeOffset?), typeof(DateTimeOffset?) });

            _epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, SupportDateTime.GetArrayCoerced(expectedTime, "cal", "cal"));
        }
Exemplo n.º 18
0
        private void RunAssertionFields(EPServiceProvider epService)
        {
            string[] fields      = "val0,val1,val2,val3,val4,val5,val6,val7".Split(',');
            string   eplFragment = "select " +
                                   "utildate.Get('msec') as val0," +
                                   "utildate.Get('sec') as val1," +
                                   "utildate.Get('minutes') as val2," +
                                   "utildate.Get('hour') as val3," +
                                   "utildate.Get('day') as val4," +
                                   "utildate.Get('month') as val5," +
                                   "utildate.Get('year') as val6," +
                                   "utildate.Get('week') as val7" +
                                   " from SupportDateTime";
            EPStatement stmtFragment = epService.EPAdministrator.CreateEPL(eplFragment);
            var         listener     = new SupportUpdateListener();

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

            string startTime = "2002-05-30T09:01:02.003";

            epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] {
                3, 2, 1, 9, 30, 5, 2002, 22
            });

            stmtFragment.Dispose();
        }
Exemplo n.º 19
0
        private void RunAssertionDateformatNonString(EPServiceProvider epService)
        {
            var sdt = SupportDateTime.Make("2002-05-30T09:00:00.000");

#if false
            string sdfDate = SimpleDateFormat.Instance.Format(sdt.Utildate);
            string ldtDate = sdt.Localdate.Format(DateTimeFormatter.ISO_DATE_TIME);

            var epl = "select " +
                      "cast('" + sdfDate + "',date,dateformat:SimpleDateFormat.Instance) as c0," +
                      "cast('" + ldtDate + "',localdatetime,dateformat:java.time.format.DateTimeFormatter.ISO_DATE_TIME) as c1" +
                      " from SupportBean";
            var stmt     = epService.EPAdministrator.CreateEPL(epl);
            var listener = new SupportUpdateListener();
            stmt.Events += listener.Update;

            epService.EPRuntime.SendEvent(new SupportBean());
            var @event = listener.AssertOneGetNewAndReset();
            EPAssertionUtil.AssertProps(@event, "c0,c1".Split(','), new object[]
            {
                sdt.Utildate, sdt.Localdate
            });

            stmt.Dispose();
#endif
        }
Exemplo n.º 20
0
        public override void Run(EPServiceProvider epService)
        {
            epService.EPAdministrator.CreateEPL("create variable int varhour");
            epService.EPAdministrator.CreateEPL("create variable int varmin");
            epService.EPAdministrator.CreateEPL("create variable int varsec");
            epService.EPAdministrator.CreateEPL("create variable int varmsec");
            string startTime = "2002-05-30T09:00:00.000";

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

            string[] fields      = "val0,val1,val2,val3".Split(',');
            string   eplFragment = "select " +
                                   "current_timestamp.WithTime(varhour, varmin, varsec, varmsec) as val0," +
                                   "utildate.WithTime(varhour, varmin, varsec, varmsec) as val1," +
                                   "longdate.WithTime(varhour, varmin, varsec, varmsec) as val2," +
                                   "caldate.WithTime(varhour, varmin, varsec, varmsec) as val3" +
                                   " from SupportDateTime";
            EPStatement stmtFragment = epService.EPAdministrator.CreateEPL(eplFragment);
            var         listener     = new SupportUpdateListener();

            stmtFragment.Events += listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[] {
                typeof(long?), typeof(DateTimeOffset?), typeof(long?), typeof(DateTimeEx)
            });

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

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

            epService.EPRuntime.SetVariableValue("varhour", null); // variable is null
            epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields,
                                        SupportDateTime.GetArrayCoerced(expectedTime, "long", "util", "long", "cal"));

            expectedTime = "2002-05-30T01:02:03.004";
            epService.EPRuntime.SetVariableValue("varhour", 1);
            epService.EPRuntime.SetVariableValue("varmin", 2);
            epService.EPRuntime.SetVariableValue("varsec", 3);
            epService.EPRuntime.SetVariableValue("varmsec", 4);
            epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields,
                                        SupportDateTime.GetArrayCoerced(expectedTime, "long", "util", "long", "cal"));

            expectedTime = "2002-05-30T00:00:00.006";
            epService.EPRuntime.SetVariableValue("varhour", 0);
            epService.EPRuntime.SetVariableValue("varmin", null);
            epService.EPRuntime.SetVariableValue("varsec", null);
            epService.EPRuntime.SetVariableValue("varmsec", 6);
            epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields,
                                        SupportDateTime.GetArrayCoerced(expectedTime, "long", "util", "long", "cal"));
        }
Exemplo n.º 21
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();
            }
Exemplo n.º 22
0
        private void RunAssertionRoundHalf(EPServiceProvider epService)
        {
            string[] fields      = "val0,val1,val2,val3,val4,val5,val6".Split(',');
            string   eplFragment = "select " +
                                   "utildate.RoundHalf('msec') as val0," +
                                   "utildate.RoundHalf('sec') as val1," +
                                   "utildate.RoundHalf('minutes') as val2," +
                                   "utildate.RoundHalf('hour') as val3," +
                                   "utildate.RoundHalf('day') as val4," +
                                   "utildate.RoundHalf('month') as val5," +
                                   "utildate.RoundHalf('year') as val6" +
                                   " from SupportDateTime";
            EPStatement stmtFragment = epService.EPAdministrator.CreateEPL(eplFragment);
            var         listener     = new SupportUpdateListener();

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

            string[] expected =
            {
                "2002-05-30T15:30:02.550",
                "2002-05-30T15:30:03.000",
                "2002-05-30T15:30:00.000",
                "2002-05-30T16:00:00.00",
                "2002-05-31T00:00:00.000",
                "2002-06-01T00:00:00.000",
                "2002-01-01T00:00:00.000",
            };
            string startTime = "2002-05-30T15:30:02.550";

            epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, SupportDateTime.GetArrayCoerced(expected, "util"));

            // test rounding up/down
            stmtFragment.Dispose();
            fields               = "val0".Split(',');
            eplFragment          = "select Utildate.RoundHalf('min') as val0 from SupportDateTime";
            stmtFragment         = epService.EPAdministrator.CreateEPL(eplFragment);
            stmtFragment.Events += listener.Update;

            epService.EPRuntime.SendEvent(SupportDateTime.Make("2002-05-30T15:30:29.999"));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { SupportDateTime.GetValueCoerced("2002-05-30T15:30:00.000", "util") });

            epService.EPRuntime.SendEvent(SupportDateTime.Make("2002-05-30T15:30:30.000"));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { SupportDateTime.GetValueCoerced("2002-05-30T15:31:00.000", "util") });

            epService.EPRuntime.SendEvent(SupportDateTime.Make("2002-05-30T15:30:30.001"));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { SupportDateTime.GetValueCoerced("2002-05-30T15:31:00.000", "util") });

            stmtFragment.Dispose();
        }
Exemplo n.º 23
0
        private void RunAssertionPlusMinus(EPServiceProvider epService)
        {
            epService.EPAdministrator.CreateEPL("create variable long varmsec");
            string startTime = "2002-05-30T09:00:00.000";

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

            string[] fields      = "val0,val1,val2,val3,val4,val5".Split(',');
            string   eplFragment = "select " +
                                   "current_timestamp.Plus(varmsec) as val0," +
                                   "utildate.Plus(varmsec) as val1," +
                                   "longdate.Plus(varmsec) as val2," +
                                   "current_timestamp.minus(varmsec) as val3," +
                                   "utildate.Minus(varmsec) as val4," +
                                   "longdate.Minus(varmsec) as val5" +
                                   " from SupportDateTime";
            EPStatement stmtFragment = epService.EPAdministrator.CreateEPL(eplFragment);
            var         listener     = new SupportUpdateListener();

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

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

            object[] expectedPlus  = SupportDateTime.GetArrayCoerced(startTime, "long", "util", "long");
            object[] expectedMinus = SupportDateTime.GetArrayCoerced(startTime, "long", "util", "long");
            epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, EPAssertionUtil.ConcatenateArray(expectedPlus, expectedMinus));

            epService.EPRuntime.SetVariableValue("varmsec", 1000);
            epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            //Log.Info("===> " + SupportDateTime.Print(listener.AssertOneGetNew().Get("val4")));
            expectedPlus  = SupportDateTime.GetArrayCoerced("2002-05-30T09:00:01.000", "long", "util", "long");
            expectedMinus = SupportDateTime.GetArrayCoerced("2002-05-30T08:59:59.000", "long", "util", "long");
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, EPAssertionUtil.ConcatenateArray(expectedPlus, expectedMinus));

            epService.EPRuntime.SetVariableValue("varmsec", 2 * 24 * 60 * 60 * 1000);
            epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            expectedMinus = SupportDateTime.GetArrayCoerced("2002-05-28T09:00:00.000", "long", "util", "long");
            expectedPlus  = SupportDateTime.GetArrayCoerced("2002-06-1T09:00:00.000", "long", "util", "long");
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, EPAssertionUtil.ConcatenateArray(expectedPlus, expectedMinus));

            stmtFragment.Dispose();
        }
Exemplo n.º 24
0
        private static void RunAssertionAllCombinations(
            RegressionEnvironment env,
            string field,
            AtomicLong milestone)
        {
            var methods = Collections.List(
                "getMinuteOfHour",    // c0
                "getMonthOfYear",     // c1
                "getDayOfMonth",      // c2
                "getDayOfWeek",       // c3
                "getDayOfYear",       // c4
                "getHourOfDay",       // c5
                "getMillisOfSecond",  // c6
                "getSecondOfMinute",  // c7
                "getWeekyear",        // c8
                "getYear"             // c9
                );
            var epl = new StringBuilder();
            epl.Append("@Name('s0') select ");
            var count = 0;
            var delimiter = "";
            foreach (var method in methods) {
                epl.Append(delimiter)
                    .Append(field)
                    .Append(".")
                    .Append(method)
                    .Append("() ")
                    .Append("c")
                    .Append(Convert.ToString(count++));
                delimiter = ",";
            }

            epl.Append(" from SupportDateTime");

            env.CompileDeployAddListenerMile(epl.ToString(), "s0", milestone.GetAndIncrement());

            var sdt = SupportDateTime.Make("2002-05-30T09:01:02.003");
            sdt.DateTimeEx.SetMillis(3);
            env.SendEventBean(sdt);

            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                new [] { "c0","c1","c2","c3","c4","c5","c6","c7","c8","c9" },
                new object[] {
                    1, 5, 30, 4, 150, 9, 3, 2, 22, 2002
                });

            env.UndeployAll();
        }
Exemplo n.º 25
0
        private void RunAssertionFields(EPServiceProvider epService)
        {
            string[] fields      = "val0,val1,val2,val3,val4,val5,val6,val7".Split(',');
            string   eplFragment = "select " +
                                   "utildate.WithMax('msec') as val0," +
                                   "utildate.WithMax('sec') as val1," +
                                   "utildate.WithMax('minutes') as val2," +
                                   "utildate.WithMax('hour') as val3," +
                                   "utildate.WithMax('day') as val4," +
                                   "utildate.WithMax('month') as val5," +
                                   "utildate.WithMax('year') as val6," +
                                   "utildate.WithMax('week') as val7" +
                                   " from SupportDateTime";
            EPStatement stmtFragment = epService.EPAdministrator.CreateEPL(eplFragment);
            var         listener     = new SupportUpdateListener();

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

            string[] expected =
            {
                "2002-5-30T09:00:00.999",
                "2002-5-30T09:00:59.000",
                "2002-5-30T09:59:00.000",
                "2002-5-30T23:00:00.000",
                "2002-5-31T09:00:00.000",
                "2002-12-30T09:00:00.000",
                "9999-05-30T09:00:00.000",
                "2002-12-26T09:00:00.000"
            };
            string startTime = "2002-05-30T09:00:00.000";

            epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields,
                                        SupportDateTime.GetArrayCoerced(expected, "util"));

            stmtFragment.Dispose();
        }
Exemplo n.º 26
0
            public void Run(RegressionEnvironment env)
            {
                var fields = new [] { "val0","val1","val2","val3","val4","val5","val6" };
                var eplFragment = "@Name('s0') select " +
                                  "DateTimeOffset.set('msec', 1) as val0," +
                                  "DateTimeOffset.set('sec', 2) as val1," +
                                  "DateTimeOffset.set('minutes', 3) as val2," +
                                  "DateTimeOffset.set('hour', 13) as val3," +
                                  "DateTimeOffset.set('day', 5) as val4," +
                                  "DateTimeOffset.set('month', 6) as val5," +
                                  "DateTimeOffset.set('year', 7) as val6" +
                                  " from SupportDateTime";
                env.CompileDeploy(eplFragment).AddListener("s0");
                LambdaAssertionUtil.AssertTypes(
                    env.Statement("s0").EventType,
                    fields,
                    new[] {
                        typeof(DateTimeOffset?), // val0
                        typeof(DateTimeOffset?), // val1
                        typeof(DateTimeOffset?), // val2
                        typeof(DateTimeOffset?), // val3
                        typeof(DateTimeOffset?), // val4
                        typeof(DateTimeOffset?), // val5
                        typeof(DateTimeOffset?)  // val6
                    });

                string[] expected = {
                    "2002-05-30T09:00:00.001", // val0
                    "2002-05-30T09:00:02.000", // val1
                    "2002-05-30T09:03:00.000", // val2
                    "2002-05-30T13:00:00.000", // val3
                    "2002-05-05T09:00:00.000", // val4
                    "2002-06-30T09:00:00.000", // val5
                    "0007-05-30T09:00:00.000"  // val6
                };
                var startTime = "2002-05-30T09:00:00.000";
                env.SendEventBean(SupportDateTime.Make(startTime));
                var datesCoerced = SupportDateTime.GetArrayCoerced(expected, "dto");
                
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    datesCoerced);

                env.UndeployAll();
            }
Exemplo n.º 27
0
            public void Run(RegressionEnvironment env)
            {
                var fields = new [] { "val0","val1","val2","val3","val4","val5","val6" };
                var eplFragment = "@Name('s0') select " +
                                  "DateTimeOffset.withMin('msec') as val0," +
                                  "DateTimeOffset.withMin('sec') as val1," +
                                  "DateTimeOffset.withMin('minutes') as val2," +
                                  "DateTimeOffset.withMin('hour') as val3," +
                                  "DateTimeOffset.withMin('day') as val4," +
                                  "DateTimeOffset.withMin('month') as val5," +
                                  "DateTimeOffset.withMin('year') as val6" +
                                  " from SupportDateTime";
                env.CompileDeploy(eplFragment).AddListener("s0");
                LambdaAssertionUtil.AssertTypes(
                    env.Statement("s0").EventType,
                    fields,
                    new[] {
                        typeof(DateTimeOffset?),
                        typeof(DateTimeOffset?),
                        typeof(DateTimeOffset?),
                        typeof(DateTimeOffset?),
                        typeof(DateTimeOffset?),
                        typeof(DateTimeOffset?),
                        typeof(DateTimeOffset?)
                    });

                string[] expected = {
                    "2002-05-30T09:01:02.000",
                    "2002-05-30T09:01:00.003",
                    "2002-05-30T09:00:02.003",
                    "2002-05-30T00:01:02.003",
                    "2002-05-01T09:01:02.003",
                    "2002-01-30T09:01:02.003",
                    "0001-05-30T09:01:02.003"
                };
                var startTime = "2002-05-30T09:01:02.003";
                env.SendEventBean(SupportDateTime.Make(startTime));
                //System.out.println("==-> " + SupportDateTime.print(env.Listener("s0").assertOneGetNew().Get("val7")));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    SupportDateTime.GetArrayCoerced(expected, "dto"));

                env.UndeployAll();
            }
Exemplo n.º 28
0
        public void TestPlusMinus()
        {
            _epService.EPAdministrator.CreateEPL("create variable long varmsec");
            String startTime = "2002-05-30 9:00:00.000";

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

            String[] fields      = "val0,val1,val2,val4,val5,val6".Split(',');
            String   eplFragment = "select " +
                                   "current_timestamp.plus(varmsec) as val0," +
                                   "utildate.plus(varmsec) as val1," +
                                   "msecdate.plus(varmsec) as val2," +
                                   "current_timestamp.minus(varmsec) as val4," +
                                   "utildate.minus(varmsec) as val5," +
                                   "msecdate.minus(varmsec) as val6" +
                                   " from SupportDateTime";
            EPStatement stmtFragment = _epService.EPAdministrator.CreateEPL(eplFragment);

            stmtFragment.Events += _listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[] { typeof(long?), typeof(DateTimeOffset?), typeof(long?), typeof(long?), typeof(DateTimeOffset?), typeof(long?) });

            _epService.EPRuntime.SendEvent(SupportDateTime.Make(null));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] {
                SupportDateTime.GetValueCoerced(startTime, "msec"), null, null,
                SupportDateTime.GetValueCoerced(startTime, "msec"), null, null,
            });

            Object[] expectedPlus  = SupportDateTime.GetArrayCoerced(startTime, "msec", "util", "msec");
            Object[] expectedMinus = SupportDateTime.GetArrayCoerced(startTime, "msec", "util", "msec");
            _epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, EPAssertionUtil.ConcatenateArray(expectedPlus, expectedMinus));

            _epService.EPRuntime.SetVariableValue("varmsec", 1000);
            _epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            //Console.WriteLine("===> " + SupportDateTime.Print(listener.AssertOneGetNew().Get("val4")));
            expectedPlus  = SupportDateTime.GetArrayCoerced("2002-05-30 09:00:01.000", "msec", "util", "msec");
            expectedMinus = SupportDateTime.GetArrayCoerced("2002-05-30 08:59:59.000", "msec", "util", "msec");
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, EPAssertionUtil.ConcatenateArray(expectedPlus, expectedMinus));

            _epService.EPRuntime.SetVariableValue("varmsec", 2 * 24 * 60 * 60 * 1000);
            _epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            expectedMinus = SupportDateTime.GetArrayCoerced("2002-05-28 09:00:00.000", "msec", "util", "msec");
            expectedPlus  = SupportDateTime.GetArrayCoerced("2002-06-1 09:00:00.000", "msec", "util", "msec");
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, EPAssertionUtil.ConcatenateArray(expectedPlus, expectedMinus));
        }
Exemplo n.º 29
0
        public void TestInput()
        {
            String[] fields      = "val0,val1".Split(',');
            String   eplFragment = "select " +
                                   "utildate.roundCeiling('hour') as val0," +
                                   "msecdate.roundCeiling('hour') as val1" +
                                   " from SupportDateTime";
            EPStatement stmtFragment = _epService.EPAdministrator.CreateEPL(eplFragment);

            stmtFragment.Events += _listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[] { typeof(DateTimeOffset?), typeof(long?) });

            String startTime    = "2002-05-30 09:01:02.003";
            String expectedTime = "2002-5-30 10:00:00.000";

            _epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, SupportDateTime.GetArrayCoerced(expectedTime, "util", "msec"));
        }
Exemplo n.º 30
0
        private static void RunAssertionLongProperty(
            RegressionEnvironment env,
            long startTime,
            SupportDateTime @event,
            string select,
            string[] fields,
            object[] expected)
        {
            env.AdvanceTime(startTime);

            var epl = "@Name('s0') select " + select + " from SupportDateTime";
            env.CompileDeploy(epl).AddListener("s0");

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

            env.UndeployAll();
        }