Changes to PAP infrastructure to support PDP
[policy/pap.git] / main / src / test / java / org / onap / policy / pap / main / startstop / TestMain.java
index 37da7e9..650e824 100644 (file)
 package org.onap.policy.pap.main.startstop;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 import org.junit.After;
+import org.junit.Before;
 import org.junit.Test;
+import org.onap.policy.common.utils.services.Registry;
+import org.onap.policy.pap.main.PapConstants;
 import org.onap.policy.pap.main.PolicyPapException;
 import org.onap.policy.pap.main.parameters.CommonTestData;
 
@@ -37,6 +41,14 @@ import org.onap.policy.pap.main.parameters.CommonTestData;
 public class TestMain {
     private Main main;
 
+    /**
+     * Set up.
+     */
+    @Before
+    public void setUp() {
+        Registry.newRegistry();
+    }
+
     /**
      * Shuts "main" down.
      * @throws Exception if an error occurs
@@ -44,9 +56,9 @@ public class TestMain {
     @After
     public void tearDown() throws Exception {
         // shut down activator
-        PapActivator activator = PapActivator.getCurrent();
+        PapActivator activator = Registry.getOrDefault(PapConstants.REG_PAP_ACTIVATOR, PapActivator.class, null);
         if (activator != null && activator.isAlive()) {
-            activator.terminate();
+            activator.stop();
         }
     }
 
@@ -58,6 +70,9 @@ public class TestMain {
         assertTrue(main.getParameters().isValid());
         assertEquals(CommonTestData.PAP_GROUP_NAME, main.getParameters().getName());
 
+        // ensure items were added to the registry
+        assertNotNull(Registry.get(PapConstants.REG_PAP_ACTIVATOR, PapActivator.class));
+
         main.shutdown();
     }