2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Modifications Copyright (C) 2019 Samsung
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
22 package org.onap.policy.pdp.rest.api.services;
24 import static org.junit.Assert.assertEquals;
26 import java.io.FileInputStream;
27 import java.io.FileNotFoundException;
28 import java.io.IOException;
29 import java.util.Arrays;
30 import java.util.List;
31 import java.util.Properties;
33 import org.junit.AfterClass;
34 import org.junit.BeforeClass;
35 import org.junit.Test;
36 import org.onap.policy.api.PolicyParameters;
38 public class BRMSRawPolicyServiceTest {
40 private static final String SYSTEM_KEY = "xacml.properties";
41 private static String oldProperty;
44 public static void setUpBeforeClass() throws Exception {
45 Properties prop = new Properties();
46 prop.load(new FileInputStream("src/test/resources/pass.xacml.pdp.properties"));
47 String succeeded = prop.getProperty("xacml.rest.pap.url");
48 List<String> paps = Arrays.asList(succeeded.split(","));
49 PAPServices.setPaps(paps);
50 PAPServices.setJunit(true);
51 oldProperty = System.getProperty(SYSTEM_KEY);
55 public static void tearDownAfterClass() {
56 PAPServices.setPaps(null);
57 PAPServices.setJunit(false);
58 // Restore the original system property
59 if (oldProperty != null) {
60 System.setProperty(SYSTEM_KEY, oldProperty);
62 System.clearProperty(SYSTEM_KEY);
67 public void testRaw() throws FileNotFoundException, IOException {
69 String testVal = "testVal";
70 PolicyParameters testParams = new PolicyParameters();
72 // Set the system property temporarily
73 System.setProperty(SYSTEM_KEY, "xacml.pdp.properties");
75 BRMSRawPolicyService service =
76 new BRMSRawPolicyService(testVal, testVal, testParams, testVal);
77 assertEquals(false, service.getValidation());
78 assertEquals("PE300 - Data Issue: No Rule Body given", service.getMessage());