activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [3/3] activemq-artemis git commit: ARTEMIS-1462 Fixing QueueControlTest
Date Wed, 18 Oct 2017 16:21:57 GMT
ARTEMIS-1462 Fixing QueueControlTest


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/c66a7975
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/c66a7975
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/c66a7975

Branch: refs/heads/master
Commit: c66a7975e6834293eee52a87689b3a15839b4843
Parents: 02af1f4
Author: Clebert Suconic <clebertsuconic@apache.org>
Authored: Tue Oct 17 22:30:59 2017 -0400
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Wed Oct 18 12:21:47 2017 -0400

----------------------------------------------------------------------
 .../core/server/ActiveMQScheduledComponent.java |  4 +--
 .../utils/ActiveMQScheduledComponentTest.java   | 30 +++++++++++++-------
 2 files changed, 21 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/c66a7975/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQScheduledComponent.java
----------------------------------------------------------------------
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQScheduledComponent.java
b/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQScheduledComponent.java
index d891dd5..a4e43e3 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQScheduledComponent.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQScheduledComponent.java
@@ -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);
       }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/c66a7975/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ActiveMQScheduledComponentTest.java
----------------------------------------------------------------------
diff --git a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ActiveMQScheduledComponentTest.java
b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ActiveMQScheduledComponentTest.java
index 25cc3e1..aa67582 100644
--- a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ActiveMQScheduledComponentTest.java
+++ b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ActiveMQScheduledComponentTest.java
@@ -79,6 +79,25 @@ public class ActiveMQScheduledComponentTest {
    }
 
    @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());
-   }
 }


Mime
View raw message