0dcb3a9d4ba99aec490c30fff8b43bce8cfe03ac
[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 public class JU_PropAccessTest {\r
41 \r
42         @Before\r
43         public void setUp() throws Exception {\r
44         }\r
45 \r
46         @Test\r
47         public void testPropAccess() throws IOException {\r
48                 PropAccess p = new PropAccess(new Object());\r
49                 \r
50                 assertNotNull(p);\r
51                 assertNotNull(p.getProperties());\r
52                 assertNull(p.getProperty("anything"));\r
53                 \r
54                 p.setProperty("prop", "value");\r
55                 assertEquals(p.getProperty("prop"), "value");\r
56                 \r
57                 p.setProperty(Config.CADI_KEYFILE, "value");\r
58                 assertEquals(p.getProperty("prop"), "value");\r
59                 \r
60                 p.setLogLevel(Level.INFO);\r
61                 assertTrue(p.willLog(Level.INFO));\r
62                 p.log(Level.DEBUG, new Object());\r
63                 String[] args = {"key=value","wow=wow"};\r
64                 p = new PropAccess(args);\r
65         }\r
66         \r
67         @Test\r
68         public void testPropAccessone() throws IOException {\r
69                 PropAccess p = new PropAccess(new Object());\r
70                 \r
71                 assertNotNull(p);\r
72                 assertNotNull(p.getProperties());\r
73                 assertNull(p.getProperty("everything"));\r
74                 \r
75                 p.setProperty("prop1", "value1");\r
76                 assertEquals(p.getProperty("prop1"), "value1");\r
77                 \r
78                 p.setProperty(Config.CADI_KEYFILE, "value1");\r
79                 assertEquals(p.getProperty("prop1"), "value1");\r
80                 \r
81                 p.setLogLevel(Level.INFO);\r
82                 assertTrue(p.willLog(Level.INFO));\r
83                 p.log(Level.DEBUG, new Object());\r
84                 String[] args = {"key=value1","wow=wow1"};\r
85                 p = new PropAccess(args);\r
86         }\r
87         \r
88         @Test\r
89         public void testPropAccesstwo() throws IOException {\r
90                 PropAccess p = new PropAccess(new Object());\r
91                 \r
92                 assertNotNull(p);\r
93                 assertNotNull(p.getProperties());\r
94                 assertNull(p.getProperty("everythingone"));\r
95                 \r
96                 p.setProperty("prop12", "value12");\r
97                 assertEquals(p.getProperty("prop12"), "value12");\r
98                 \r
99                 p.setProperty(Config.CADI_KEYFILE, "value12");\r
100                 assertEquals(p.getProperty("prop12"), "value12");\r
101                 \r
102                 p.setLogLevel(Level.INFO);\r
103                 assertTrue(p.willLog(Level.INFO));\r
104                 p.log(Level.DEBUG, new Object());\r
105                 String[] args = {"key=value12","wow=wow12"};\r
106                 p = new PropAccess(args);\r
107         }\r
108 \r
109 }