2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.rest;
23 /*import java.io.IOException;
24 import java.io.InputStream;
25 import java.util.ArrayList;
26 import java.util.Collections;
27 import java.util.List;
28 import java.util.Properties;
29 import java.util.Random;
31 import javax.servlet.ServletConfig;
32 import javax.servlet.ServletInputStream;
33 import javax.servlet.ServletOutputStream;
34 import javax.servlet.http.HttpServletRequest;
35 import javax.servlet.http.HttpServletResponse;
37 import junit.framework.TestCase;
39 import org.apache.commons.logging.Log;
40 import org.apache.commons.logging.LogFactory;
41 import org.junit.Before;
42 import org.junit.Test;
43 import org.mockito.Mockito;
44 import org.springframework.mock.web.MockHttpServletResponse;
45 import org.springframework.mock.web.MockServletConfig;
47 import com.att.research.xacml.util.XACMLProperties;
48 import com.mockrunner.mock.web.MockServletInputStream;
50 public class XACMLRestTest extends TestCase{
51 private static Log logger = LogFactory.getLog(XACMLRestTest.class);
53 private List<String> headers = new ArrayList<String>();
55 private HttpServletRequest httpServletRequest;
56 private HttpServletResponse httpServletResponse;
57 private ServletOutputStream mockOutput;
58 private ServletInputStream mockInput;
59 private ServletConfig servletConfig;
64 httpServletRequest = Mockito.mock(HttpServletRequest.class);
65 Mockito.when(httpServletRequest.getMethod()).thenReturn("POST");
66 Mockito.when(httpServletRequest.getHeaderNames()).thenReturn(Collections.enumeration(headers));
67 Mockito.when(httpServletRequest.getAttributeNames()).thenReturn(Collections.enumeration(headers));
69 mockOutput = Mockito.mock(ServletOutputStream.class);
71 httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
74 Mockito.when(httpServletResponse.getOutputStream()).thenReturn(mockOutput);
75 } catch (IOException e) {
79 servletConfig = Mockito.mock(MockServletConfig.class);
80 Mockito.when(servletConfig.getInitParameterNames()).thenReturn(Collections.enumeration(headers));
81 //pdpServlet = new XACMLPdpServlet();
83 Mockito.when(servletConfig.getInitParameter("XACML_PROPERTIES_NAME")).thenReturn("xacml.pdp.properties");
85 System.setProperty("xacml.properties", "xacml.pdp.properties");
86 System.setProperty("xacml.rest.pdp.config", "config_testing");
87 System.setProperty("xacml.rest.pep.idfile", "testclient.properties");
88 System.setProperty("xacml.rest.pdp.webapps", "/webapps");
89 System.setProperty("xacml.rootPolicies", "test_PolicyEngine.xml");
90 System.setProperty("xacml.referencedPolicies", "test_PolicyEngine.xml");
91 System.setProperty("test_PolicyEngine.xml.file", "config_testing\\test_PolicyEngine.xml");
92 System.setProperty("xacml.rest.pdp.register", "false");
96 public void testDummy(){
97 logger.info("XACMLRestTest - testInit");
100 } catch (Exception e) {