3630889b0e676f80ad72bde25e004f892dfca7d2
[policy/engine.git] / ONAP-PAP-REST / src / test / java / org / onap / policy / pap / xacml / rest / XACMLPapServletTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP-PAP-REST
4  * ================================================================================
5  * Copyright (C) 2018 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.pap.xacml.rest;
22
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertNotNull;
25 import org.junit.Test;
26 import org.onap.policy.pap.xacml.rest.XACMLPapServlet;
27
28 public class XACMLPapServletTest {
29         @Test
30         public void testSetAndGet() {
31                 String systemKey = "xacml.properties";
32                 String testVal = "testVal";
33                 XACMLPapServlet servlet = new XACMLPapServlet();
34                 
35                 // Set the system property temporarily
36                 String oldProperty = System.getProperty(systemKey);
37                 System.setProperty(systemKey, "xacml.pap.properties");
38                                 
39                 assertNotNull(XACMLPapServlet.getConfigHome());
40                 assertNotNull(XACMLPapServlet.getActionHome());
41                 assertEquals(XACMLPapServlet.getPersistenceUnit(), "XACML-PAP-REST");
42
43                 //assertNull(XACMLPapServlet.getEmf());
44                 //assertNull(XACMLPapServlet.getPDPFile());
45                 //assertNull(XACMLPapServlet.getPAPEngine());
46                 //assertNull(servlet.getIa());
47                 
48                 XACMLPapServlet.setPapDbDriver(testVal);
49                 assertEquals(XACMLPapServlet.getPapDbDriver(), testVal);
50                 XACMLPapServlet.setPapDbUrl(testVal);
51                 assertEquals(XACMLPapServlet.getPapDbUrl(), testVal);
52                 XACMLPapServlet.setPapDbUser(testVal);
53                 assertEquals(XACMLPapServlet.getPapDbUser(), testVal);
54                 XACMLPapServlet.setPapDbPassword(testVal);
55                 assertEquals(XACMLPapServlet.getPapDbPassword(), testVal);
56                 XACMLPapServlet.setMsOnapName(testVal);
57                 assertEquals(XACMLPapServlet.getMsOnapName(), testVal);
58                 XACMLPapServlet.setMsPolicyName(testVal);
59                 assertEquals(XACMLPapServlet.getMsPolicyName(), testVal);
60                 
61                 // Restore the original system property
62                 if (oldProperty != null) {
63                         System.setProperty(systemKey,  oldProperty);
64                 }
65                 else {
66                         System.clearProperty(systemKey);
67                 }
68         }
69 }