aboutsummaryrefslogtreecommitdiffstats
path: root/testsuites/integration/integration-uservice-test
diff options
context:
space:
mode:
Diffstat (limited to 'testsuites/integration/integration-uservice-test')
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestFile2Rest.java93
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRest2File.java118
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restserver/TestRestServer.java125
3 files changed, 171 insertions, 165 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 568e9f3f2..04a1e6faf 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
@@ -22,7 +22,8 @@
package org.onap.policy.apex.testsuites.integration.uservice.adapt.restclient;
-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;
@@ -31,9 +32,11 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Map;
+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;
@@ -63,6 +66,7 @@ public class TestFile2Rest {
private final PrintStream stdout = System.out;
private final PrintStream stderr = System.err;
+ private ApexMain apexMain;
/**
* Sets the up.
@@ -97,11 +101,26 @@ public class TestFile2Rest {
}
/**
- * Clear relative file root environment variable.
+ * Before test.
*/
@Before
- public void clearRelativeFileRoot() {
+ public void beforeTest() {
System.clearProperty("APEX_RELATIVE_FILE_ROOT");
+ System.setOut(new PrintStream(outContent));
+ System.setErr(new PrintStream(errContent));
+ }
+
+ /**
+ * After test.
+ * @throws ApexException the exception.
+ */
+ @After
+ public void afterTest() throws ApexException {
+ if (null != apexMain) {
+ apexMain.shutdown();
+ }
+ System.setOut(stdout);
+ System.setErr(stderr);
}
/**
@@ -207,22 +226,12 @@ public class TestFile2Rest {
*/
@Test
public void testFileEventsNoUrl() throws MessagingException, ApexException, IOException {
- System.setOut(new PrintStream(outContent));
- System.setErr(new PrintStream(errContent));
final String[] args = {"src/test/resources/prodcons/File2RESTJsonEventNoURL.json"};
- final ApexMain apexMain = new ApexMain(args);
-
- ThreadUtilities.sleep(200);
- apexMain.shutdown();
-
+ apexMain = new ApexMain(args);
final String outString = outContent.toString();
-
- System.setOut(stdout);
- System.setErr(stderr);
-
- LOGGER.info("NoUrl-OUTSTRING=\n" + outString + "\nEnd-NoUrl");
- assertTrue(outString.contains(" no URL has been set for event sending on RESTCLIENT"));
+ LOGGER.info("NoUrl-OUTSTRING=\n {} \nEnd-NoUrl", outString);
+ assertThat(outString).contains(" no URL has been set for event sending on RESTCLIENT");
}
/**
@@ -234,23 +243,15 @@ public class TestFile2Rest {
*/
@Test
public void testFileEventsBadUrl() throws MessagingException, ApexException, IOException {
- System.setOut(new PrintStream(outContent));
- System.setErr(new PrintStream(errContent));
final String[] args = {"src/test/resources/prodcons/File2RESTJsonEventBadURL.json"};
- final ApexMain apexMain = new ApexMain(args);
-
- ThreadUtilities.sleep(2000);
- apexMain.shutdown();
-
- final String outString = outContent.toString();
-
- System.setOut(stdout);
- System.setErr(stderr);
-
- LOGGER.info("BadUrl-OUTSTRING=\n" + outString + "\nEnd-BadUrl");
- assertTrue(outString.contains(
- "send of event to URL \"http://localhost:32801/TestFile2Rest/apex/event/Bad\" using HTTP \"POST\" failed with status code 404"));
+ apexMain = new ApexMain(args);
+ await().atMost(5, TimeUnit.SECONDS)
+ .until(() -> outContent.toString()
+ .contains("send of event to URL \"http://localhost:32801/TestFile2Rest/apex/event/Bad\" "
+ + "using HTTP \"POST\" failed with status code 404"));
+ assertTrue(apexMain.isAlive());
+ LOGGER.info("BadUrl-OUTSTRING=\n {} \nEnd-BadUrl", outContent.toString());
}
/**
@@ -262,10 +263,14 @@ public class TestFile2Rest {
*/
@Test
public void testFileEventsBadHttpMethod() throws MessagingException, ApexException, IOException {
+
final String[] args = {"src/test/resources/prodcons/File2RESTJsonEventBadHTTPMethod.json"};
- 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)");
+ apexMain = new ApexMain(args);
+ final String outString = outContent.toString();
+ LOGGER.info("BadHttpMethod-OUTSTRING=\n {} \nEnd-BadHttpMethod", outString);
+ assertThat(outString)
+ .contains("specified HTTP method of \"DELETE\" is invalid, only HTTP methods \"POST\" and \"PUT\" "
+ + "are supported for event sending on REST client producer");
}
/**
@@ -277,23 +282,15 @@ public class TestFile2Rest {
*/
@Test
public void testFileEventsBadResponse() throws MessagingException, ApexException, IOException {
- System.setOut(new PrintStream(outContent));
- System.setErr(new PrintStream(errContent));
final String[] args = {"src/test/resources/prodcons/File2RESTJsonEventPostBadResponse.json"};
- final ApexMain apexMain = new ApexMain(args);
-
- ThreadUtilities.sleep(2000);
- apexMain.shutdown();
-
- final String outString = outContent.toString();
-
- System.setOut(stdout);
- System.setErr(stderr);
+ apexMain = new ApexMain(args);
- LOGGER.info("BadResponse-OUTSTRING=\n" + outString + "\nEnd-BadResponse");
- assertTrue(outString.contains(
+ await().atMost(5, TimeUnit.SECONDS)
+ .until(() -> outContent.toString().contains(
"send of event to URL \"http://localhost:32801/TestFile2Rest/apex/event/PostEventBadResponse\""
- + " using HTTP \"POST\" failed with status code 400"));
+ + " using HTTP \"POST\" failed with status code 400"));
+ assertTrue(apexMain.isAlive());
+ LOGGER.info("BadResponse-OUTSTRING=\n {} \nEnd-BadResponse", outContent.toString());
}
}
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 25ff12243..0aeb196f0 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
@@ -22,24 +22,26 @@
package org.onap.policy.apex.testsuites.integration.uservice.adapt.restclient;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.awaitility.Awaitility.await;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.concurrent.TimeUnit;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.core.infrastructure.messaging.MessagingException;
-import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.service.engine.main.ApexMain;
import org.onap.policy.common.endpoints.http.server.HttpServletServer;
import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
import org.onap.policy.common.gson.GsonMessageBodyHandler;
import org.onap.policy.common.utils.network.NetworkUtil;
-import org.onap.policy.common.utils.resources.TextFileUtils;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -57,13 +59,16 @@ public class TestRest2File {
private final PrintStream stdout = System.out;
private final PrintStream stderr = System.err;
+ private ApexMain apexMain;
/**
- * Clear relative file root environment variable.
+ * Before Test.
*/
@Before
- public void clearRelativeFileRoot() {
+ public void beforeTest() {
System.clearProperty("APEX_RELATIVE_FILE_ROOT");
+ System.setOut(new PrintStream(outContent));
+ System.setErr(new PrintStream(errContent));
}
/**
@@ -93,9 +98,14 @@ public class TestRest2File {
*/
@After
public void tearDown() throws Exception {
+ if (null != apexMain) {
+ apexMain.shutdown();
+ }
if (server != null) {
server.stop();
}
+ System.setOut(stdout);
+ System.setErr(stderr);
}
/**
@@ -109,16 +119,11 @@ public class TestRest2File {
public void testRestEventsIn() throws MessagingException, ApexException, IOException {
final String[] args = {"-rfr", "target", "-p", "target/examples/config/SampleDomain/REST2FileJsonEvent.json"};
- final ApexMain apexMain = new ApexMain(args);
-
- ThreadUtilities.sleep(5000);
- apexMain.shutdown();
-
- final String outputEventText =
- TextFileUtils.getTextFileAsString("target/examples/events/SampleDomain/EventsOut.json");
-
- checkRequiredString(outputEventText,
- "04\",\n" + " \"version\": \"0.0.1\",\n" + " \"nameSpace\": \"org.onap.policy.apex.sample.events\"");
+ apexMain = new ApexMain(args);
+ await().atMost(5, TimeUnit.SECONDS).until(
+ () -> Files.readString(Path.of("target/examples/events/SampleDomain/EventsOut.json")).contains(
+ "04\",\n" + " \"version\": \"0.0.1\",\n" + " \"nameSpace\": \"org.onap.policy.apex.sample.events\""));
+ assertTrue(apexMain.isAlive());
}
/**
@@ -130,22 +135,12 @@ public class TestRest2File {
*/
@Test
public void testFileEmptyEvents() throws MessagingException, ApexException, IOException {
- System.setOut(new PrintStream(outContent));
- System.setErr(new PrintStream(errContent));
final String[] args = {"src/test/resources/prodcons/REST2FileJsonEmptyEvents.json"};
- final ApexMain apexMain = new ApexMain(args);
-
- ThreadUtilities.sleep(5000);
- apexMain.shutdown();
-
- final String outString = outContent.toString();
-
- System.setOut(stdout);
- System.setErr(stderr);
-
- checkRequiredString(outString,
- "received an empty event from URL " + "\"http://localhost:32801/TestRest2File/apex/event/GetEmptyEvent\"");
+ apexMain = new ApexMain(args);
+ await().atMost(5, TimeUnit.SECONDS).until(() -> outContent.toString().contains(
+ "received an empty event from URL " + "\"http://localhost:32801/TestRest2File/apex/event/GetEmptyEvent\""));
+ assertTrue(apexMain.isAlive());
}
/**
@@ -157,20 +152,11 @@ public class TestRest2File {
*/
@Test
public void testFileEventsNoUrl() throws MessagingException, ApexException, IOException {
- System.setOut(new PrintStream(outContent));
- System.setErr(new PrintStream(errContent));
final String[] args = {"src/test/resources/prodcons/REST2FileJsonEventNoURL.json"};
- final ApexMain apexMain = new ApexMain(args);
-
- ThreadUtilities.sleep(5000);
- apexMain.shutdown();
-
+ apexMain = new ApexMain(args);
final String outString = outContent.toString();
- System.setOut(stdout);
- System.setErr(stderr);
-
checkRequiredString(outString, " no URL has been set for event sending on RESTCLIENT");
}
@@ -183,34 +169,32 @@ public class TestRest2File {
*/
@Test
public void testFileEventsBadUrl() throws MessagingException, ApexException, IOException {
- System.setOut(new PrintStream(outContent));
- System.setErr(new PrintStream(errContent));
final String[] args = {"src/test/resources/prodcons/REST2FileJsonEventBadURL.json"};
- final ApexMain apexMain = new ApexMain(args);
-
- ThreadUtilities.sleep(5000);
- apexMain.shutdown();
-
- final String outString = outContent.toString();
-
- System.setOut(stdout);
- System.setErr(stderr);
+ apexMain = new ApexMain(args);
- checkRequiredString(outString, "reception of event from URL "
- + "\"http://localhost:32801/TestRest2File/apex/event/Bad\" failed with status code 404");
+ await().atMost(5, TimeUnit.SECONDS).until(() -> outContent.toString().contains("reception of event from URL "
+ + "\"http://localhost:32801/TestRest2File/apex/event/Bad\" failed with status code 404"));
+ assertTrue(apexMain.isAlive());
}
/**
* 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() {
+ public void testFileEventsBadHttpMethod() throws MessagingException, ApexException, IOException {
+
final String[] args = {"src/test/resources/prodcons/REST2FileJsonEventBadHTTPMethod.json"};
- 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)");
+ apexMain = new ApexMain(args);
+
+ final String outString = outContent.toString();
+ checkRequiredString(outString, "specified HTTP method of \"POST\" is invalid, "
+ + "only HTTP method \"GET\" is supported for event reception on REST client consumer");
}
/**
@@ -222,23 +206,15 @@ public class TestRest2File {
*/
@Test
public void testFileEventsBadResponse() throws MessagingException, ApexException, IOException {
- System.setOut(new PrintStream(outContent));
- System.setErr(new PrintStream(errContent));
final String[] args = {"src/test/resources/prodcons/REST2FileJsonEventBadResponse.json"};
- final ApexMain apexMain = new ApexMain(args);
-
- ThreadUtilities.sleep(5000);
- apexMain.shutdown();
-
- final String outString = outContent.toString();
-
- System.setOut(stdout);
- System.setErr(stderr);
-
- checkRequiredString(outString,
- "reception of event from URL " + "\"http://localhost:32801/TestRest2File/apex/event/GetEventBadResponse\" "
- + "failed with status code 400 and message \"");
+ apexMain = new ApexMain(args);
+ await().atMost(5, TimeUnit.SECONDS)
+ .until(() -> outContent.toString()
+ .contains("reception of event from URL "
+ + "\"http://localhost:32801/TestRest2File/apex/event/GetEventBadResponse\" "
+ + "failed with status code 400 and message \""));
+ assertTrue(apexMain.isAlive());
}
/**
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 39173bc72..0596a65e8 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
@@ -22,7 +22,7 @@
package org.onap.policy.apex.testsuites.integration.uservice.adapt.restserver;
-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;
@@ -38,10 +38,10 @@ import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.core.infrastructure.messaging.MessagingException;
-import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.service.engine.main.ApexMain;
import org.onap.policy.common.utils.network.NetworkUtil;
@@ -63,11 +63,22 @@ public class TestRestServer {
private static int eventsSent = 0;
/**
- * Clear relative file root environment variable.
+ * Before Test.
*/
@Before
- public void clearRelativeFileRoot() {
+ public void beforeTest() {
System.clearProperty("APEX_RELATIVE_FILE_ROOT");
+ System.setOut(new PrintStream(outContent));
+ System.setErr(new PrintStream(errContent));
+ }
+
+ /**
+ * After test.
+ */
+ @After
+ public void afterTest() {
+ System.setOut(stdout);
+ System.setErr(stderr);
}
/**
@@ -286,14 +297,28 @@ 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() {
+ public void testRestServerProducerStandalone()
+ throws MessagingException, ApexException, IOException, InterruptedException {
LOGGER.debug("testRestServerProducerStandalone start");
final String[] args = {"src/test/resources/prodcons/RESTServerJsonEventProducerStandalone.json"};
- assertThatThrownBy(() -> new ApexMain(args))
- .hasRootCauseMessage("the parameters \"host\", \"port\", and \"standalone\" are illegal"
- + " on REST Server producer (FirstProducer)");
+
+ final ApexMain apexMain = new ApexMain(args);
+ apexMain.shutdown();
+
+ await().atMost(10L, TimeUnit.SECONDS).until(() -> !apexMain.isAlive());
+
+ final String outString = outContent.toString();
+
+ assertThat(outString)
+ .contains("the parameters \"host\", \"port\", and \"standalone\" are illegal on REST Server producer");
+ LOGGER.debug("testRestServerProducerStandalone end");
}
/**
@@ -308,23 +333,15 @@ public class TestRestServer {
public void testRestServerProducerHost()
throws MessagingException, ApexException, IOException, InterruptedException {
LOGGER.debug("testRestServerProducerHost start");
- System.setOut(new PrintStream(outContent));
- System.setErr(new PrintStream(errContent));
-
final String[] args = {"src/test/resources/prodcons/RESTServerJsonEventProducerHost.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(" host is specified only in standalone mode"));
+ assertThat(outString).contains(" host is specified only in standalone mode");
LOGGER.debug("testRestServerProducerHost end");
}
@@ -340,61 +357,84 @@ public class TestRestServer {
public void testRestServerProducerPort()
throws MessagingException, ApexException, IOException, InterruptedException {
LOGGER.debug("testRestServerProducerPort start");
- System.setOut(new PrintStream(outContent));
- System.setErr(new PrintStream(errContent));
-
final String[] args = {"src/test/resources/prodcons/RESTServerJsonEventProducerPort.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(" port is specified only in standalone mode"));
+ assertThat(outString).contains(" port is specified only in standalone mode");
LOGGER.debug("testRestServerProducerPort end");
}
/**
* 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() {
+ public void testRestServerConsumerStandaloneNoHost() throws MessagingException, ApexException, IOException {
LOGGER.debug("testRestServerConsumerStandaloneNoHost start");
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);
+ apexMain.shutdown();
+
+ await().atMost(10L, TimeUnit.SECONDS).until(() -> !apexMain.isAlive());
+
+ final String outString = outContent.toString();
+ assertThat(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() {
+ public void testRestServerConsumerStandaloneNoPort() throws MessagingException, ApexException, IOException {
LOGGER.debug("testRestServerConsumerStandaloneNoPort start");
final String[] args = {"src/test/resources/prodcons/RESTServerJsonEventConsumerStandaloneNoPort.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);
+ apexMain.shutdown();
+
+ await().atMost(10L, TimeUnit.SECONDS).until(() -> !apexMain.isAlive());
+
+ final String outString = outContent.toString();
+ assertThat(outString).contains("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() {
+ public void testRestServerProducerNotSync() throws MessagingException, ApexException, IOException {
LOGGER.debug("testRestServerProducerNotSync start");
final String[] args = {"src/test/resources/prodcons/RESTServerJsonEventProducerNotSync.json"};
- assertThatThrownBy(() -> new ApexMain(args)).hasRootCauseMessage(
+
+ final ApexMain apexMain = new ApexMain(args);
+ apexMain.shutdown();
+
+ await().atMost(10L, TimeUnit.SECONDS).until(() -> !apexMain.isAlive());
+
+ final String outString = outContent.toString();
+
+ assertThat(outString).contains(
"REST Server producer (FirstProducer) must run in synchronous mode " + "with a REST Server consumer");
LOGGER.debug("testRestServerProducerNotSync end");
}
@@ -409,25 +449,18 @@ public class TestRestServer {
@Test
public void testRestServerConsumerNotSync() throws MessagingException, ApexException, IOException {
LOGGER.debug("testRestServerConsumerNotSync start");
- System.setOut(new PrintStream(outContent));
- System.setErr(new PrintStream(errContent));
-
final String[] args = {"src/test/resources/prodcons/RESTServerJsonEventConsumerNotSync.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("peer \"FirstConsumer for peered mode SYNCHRONOUS does not exist or is not defined "
- + "with the same peered mode"));
+ assertThat(outString)
+ .contains("peer \"FirstConsumer for peered mode SYNCHRONOUS does not exist or is not defined "
+ + "with the same peered mode");
LOGGER.debug("testRestServerConsumerNotSync end");
}