aboutsummaryrefslogtreecommitdiffstats
path: root/testsuites/integration/integration-uservice-test/src/test/java
diff options
context:
space:
mode:
authora.sreekumar <ajith.sreekumar@bell.ca>2021-01-25 11:03:42 +0000
committera.sreekumar <ajith.sreekumar@bell.ca>2021-01-28 13:14:51 +0000
commit658e67bc821a3bc55f2c6d877e7e0baa21427333 (patch)
tree5ab53c6026317858aec8b61bf0aec37459247cf5 /testsuites/integration/integration-uservice-test/src/test/java
parent84f92b44e70ce27bb4213da677d50ac91169432c (diff)
Improve handling of multiple policy in APEX PDP
Change-Id: Ic4adf5bd8876dc31fc93993298e90389baaa2c39 Issue-ID: POLICY-2883 Signed-off-by: a.sreekumar <ajith.sreekumar@bell.ca>
Diffstat (limited to 'testsuites/integration/integration-uservice-test/src/test/java')
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestFile2Rest.java22
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRest2File.java26
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restserver/TestRestServer.java108
3 files changed, 28 insertions, 128 deletions
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestFile2Rest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestFile2Rest.java
index e3d64d290..568e9f3f2 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestFile2Rest.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestFile2Rest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +22,7 @@
package org.onap.policy.apex.testsuites.integration.uservice.adapt.restclient;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -260,24 +262,10 @@ public class TestFile2Rest {
*/
@Test
public void testFileEventsBadHttpMethod() throws MessagingException, ApexException, IOException {
- System.setOut(new PrintStream(outContent));
- System.setErr(new PrintStream(errContent));
-
final String[] args = {"src/test/resources/prodcons/File2RESTJsonEventBadHTTPMethod.json"};
- final ApexMain apexMain = new ApexMain(args);
-
- ThreadUtilities.sleep(200);
- apexMain.shutdown();
-
- final String outString = outContent.toString();
-
- System.setOut(stdout);
- System.setErr(stderr);
-
- LOGGER.info("BadHttpMethod-OUTSTRING=\n" + outString + "\nEnd-BadHttpMethod");
- assertTrue(outString
- .contains("specified HTTP method of \"DELETE\" is invalid, only HTTP methods \"POST\" and \"PUT\" "
- + "are supported for event sending on REST client producer"));
+ assertThatThrownBy(() -> new ApexMain(args)).hasRootCauseMessage(
+ "specified HTTP method of \"DELETE\" is invalid, only HTTP methods \"POST\" and \"PUT\" "
+ + "are supported for event sending on REST client producer (FirstProducer)");
}
/**
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRest2File.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRest2File.java
index 671172841..25ff12243 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRest2File.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRest2File.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
- * Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2020-2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@
package org.onap.policy.apex.testsuites.integration.uservice.adapt.restclient;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.fail;
import java.io.ByteArrayOutputStream;
@@ -202,29 +203,14 @@ public class TestRest2File {
/**
* Test file events bad http method.
- *
- * @throws MessagingException the messaging exception
- * @throws ApexException the apex exception
- * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testFileEventsBadHttpMethod() throws MessagingException, ApexException, IOException {
- System.setOut(new PrintStream(outContent));
- System.setErr(new PrintStream(errContent));
-
+ public void testFileEventsBadHttpMethod() {
final String[] args = {"src/test/resources/prodcons/REST2FileJsonEventBadHTTPMethod.json"};
- final ApexMain apexMain = new ApexMain(args);
-
- ThreadUtilities.sleep(5000);
- apexMain.shutdown();
-
- final String outString = outContent.toString();
-
- System.setOut(stdout);
- System.setErr(stderr);
+ assertThatThrownBy(() -> new ApexMain(args))
+ .hasRootCauseMessage("specified HTTP method of \"POST\" is invalid, "
+ + "only HTTP method \"GET\" is supported for event reception on REST client consumer (FirstConsumer)");
- checkRequiredString(outString, "specified HTTP method of \"POST\" is invalid, "
- + "only HTTP method \"GET\" is supported for event reception on REST client consumer");
}
/**
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restserver/TestRestServer.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restserver/TestRestServer.java
index e3057ad2f..39173bc72 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restserver/TestRestServer.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restserver/TestRestServer.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
- * Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2020-2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@
package org.onap.policy.apex.testsuites.integration.uservice.adapt.restserver;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.awaitility.Awaitility.await;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -285,35 +286,14 @@ public class TestRestServer {
/**
* Test rest server producer standalone.
- *
- * @throws MessagingException the messaging exception
- * @throws ApexException the apex exception
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws InterruptedException interrupted exception
*/
@Test
- public void testRestServerProducerStandalone()
- throws MessagingException, ApexException, IOException, InterruptedException {
+ public void testRestServerProducerStandalone() {
LOGGER.debug("testRestServerProducerStandalone start");
- System.setOut(new PrintStream(outContent));
- System.setErr(new PrintStream(errContent));
-
final String[] args = {"src/test/resources/prodcons/RESTServerJsonEventProducerStandalone.json"};
-
- final ApexMain apexMain = new ApexMain(args);
- ThreadUtilities.sleep(200);
- apexMain.shutdown();
-
- await().atMost(10L, TimeUnit.SECONDS).until(() -> !apexMain.isAlive());
-
- final String outString = outContent.toString();
-
- System.setOut(stdout);
- System.setErr(stderr);
-
- assertTrue(outString
- .contains("the parameters \"host\", \"port\", and \"standalone\" are illegal on REST Server producer"));
- LOGGER.debug("testRestServerProducerStandalone end");
+ assertThatThrownBy(() -> new ApexMain(args))
+ .hasRootCauseMessage("the parameters \"host\", \"port\", and \"standalone\" are illegal"
+ + " on REST Server producer (FirstProducer)");
}
/**
@@ -382,94 +362,40 @@ public class TestRestServer {
/**
* Test rest server consumer standalone no host.
- *
- * @throws MessagingException the messaging exception
- * @throws ApexException the apex exception
- * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testRestServerConsumerStandaloneNoHost() throws MessagingException, ApexException, IOException {
+ public void testRestServerConsumerStandaloneNoHost() {
LOGGER.debug("testRestServerConsumerStandaloneNoHost start");
- System.setOut(new PrintStream(outContent));
- System.setErr(new PrintStream(errContent));
-
final String[] args = {"src/test/resources/prodcons/RESTServerJsonEventConsumerStandaloneNoHost.json"};
+ assertThatThrownBy(() -> new ApexMain(args))
+ .hasRootCauseMessage("the parameters \"host\" and \"port\" must be defined for REST Server consumer "
+ + "(FirstConsumer) in standalone mode");
- final ApexMain apexMain = new ApexMain(args);
- ThreadUtilities.sleep(200);
- apexMain.shutdown();
-
- await().atMost(10L, TimeUnit.SECONDS).until(() -> !apexMain.isAlive());
-
- final String outString = outContent.toString();
-
- System.setOut(stdout);
- System.setErr(stderr);
-
- assertTrue(outString.contains("the parameters \"host\" and \"port\" must be defined for REST Server consumer "
- + "(FirstConsumer) in standalone mode"));
LOGGER.debug("testRestServerConsumerStandaloneNoHost end");
}
/**
* Test rest server consumer standalone no port.
- *
- * @throws MessagingException the messaging exception
- * @throws ApexException the apex exception
- * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testRestServerConsumerStandaloneNoPort() throws MessagingException, ApexException, IOException {
+ public void testRestServerConsumerStandaloneNoPort() {
LOGGER.debug("testRestServerConsumerStandaloneNoPort start");
- System.setOut(new PrintStream(outContent));
- System.setErr(new PrintStream(errContent));
-
final String[] args = {"src/test/resources/prodcons/RESTServerJsonEventConsumerStandaloneNoPort.json"};
-
- final ApexMain apexMain = new ApexMain(args);
- ThreadUtilities.sleep(200);
- apexMain.shutdown();
-
- await().atMost(10L, TimeUnit.SECONDS).until(() -> !apexMain.isAlive());
-
- final String outString = outContent.toString();
-
- System.setOut(stdout);
- System.setErr(stderr);
-
- assertTrue(outString.contains("the parameters \"host\" and \"port\" must be defined for REST Server consumer "
- + "(FirstConsumer) in standalone mode"));
+ assertThatThrownBy(() -> new ApexMain(args))
+ .hasRootCauseMessage("the parameters \"host\" and \"port\" must be defined for REST Server consumer "
+ + "(FirstConsumer) in standalone mode");
LOGGER.debug("testRestServerConsumerStandaloneNoPort end");
}
/**
* Test rest server producer not sync.
- *
- * @throws MessagingException the messaging exception
- * @throws ApexException the apex exception
- * @throws IOException Signals that an I/O exception has occurred.
*/
@Test
- public void testRestServerProducerNotSync() throws MessagingException, ApexException, IOException {
+ public void testRestServerProducerNotSync() {
LOGGER.debug("testRestServerProducerNotSync start");
- System.setOut(new PrintStream(outContent));
- System.setErr(new PrintStream(errContent));
-
final String[] args = {"src/test/resources/prodcons/RESTServerJsonEventProducerNotSync.json"};
-
- final ApexMain apexMain = new ApexMain(args);
- ThreadUtilities.sleep(200);
- apexMain.shutdown();
-
- await().atMost(10L, TimeUnit.SECONDS).until(() -> !apexMain.isAlive());
-
- final String outString = outContent.toString();
-
- System.setOut(stdout);
- System.setErr(stderr);
-
- assertTrue(outString.contains(
- "REST Server producer (FirstProducer) must run in synchronous mode " + "with a REST Server consumer"));
+ assertThatThrownBy(() -> new ApexMain(args)).hasRootCauseMessage(
+ "REST Server producer (FirstProducer) must run in synchronous mode " + "with a REST Server consumer");
LOGGER.debug("testRestServerProducerNotSync end");
}