ARTEMIS-1462 Fixing QueueControlTest
This commit is contained in:
parent
02af1f49cf
commit
c66a7975e6
|
@ -90,7 +90,7 @@ public abstract class ActiveMQScheduledComponent implements ActiveMQComponent, R
|
|||
long checkPeriod,
|
||||
TimeUnit timeUnit,
|
||||
boolean onDemand) {
|
||||
this(scheduledExecutorService, executor, checkPeriod, checkPeriod, timeUnit, onDemand);
|
||||
this(scheduledExecutorService, executor, -1, checkPeriod, timeUnit, onDemand);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -144,7 +144,7 @@ public abstract class ActiveMQScheduledComponent implements ActiveMQComponent, R
|
|||
this.millisecondsPeriod = timeUnit.convert(period, TimeUnit.MILLISECONDS);
|
||||
|
||||
if (period >= 0) {
|
||||
future = scheduledExecutorService.scheduleWithFixedDelay(runForScheduler, initialDelay, period, timeUnit);
|
||||
future = scheduledExecutorService.scheduleWithFixedDelay(runForScheduler, initialDelay >= 0 ? initialDelay : period, period, timeUnit);
|
||||
} else {
|
||||
logger.tracef("did not start scheduled executor on %s because period was configured as %d", this, period);
|
||||
}
|
||||
|
|
|
@ -78,6 +78,25 @@ public class ActiveMQScheduledComponentTest {
|
|||
Assert.assertTrue("just because one took a lot of time, it doesn't mean we can accumulate many, we got " + count + " executions", count.get() < 5);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVerifyInitialDelayChanged() {
|
||||
final long initialDelay = 10;
|
||||
final long period = 100;
|
||||
final ActiveMQScheduledComponent local = new ActiveMQScheduledComponent(scheduledExecutorService, executorService, initialDelay, period, TimeUnit.MILLISECONDS, false) {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
};
|
||||
local.start();
|
||||
final long newInitialDelay = 1000;
|
||||
//the parameters are valid?
|
||||
assert initialDelay != newInitialDelay && newInitialDelay != period;
|
||||
local.setInitialDelay(newInitialDelay);
|
||||
local.stop();
|
||||
Assert.assertEquals("the initial dalay can't change", newInitialDelay, local.getInitialDelay());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAccumulationOwnPool() throws Exception {
|
||||
final AtomicInteger count = new AtomicInteger(0);
|
||||
|
@ -187,15 +206,4 @@ public class ActiveMQScheduledComponentTest {
|
|||
local.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVerifyDefaultInitialDelay() throws InterruptedException {
|
||||
final ActiveMQScheduledComponent local = new ActiveMQScheduledComponent(scheduledExecutorService, executorService, 100, TimeUnit.MILLISECONDS, false) {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
};
|
||||
Assert.assertEquals("The initial delay must be defaulted to the period", local.getPeriod(), local.getInitialDelay());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue