Exemple #1
0
        /// <summary>
        /// A helper function to calculate black interval results or white interval
        /// results.
        /// </summary>
        ///
        /// <param name="list"></param>
        /// <param name="timeStamp">The time stamp as milliseconds since Jan 1, 1970 UTC.</param>
        /// <param name="positiveResult">The positive result which is updated.</param>
        /// <param name="negativeResult">The negative result which is updated.</param>
        private static void calculateIntervalResult(SortedSet list, double timeStamp,
                                                    Interval positiveResult, Interval negativeResult)
        {
            for (IIterator i = new ILOG.J2CsMapping.Collections.IteratorAdapter(list.GetEnumerator()); i.HasNext();)
            {
                RepetitiveInterval element = (RepetitiveInterval)i.Next();

                RepetitiveInterval.Result result = element.getInterval(timeStamp);
                Interval tempInterval            = result.interval;
                if (result.isPositive == true)
                {
                    try {
                        positiveResult.unionWith(tempInterval);
                    } catch (Interval.Error ex) {
                        // We don't expect to get this error.
                        throw new Exception("Error in Interval.unionWith: "
                                            + ex.Message);
                    }
                }
                else
                {
                    if (!negativeResult.isValid())
                    {
                        negativeResult.set(tempInterval);
                    }
                    else
                    {
                        negativeResult.intersectWith(tempInterval);
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Encode this Schedule.
        /// </summary>
        ///
        /// <returns>The encoded buffer.</returns>
        public Blob wireEncode()
        {
            // For now, don't use WireFormat and hardcode to use TLV since the encoding
            // doesn't go out over the wire, only into the local SQL database.
            TlvEncoder encoder    = new TlvEncoder(256);
            int        saveLength = encoder.getLength();

            // Encode backwards.
            // Encode the blackIntervalList.
            int saveLengthForList = encoder.getLength();

            for (IIterator i = blackIntervalList_.descendingIterator(); i.HasNext();)
            {
                RepetitiveInterval element = (RepetitiveInterval)i.Next();
                encodeRepetitiveInterval(element, encoder);
            }
            encoder.writeTypeAndLength(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_BlackIntervalList,
                                       encoder.getLength() - saveLengthForList);

            // Encode the whiteIntervalList.
            saveLengthForList = encoder.getLength();
            for (IIterator i_0 = whiteIntervalList_.descendingIterator(); i_0.HasNext();)
            {
                RepetitiveInterval element_1 = (RepetitiveInterval)i_0.Next();
                encodeRepetitiveInterval(element_1, encoder);
            }
            encoder.writeTypeAndLength(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_WhiteIntervalList,
                                       encoder.getLength() - saveLengthForList);

            encoder.writeTypeAndLength(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_Schedule, encoder.getLength()
                                       - saveLength);

            return(new Blob(encoder.getOutput(), false));
        }
 /// <summary>
 /// Create a RepetitiveInterval, copying values from the given repetitiveInterval.
 /// </summary>
 ///
 /// <param name="repetitiveInterval">The RepetitiveInterval to copy values from.</param>
 public RepetitiveInterval(RepetitiveInterval repetitiveInterval)
 {
     startDate_         = repetitiveInterval.startDate_;
     endDate_           = repetitiveInterval.endDate_;
     intervalStartHour_ = repetitiveInterval.intervalStartHour_;
     intervalEndHour_   = repetitiveInterval.intervalEndHour_;
     nRepeats_          = repetitiveInterval.nRepeats_;
     repeatUnit_        = repetitiveInterval.repeatUnit_;
 }
        /// <summary>
        /// Create a RepetitiveInterval with the given values. startDate must be
        /// earlier than or same as endDate. intervalStartHour must be less than
        /// intervalEndHour.
        /// </summary>
        ///
        /// <param name="startDate">The start date as milliseconds since Jan 1, 1970 UTC.</param>
        /// <param name="endDate">The end date as milliseconds since Jan 1, 1970 UTC.</param>
        /// <param name="intervalStartHour">The start hour in the day, from 0 to 23.</param>
        /// <param name="intervalEndHour">The end hour in the day from 1 to 24.</param>
        /// <param name="nRepeats"></param>
        /// <param name="repeatUnit"></param>
        /// <exception cref="System.Exception">if the above conditions are not met.</exception>
        public RepetitiveInterval(double startDate, double endDate,
				int intervalStartHour, int intervalEndHour, int nRepeats,
				RepetitiveInterval.RepeatUnit  repeatUnit)
        {
            startDate_ = toDateOnlyMilliseconds(startDate);
            endDate_ = toDateOnlyMilliseconds(endDate);
            intervalStartHour_ = intervalStartHour;
            intervalEndHour_ = intervalEndHour;
            nRepeats_ = nRepeats;
            repeatUnit_ = repeatUnit;

            validate();
        }
        /// <summary>
        /// Compare this to the other RepetitiveInterval.
        /// </summary>
        ///
        /// <param name="other">The other RepetitiveInterval to compare to.</param>
        /// <returns>-1 if this is less than the other, 1 if greater and 0 if equal.</returns>
        public int compare(RepetitiveInterval other)
        {
            if (startDate_ < other.startDate_)
            {
                return(-1);
            }
            if (startDate_ > other.startDate_)
            {
                return(1);
            }

            if (endDate_ < other.endDate_)
            {
                return(-1);
            }
            if (endDate_ > other.endDate_)
            {
                return(1);
            }

            if (intervalStartHour_ < other.intervalStartHour_)
            {
                return(-1);
            }
            if (intervalStartHour_ > other.intervalStartHour_)
            {
                return(1);
            }

            if (intervalEndHour_ < other.intervalEndHour_)
            {
                return(-1);
            }
            if (intervalEndHour_ > other.intervalEndHour_)
            {
                return(1);
            }

            if (nRepeats_ < other.nRepeats_)
            {
                return(-1);
            }
            if (nRepeats_ > other.nRepeats_)
            {
                return(1);
            }

            return(repeatUnit_.compare(other.repeatUnit_));
        }
        public void testConstruction()
        {
            RepetitiveInterval repetitiveInterval1 = new RepetitiveInterval(
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150825T000000"),
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150825T000000"), 5, 10);
            Assert.AssertEquals("20150825T000000",
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.toIsoString(repetitiveInterval1.getStartDate()));
            Assert.AssertEquals("20150825T000000",
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.toIsoString(repetitiveInterval1.getEndDate()));
            Assert.AssertEquals(5, repetitiveInterval1.getIntervalStartHour());
            Assert.AssertEquals(10, repetitiveInterval1.getIntervalEndHour());

            RepetitiveInterval repetitiveInterval2 = new RepetitiveInterval(
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150825T000000"),
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150827T000000"), 5, 10, 1,
                    net.named_data.jndn.encrypt.RepetitiveInterval.RepeatUnit.DAY);

            Assert.AssertEquals(1, repetitiveInterval2.getNRepeats());
            Assert.AssertEquals(net.named_data.jndn.encrypt.RepetitiveInterval.RepeatUnit.DAY,
                    repetitiveInterval2.getRepeatUnit());

            RepetitiveInterval repetitiveInterval3 = new RepetitiveInterval(
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150825T000000"),
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20151227T000000"), 5, 10, 2,
                    net.named_data.jndn.encrypt.RepetitiveInterval.RepeatUnit.MONTH);

            Assert.AssertEquals(2, repetitiveInterval3.getNRepeats());
            Assert.AssertEquals(net.named_data.jndn.encrypt.RepetitiveInterval.RepeatUnit.MONTH,
                    repetitiveInterval3.getRepeatUnit());

            RepetitiveInterval repetitiveInterval4 = new RepetitiveInterval(
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150825T000000"),
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20301227T000000"), 5, 10, 5,
                    net.named_data.jndn.encrypt.RepetitiveInterval.RepeatUnit.YEAR);

            Assert.AssertEquals(5, repetitiveInterval4.getNRepeats());
            Assert.AssertEquals(net.named_data.jndn.encrypt.RepetitiveInterval.RepeatUnit.YEAR,
                    repetitiveInterval4.getRepeatUnit());

            RepetitiveInterval repetitiveInterval5 = new RepetitiveInterval();

            Assert.AssertEquals(0, repetitiveInterval5.getNRepeats());
            Assert.AssertEquals(net.named_data.jndn.encrypt.RepetitiveInterval.RepeatUnit.NONE,
                    repetitiveInterval5.getRepeatUnit());
        }
Exemple #7
0
        /// <summary>
        /// Encode this Schedule.
        /// </summary>
        ///
        /// <returns>The encoded buffer.</returns>
        public Blob wireEncode()
        {
            // For now, don't use WireFormat and hardcode to use TLV since the encoding
            // doesn't go out over the wire, only into the local SQL database.
            TlvEncoder encoder    = new TlvEncoder(256);
            int        saveLength = encoder.getLength();

            // Encode backwards.
            // Encode the blackIntervalList.
            int saveLengthForList = encoder.getLength();

            Object[] array = ILOG.J2CsMapping.Collections.Collections.ToArray(blackIntervalList_);
            System.Array.Sort(array);
            for (int i = array.Length - 1; i >= 0; --i)
            {
                RepetitiveInterval element = (RepetitiveInterval)array[i];
                encodeRepetitiveInterval(element, encoder);
            }
            encoder.writeTypeAndLength(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_BlackIntervalList,
                                       encoder.getLength() - saveLengthForList);

            // Encode the whiteIntervalList.
            saveLengthForList = encoder.getLength();
            array             = ILOG.J2CsMapping.Collections.Collections.ToArray(whiteIntervalList_);
            System.Array.Sort(array);
            for (int i_0 = array.Length - 1; i_0 >= 0; --i_0)
            {
                RepetitiveInterval element_1 = (RepetitiveInterval)array[i_0];
                encodeRepetitiveInterval(element_1, encoder);
            }
            encoder.writeTypeAndLength(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_WhiteIntervalList,
                                       encoder.getLength() - saveLengthForList);

            encoder.writeTypeAndLength(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_Schedule, encoder.getLength()
                                       - saveLength);

            return(new Blob(encoder.getOutput(), false));
        }
Exemple #8
0
        /// <summary>
        /// Encode the RepetitiveInterval as NDN-TLV to the encoder.
        /// </summary>
        ///
        /// <param name="repetitiveInterval">The RepetitiveInterval to encode.</param>
        /// <param name="encoder">The TlvEncoder to receive the encoding.</param>
        private static void encodeRepetitiveInterval(
            RepetitiveInterval repetitiveInterval, TlvEncoder encoder)
        {
            int saveLength = encoder.getLength();

            // Encode backwards.
            encoder.writeNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_RepeatUnit,
                                               repetitiveInterval.getRepeatUnit().getNumericType());
            encoder.writeNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_NRepeats,
                                               repetitiveInterval.getNRepeats());
            encoder.writeNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_IntervalEndHour,
                                               repetitiveInterval.getIntervalEndHour());
            encoder.writeNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_IntervalStartHour,
                                               repetitiveInterval.getIntervalStartHour());
            // Use Blob to convert the string to UTF8 encoding.
            encoder.writeBlobTlv(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_EndDate, new Blob(
                                     toIsoString(repetitiveInterval.getEndDate())).buf());
            encoder.writeBlobTlv(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_StartDate, new Blob(
                                     toIsoString(repetitiveInterval.getStartDate())).buf());

            encoder.writeTypeAndLength(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_RepetitiveInterval,
                                       encoder.getLength() - saveLength);
        }
Exemple #9
0
        /// <summary>
        /// A helper function to calculate black interval results or white interval
        /// results.
        /// </summary>
        ///
        /// <param name="list"></param>
        /// <param name="timeStamp">The time stamp as milliseconds since Jan 1, 1970 UTC.</param>
        /// <param name="positiveResult">The positive result which is updated.</param>
        /// <param name="negativeResult">The negative result which is updated.</param>
        private static void calculateIntervalResult(
            HashedSet <RepetitiveInterval> list, double timeStamp,
            Interval positiveResult, Interval negativeResult)
        {
            Object[] array = ILOG.J2CsMapping.Collections.Collections.ToArray(list);
            System.Array.Sort(array);
            /* foreach */
            foreach (Object elementObj  in  array)
            {
                RepetitiveInterval element = (RepetitiveInterval)elementObj;

                RepetitiveInterval.Result result = element.getInterval(timeStamp);
                Interval tempInterval            = result.interval;
                if (result.isPositive == true)
                {
                    try {
                        positiveResult.unionWith(tempInterval);
                    } catch (Interval.Error ex) {
                        // We don't expect to get this error.
                        throw new Exception("Error in Interval.unionWith: "
                                            + ex.Message);
                    }
                }
                else
                {
                    if (!negativeResult.isValid())
                    {
                        negativeResult.set(tempInterval);
                    }
                    else
                    {
                        negativeResult.intersectWith(tempInterval);
                    }
                }
            }
        }
        public void testDatabaseFunctions()
        {
            Blob scheduleBlob = new Blob(SCHEDULE, false);

            // Create a schedule.
            Schedule schedule = new Schedule();
            try {
                schedule.wireDecode(scheduleBlob);
            } catch (EncodingException ex) {
                // We don't expect this to happen.
                Fail("Error decoding Schedule: " + ex.Message);
            }

            // Create a member.
            RsaKeyParams // Create a member.
                    paras = new RsaKeyParams();
            DecryptKey decryptKey;
            EncryptKey encryptKey;
            try {
                decryptKey = net.named_data.jndn.encrypt.algo.RsaAlgorithm.generateKey(paras);
                encryptKey = net.named_data.jndn.encrypt.algo.RsaAlgorithm.deriveEncryptKey(decryptKey.getKeyBits());
            } catch (Exception ex_0) {
                // Don't expect this to happen.
                Fail("Error creating test keys: " + ex_0.Message);
                return;
            }
            Blob keyBlob = encryptKey.getKeyBits();

            Name name1 = new Name("/ndn/BoyA/ksk-123");
            Name name2 = new Name("/ndn/BoyB/ksk-1233");
            Name name3 = new Name("/ndn/GirlC/ksk-123");
            Name name4 = new Name("/ndn/GirlD/ksk-123");
            Name name5 = new Name("/ndn/Hello/ksk-123");

            // Add schedules into the database.
            try {
                database.addSchedule("work-time", schedule);
                database.addSchedule("rest-time", schedule);
                database.addSchedule("play-time", schedule);
                database.addSchedule("boelter-time", schedule);
            } catch (Exception ex_1) {
                Fail("Unexpected error adding a schedule: " + ex_1.Message);
            }

            // Throw an exception when adding a schedule with an existing name.
            bool gotError = true;
            try {
                database.addSchedule("boelter-time", schedule);
                gotError = false;
            } catch (GroupManagerDb.Error ex_2) {
            }
            if (!gotError)
                Fail("Expected an error adding a duplicate schedule");

            // Add members into the database.
            try {
                database.addMember("work-time", name1, keyBlob);
                database.addMember("rest-time", name2, keyBlob);
                database.addMember("play-time", name3, keyBlob);
                database.addMember("play-time", name4, keyBlob);
            } catch (Exception ex_3) {
                Fail("Unexpected error adding a member: " + ex_3.Message);
            }

            // Throw an exception when adding a member with a non-existing schedule name.
            gotError = true;
            try {
                database.addMember("false-time", name5, keyBlob);
                gotError = false;
            } catch (GroupManagerDb.Error ex_4) {
            }
            if (!gotError)
                Fail("Expected an error adding a member with non-existing schedule");

            try {
                database.addMember("boelter-time", name5, keyBlob);
            } catch (Exception ex_5) {
                Fail("Unexpected error adding a member: " + ex_5.Message);
            }

            // Throw an exception when adding a member having an existing identity.
            gotError = true;
            try {
                database.addMember("work-time", name5, keyBlob);
                gotError = false;
            } catch (GroupManagerDb.Error ex_6) {
            }
            if (!gotError)
                Fail("Expected an error adding a member with an existing identity");

            // Test has functions.
            AssertEquals(true, database.hasSchedule("work-time"));
            AssertEquals(true, database.hasSchedule("rest-time"));
            AssertEquals(true, database.hasSchedule("play-time"));
            AssertEquals(false, database.hasSchedule("sleep-time"));
            AssertEquals(false, database.hasSchedule(""));

            AssertEquals(true, database.hasMember(new Name("/ndn/BoyA")));
            AssertEquals(true, database.hasMember(new Name("/ndn/BoyB")));
            AssertEquals(false, database.hasMember(new Name("/ndn/BoyC")));

            // Get a schedule.
            Schedule scheduleResult = database.getSchedule("work-time");
            AssertTrue(scheduleResult.wireEncode().equals(scheduleBlob));

            scheduleResult = database.getSchedule("play-time");
            AssertTrue(scheduleResult.wireEncode().equals(scheduleBlob));

            // Throw an exception when when there is no such schedule in the database.
            gotError = true;
            try {
                database.getSchedule("work-time-11");
                gotError = false;
            } catch (GroupManagerDb.Error ex_7) {
            }
            if (!gotError)
                Fail("Expected an error getting a non-existing schedule");

            // List all schedule names.
            IList names = database.listAllScheduleNames();
            AssertTrue(names.Contains("work-time"));
            AssertTrue(names.Contains("play-time"));
            AssertTrue(names.Contains("rest-time"));
            AssertTrue(!names.Contains("sleep-time"));

            // List members of a schedule.
            IDictionary memberMap = database.getScheduleMembers("play-time");
            AssertTrue(memberMap.Count != 0);

            // When there's no such schedule, the return map's size should be 0.
            AssertEquals(0, database.getScheduleMembers("sleep-time").Count);

            // List all members.
            IList members = database.listAllMembers();
            AssertTrue(members.Contains(new Name("/ndn/GirlC")));
            AssertTrue(members.Contains(new Name("/ndn/GirlD")));
            AssertTrue(members.Contains(new Name("/ndn/BoyA")));
            AssertTrue(members.Contains(new Name("/ndn/BoyB")));

            // Rename a schedule.
            AssertEquals(true, database.hasSchedule("boelter-time"));
            database.renameSchedule("boelter-time", "rieber-time");
            AssertEquals(false, database.hasSchedule("boelter-time"));
            AssertEquals(true, database.hasSchedule("rieber-time"));
            AssertEquals("rieber-time",
                    database.getMemberSchedule(new Name("/ndn/Hello")));

            // Update a schedule.
            Schedule newSchedule = new Schedule();
            try {
                newSchedule.wireDecode(scheduleBlob);
            } catch (EncodingException ex_8) {
                // We don't expect this to happen.
                Fail("Error decoding Schedule: " + ex_8.Message);
            }
            RepetitiveInterval repetitiveInterval = new RepetitiveInterval(
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150825T000000"),
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150921T000000"), 2, 10, 5,
                    net.named_data.jndn.encrypt.RepetitiveInterval.RepeatUnit.DAY);
            newSchedule.addWhiteInterval(repetitiveInterval);
            database.updateSchedule("rieber-time", newSchedule);
            scheduleResult = database.getSchedule("rieber-time");
            AssertTrue(!scheduleResult.wireEncode().equals(scheduleBlob));
            AssertTrue(scheduleResult.wireEncode().equals(newSchedule.wireEncode()));

            // Add a new schedule when updating a non-existing schedule.
            AssertEquals(false, database.hasSchedule("ralphs-time"));
            database.updateSchedule("ralphs-time", newSchedule);
            AssertEquals(true, database.hasSchedule("ralphs-time"));

            // Update the schedule of a member.
            database.updateMemberSchedule(new Name("/ndn/Hello"), "play-time");
            AssertEquals("play-time",
                    database.getMemberSchedule(new Name("/ndn/Hello")));

            // Delete a member.
            AssertEquals(true, database.hasMember(new Name("/ndn/Hello")));
            database.deleteMember(new Name("/ndn/Hello"));
            AssertEquals(false, database.hasMember(new Name("/ndn/Hello")));

            // Delete a non-existing member.
            try {
                database.deleteMember(new Name("/ndn/notExisting"));
            } catch (Exception ex_9) {
                Fail("Unexpected error deleting a non-existing member: "
                        + ex_9.Message);
            }

            // Delete a schedule. All the members using this schedule should be deleted.
            database.deleteSchedule("play-time");
            AssertEquals(false, database.hasSchedule("play-time"));
            AssertEquals(false, database.hasMember(new Name("/ndn/GirlC")));
            AssertEquals(false, database.hasMember(new Name("/ndn/GirlD")));

            // Delete a non-existing schedule.
            try {
                database.deleteSchedule("not-existing-time");
            } catch (Exception ex_10) {
                Fail("Unexpected error deleting a non-existing schedule: "
                        + ex_10.Message);
            }
        }
Exemple #11
0
 /// <summary>
 /// Add the repetitiveInterval to the blackIntervalList.
 /// </summary>
 ///
 /// <param name="repetitiveInterval"></param>
 /// <returns>This Schedule so you can chain calls to add.</returns>
 public Schedule addBlackInterval(RepetitiveInterval repetitiveInterval)
 {
     // RepetitiveInterval is immutable, so we don't need to make a copy.
     ILOG.J2CsMapping.Collections.Collections.Add(blackIntervalList_,repetitiveInterval);
     return this;
 }
Exemple #12
0
        /// <summary>
        /// Encode the RepetitiveInterval as NDN-TLV to the encoder.
        /// </summary>
        ///
        /// <param name="repetitiveInterval">The RepetitiveInterval to encode.</param>
        /// <param name="encoder">The TlvEncoder to receive the encoding.</param>
        private static void encodeRepetitiveInterval(
				RepetitiveInterval repetitiveInterval, TlvEncoder encoder)
        {
            int saveLength = encoder.getLength();

            // Encode backwards.
            encoder.writeNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_RepeatUnit,
                    net.named_data.jndn.encrypt.RepetitiveInterval.getRepeatUnitNumericType(repetitiveInterval
                            .getRepeatUnit()));
            encoder.writeNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_NRepeats,
                    repetitiveInterval.getNRepeats());
            encoder.writeNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_IntervalEndHour,
                    repetitiveInterval.getIntervalEndHour());
            encoder.writeNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_IntervalStartHour,
                    repetitiveInterval.getIntervalStartHour());
            // Use Blob to convert the string to UTF8 encoding.
            encoder.writeBlobTlv(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_EndDate, new Blob(
                    toIsoString(repetitiveInterval.getEndDate())).buf());
            encoder.writeBlobTlv(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_StartDate, new Blob(
                    toIsoString(repetitiveInterval.getStartDate())).buf());

            encoder.writeTypeAndLength(net.named_data.jndn.encoding.tlv.Tlv.Encrypt_RepetitiveInterval,
                    encoder.getLength() - saveLength);
        }
        public void testEncodeAndDecode()
        {
            Schedule schedule = new Schedule();

            RepetitiveInterval interval1 = new RepetitiveInterval(
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150825T000000"),
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150828T000000"), 5, 10, 2,
                    net.named_data.jndn.encrypt.RepetitiveInterval.RepeatUnit.DAY);
            RepetitiveInterval interval2 = new RepetitiveInterval(
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150825T000000"),
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150828T000000"), 6, 8, 1,
                    net.named_data.jndn.encrypt.RepetitiveInterval.RepeatUnit.DAY);
            RepetitiveInterval interval3 = new RepetitiveInterval(
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150827T000000"),
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150827T000000"), 7, 8);
            RepetitiveInterval interval4 = new RepetitiveInterval(
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150825T000000"),
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150825T000000"), 4, 7);

            schedule.addWhiteInterval(interval1);
            schedule.addWhiteInterval(interval2);
            schedule.addWhiteInterval(interval4);
            schedule.addBlackInterval(interval3);

            Blob encoding = schedule.wireEncode();
            Blob encoding2 = new Blob(SCHEDULE, false);
            Assert.AssertTrue(encoding.equals(encoding2));

            Schedule schedule2 = new Schedule();
            try {
                schedule2.wireDecode(encoding);
            } catch (EncodingException ex) {
                Assert.Fail("Error decoding Schedule: " + ex.Message);
            }

            Schedule.Result result;

            // timePoint1 --> positive 8.25 4-10
            double timePoint1 = net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150825T063000");
            result = schedule.getCoveringInterval(timePoint1);
            Assert.AssertEquals(true, result.isPositive);
            Assert.AssertEquals("20150825T040000",
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.toIsoString(result.interval.getStartTime()));
            Assert.AssertEquals("20150825T100000",
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.toIsoString(result.interval.getEndTime()));

            // timePoint2 --> positive 8.26 6-8
            double timePoint2 = net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150826T073000");
            result = schedule.getCoveringInterval(timePoint2);
            Assert.AssertEquals(true, result.isPositive);
            Assert.AssertEquals("20150826T060000",
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.toIsoString(result.interval.getStartTime()));
            Assert.AssertEquals("20150826T080000",
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.toIsoString(result.interval.getEndTime()));
        }
        /// <summary>
        /// Compare this to the other RepetitiveInterval.
        /// </summary>
        ///
        /// <param name="other">The other RepetitiveInterval to compare to.</param>
        /// <returns>-1 if this is less than the other, 1 if greater and 0 if equal.</returns>
        public int compare(RepetitiveInterval other)
        {
            if (startDate_ < other.startDate_)
                return -1;
            if (startDate_ > other.startDate_)
                return 1;

            if (endDate_ < other.endDate_)
                return -1;
            if (endDate_ > other.endDate_)
                return 1;

            if (intervalStartHour_ < other.intervalStartHour_)
                return -1;
            if (intervalStartHour_ > other.intervalStartHour_)
                return 1;

            if (intervalEndHour_ < other.intervalEndHour_)
                return -1;
            if (intervalEndHour_ > other.intervalEndHour_)
                return 1;

            if (nRepeats_ < other.nRepeats_)
                return -1;
            if (nRepeats_ > other.nRepeats_)
                return 1;

            // Lastly, compare the repeat units.
            // Compare without using Integer.compare so it works in older Java compilers.
            if (getRepeatUnitNumericType(repeatUnit_) < getRepeatUnitNumericType(other.repeatUnit_))
                return -1;
            else if (getRepeatUnitNumericType(repeatUnit_) == getRepeatUnitNumericType(other.repeatUnit_))
                return 0;
            else
                return 1;
        }
 /// <summary>
 /// Get the numeric value associated with the repeatUnit. This is a separate
 /// method for portability.
 /// </summary>
 ///
 /// <param name="repeatUnit">The RepeatUnit.</param>
 /// <returns>The numeric value for repeatUnit.</returns>
 public static int getRepeatUnitNumericType(RepetitiveInterval.RepeatUnit  repeatUnit)
 {
     if (repeatUnit == net.named_data.jndn.encrypt.RepetitiveInterval.RepeatUnit.DAY)
         return 1;
     else if (repeatUnit == net.named_data.jndn.encrypt.RepetitiveInterval.RepeatUnit.MONTH)
         return 2;
     else if (repeatUnit == net.named_data.jndn.encrypt.RepetitiveInterval.RepeatUnit.YEAR)
         return 3;
     else
         return 0;
 }
 /// <summary>
 /// Create a RepetitiveInterval, copying values from the given repetitiveInterval.
 /// </summary>
 ///
 /// <param name="repetitiveInterval">The RepetitiveInterval to copy values from.</param>
 public RepetitiveInterval(RepetitiveInterval repetitiveInterval)
 {
     startDate_ = repetitiveInterval.startDate_;
     endDate_ = repetitiveInterval.endDate_;
     intervalStartHour_ = repetitiveInterval.intervalStartHour_;
     intervalEndHour_ = repetitiveInterval.intervalEndHour_;
     nRepeats_ = repetitiveInterval.nRepeats_;
     repeatUnit_ = repetitiveInterval.repeatUnit_;
 }
        internal void setManager(GroupManager manager)
        {
            // Set up the first schedule.
            Schedule schedule1 = new Schedule();
            RepetitiveInterval interval11 = new RepetitiveInterval(
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150825T000000"),
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150827T000000"), 5, 10, 2,
                    net.named_data.jndn.encrypt.RepetitiveInterval.RepeatUnit.DAY);
            RepetitiveInterval interval12 = new RepetitiveInterval(
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150825T000000"),
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150827T000000"), 6, 8, 1,
                    net.named_data.jndn.encrypt.RepetitiveInterval.RepeatUnit.DAY);
            RepetitiveInterval interval13 = new RepetitiveInterval(
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150827T000000"),
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150827T000000"), 7, 8);
            schedule1.addWhiteInterval(interval11);
            schedule1.addWhiteInterval(interval12);
            schedule1.addBlackInterval(interval13);

            // Set up the second schedule.
            Schedule schedule2 = new Schedule();
            RepetitiveInterval interval21 = new RepetitiveInterval(
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150825T000000"),
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150827T000000"), 9, 12, 1,
                    net.named_data.jndn.encrypt.RepetitiveInterval.RepeatUnit.DAY);
            RepetitiveInterval interval22 = new RepetitiveInterval(
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150827T000000"),
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150827T000000"), 6, 8);
            RepetitiveInterval interval23 = new RepetitiveInterval(
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150827T000000"),
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150827T000000"), 2, 4);
            schedule2.addWhiteInterval(interval21);
            schedule2.addWhiteInterval(interval22);
            schedule2.addBlackInterval(interval23);

            // Add them to the group manager database.
            manager.addSchedule("schedule1", schedule1);
            manager.addSchedule("schedule2", schedule2);

            // Make some adaptions to certificate.
            Blob dataBlob = certificate.wireEncode();

            Data memberA = new Data();
            memberA.wireDecode(dataBlob, net.named_data.jndn.encoding.TlvWireFormat.get());
            memberA.setName(new Name("/ndn/memberA/KEY/ksk-123/ID-CERT/123"));
            Data memberB = new Data();
            memberB.wireDecode(dataBlob, net.named_data.jndn.encoding.TlvWireFormat.get());
            memberB.setName(new Name("/ndn/memberB/KEY/ksk-123/ID-CERT/123"));
            Data memberC = new Data();
            memberC.wireDecode(dataBlob, net.named_data.jndn.encoding.TlvWireFormat.get());
            memberC.setName(new Name("/ndn/memberC/KEY/ksk-123/ID-CERT/123"));

            // Add the members to the database.
            manager.addMember("schedule1", memberA);
            manager.addMember("schedule1", memberB);
            manager.addMember("schedule2", memberC);
        }
        public void testCalculateIntervalWithoutWhite()
        {
            Schedule schedule = new Schedule();
            RepetitiveInterval interval1 = new RepetitiveInterval(
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150825T000000"),
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150827T000000"), 5, 10, 2,
                    net.named_data.jndn.encrypt.RepetitiveInterval.RepeatUnit.DAY);
            RepetitiveInterval interval2 = new RepetitiveInterval(
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150825T000000"),
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150827T000000"), 6, 8, 1,
                    net.named_data.jndn.encrypt.RepetitiveInterval.RepeatUnit.DAY);

            schedule.addBlackInterval(interval1);
            schedule.addBlackInterval(interval2);

            Schedule.Result result;

            // timePoint1 --> negative 8.25 4-10
            double timePoint1 = net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150825T063000");
            result = schedule.getCoveringInterval(timePoint1);
            Assert.AssertEquals(false, result.isPositive);
            Assert.AssertEquals(false, result.interval.isEmpty());
            Assert.AssertEquals("20150825T050000",
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.toIsoString(result.interval.getStartTime()));
            Assert.AssertEquals("20150825T100000",
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.toIsoString(result.interval.getEndTime()));

            // timePoint2 --> negative 8.25 0-4
            double timePoint2 = net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150825T013000");
            result = schedule.getCoveringInterval(timePoint2);
            Assert.AssertEquals(false, result.isPositive);
            Assert.AssertEquals(false, result.interval.isEmpty());
            Assert.AssertEquals("20150825T000000",
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.toIsoString(result.interval.getStartTime()));
            Assert.AssertEquals("20150826T000000",
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.toIsoString(result.interval.getEndTime()));
        }
        private static bool check(RepetitiveInterval small,
				RepetitiveInterval big)
        {
            return small.compare(big) < 0 && !(big.compare(small) < 0);
        }
        public void testCoverTimePoint()
        {
            ///////////////////////////////////////////// With the repeat unit DAY.

            RepetitiveInterval repetitiveInterval1 = new RepetitiveInterval(
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150825T000000"),
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150925T000000"), 5, 10, 2,
                    net.named_data.jndn.encrypt.RepetitiveInterval.RepeatUnit.DAY);
            RepetitiveInterval.Result result;

            double timePoint1 = net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150825T050000");

            result = repetitiveInterval1.getInterval(timePoint1);
            Assert.AssertEquals(true, result.isPositive);
            Assert.AssertEquals("20150825T050000",
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.toIsoString(result.interval.getStartTime()));
            Assert.AssertEquals("20150825T100000",
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.toIsoString(result.interval.getEndTime()));

            double timePoint2 = net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150902T060000");

            result = repetitiveInterval1.getInterval(timePoint2);
            Assert.AssertEquals(true, result.isPositive);
            Assert.AssertEquals("20150902T050000",
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.toIsoString(result.interval.getStartTime()));
            Assert.AssertEquals("20150902T100000",
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.toIsoString(result.interval.getEndTime()));

            double timePoint3 = net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150929T040000");

            result = repetitiveInterval1.getInterval(timePoint3);
            Assert.AssertEquals(false, result.isPositive);

            ///////////////////////////////////////////// With the repeat unit MONTH.

            RepetitiveInterval repetitiveInterval2 = new RepetitiveInterval(
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150825T000000"),
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20160825T000000"), 5, 10, 2,
                    net.named_data.jndn.encrypt.RepetitiveInterval.RepeatUnit.MONTH);

            double timePoint4 = net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150825T050000");

            result = repetitiveInterval2.getInterval(timePoint4);
            Assert.AssertEquals(true, result.isPositive);
            Assert.AssertEquals("20150825T050000",
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.toIsoString(result.interval.getStartTime()));
            Assert.AssertEquals("20150825T100000",
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.toIsoString(result.interval.getEndTime()));

            double timePoint5 = net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20151025T060000");

            result = repetitiveInterval2.getInterval(timePoint5);
            Assert.AssertEquals(true, result.isPositive);
            Assert.AssertEquals("20151025T050000",
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.toIsoString(result.interval.getStartTime()));
            Assert.AssertEquals("20151025T100000",
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.toIsoString(result.interval.getEndTime()));

            double timePoint6 = net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20151226T050000");

            result = repetitiveInterval2.getInterval(timePoint6);
            Assert.AssertEquals(false, result.isPositive);

            double timePoint7 = net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20151225T040000");

            result = repetitiveInterval2.getInterval(timePoint7);
            Assert.AssertEquals(false, result.isPositive);

            ///////////////////////////////////////////// With the repeat unit YEAR.

            RepetitiveInterval repetitiveInterval3 = new RepetitiveInterval(
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150825T000000"),
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20300825T000000"), 5, 10, 3,
                    net.named_data.jndn.encrypt.RepetitiveInterval.RepeatUnit.YEAR);

            double timePoint8 = net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150825T050000");

            result = repetitiveInterval3.getInterval(timePoint8);
            Assert.AssertEquals(true, result.isPositive);
            Assert.AssertEquals("20150825T050000",
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.toIsoString(result.interval.getStartTime()));
            Assert.AssertEquals("20150825T100000",
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.toIsoString(result.interval.getEndTime()));

            double timePoint9 = net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20180825T060000");

            result = repetitiveInterval3.getInterval(timePoint9);
            Assert.AssertEquals(true, result.isPositive);
            Assert.AssertEquals("20180825T050000",
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.toIsoString(result.interval.getStartTime()));
            Assert.AssertEquals("20180825T100000",
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.toIsoString(result.interval.getEndTime()));

            double timePoint10 = net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20180826T050000");
            result = repetitiveInterval3.getInterval(timePoint10);
            Assert.AssertEquals(false, result.isPositive);

            double timePoint11 = net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20210825T040000");
            result = repetitiveInterval3.getInterval(timePoint11);
            Assert.AssertEquals(false, result.isPositive);

            double timePoint12 = net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20300825T040000");
            result = repetitiveInterval3.getInterval(timePoint12);
            Assert.AssertEquals(false, result.isPositive);
        }
Exemple #21
0
        /// <summary>
        /// Compare this to the other RepetitiveInterval.
        /// </summary>
        ///
        /// <param name="other">The other RepetitiveInterval to compare to.</param>
        /// <returns>-1 if this is less than the other, 1 if greater and 0 if equal.</returns>
        public int compare(RepetitiveInterval other)
        {
            if (startDate_ < other.startDate_)
            {
                return(-1);
            }
            if (startDate_ > other.startDate_)
            {
                return(1);
            }

            if (endDate_ < other.endDate_)
            {
                return(-1);
            }
            if (endDate_ > other.endDate_)
            {
                return(1);
            }

            if (intervalStartHour_ < other.intervalStartHour_)
            {
                return(-1);
            }
            if (intervalStartHour_ > other.intervalStartHour_)
            {
                return(1);
            }

            if (intervalEndHour_ < other.intervalEndHour_)
            {
                return(-1);
            }
            if (intervalEndHour_ > other.intervalEndHour_)
            {
                return(1);
            }

            if (nRepeats_ < other.nRepeats_)
            {
                return(-1);
            }
            if (nRepeats_ > other.nRepeats_)
            {
                return(1);
            }

            // Lastly, compare the repeat units.
            // Compare without using Integer.compare so it works in older Java compilers.
            if (getRepeatUnitNumericType(repeatUnit_) < getRepeatUnitNumericType(other.repeatUnit_))
            {
                return(-1);
            }
            else if (getRepeatUnitNumericType(repeatUnit_) == getRepeatUnitNumericType(other.repeatUnit_))
            {
                return(0);
            }
            else
            {
                return(1);
            }
        }
Exemple #22
0
 /// <summary>
 /// Add the repetitiveInterval to the blackIntervalList.
 /// </summary>
 ///
 /// <param name="repetitiveInterval"></param>
 /// <returns>This Schedule so you can chain calls to add.</returns>
 public Schedule addBlackInterval(RepetitiveInterval repetitiveInterval)
 {
     // RepetitiveInterval is immutable, so we don't need to make a copy.
     ILOG.J2CsMapping.Collections.Collections.Add(blackIntervalList_, repetitiveInterval);
     return(this);
 }
        public void testCalculateIntervalWithBlackAndWhite()
        {
            Schedule schedule = new Schedule();
            RepetitiveInterval interval1 = new RepetitiveInterval(
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150825T000000"),
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150827T000000"), 5, 10, 2,
                    net.named_data.jndn.encrypt.RepetitiveInterval.RepeatUnit.DAY);
            RepetitiveInterval interval2 = new RepetitiveInterval(
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150825T000000"),
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150827T000000"), 6, 8, 1,
                    net.named_data.jndn.encrypt.RepetitiveInterval.RepeatUnit.DAY);
            RepetitiveInterval interval3 = new RepetitiveInterval(
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150827T000000"),
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150827T000000"), 7, 8);
            RepetitiveInterval interval4 = new RepetitiveInterval(
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150825T000000"),
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150825T000000"), 4, 7);

            schedule.addWhiteInterval(interval1);
            schedule.addWhiteInterval(interval2);
            schedule.addWhiteInterval(interval4);
            schedule.addBlackInterval(interval3);

            Schedule.Result result;

            // timePoint1 --> positive 8.25 4-10
            double timePoint1 = net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150825T063000");
            result = schedule.getCoveringInterval(timePoint1);
            Assert.AssertEquals(true, result.isPositive);
            Assert.AssertEquals("20150825T040000",
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.toIsoString(result.interval.getStartTime()));
            Assert.AssertEquals("20150825T100000",
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.toIsoString(result.interval.getEndTime()));

            // timePoint2 --> positive 8.26 6-8
            double timePoint2 = net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150826T073000");
            result = schedule.getCoveringInterval(timePoint2);
            Assert.AssertEquals(true, result.isPositive);
            Assert.AssertEquals("20150826T060000",
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.toIsoString(result.interval.getStartTime()));
            Assert.AssertEquals("20150826T080000",
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.toIsoString(result.interval.getEndTime()));

            // timePoint3 --> positive 8.27 5-7
            double timePoint3 = net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150827T053000");
            result = schedule.getCoveringInterval(timePoint3);
            Assert.AssertEquals(true, result.isPositive);
            Assert.AssertEquals("20150827T050000",
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.toIsoString(result.interval.getStartTime()));
            Assert.AssertEquals("20150827T070000",
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.toIsoString(result.interval.getEndTime()));

            // timePoint4 --> positive 8.27 5-7
            double timePoint4 = net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150827T063000");
            result = schedule.getCoveringInterval(timePoint4);
            Assert.AssertEquals(true, result.isPositive);
            Assert.AssertEquals("20150827T050000",
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.toIsoString(result.interval.getStartTime()));
            Assert.AssertEquals("20150827T070000",
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.toIsoString(result.interval.getEndTime()));

            // timePoint5 --> negative 8.27 7-8
            double timePoint5 = net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150827T073000");
            result = schedule.getCoveringInterval(timePoint5);
            Assert.AssertEquals(false, result.isPositive);
            Assert.AssertEquals(false, result.interval.isEmpty());
            Assert.AssertEquals("20150827T070000",
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.toIsoString(result.interval.getStartTime()));
            Assert.AssertEquals("20150827T080000",
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.toIsoString(result.interval.getEndTime()));

            // timePoint6 --> negative 8.25 10-24
            double timePoint6 = net.named_data.jndn.tests.unit_tests.UnitTestsCommon.fromIsoString("20150825T113000");
            result = schedule.getCoveringInterval(timePoint6);
            Assert.AssertEquals(false, result.isPositive);
            Assert.AssertEquals(false, result.interval.isEmpty());
            Assert.AssertEquals("20150825T100000",
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.toIsoString(result.interval.getStartTime()));
            Assert.AssertEquals("20150826T000000",
                    net.named_data.jndn.tests.unit_tests.UnitTestsCommon.toIsoString(result.interval.getEndTime()));
        }