aboutsummaryrefslogtreecommitdiffstats
path: root/POLICY-SDK-APP/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'POLICY-SDK-APP/src/test')
-rw-r--r--POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyManagerServletTest.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyManagerServletTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyManagerServletTest.java
index dc2159bc1..267d5fa4e 100644
--- a/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyManagerServletTest.java
+++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyManagerServletTest.java
@@ -19,6 +19,7 @@
*/
package org.onap.policy.admin;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.BufferedReader;
@@ -134,12 +135,46 @@ public class PolicyManagerServletTest extends Mockito{
when(servletConfig.getInitParameter("XACML_PROPERTIES_NAME")).thenReturn("xacml.admin.properties");
System.setProperty("xacml.rest.admin.closedLoopJSON", new File(".").getCanonicalPath() + File.separator + "src"+ File.separator + "test" + File.separator + "resources" + File.separator + "JSONConfig.json");
servlet.init(servletConfig);
+
+ assertTrue(PolicyManagerServlet.getServiceTypeNamesList().size() > 0);
+ assertTrue(PolicyManagerServlet.getPolicyNames().size() > 0);
+
} catch (Exception e1) {
logger.error("Exception Occured"+e1);
fail();
}
}
+ @Test
+ public void testBadInitJson() {
+ PolicyManagerServlet servlet = new PolicyManagerServlet();
+ ServletConfig servletConfig = mock(ServletConfig.class);
+ try {
+ when(servletConfig.getInitParameterNames()).thenReturn(Collections.enumeration(headers));
+ when(servletConfig.getInitParameter("XACML_PROPERTIES_NAME")).thenReturn("xacml.admin.properties");
+ System.setProperty("xacml.rest.admin.closedLoopJSON", new File(".").getCanonicalPath() + File.separator + "src"+ File.separator + "test" + File.separator + "resources" + File.separator + "JSONConfig.foo");
+ servlet.init(servletConfig);
+ } catch (Exception e1) {
+ logger.error("Exception Occured"+e1);
+ fail();
+ }
+ }
+
+ @Test
+ public void testBadInitJsonInvalidFile() {
+ PolicyManagerServlet servlet = new PolicyManagerServlet();
+ ServletConfig servletConfig = mock(ServletConfig.class);
+ try {
+ when(servletConfig.getInitParameterNames()).thenReturn(Collections.enumeration(headers));
+ when(servletConfig.getInitParameter("XACML_PROPERTIES_NAME")).thenReturn("xacml.admin.properties");
+ System.setProperty("xacml.rest.admin.closedLoopJSON", new File(".").getCanonicalPath() + File.separator + "src"+ File.separator + "test" + File.separator + "resources" + File.separator + "IDonotExist.json");
+ servlet.init(servletConfig);
+ } catch (Exception e1) {
+ logger.error("Exception Occured"+e1);
+ fail();
+ }
+ }
+
@SuppressWarnings("static-access")
@Test
public void testDescribePolicy(){