aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/XACMLPdpServletTest.java27
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/impl/test/XACMLPdpPolicyFinderFactoryTest.java79
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/jmx/PdpRestMBeanListenerTest.java55
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/jmx/ServerContextImpl.java357
4 files changed, 512 insertions, 6 deletions
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/XACMLPdpServletTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/XACMLPdpServletTest.java
index 3f01f0f94..8c7fd7ef7 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/XACMLPdpServletTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/XACMLPdpServletTest.java
@@ -20,6 +20,9 @@
package org.onap.policy.pdp.rest;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
@@ -44,6 +47,7 @@ import org.onap.policy.common.ia.DbDAO;
import org.onap.policy.common.ia.IntegrityAuditProperties;
import org.onap.policy.common.im.IntegrityMonitor;
import org.onap.policy.common.im.IntegrityMonitorException;
+import org.onap.policy.common.logging.ONAPLoggingContext;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.rest.XACMLRestProperties;
@@ -202,14 +206,12 @@ public class XACMLPdpServletTest extends TestCase{
@Test
public void testUebNotification() {
- System.out.println("drewtest1");
- LOGGER.info("XACMLPdpServletTest - drewTest1");
+ LOGGER.info("XACMLPdpServletTest - testUebNotification");
try {
XACMLProperties.reloadProperties();
System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "src/test/resources/xacml.pdp.ueb.properties");
XACMLProperties.getProperties();
- XACMLProperties.setProperty(XACMLRestProperties.PROP_NOTIFICATION_TYPE, "ueb");
pdpServlet.init(servletConfig);
@@ -228,14 +230,12 @@ public class XACMLPdpServletTest extends TestCase{
@Test
public void testDmaapNotification() {
- System.out.println("drewtest2");
- LOGGER.info("XACMLPdpServletTest - drewTest2");
+ LOGGER.info("XACMLPdpServletTest - testDmaapNotification");
try {
XACMLProperties.reloadProperties();
System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "src/test/resources/xacml.pdp.dmaap.properties");
XACMLProperties.getProperties();
- XACMLProperties.setProperty(XACMLRestProperties.PROP_NOTIFICATION_TYPE, "dmaap");
pdpServlet.init(servletConfig);
@@ -254,6 +254,21 @@ public class XACMLPdpServletTest extends TestCase{
@Test
+ public void testXACMLPdpRegisterThread() {
+ LOGGER.info("XACMLPdpServletTest - testXACMLPdpRegisterThread");
+ try {
+ ONAPLoggingContext baseLoggingContext = new ONAPLoggingContext();
+ baseLoggingContext.setServer("localhost");
+ XACMLPdpRegisterThread regThread = new XACMLPdpRegisterThread(baseLoggingContext);
+ regThread.run();
+ assertTrue(true);
+ } catch (Exception e) {
+ LOGGER.error("Exception Occured"+e);
+ fail();
+ }
+ }
+
+ @Test
public void testDoGetNoTypeError(){
LOGGER.info("XACMLPdpServletTest - testDoGetNoTypeError");
try{
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/impl/test/XACMLPdpPolicyFinderFactoryTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/impl/test/XACMLPdpPolicyFinderFactoryTest.java
new file mode 100644
index 000000000..af2ea7271
--- /dev/null
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/impl/test/XACMLPdpPolicyFinderFactoryTest.java
@@ -0,0 +1,79 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-PDP-REST
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.pdp.rest.impl.test;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Properties;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.Test;
+import org.onap.policy.pdp.rest.impl.XACMLPdpPolicyFinderFactory;
+
+import com.att.research.xacml.util.XACMLProperties;
+
+public class XACMLPdpPolicyFinderFactoryTest {
+ private static Log LOGGER = LogFactory.getLog(XACMLPdpPolicyFinderFactoryTest.class);
+
+ @Test
+ public void testDefaultConstructor() throws IOException {
+
+ LOGGER.info("XACMLPdpPolicyFinderFactoryTest - testDefaultConstructor");
+ try {
+ XACMLProperties.reloadProperties();
+ System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "src/test/resources/xacml.pdp.properties");
+ XACMLProperties.getProperties();
+
+ XACMLPdpPolicyFinderFactory finderFactory = new XACMLPdpPolicyFinderFactory();
+
+ finderFactory.getPolicyFinder();
+
+ assertTrue(true);
+ } catch (Exception e) {
+ LOGGER.error("Exception Occured"+e);
+ fail();
+
+ }
+ }
+ @Test
+ public void testPropertiesConstructor () {
+
+ LOGGER.info("XACMLPdpPolicyFinderFactoryTest - testPropertiesConstructor");
+ try {
+ Properties properties = new Properties();
+ FileInputStream input = new FileInputStream("src/test/resources/xacml.pdp.properties");
+ properties.load(input);
+
+ XACMLPdpPolicyFinderFactory finderFactory = new XACMLPdpPolicyFinderFactory(properties);
+
+ assertTrue(true);
+ } catch (Exception e) {
+ LOGGER.error("Exception Occured"+e);
+ fail();
+
+ }
+
+ }
+}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/jmx/PdpRestMBeanListenerTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/jmx/PdpRestMBeanListenerTest.java
new file mode 100644
index 000000000..ea689e663
--- /dev/null
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/jmx/PdpRestMBeanListenerTest.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-PDP-REST
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.policy.pdp.rest.jmx;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import javax.servlet.ServletContextEvent;
+
+import org.junit.Test;
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
+
+public class PdpRestMBeanListenerTest {
+
+ private static Logger LOGGER = FlexLogger.getLogger(PdpRestMBeanListenerTest.class);
+
+ @Test
+ public void test() {
+
+ try {
+ PdpRestMBeanListener listener = new PdpRestMBeanListener();
+ ServerContextImpl source = new ServerContextImpl();
+ ServletContextEvent event = new ServletContextEvent(source);
+
+ listener.contextInitialized(event);
+ listener.contextDestroyed(event);
+
+ assertTrue(true);
+ } catch (Exception e) {
+ LOGGER.error("Exception Occured"+e);
+ fail();
+
+ }
+
+ }
+
+}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/jmx/ServerContextImpl.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/jmx/ServerContextImpl.java
new file mode 100644
index 000000000..d936fbe85
--- /dev/null
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/jmx/ServerContextImpl.java
@@ -0,0 +1,357 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-PDP-REST
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.pdp.rest.jmx;
+
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.EventListener;
+import java.util.Map;
+import java.util.Set;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterRegistration;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRegistration;
+import javax.servlet.ServletRegistration.Dynamic;
+import javax.servlet.SessionCookieConfig;
+import javax.servlet.SessionTrackingMode;
+import javax.servlet.descriptor.JspConfigDescriptor;
+
+public class ServerContextImpl implements ServletContext{
+
+ @Override
+ public String getContextPath() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ServletContext getContext(String uripath) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getMajorVersion() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getMinorVersion() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getEffectiveMajorVersion() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getEffectiveMinorVersion() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public String getMimeType(String file) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Set<String> getResourcePaths(String path) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public URL getResource(String path) throws MalformedURLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public InputStream getResourceAsStream(String path) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public RequestDispatcher getRequestDispatcher(String path) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public RequestDispatcher getNamedDispatcher(String name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Servlet getServlet(String name) throws ServletException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Enumeration<Servlet> getServlets() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Enumeration<String> getServletNames() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void log(String msg) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void log(Exception exception, String msg) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void log(String message, Throwable throwable) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public String getRealPath(String path) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getServerInfo() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getInitParameter(String name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Enumeration<String> getInitParameterNames() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean setInitParameter(String name, String value) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public Object getAttribute(String name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Enumeration<String> getAttributeNames() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void setAttribute(String name, Object object) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void removeAttribute(String name) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public String getServletContextName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Dynamic addServlet(String servletName, String className) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Dynamic addServlet(String servletName, Servlet servlet) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Dynamic addServlet(String servletName, Class<? extends Servlet> servletClass) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public <T extends Servlet> T createServlet(Class<T> clazz) throws ServletException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ServletRegistration getServletRegistration(String servletName) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Map<String, ? extends ServletRegistration> getServletRegistrations() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public javax.servlet.FilterRegistration.Dynamic addFilter(String filterName, String className) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public javax.servlet.FilterRegistration.Dynamic addFilter(String filterName, Filter filter) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public javax.servlet.FilterRegistration.Dynamic addFilter(String filterName, Class<? extends Filter> filterClass) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public <T extends Filter> T createFilter(Class<T> clazz) throws ServletException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public FilterRegistration getFilterRegistration(String filterName) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Map<String, ? extends FilterRegistration> getFilterRegistrations() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public SessionCookieConfig getSessionCookieConfig() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void setSessionTrackingModes(Set<SessionTrackingMode> sessionTrackingModes) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Set<SessionTrackingMode> getDefaultSessionTrackingModes() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Set<SessionTrackingMode> getEffectiveSessionTrackingModes() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void addListener(String className) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public <T extends EventListener> void addListener(T t) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void addListener(Class<? extends EventListener> listenerClass) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public <T extends EventListener> T createListener(Class<T> clazz) throws ServletException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public JspConfigDescriptor getJspConfigDescriptor() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ClassLoader getClassLoader() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void declareRoles(String... roleNames) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public String getVirtualServerName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}