aboutsummaryrefslogtreecommitdiffstats
path: root/core/core-engine/src
diff options
context:
space:
mode:
authorHenry.Sun <henry.a.sun@est.tech>2020-03-02 15:47:09 +0800
committerHenry.Sun <henry.a.sun@est.tech>2020-03-04 12:02:42 +0800
commit153ad0056c3928116d28eb7e1bb14c4a04a76fc2 (patch)
tree00f973c22492c89633723dcb5f09b448973e9ba4 /core/core-engine/src
parent27dcbd57cc04c45ba85ff6f4008ef2c1d8f7c050 (diff)
replace test sleep() with awaitality package
Signed-off-by: Henry.Sun <henry.a.sun@est.tech> Change-Id: I305771ddef42bd3032ad52f4c5ecd55b01ed5a1a Issue-ID: POLICY-1914 Signed-off-by: Henry.Sun <henry.a.sun@est.tech>
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
}
}