2 * ============LICENSE_START=======================================================
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
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.pap.xacml.rest;
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;
28 public class XACMLPapServletTest {
30 public void testSetAndGet() {
31 String systemKey = "xacml.properties";
32 String testVal = "testVal";
33 XACMLPapServlet servlet = new XACMLPapServlet();
35 // Set the system property temporarily
36 String oldProperty = System.getProperty(systemKey);
37 System.setProperty(systemKey, "xacml.pap.properties");
39 assertNotNull(XACMLPapServlet.getConfigHome());
40 assertNotNull(XACMLPapServlet.getActionHome());
41 assertEquals(XACMLPapServlet.getPersistenceUnit(), "XACML-PAP-REST");
43 //assertNull(XACMLPapServlet.getEmf());
44 //assertNull(XACMLPapServlet.getPDPFile());
45 //assertNull(XACMLPapServlet.getPAPEngine());
46 //assertNull(servlet.getIa());
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);
61 // Restore the original system property
62 if (oldProperty != null) {
63 System.setProperty(systemKey, oldProperty);
66 System.clearProperty(systemKey);