示例#1
0
            public void Run(RegressionEnvironment env)
            {
                var point = typeof(Point);
                var epl   =
                    "@public @buseventtype " +
                    "@JsonSchemaField(Name=point, adapter=" + nameof(SupportJsonFieldAdapterStringPoint) + ") " +
                    "@JsonSchemaField(Name=mydate, adapter=" + nameof(SupportJsonFieldAdapterStringDate) + ") " +
                    "create json schema JsonEvent(point " + point + ", mydate DateTime);\n" +
                    "@Name('s0') select point, mydate from JsonEvent;\n" +
                    "@Name('s1') select * from JsonEvent;\n";

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

                var jsonFilled = "{\"point\":\"7,14\",\"mydate\":\"2002-05-01T08:00:01.999\"}";

                SendAssert(
                    env,
                    jsonFilled,
                    new object[] {
                    new Point(7, 14), DateTimeParsingFunctions.ParseDefaultEx("2002-05-1T08:00:01.999")
                });

                var jsonNulled = "{\"point\":null,\"mydate\":null}";

                SendAssert(
                    env,
                    jsonNulled,
                    new object[] {
                    null, null
                });

                env.UndeployAll();
            }
示例#2
0
            public void Run(RegressionEnvironment env)
            {
                var epl =
                    "@public @buseventtype create schema LocalEvent as " + typeof(LocalEvent).FullName + ";\n" +
                    "@JsonSchemaField(Name=mydate, adapter=" + nameof(SupportJsonFieldAdapterStringDate) + ") " +
                    "@JsonSchemaField(Name=point, adapter=" + nameof(SupportJsonFieldAdapterStringPoint) + ") " +
                    EventRepresentationChoice.JSON.GetAnnotationText() +
                    " insert into JsonEvent select point, mydate from LocalEvent;\n" +
                    "@Name('s0') select point, mydate from JsonEvent;\n" +
                    "@Name('s1') select * from JsonEvent;\n";

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

                env.SendEventBean(
                    new LocalEvent(
                        new Point(7, 14),
                        DateTimeParsingFunctions.ParseDefaultEx("2002-05-01T08:00:01.999")));

                var jsonFilled = "{\"point\":\"7,14\",\"mydate\":\"2002-05-01T08:00:01.999\"}";

                DoAssert(
                    env,
                    jsonFilled,
                    new object[] {
                    new Point(7, 14),
                    DateTimeParsingFunctions.ParseDefaultEx("2002-05-1T08:00:01.999")
                });

                env.UndeployAll();
            }
示例#3
0
        protected SupportTimeStartBase(
            string key,
            string datestr,
            long duration)
        {
            Key = key;

            if (datestr != null)
            {
                // expected : 2002-05-30T09:00:00.000
                var start = DateTimeParsingFunctions.ParseDefaultEx(datestr);

                DateTimeExStart = start;
                DateTimeOffsetStart = DateTimeExStart.DateTime;
                DateTimeStart = DateTimeOffsetStart.DateTime;
                LongdateStart = start.UtcMillis;

                var end = start.Clone().AddTimeSpan(TimeSpan.FromMilliseconds(duration));

                DateTimeExEnd = end;
                DateTimeOffsetEnd = DateTimeExEnd.DateTime;
                DateTimeEnd = DateTimeOffsetEnd.DateTime;
                LongdateEnd = end.UtcMillis;

#if false
                Console.WriteLine("DateTimeExStart: " + DateTimeExStart + " / " + DateTimeExStart.Millisecond);
                Console.WriteLine("DateTimeOffsetStart: " + DateTimeOffsetStart + " / " + DateTimeOffsetStart.Millisecond);
                Console.WriteLine("DateTimeStart: " + DateTimeStart + " / " + DateTimeStart.Millisecond);

                Console.WriteLine("DateTimeExEnd: " + DateTimeExEnd + " / " + DateTimeExEnd.Millisecond);
                Console.WriteLine("DateTimeOffsetEnd: " + DateTimeOffsetEnd + " / " + DateTimeOffsetEnd.Millisecond);
                Console.WriteLine("DateTimeEnd: " + DateTimeEnd + " / " + DateTimeEnd.Millisecond);
#endif
            }
        }
