summaryrefslogtreecommitdiffstats
path: root/services/services-engine/src/main
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@ericsson.com>2018-10-05 23:33:00 +0100
committerliamfallon <liam.fallon@ericsson.com>2018-10-05 23:33:47 +0100
commit5b416f07f49e719d1e0ad1f0830588c1d19a17dd (patch)
treec3021c20cceee3523c4ae70b3c02b3e5934e6b84 /services/services-engine/src/main
parent9cedbd41c0ee3bade89de5d2e1e822cc4e9a36e7 (diff)
JUnit for apex Admin Protocol listener
Added coverage for this package. i Issue-ID: POLICY-1034 Change-Id: I2e4b51983eec245eb9f105587d15f853656ce35a Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Diffstat (limited to 'services/services-engine/src/main')
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/engdep/EngDepMessageListener.java5
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/engdep/EngDepMessagingService.java24
2 files changed, 17 insertions, 12 deletions
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/engdep/EngDepMessageListener.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/engdep/EngDepMessageListener.java
index 261ba41cf..1b84c0a92 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/engdep/EngDepMessageListener.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/engdep/EngDepMessageListener.java
@@ -256,11 +256,8 @@ public class EngDepMessageListener implements MessageListener<Message>, Runnable
handleEngineInfoMessage(message, webSocket);
break;
- case RESPONSE:
- throw new ApexException("RESPONSE action on received message not handled by engine");
-
default:
- break;
+ throw new ApexException("action " + enDepAction + " on received message not handled by engine");
}
}
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/engdep/EngDepMessagingService.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/engdep/EngDepMessagingService.java
index 7ebcad830..d46a58d49 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/engdep/EngDepMessagingService.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/engdep/EngDepMessagingService.java
@@ -31,25 +31,22 @@ import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
/**
- * The Class EngDepMessagingService is used to encapsulate the server side of EngDep communication.
- * This class allows users to create and start an EngDep server.
+ * The Class EngDepMessagingService is used to encapsulate the server side of EngDep communication. This class allows
+ * users to create and start an EngDep server.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class EngDepMessagingService {
private static final XLogger LOGGER = XLoggerFactory.getXLogger(EngDepMessagingService.class);
- // Messaging service is used to transmit and receive messages over a communication protocol
- private static MessagingServiceFactory<Message> messageServiceFactory = new MessagingServiceFactory<>();
private final MessagingService<Message> messageService;
// The listener that is listening for messages coming in on the EngDep protocol from clients
private final EngDepMessageListener messageListener;
/**
- * Instantiates a new EngDep messaging service. It creates the message service instance, a
- * listener for incoming messages, and starts the message listener thread for handling incoming
- * messages.
+ * Instantiates a new EngDep messaging service. It creates the message service instance, a listener for incoming
+ * messages, and starts the message listener thread for handling incoming messages.
*
* @param service the Apex engine service that this EngDep service is running for
* @param port the port The port to use for EngDep communication
@@ -58,7 +55,7 @@ public class EngDepMessagingService {
LOGGER.entry(service);
// Create the service and listener and add the listener.
- messageService = messageServiceFactory.createServer(new InetSocketAddress(MessagingUtils.checkPort(port)));
+ messageService = getMessageService(port);
messageListener = new EngDepMessageListener(service);
messageService.addMessageListener(messageListener);
@@ -103,4 +100,15 @@ public class EngDepMessagingService {
public boolean isStopped() {
return !messageService.isStarted();
}
+
+ /**
+ * Get a message service instance. This method is protected so that it can be intercepted in unit test.
+ * @param port the message service port
+ * @return the message service
+ */
+ protected MessagingService<Message> getMessageService(final int port) {
+ // Messaging service is used to transmit and receive messages over a communication protocol
+ MessagingServiceFactory<Message> factory = new MessagingServiceFactory<>();
+ return factory.createServer(new InetSocketAddress(MessagingUtils.checkPort(port)));
+ }
}