diff options
author | a.sreekumar <ajith.sreekumar@bell.ca> | 2021-02-09 18:21:49 +0000 |
---|---|---|
committer | Ajith Sreekumar <ajith.sreekumar@bell.ca> | 2021-02-11 10:01:27 +0000 |
commit | f86d08ca5598571410386372f3f06d5c8c686c74 (patch) | |
tree | 644913448310e4ea5fe201c16554a2f739d49a43 /plugins/plugins-event | |
parent | c64320a45b77eb3474f1f3f7372f1cd1f85ddfef (diff) |
Changes related to multi policy handling improvement in APEX
This review fixes an issue identified during testing the changes done
for improving multiple policy handling in APEX.
Changes done to a few test files in the previous review are reverted as
well.
Change-Id: I98324da708239d314aadd4c45dc377137fd552ba
Issue-ID: POLICY-2883
Signed-off-by: a.sreekumar <ajith.sreekumar@bell.ca>
Diffstat (limited to 'plugins/plugins-event')
-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.java | 49 |
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) { |