diff options
author | Pamela Dragosh <pdragosh@research.att.com> | 2017-02-14 19:41:00 -0500 |
---|---|---|
committer | Pamela Dragosh <pdragosh@research.att.com> | 2017-02-14 19:41:32 -0500 |
commit | 91d04c64771832a0b8815ffbe1f0f9920320d94d (patch) | |
tree | fb02d5e1c84a3d91def9a7ee95bc87f9c046cc96 /ECOMP-REST/src/test | |
parent | b9d4caa40ef8e3566ac475968bce17b9b64b6939 (diff) |
Initial OpenECOMP policy/engine commit
Change-Id: I7dbff37733b661643dd4d1caefa3d7dccc361b6e
Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'ECOMP-REST/src/test')
-rw-r--r-- | ECOMP-REST/src/test/java/org/openecomp/policy/rest/XACMLRestTest.java | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/ECOMP-REST/src/test/java/org/openecomp/policy/rest/XACMLRestTest.java b/ECOMP-REST/src/test/java/org/openecomp/policy/rest/XACMLRestTest.java new file mode 100644 index 000000000..0d9355ad5 --- /dev/null +++ b/ECOMP-REST/src/test/java/org/openecomp/policy/rest/XACMLRestTest.java @@ -0,0 +1,108 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * Copyright (C) 2017 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.openecomp.policy.rest; + +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Properties; +import java.util.Random; + +import javax.servlet.ServletConfig; +import javax.servlet.ServletInputStream; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import junit.framework.TestCase; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; +import org.springframework.mock.web.MockHttpServletResponse; +import org.springframework.mock.web.MockServletConfig; + +import com.att.research.xacml.util.XACMLProperties; +import com.mockrunner.mock.web.MockServletInputStream; + +public class XACMLRestTest extends TestCase{ + private static Log logger = LogFactory.getLog(XACMLRestTest.class); + + private List<String> headers = new ArrayList<String>(); + + private HttpServletRequest httpServletRequest; + private HttpServletResponse httpServletResponse; + private ServletOutputStream mockOutput; + private ServletInputStream mockInput; + private ServletConfig servletConfig; + + + @Before + public void setUp(){ + httpServletRequest = Mockito.mock(HttpServletRequest.class); + Mockito.when(httpServletRequest.getMethod()).thenReturn("POST"); + Mockito.when(httpServletRequest.getHeaderNames()).thenReturn(Collections.enumeration(headers)); + Mockito.when(httpServletRequest.getAttributeNames()).thenReturn(Collections.enumeration(headers)); + + mockOutput = Mockito.mock(ServletOutputStream.class); + + httpServletResponse = Mockito.mock(MockHttpServletResponse.class); + + try { + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(mockOutput); + } catch (IOException e) { + // TODO Auto-generated catch block + fail(); + } + + servletConfig = Mockito.mock(MockServletConfig.class); + Mockito.when(servletConfig.getInitParameterNames()).thenReturn(Collections.enumeration(headers)); + //pdpServlet = new XACMLPdpServlet(); + + Mockito.when(servletConfig.getInitParameter("XACML_PROPERTIES_NAME")).thenReturn("xacml.pdp.properties"); + + System.setProperty("xacml.properties", "xacml.pdp.properties"); + System.setProperty("xacml.rest.pdp.config", "config_testing"); + System.setProperty("xacml.rest.pep.idfile", "testclient.properties"); + System.setProperty("xacml.rest.pdp.webapps", "/webapps"); + System.setProperty("xacml.rootPolicies", "test_PolicyEngine.xml"); + System.setProperty("xacml.referencedPolicies", "test_PolicyEngine.xml"); + System.setProperty("test_PolicyEngine.xml.file", "config_testing\\test_PolicyEngine.xml"); + System.setProperty("xacml.rest.pdp.register", "false"); + } + + @Test + public void testDummy(){ + logger.info("XACMLRestTest - testInit"); + try { + assertTrue(true); + } catch (Exception e) { + // TODO Auto-generated catch block + fail(); + + } + + } +} |