Exemplo n.º 1
0
        private void RunAssertionISO8601Date()
        {
            var epl = "select " +
                      "cast('1997-07-16T19:20:30Z',date,dateformat:'iso') as c0," +
                      "cast('1997-07-16T19:20:30+01:00',date,dateformat:'iso') as c1," +
                      "cast('1997-07-16T19:20:30',date,dateformat:'iso') as c2," +
                      "cast('1997-07-16T19:20:30.45Z',date,dateformat:'iso') as c3," +
                      "cast('1997-07-16T19:20:30.45+01:00',date,dateformat:'iso') as c4," +
                      "cast('1997-07-16T19:20:30.45',date,dateformat:'iso') as c5," +
                      "cast('1997-07-16T19:20:30.45',long,dateformat:'iso') as c6," +
                      "cast('1997-07-16T19:20:30.45',date,dateformat:'iso') as c7," +
                      "cast(theString,date,dateformat:'iso') as c8," +
                      "cast(theString,long,dateformat:'iso') as c9," +
                      "cast(theString,date,dateformat:'iso') as c10" +
                      " from SupportBean";
            var stmt = _epService.EPAdministrator.CreateEPL(epl).AddListener(_listener);

            _epService.EPRuntime.SendEvent(new SupportBean());
            var @event = _listener.AssertOneGetNewAndReset();

            SupportDateTimeUtil.CompareDate(@event.Get("c0").AsDateTimeOffset(), 1997, 7, 16, 19, 20, 30, 0, "GMT+00:00");
            SupportDateTimeUtil.CompareDate(@event.Get("c1").AsDateTimeOffset(), 1997, 7, 16, 19, 20, 30, 0, "GMT+01:00");
            SupportDateTimeUtil.CompareDate(@event.Get("c2").AsDateTimeOffset(), 1997, 7, 16, 19, 20, 30, 0, TimeZone.CurrentTimeZone.StandardName);
            SupportDateTimeUtil.CompareDate(@event.Get("c3").AsDateTimeOffset(), 1997, 7, 16, 19, 20, 30, 450, "GMT+00:00");
            SupportDateTimeUtil.CompareDate(@event.Get("c4").AsDateTimeOffset(), 1997, 7, 16, 19, 20, 30, 450, "GMT+01:00");
            SupportDateTimeUtil.CompareDate(@event.Get("c5").AsDateTimeOffset(), 1997, 7, 16, 19, 20, 30, 450, TimeZone.CurrentTimeZone.StandardName);
            Assert.That(@event.Get("c6").GetType(), Is.EqualTo(typeof(long)));
            Assert.That(@event.Get("c7").GetType(), Is.EqualTo(typeof(DateTimeOffset)));
            foreach (var prop in "c8,c9,c10".Split(','))
            {
                Assert.IsNull(@event.Get(prop));
            }
        }
