Improve code coverage for aaf cadi modules
[aaf/cadi.git] / core / src / test / java / org / onap / aaf / cadi / JU_PropAccessTest.java
1 /*******************************************************************************\r
2  * ============LICENSE_START====================================================\r
3  * * org.onap.aaf\r
4  * * ===========================================================================\r
5  * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
6  * * ===========================================================================\r
7  * * Licensed under the Apache License, Version 2.0 (the "License");\r
8  * * you may not use this file except in compliance with the License.\r
9  * * You may obtain a copy of the License at\r
10  * * \r
11  *  *      http://www.apache.org/licenses/LICENSE-2.0\r
12  * * \r
13  *  * Unless required by applicable law or agreed to in writing, software\r
14  * * distributed under the License is distributed on an "AS IS" BASIS,\r
15  * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  * * See the License for the specific language governing permissions and\r
17  * * limitations under the License.\r
18  * * ============LICENSE_END====================================================\r
19  * *\r
20  * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
21  * *\r
22  ******************************************************************************/\r
23 package org.onap.aaf.cadi;\r
24 \r
25 \r
26 import static org.junit.Assert.assertEquals;\r
27 import static org.junit.Assert.assertFalse;\r
28 import static org.junit.Assert.assertNotNull;\r
29 import static org.junit.Assert.assertNull;\r
30 import static org.junit.Assert.assertTrue;\r
31 \r
32 import java.io.IOException;\r
33 import java.util.Properties;\r
34 \r
35 import org.junit.Before;\r
36 import org.junit.Test;\r
37 import org.onap.aaf.cadi.Access.Level;\r
38 import org.onap.aaf.cadi.config.Config;\r
39 \r
40 import java.util.Properties;\r
41 \r
42 import org.junit.Test;\r
43 import org.onap.aaf.cadi.Access.Level;\r
44 \r
45 public class JU_PropAccessTest {\r
46 \r
47         @Test\r
48         public void test() {\r
49                 PropAccess prop = new PropAccess(new Object());\r
50                 \r
51                 prop = new PropAccess("cadi_name=user","cadi_loglevel=DEBUG","cadi_prop_files=test/cadi.properties");\r
52                 \r
53                 assertTrue(prop.getProperties().keySet().contains("cadi_name"));\r
54                 assertTrue(prop.getProperty("cadi_name").equals("user"));\r
55                 \r
56                 prop.setProperty("cadi_keyfile", "file");\r
57                 prop.setLogLevel(Level.DEBUG);\r
58                 assertEquals(prop.getProperty("cadi_keyfile"),"file");\r
59 //              assertEquals(prop.getDME2Properties().size(),3);\r
60                 prop.log(Level.DEBUG);\r
61         }\r
62         \r
63         @Test\r
64         public void testWithProperties() {\r
65                 Properties p = new Properties();\r
66                 p.put("cadi_name", "user");\r
67                 p.put("cadi_loglevel", "DEBUG");\r
68                 \r
69                 PropAccess prop = new PropAccess(p);\r
70                 \r
71                 assertTrue(prop.getProperties().keySet().contains("cadi_name"));\r
72                 assertTrue(prop.getProperty("cadi_name").equals("user"));\r
73                 \r
74                 prop.setProperty("cadi_keyfile", "file");\r
75                 prop.setLogLevel(Level.DEBUG);\r
76                 assertEquals(prop.getProperty("cadi_keyfile"),"file");\r
77 //              assertEquals(prop.getDME2Properties().size(),3);\r
78                 prop.log(Level.DEBUG);\r
79         }\r
80 }\r