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 \r
34 import org.junit.Before;\r
35 import org.junit.Test;\r
36 import org.onap.aaf.cadi.Access.Level;\r
37 import org.onap.aaf.cadi.config.Config;\r
38 \r
39 public class JU_PropAccessTest {\r
40 \r
41         @Before\r
42         public void setUp() throws Exception {\r
43         }\r
44 \r
45         @Test\r
46         public void testPropAccess() throws IOException {\r
47                 PropAccess p = new PropAccess(new Object());\r
48                 \r
49                 assertNotNull(p);\r
50                 assertNotNull(p.getProperties());\r
51                 assertNull(p.getProperty("anything"));\r
52                 \r
53                 p.setProperty("prop", "value");\r
54                 assertEquals(p.getProperty("prop"), "value");\r
55                 \r
56                 p.setProperty(Config.CADI_KEYFILE, "value");\r
57                 assertEquals(p.getProperty("prop"), "value");\r
58                 \r
59                 p.setLogLevel(Level.INFO);\r
60                 assertTrue(p.willLog(Level.INFO));\r
61                 p.log(Level.DEBUG, new Object());\r
62                 String[] args = {"key=value","wow=wow"};\r
63                 p = new PropAccess(args);\r
64         }\r
65         \r
66         @Test\r
67         public void testPropAccessone() throws IOException {\r
68                 PropAccess p = new PropAccess(new Object());\r
69                 \r
70                 assertNotNull(p);\r
71                 assertNotNull(p.getProperties());\r
72                 assertNull(p.getProperty("everything"));\r
73                 \r
74                 p.setProperty("prop1", "value1");\r
75                 assertEquals(p.getProperty("prop1"), "value1");\r
76                 \r
77                 p.setProperty(Config.CADI_KEYFILE, "value1");\r
78                 assertEquals(p.getProperty("prop1"), "value1");\r
79                 \r
80                 p.setLogLevel(Level.INFO);\r
81                 assertTrue(p.willLog(Level.INFO));\r
82                 p.log(Level.DEBUG, new Object());\r
83                 String[] args = {"key=value1","wow=wow1"};\r
84                 p = new PropAccess(args);\r
85         }\r
86 \r
87 }\r
88 \r