aboutsummaryrefslogtreecommitdiffstats
path: root/feature-lifecycle/src/main/java
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2019-08-14 17:31:50 -0400
committerJim Hahn <jrh3@att.com>2019-08-21 13:49:54 -0400
commitdfe8fa8bc3e75c186589d21b619baa55454ef8a2 (patch)
treeca3c7dbbe53815afdacb1c97e62ee97ace3f867c /feature-lifecycle/src/main/java
parent59e9b9a8b56d563814ef21a23716959f772f9194 (diff)
Use pseudo time for junits
Modified feature-active-standby-management and feature-lifecycle to be able to use TestTimeMulti, eliminating the need for sleep() calls in the junit tests and speeding the tests up significantly. Also modified feature-active-standby-management to use a memory DB for its junit tests. Change-Id: I6d7ae61bb73cbb19ff405b8d9fb660e92732edbb Issue-ID: POLICY-1968 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'feature-lifecycle/src/main/java')
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java18
1 files changed, 13 insertions, 5 deletions
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
index 36d2a545..5b4bd1ec 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
@@ -26,6 +26,7 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Properties;
+import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
@@ -85,7 +86,7 @@ public class LifecycleFsm implements Startable {
protected volatile LifecycleState state = new LifecycleStateTerminated(this);
@GsonJsonIgnore
- protected ScheduledThreadPoolExecutor scheduler = new ScheduledThreadPoolExecutor(1);
+ protected ScheduledExecutorService scheduler = makeExecutor();
@GsonJsonIgnore
protected ScheduledFuture<?> statusTask;
@@ -118,10 +119,6 @@ public class LifecycleFsm implements Startable {
*/
public LifecycleFsm() {
this.properties = SystemPersistenceConstants.getManager().getProperties(CONFIGURATION_PROPERTIES_NAME);
-
- scheduler.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
- scheduler.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
- scheduler.setRemoveOnCancelPolicy(true);
}
@Override
@@ -476,4 +473,15 @@ public class LifecycleFsm implements Startable {
return fsm.isItMe(update.getName(), update.getPdpGroup(), update.getPdpSubgroup());
}
}
+
+ // these may be overridden by junit tests
+
+ protected ScheduledExecutorService makeExecutor() {
+ ScheduledThreadPoolExecutor exec = new ScheduledThreadPoolExecutor(1);
+ exec.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
+ exec.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
+ exec.setRemoveOnCancelPolicy(true);
+
+ return exec;
+ }
}