From 153ad0056c3928116d28eb7e1bb14c4a04a76fc2 Mon Sep 17 00:00:00 2001 From: "Henry.Sun" Date: Mon, 2 Mar 2020 15:47:09 +0800 Subject: replace test sleep() with awaitality package Signed-off-by: Henry.Sun Change-Id: I305771ddef42bd3032ad52f4c5ecd55b01ed5a1a Issue-ID: POLICY-1914 Signed-off-by: Henry.Sun --- .../carrier/restrequestor/ApexRestRequestorConsumerTest.java | 8 +++++--- .../plugins/event/carrier/restrequestor/RestRequestorTest.java | 4 +--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor') diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumerTest.java index 46390f9d6..0c6067a75 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumerTest.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumerTest.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. @@ -21,11 +21,13 @@ package org.onap.policy.apex.plugins.event.carrier.restrequestor; +import static org.awaitility.Awaitility.await; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; import java.util.Properties; +import java.util.concurrent.TimeUnit; import org.junit.Test; import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; @@ -126,7 +128,7 @@ public class ApexRestRequestorConsumerTest { consumer.start(); ApexRestRequest request = new ApexRestRequest(123, null, EVENT_NAME, EVENT_BODY); consumer.processRestRequest(request); - ThreadUtilities.sleep(200); + await().atMost(200, TimeUnit.MILLISECONDS).until(() -> consumer.getEventsReceived() == 0); consumer.stop(); assertEquals(0, consumer.getEventsReceived()); } @@ -152,7 +154,7 @@ public class ApexRestRequestorConsumerTest { consumer.start(); ApexRestRequest request = new ApexRestRequest(123, properties, EVENT_NAME, EVENT_BODY); consumer.processRestRequest(request); - ThreadUtilities.sleep(2000); + await().atMost(2000, TimeUnit.MILLISECONDS).until(() -> consumer.getEventsReceived() == 0); consumer.stop(); assertEquals(0, consumer.getEventsReceived()); } diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorTest.java index a650d796f..55baf3cf7 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorTest.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorTest.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-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. @@ -365,8 +365,6 @@ public class RestRequestorTest { client.close(); assertEquals(Double.valueOf(8.0), getsSoFar); - - ThreadUtilities.sleep(1000); } /** -- cgit 1.2.3-korg