summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/stringmessaging/WsStringMessageClient.java9
-rw-r--r--core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/stringmessaging/WsStringMessageServer.java22
-rw-r--r--core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/stringmessaging/WsStringMessager.java6
-rw-r--r--core/core-infrastructure/src/test/java/org/onap/policy/apex/core/infrastructure/messaging/EndToEndStringMessagingTest.java2
4 files changed, 32 insertions, 7 deletions
diff --git a/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/stringmessaging/WsStringMessageClient.java b/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/stringmessaging/WsStringMessageClient.java
index 98bffdbc6..968ec97db 100644
--- a/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/stringmessaging/WsStringMessageClient.java
+++ b/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/stringmessaging/WsStringMessageClient.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 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.
@@ -135,4 +136,12 @@ public class WsStringMessageClient implements WsStringMessager {
wsStringMessageListener.receiveString(messageString);
}
}
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public boolean isStarted() {
+ return service.isStarted();
+ }
}
diff --git a/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/stringmessaging/WsStringMessageServer.java b/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/stringmessaging/WsStringMessageServer.java
index 41fb82a9e..6b1dc6709 100644
--- a/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/stringmessaging/WsStringMessageServer.java
+++ b/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/stringmessaging/WsStringMessageServer.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.
@@ -22,9 +22,11 @@
package org.onap.policy.apex.core.infrastructure.messaging.stringmessaging;
import com.google.common.eventbus.Subscribe;
+
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
+
import org.onap.policy.apex.core.infrastructure.messaging.MessageListener;
import org.onap.policy.apex.core.infrastructure.messaging.MessagingException;
import org.onap.policy.apex.core.infrastructure.messaging.MessagingService;
@@ -72,17 +74,15 @@ public class WsStringMessageServer implements WsStringMessager {
String lanaddress = "unknown";
try {
lanaddress = MessagingUtils.getLocalHostLanAddress().getHostAddress();
- }
- catch (final UnknownHostException ignore) {
- LOGGER.debug("Failed to find name of local address name",ignore);
+ } catch (final UnknownHostException ignore) {
+ LOGGER.debug("Failed to find name of local address name", ignore);
}
LOGGER.debug("web socket string message server LAN address=" + lanaddress);
String hostaddress = "unknown";
try {
hostaddress = InetAddress.getLocalHost().getHostAddress();
- }
- catch (final UnknownHostException ignore) {
- LOGGER.debug("Failed to find name of local address",ignore);
+ } catch (final UnknownHostException ignore) {
+ LOGGER.debug("Failed to find name of local address", ignore);
}
LOGGER.debug("web socket string message server host address=" + hostaddress);
}
@@ -145,4 +145,12 @@ public class WsStringMessageServer implements WsStringMessager {
wsStringMessageListener.receiveString(messageString);
}
}
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Override
+ public boolean isStarted() {
+ return service.isStarted();
+ }
}
diff --git a/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/stringmessaging/WsStringMessager.java b/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/stringmessaging/WsStringMessager.java
index 2a731b0eb..c6db1ffc7 100644
--- a/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/stringmessaging/WsStringMessager.java
+++ b/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/stringmessaging/WsStringMessager.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 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.
@@ -48,4 +49,9 @@ public interface WsStringMessager {
* @param stringMessage the string message to send
*/
void sendString(String stringMessage);
+
+ /**
+ * Check if the string messager is started.
+ */
+ boolean isStarted();
}
diff --git a/core/core-infrastructure/src/test/java/org/onap/policy/apex/core/infrastructure/messaging/EndToEndStringMessagingTest.java b/core/core-infrastructure/src/test/java/org/onap/policy/apex/core/infrastructure/messaging/EndToEndStringMessagingTest.java
index 5a1390163..35d348568 100644
--- a/core/core-infrastructure/src/test/java/org/onap/policy/apex/core/infrastructure/messaging/EndToEndStringMessagingTest.java
+++ b/core/core-infrastructure/src/test/java/org/onap/policy/apex/core/infrastructure/messaging/EndToEndStringMessagingTest.java
@@ -55,6 +55,8 @@ public class EndToEndStringMessagingTest {
assertNotNull(server);
server.start(new WsStringServerMessageListener());
+ await().atMost(2, TimeUnit.SECONDS).until(() -> server.isStarted());
+
try {
client = new WsStringMessageClient("localhost", 44441);
assertNotNull(client);