[POLICY-73] replace openecomp for policy-engine
[policy/engine.git] / ONAP-REST / src / test / java / org / onap / policy / rest / XACMLRestTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP-REST
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.onap.policy.rest;
22
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;
30
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;
36
37 import junit.framework.TestCase;
38
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;
46
47 import com.att.research.xacml.util.XACMLProperties;
48 import com.mockrunner.mock.web.MockServletInputStream;
49
50 public class XACMLRestTest extends TestCase{
51         private static Log logger       = LogFactory.getLog(XACMLRestTest.class);
52         
53         private List<String> headers = new ArrayList<String>();
54         
55         private HttpServletRequest httpServletRequest;
56         private HttpServletResponse httpServletResponse;
57         private ServletOutputStream mockOutput;
58         private ServletInputStream mockInput;
59         private ServletConfig servletConfig; 
60
61          
62     @Before
63     public void setUp(){
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));
68         
69         mockOutput = Mockito.mock(ServletOutputStream.class);
70         
71         httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
72         
73         try {
74                         Mockito.when(httpServletResponse.getOutputStream()).thenReturn(mockOutput);
75                 } catch (IOException e) {
76                         fail();
77                 }
78
79         servletConfig = Mockito.mock(MockServletConfig.class);
80         Mockito.when(servletConfig.getInitParameterNames()).thenReturn(Collections.enumeration(headers));
81         //pdpServlet = new XACMLPdpServlet();
82         
83         Mockito.when(servletConfig.getInitParameter("XACML_PROPERTIES_NAME")).thenReturn("xacml.pdp.properties");
84         
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");
93     }
94         
95     @Test
96         public void testDummy(){
97                 logger.info("XACMLRestTest - testInit");
98                 try {   
99                         assertTrue(true);
100                 } catch (Exception e) {
101                         fail();
102                         
103                 }
104
105         }
106 }
107 */