summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-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.java49
1 files changed, 30 insertions, 19 deletions
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 013046444..40e900413 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
@@ -22,10 +22,9 @@
package org.onap.policy.apex.plugins.event.carrier.restrequestor;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
import com.google.gson.Gson;
import java.io.ByteArrayOutputStream;
@@ -36,6 +35,7 @@ import java.util.concurrent.TimeUnit;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Response;
+import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -94,11 +94,22 @@ public class RestRequestorTest {
}
/**
- * Reset counters.
+ * Before test.
*/
@Before
- public void resetCounters() {
+ public void beforeTest() {
SupportRestRequestorEndpoint.resetCounters();
+ System.setOut(new PrintStream(outContent));
+ System.setErr(new PrintStream(errContent));
+ }
+
+ /**
+ * After test.
+ */
+ @After
+ public void afterTest() {
+ System.setOut(stdout);
+ System.setErr(stderr);
}
/**
@@ -269,14 +280,23 @@ public class RestRequestorTest {
/**
* Test REST requestor producer alone.
+ *
+ * @throws MessagingException the messaging exception
+ * @throws ApexException the apex exception
+ * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testRestRequestorProducerAlone() {
+ public void testRestRequestorProducerAlone() throws MessagingException, ApexException, IOException {
+
final String[] args = {"src/test/resources/prodcons/File2RESTRequest2FileGetProducerAlone.json"};
- assertThatThrownBy(() -> new ApexMain(args))
- .hasRootCauseMessage("REST Requestor producer (RestRequestorProducer) "
- + "must run in peered requestor mode with a REST Requestor consumer");
+ ApexMain apexMain = new ApexMain(args);
+ apexMain.shutdown();
+
+ final String outString = outContent.toString();
+
+ assertThat(outString).contains("REST Requestor producer (RestRequestorProducer) "
+ + "must run in peered requestor mode with a REST Requestor consumer");
}
/**
@@ -288,21 +308,12 @@ public class RestRequestorTest {
*/
@Test
public void testRestRequestorConsumerAlone() throws MessagingException, ApexException, IOException {
- System.setOut(new PrintStream(outContent));
- System.setErr(new PrintStream(errContent));
-
final String[] args = {"src/test/resources/prodcons/File2RESTRequest2FileGetConsumerAlone.json"};
-
ApexMain apexMain = new ApexMain(args);
apexMain.shutdown();
-
final String outString = outContent.toString();
-
- System.setOut(stdout);
- System.setErr(stderr);
-
- assertTrue(outString.contains("peer \"RestRequestorProducer for peered mode REQUESTOR "
- + "does not exist or is not defined with the same peered mode"));
+ assertThat(outString).contains("peer \"RestRequestorProducer for peered mode REQUESTOR "
+ + "does not exist or is not defined with the same peered mode");
}
private double getStatsFromServer(final Client client, final String statToGet) {