Github user franz1981 commented on a diff in the pull request:
https://github.com/apache/activemq-artemis/pull/1586#discussion_r144595987
--- Diff:
artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ActiveMQScheduledComponentTest.java
---
@@ -165,4 +165,37 @@ public void run() {
}
}
+ @Test
+ public void testUsingCustomInitialDelay() throws InterruptedException {
+ final CountDownLatch latch = new CountDownLatch(1);
+ final long initialDelayMillis = 100;
+ final long checkPeriodMillis = 100 * initialDelayMillis;
+ final ActiveMQScheduledComponent local = new
ActiveMQScheduledComponent(scheduledExecutorService, executorService,
initialDelayMillis, checkPeriodMillis, TimeUnit.MILLISECONDS, false) {
+ @Override
+ public void run() {
+ latch.countDown();
+ }
+ };
+ final long start = System.nanoTime();
+ local.start();
+ try {
+ final boolean triggeredBeforePeriod =
latch.await(local.getPeriod(), local.getTimeUnit());
+ final long timeToFirstTrigger =
TimeUnit.NANOSECONDS.convert(System.nanoTime() - start, local.getTimeUnit());
--- End diff --
I'm not scheduling at nanos but measuring elapsed time in nanoseconds, it
is different :)
The scheduling is in seconds or milliseconds in some tests.
---