aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2019-03-06 11:03:57 -0500
committerJim Hahn <jrh3@att.com>2019-03-07 09:34:56 -0500
commit1b801bab1e07f5ca67aa41e5c5e684406a8e3a63 (patch)
treef1e8687bcf70fb50b32bcbeb93f22161beedd5d1 /main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java
parent0c5e1571b5ba2d5f5d3941f22b46f13a02f92351 (diff)
Refactor REST server tests
Refactored the REST server tests so that each controller has its own test class. Also ensure things are shutdown by various tests. Added comments. Removed unneeded constant. Updated license. Modified code that restarts the REST server during tests. Modified code to just change the activator's "alive" state to false, leaving the REST server running. Fixed comment. Allocated server port. Removed file that should not have been included. Changed code to throw exceptions if activator methods are called while in the wrong state. Change-Id: I04a3a6654150797c23b3c86a6a39ecf8bb7f5a78 Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java')
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java8
1 files changed, 8 insertions, 0 deletions
diff --git a/main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java b/main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java
index 18b87641..687c5fb0 100644
--- a/main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java
+++ b/main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java
@@ -71,6 +71,10 @@ public class PapActivator {
* @throws PolicyPapException on errors in initializing the service
*/
public void initialize() throws PolicyPapException {
+ if (isAlive()) {
+ throw new IllegalStateException("activator already initialized");
+ }
+
try {
LOGGER.debug("Policy pap starting as a service . . .");
startPapRestServer();
@@ -89,6 +93,10 @@ public class PapActivator {
* @throws PolicyPapException on errors in terminating the service
*/
public void terminate() throws PolicyPapException {
+ if (!isAlive()) {
+ throw new IllegalStateException("activator is not running");
+ }
+
try {
deregisterToParameterService(papParameterGroup);
setAlive(false);