@Test public void testScheduleSameTimeHeadAndTail() throws Exception { ScheduledDeliveryHandlerImpl handler = new ScheduledDeliveryHandlerImpl(null, new FakeQueueForScheduleUnitTest(0)); long time = System.currentTimeMillis() + 10000; for (int i = 10001; i < 20000; i++) { addMessage(handler, i, time, true); } addMessage(handler, 10000, time, false); time = System.currentTimeMillis() + 5000; for (int i = 1; i < 10000; i++) { addMessage(handler, i, time, true); } addMessage(handler, 0, time, false); debugList(true, handler, 20000); validateSequence(handler); }
@Test public void testScheduleFixedSample() throws Exception { ScheduledDeliveryHandlerImpl handler = new ScheduledDeliveryHandlerImpl(null, new FakeQueueForScheduleUnitTest(0)); addMessage(handler, 0, 48L, true); addMessage(handler, 1, 75L, true); addMessage(handler, 2, 56L, true); addMessage(handler, 3, 7L, false); addMessage(handler, 4, 69L, true); debugList(true, handler, 5); }
@Test public void testScheduleRandom() throws Exception { ScheduledDeliveryHandlerImpl handler = new ScheduledDeliveryHandlerImpl(null, new FakeQueueForScheduleUnitTest(0)); long nextMessage = 0; long NUMBER_OF_SEQUENCES = 100000; for (int i = 0; i < NUMBER_OF_SEQUENCES; i++) { int numberOfMessages = RandomUtil.randomInt() % 10; if (numberOfMessages == 0) numberOfMessages = 1; long nextScheduledTime = RandomUtil.randomPositiveLong(); for (int j = 0; j < numberOfMessages; j++) { boolean tail = RandomUtil.randomBoolean(); addMessage(handler, nextMessage++, nextScheduledTime, tail); } } debugList(true, handler, nextMessage); }