示例#4
0
        private void TryAssertionCreateSchema(
            RegressionEnvironment env,
            EventRepresentationChoice eventRepresentationEnum)
        {
            var startA = "2002-05-30T09:00:00.000";
            var endA = "2002-05-30T09:00:01.000";
            var startB = "2002-05-30T09:00:00.500";
            var endB = "2002-05-30T09:00:00.700";

            // test Map type Long-type timestamps
            RunAssertionCreateSchemaWTypes<MyLocalJsonProvidedLong>(
                env,
                eventRepresentationEnum,
                "long",
                DateTimeParsingFunctions.ParseDefaultMSec(startA),
                DateTimeParsingFunctions.ParseDefaultMSec(endA),
                DateTimeParsingFunctions.ParseDefaultMSec(startB),
                DateTimeParsingFunctions.ParseDefaultMSec(endB));

            // test Map type DateTimeEx-type timestamps
            if (!eventRepresentationEnum.IsAvroOrJsonEvent()) {
                RunAssertionCreateSchemaWTypes<MyLocalJsonProvidedDateTimeEx>(
                    env,
                    eventRepresentationEnum,
                    typeof(DateTimeEx).FullName,
                    DateTimeParsingFunctions.ParseDefaultEx(startA),
                    DateTimeParsingFunctions.ParseDefaultEx(endA),
                    DateTimeParsingFunctions.ParseDefaultEx(startB),
                    DateTimeParsingFunctions.ParseDefaultEx(endB));
            }

            // test Map type DateTimeOffset-type timestamps
            if (!eventRepresentationEnum.IsAvroOrJsonEvent()) {
                RunAssertionCreateSchemaWTypes<MyLocalJsonProvidedDateTimeOffset>(
                    env,
                    eventRepresentationEnum,
                    typeof(DateTimeOffset).FullName,
                    DateTimeParsingFunctions.ParseDefaultDateTimeOffset(startA),
                    DateTimeParsingFunctions.ParseDefaultDateTimeOffset(endA),
                    DateTimeParsingFunctions.ParseDefaultDateTimeOffset(startB),
                    DateTimeParsingFunctions.ParseDefaultDateTimeOffset(endB));
            }

            // test Map type DateTime-type timestamps
            if (!eventRepresentationEnum.IsAvroOrJsonEvent()) {
                RunAssertionCreateSchemaWTypes<MyLocalJsonProvidedDateTime>(
                    env,
                    eventRepresentationEnum,
                    typeof(DateTime).FullName,
                    DateTimeParsingFunctions.ParseDefaultDateTimeOffset(startA).DateTime,
                    DateTimeParsingFunctions.ParseDefaultDateTimeOffset(endA).DateTime,
                    DateTimeParsingFunctions.ParseDefaultDateTimeOffset(startB).DateTime,
                    DateTimeParsingFunctions.ParseDefaultDateTimeOffset(endB).DateTime);
            }
        }
        private void AssertCompute(long current, TimePeriod timePeriod, string reference,
                                   LongAssertion factorAssertion, string expectedTarget)
        {
            var referenceDate = DateTimeParsingFunctions.ParseDefaultEx(reference);
            CalendarOpPlusFastAddResult result = CalendarOpPlusFastAddHelper.ComputeNextDue(current, timePeriod, referenceDate, TimeAbacusMilliseconds.INSTANCE, 0);

            Assert.That(
                result.Scheduled,
                Is.EqualTo(DateTimeParsingFunctions.ParseDefaultEx(expectedTarget)));
            factorAssertion.AssertLong(result.Factor);
        }
示例#6
0
        public static SupportDateTime Make(string datestr)
        {
            if (datestr == null) {
                return new SupportDateTime(null, null, null, null);
            }

            // expected : 2002-05-30T09:00:00
            var dateTimeEx = DateTimeParsingFunctions.ParseDefaultEx(datestr);

            return new SupportDateTime(
                dateTimeEx.UtcMillis,
                dateTimeEx,
                dateTimeEx.UtcDateTime,
                dateTimeEx.UtcDateTime.DateTime);
        }
 public static DateTimeEx ParseDate(string dateText)
 {
     try {
         return DateTimeParsingFunctions.ParseDefaultEx(dateText);
         //return javax.xml.datatype.DatatypeFactory.NewInstance().NewXMLGregorianCalendar(dateText)
         //    .ToGregorianCalendar();
     }
     catch (EPException) {
         throw;
     }
     catch (Exception e) {
         var message = "Exception parsing date '" + dateText + "', the date is not a supported ISO 8601 date";
         log.Debug(message, e);
         throw new ScheduleParameterException(message);
     }
 }
示例#8
0
 public DateTimeEx Parse(string value)
 {
     return(value == null ? null : DateTimeParsingFunctions.ParseDefaultEx(value));
 }