aboutsummaryrefslogtreecommitdiffstats
path: root/core/core-engine/src
diff options
context:
space:
mode:
authorLiam Fallon <liam.fallon@est.tech>2020-03-04 13:32:27 +0000
committerGerrit Code Review <gerrit@onap.org>2020-03-04 13:32:27 +0000
commita9b60303e7e3699cc4df904144592ea6a9b6c586 (patch)
tree1b710f2f899598d3032a6485db54c2e4a8cc92a2 /core/core-engine/src
parent9f17d75f75dd087a58822dcc5aa2821267aa2193 (diff)
parent153ad0056c3928116d28eb7e1bb14c4a04a76fc2 (diff)
Merge "replace test sleep() with awaitality package"
Diffstat (limited to 'core/core-engine/src')
-rw-r--r--core/core-engine/src/test/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineImplTest.java10
-rw-r--r--core/core-engine/src/test/java/org/onap/policy/apex/core/engine/engine/impl/DummySlowEnEventListener.java3
2 files changed, 8 insertions, 5 deletions
diff --git a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineImplTest.java b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineImplTest.java
index 2663dfc0d..f91b58bb9 100644
--- a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineImplTest.java
+++ b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineImplTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@
package org.onap.policy.apex.core.engine.engine.impl;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.awaitility.Awaitility.await;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -32,6 +33,8 @@ import static org.junit.Assert.fail;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.HashMap;
+import java.util.concurrent.TimeUnit;
+
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -312,8 +315,7 @@ public class ApexEngineImplTest {
assertEquals(AxEngineState.STOPPED, engine.getState());
}
}).start();
-
- Thread.sleep(50);
+ await().atLeast(50, TimeUnit.MILLISECONDS).until(() -> engine.getState().equals(AxEngineState.EXECUTING));
assertEquals(AxEngineState.EXECUTING, engine.getState());
assertFalse(engine.handleEvent(event));
@@ -343,7 +345,7 @@ public class ApexEngineImplTest {
}
}).start();
- Thread.sleep(50);
+ await().atLeast(50, TimeUnit.MILLISECONDS).until(() -> engine.getState().equals(AxEngineState.EXECUTING));
assertEquals(AxEngineState.EXECUTING, engine.getState());
try {
engine.stop();
diff --git a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/engine/impl/DummySlowEnEventListener.java b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/engine/impl/DummySlowEnEventListener.java
index 9b6fc398c..178e16a43 100644
--- a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/engine/impl/DummySlowEnEventListener.java
+++ b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/engine/impl/DummySlowEnEventListener.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,7 +42,7 @@ public class DummySlowEnEventListener implements EnEventListener {
Thread.sleep(waitTime);
}
catch (InterruptedException ie) {
- // Do nothing
+ //Do nothing
}
}