summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTaka Cho <takamune.cho@att.com>2020-06-23 15:09:28 -0400
committerTaka Cho <takamune.cho@att.com>2020-06-25 13:19:40 -0400
commit222d685035033f8c61f0ae1e31ce37b2068bb2a0 (patch)
tree90f0e48bbcabe69c7c3343f1062d8646526943d6
parent57a0ddae233fba3dadd689fd7f48734c3c6c04a6 (diff)
replace Thread sleep with Awaitility
- use '{}' for logger msg - sonar suggest using use libraries Awaitility for asynchroneous testing Issue-ID: POLICY-2616 Change-Id: I09828cdb9467235403f299c6419e8560ca21aefd Signed-off-by: Taka Cho <takamune.cho@att.com>
-rw-r--r--feature-server-pool/src/test/java/org/onap/policy/drools/serverpool/AdapterImpl.java2
-rw-r--r--feature-server-pool/src/test/java/org/onap/policy/drools/serverpooltest/Test1.java4
2 files changed, 2 insertions, 4 deletions
diff --git a/feature-server-pool/src/test/java/org/onap/policy/drools/serverpool/AdapterImpl.java b/feature-server-pool/src/test/java/org/onap/policy/drools/serverpool/AdapterImpl.java
index 789dfe61..044067a3 100644
--- a/feature-server-pool/src/test/java/org/onap/policy/drools/serverpool/AdapterImpl.java
+++ b/feature-server-pool/src/test/java/org/onap/policy/drools/serverpool/AdapterImpl.java
@@ -175,7 +175,7 @@ public class AdapterImpl extends Adapter {
for (int i = 0; i < Bucket.BUCKETCOUNT; i += 1) {
Bucket bucket = Bucket.getBucket(i);
while (bucket.getOwner() == null) {
- Thread.sleep(Math.min(endTime - System.currentTimeMillis(), 100L));
+ await().atMost(Math.min(endTime - System.currentTimeMillis(), 100L), TimeUnit.MILLISECONDS);
}
}
} catch (IllegalArgumentException e) {
diff --git a/feature-server-pool/src/test/java/org/onap/policy/drools/serverpooltest/Test1.java b/feature-server-pool/src/test/java/org/onap/policy/drools/serverpooltest/Test1.java
index 436cf77f..fe525788 100644
--- a/feature-server-pool/src/test/java/org/onap/policy/drools/serverpooltest/Test1.java
+++ b/feature-server-pool/src/test/java/org/onap/policy/drools/serverpooltest/Test1.java
@@ -181,9 +181,7 @@ public class Test1 {
UUID leaderUuid = firstAdapter.getLeader().getUuid();
for (Adapter adapter : Adapter.adapters) {
UUID uuid = adapter.getLeader().getUuid();
- assertTrue(adapter.toString() + " has UUID " + uuid
- + " (expected UUID " + leaderUuid + ")",
- uuid.equals(leaderUuid));
+ assertEquals(adapter.toString(), leaderUuid, uuid);
}
}