aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConusmerTest.java29
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumerTest.java8
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorTest.java4
3 files changed, 19 insertions, 22 deletions
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConusmerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConusmerTest.java
index 6face9e50..3341082c0 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConusmerTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConusmerTest.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,6 +21,7 @@
package org.onap.policy.apex.plugins.event.carrier.restclient;
+import static org.awaitility.Awaitility.await;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -28,6 +29,7 @@ import static org.junit.Assert.fail;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
+import java.util.concurrent.TimeUnit;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.Invocation.Builder;
@@ -39,7 +41,6 @@ import org.junit.Test;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
-import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
import org.onap.policy.apex.service.engine.event.ApexEventException;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
@@ -119,7 +120,7 @@ public class ApexRestClientConusmerTest {
// We have not set the URL, this test should not receive any events
arcc.start();
- ThreadUtilities.sleep(200);
+ await().atMost(200, TimeUnit.MILLISECONDS).until(() -> incomingEventReceiver.getEventCount() == 0);
arcc.stop();
assertEquals(0, incomingEventReceiver.getEventCount());
@@ -127,7 +128,7 @@ public class ApexRestClientConusmerTest {
// We have not set the URL, this test should not receive any events
arcc.start();
- ThreadUtilities.sleep(200);
+ await().atMost(200, TimeUnit.MILLISECONDS).until(() -> incomingEventReceiver.getEventCount() == 0);
arcc.stop();
assertEquals(0, incomingEventReceiver.getEventCount());
}
@@ -169,7 +170,7 @@ public class ApexRestClientConusmerTest {
// We have not set the URL, this test should not receive any events
arcc.start();
- ThreadUtilities.sleep(200);
+ await().atMost(200, TimeUnit.MILLISECONDS).until(() -> incomingEventReceiver.getEventCount() == 0);
arcc.stop();
assertEquals(0, incomingEventReceiver.getEventCount());
}
@@ -214,14 +215,10 @@ public class ApexRestClientConusmerTest {
// We have not set the URL, this test should not receive any events
arcc.start();
- ThreadUtilities.sleep(200);
+ await().atMost(400, TimeUnit.MILLISECONDS).until(() -> outContent.toString()
+ .contains("received an empty event from URL \"http://some.place.that.does.not/exist\""));
arcc.stop();
-
assertEquals(0, incomingEventReceiver.getEventCount());
-
- final String outString = outContent.toString();
-
- assertTrue(outString.contains("received an empty event from URL \"http://some.place.that.does.not/exist\""));
}
@Test
@@ -261,7 +258,8 @@ public class ApexRestClientConusmerTest {
// We have not set the URL, this test should not receive any events
arcc.start();
- ThreadUtilities.sleep(200);
+ await().atMost(200, TimeUnit.MILLISECONDS).until(() -> outContent.toString()
+ .contains("received an empty event from URL \"http://some.place.that.does.not/exist\""));
arcc.stop();
assertEquals(0, incomingEventReceiver.getEventCount());
@@ -305,10 +303,9 @@ public class ApexRestClientConusmerTest {
// We have not set the URL, this test should not receive any events
arcc.start();
- ThreadUtilities.sleep(200);
+ await().atMost(400, TimeUnit.MILLISECONDS).until(
+ () -> incomingEventReceiver.getLastEvent().equals("This is an event"));
arcc.stop();
-
- assertEquals("This is an event", incomingEventReceiver.getLastEvent());
}
@Test
@@ -349,7 +346,7 @@ public class ApexRestClientConusmerTest {
try {
// We have not set the URL, this test should not receive any events
arcc.start();
- ThreadUtilities.sleep(200);
+ await().atMost(200, TimeUnit.MILLISECONDS).until(() -> incomingEventReceiver.getEventCount() == 0);
arcc.stop();
} catch (Exception e) {
// test invalid status code
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);
}
/**