Exemplo n.º 2
0
        private static void RunAssertionISO8601Date(
            RegressionEnvironment env,
            AtomicLong milestone)
        {
            var epl = "@Name('s0') select " +
                      "cast('1997-07-16T19:20:30Z',dtx,dateformat:'iso') as c0," +
                      "cast('1997-07-16T19:20:30+01:00',dtx,dateformat:'iso') as c1," +
                      "cast('1997-07-16T19:20:30',dtx,dateformat:'iso') as c2," +
                      "cast('1997-07-16T19:20:30.45Z',dtx,dateformat:'iso') as c3," +
                      "cast('1997-07-16T19:20:30.45+01:00',dtx,dateformat:'iso') as c4," +
                      "cast('1997-07-16T19:20:30.45',dtx,dateformat:'iso') as c5," +
                      "cast('1997-07-16T19:20:30.45',long,dateformat:'iso') as c6," +
                      "cast('1997-07-16T19:20:30.45',datetime,dateformat:'iso') as c7," +
                      "cast(TheString,dtx,dateformat:'iso') as c8," +
                      "cast(TheString,long,dateformat:'iso') as c9," +
                      "cast(TheString,datetime,dateformat:'iso') as c10," +
                      "cast('1997-07-16T19:20:30.45',datetimeoffset,dateformat:'iso') as c11," +
                      "cast('1997-07-16T19:20:30+01:00',datetime,dateformat:'iso') as c12," +
                      "cast('1997-07-16',datetimeoffset,dateformat:'iso') as c13," +
                      "cast('19:20:30',datetimeoffset,dateformat:'iso') as c14" +
                      " from SupportBean";

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

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

            SupportDateTimeUtil.CompareDate((DateTimeEx)@event.Get("c0"), 1997, 7, 16, 19, 20, 30, 0, "UTC");
            SupportDateTimeUtil.CompareDate((DateTimeEx)@event.Get("c1"), 1997, 7, 16, 19, 20, 30, 0, "GMT+01:00");
            SupportDateTimeUtil.CompareDate((DateTimeEx)@event.Get("c2"), 1997, 7, 16, 19, 20, 30, 0, "UTC");
            SupportDateTimeUtil.CompareDate((DateTimeEx)@event.Get("c3"), 1997, 7, 16, 19, 20, 30, 450, "UTC");
            SupportDateTimeUtil.CompareDate((DateTimeEx)@event.Get("c4"), 1997, 7, 16, 19, 20, 30, 450, "GMT+01:00");
            SupportDateTimeUtil.CompareDate((DateTimeEx)@event.Get("c5"), 1997, 7, 16, 19, 20, 30, 450, "UTC");

            Assert.That(@event.Get("c6"), Is.InstanceOf <long>());
            Assert.That(@event.Get("c7"), Is.InstanceOf <DateTime>());

            foreach (var prop in "c8,c9,c10".SplitCsv())
            {
                Assert.IsNull(@event.Get(prop));
            }

            var isoDateTimeFormat = DateTimeFormat.ISO_DATE_TIME;

            var expectedC11 = isoDateTimeFormat.Parse("1997-07-16T19:20:30.45").DateTime;
            var expectedC12 = isoDateTimeFormat.Parse("1997-07-16T19:20:30+01:00").DateTime.DateTime;
            var expectedC13 = DateTimeParsingFunctions.ParseDefault("1997-07-16");
            var expectedC14 = DateTimeParsingFunctions.ParseDefault("19:20:30");

            Assert.That(@event.Get("c11"), Is.EqualTo(expectedC11));
            Assert.That(@event.Get("c12"), Is.EqualTo(expectedC12));
            Assert.That(@event.Get("c13"), Is.EqualTo(expectedC13));
            Assert.That(@event.Get("c14"), Is.EqualTo(expectedC14));

            env.UndeployAll();
        }
Exemplo n.º 3
0
        private void AssertTimeParse(string date, int year, int month, int day, int hour, int minute, int second, int millis, string zone)
        {
            TimeZoneInfo      timeZoneInfoTarget = TimeZoneHelper.GetTimeZoneInfo(zone);
            TimeZoneInfo      timeZoneInfoLocal  = TimeZoneHelper.Local;
            TimerScheduleSpec spec = TimerScheduleISO8601Parser.Parse(date);
            // the date time will be parsed by the ISO8601 parser but the time returned will be in "offset" terms
            DateTimeOffset specDate = spec.OptionalDate.DateTime.TranslateTo(timeZoneInfoTarget);

            SupportDateTimeUtil.CompareDate(specDate, year, month, day, hour, minute, second, millis);
            //Assert.AreEqual(zone, spec.OptionalDate.TimeZone.DisplayName);
        }
        private void AssertTimeParse(
            string date,
            int year,
            int month,
            int day,
            int hour,
            int minute,
            int second,
            int millis,
            string zone)
        {
            var spec = TimerScheduleISO8601Parser.Parse(date);

            SupportDateTimeUtil.CompareDate(spec.OptionalDate, year, month, day, hour, minute, second, millis);
            Assert.AreEqual(zone, spec.OptionalDate.TimeZone.DisplayName);
        }