[POLICY-73] replace openecomp for policy-engine
[policy/engine.git] / ONAP-XACML / src / test / java / org / onap / policy / xacml / test / util / XACMLPolicyWriterTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP-XACML
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 package org.onap.policy.xacml.test.util;
21
22 import static org.junit.Assert.assertTrue;
23
24 import java.io.File;
25 import java.io.IOException;
26 import java.nio.file.Path;
27
28 import org.apache.commons.logging.Log;
29 import org.apache.commons.logging.LogFactory;
30 import org.junit.Before;
31 import org.junit.Test;
32 import org.onap.policy.xacml.util.XACMLPolicyWriter;
33
34 public class XACMLPolicyWriterTest {
35         private static final Log logger                         = LogFactory.getLog(XACMLPolicyWriterTest.class);
36         private static Path configPolicyPathValue;
37         private static Path actionPolicyPathValue;
38         
39         @Before
40         public void setUp() {
41                 File templateFile;
42                 ClassLoader classLoader = getClass().getClassLoader();
43         try {
44                 templateFile = new File(classLoader.getResource("Config_SampleTest1206.1.xml").getFile());
45                 configPolicyPathValue = templateFile.toPath();
46                 templateFile = new File(classLoader.getResource("Action_TestActionPolicy.1.xml").getFile());
47                 actionPolicyPathValue = templateFile.toPath();
48                 } catch (Exception e1) {
49                         logger.error("Exception Occured"+e1);
50                 }
51         }
52         
53         @SuppressWarnings("static-access")
54         @Test
55         public void xacmlPolicyWriterTest() throws IOException{
56                 XACMLPolicyWriter writer = new XACMLPolicyWriter();
57                 String configResponseValue = writer.changeFileNameInXmlWhenRenamePolicy(configPolicyPathValue);
58                 assertTrue(configResponseValue.equals("txt"));
59                 String actionResponseValue = writer.changeFileNameInXmlWhenRenamePolicy(actionPolicyPathValue);
60                 assertTrue(actionResponseValue.equals("json"));
61         }
62 }