1 /*******************************************************************************
\r
2 * ============LICENSE_START====================================================
\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
11 * * http://www.apache.org/licenses/LICENSE-2.0
\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
20 * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
\r
22 ******************************************************************************/
\r
23 package org.onap.aaf.cadi;
\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
32 import java.io.IOException;
\r
33 import java.util.Properties;
\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
40 public class JU_PropAccessTest {
\r
43 public void setUp() throws Exception {
\r
47 public void testPropAccess() throws IOException {
\r
48 PropAccess p = new PropAccess(new Object());
\r
51 assertNotNull(p.getProperties());
\r
52 assertNull(p.getProperty("anything"));
\r
54 p.setProperty("prop", "value");
\r
55 assertEquals(p.getProperty("prop"), "value");
\r
57 p.setProperty(Config.CADI_KEYFILE, "value");
\r
58 assertEquals(p.getProperty("prop"), "value");
\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
68 public void testPropAccessone() throws IOException {
\r
69 PropAccess p = new PropAccess(new Object());
\r
72 assertNotNull(p.getProperties());
\r
73 assertNull(p.getProperty("everything"));
\r
75 p.setProperty("prop1", "value1");
\r
76 assertEquals(p.getProperty("prop1"), "value1");
\r
78 p.setProperty(Config.CADI_KEYFILE, "value1");
\r
79 assertEquals(p.getProperty("prop1"), "value1");
\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
89 public void testPropAccesstwo() throws IOException {
\r
90 PropAccess p = new PropAccess(new Object());
\r
93 assertNotNull(p.getProperties());
\r
94 assertNull(p.getProperty("everythingone"));
\r
96 p.setProperty("prop12", "value12");
\r
97 assertEquals(p.getProperty("prop12"), "value12");
\r
99 p.setProperty(Config.CADI_KEYFILE, "value12");
\r
100 assertEquals(p.getProperty("prop12"), "value12");
\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