2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017-2018 Amdocs
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.aai.sparky.util;
24 import static org.junit.Assert.assertFalse;
25 import static org.junit.Assert.assertNotNull;
26 import static org.hamcrest.MatcherAssert.assertThat;
28 import java.io.IOException;
29 import java.nio.file.FileSystems;
30 import java.util.Properties;
32 import org.junit.Before;
33 import org.junit.Test;
34 import static org.junit.Assert.assertEquals;
35 public class ConfigHelperTest {
37 private ConfigHelper configHelper;
38 private Properties props;
41 public void init() throws Exception {
42 configHelper = new ConfigHelper();
43 props = new Properties();
47 @SuppressWarnings("static-access")
49 public void updateValues() throws Exception {
51 assertNotNull(configHelper.getConfigWithPrefix("aai-ui", props));
52 assertFalse(configHelper.isEssDevModeEnabled());
53 assertNotNull(configHelper.getFilepath("sparky-aaui", false));
58 public void getFileContents() {
59 File file = new File(getClass().getClassLoader().getResource("configHelperTest.properties").getFile());
61 assertNotNull(ConfigHelper.getFileContents(file.getAbsolutePath()));
62 } catch (IOException e) {
68 public void loadConfig() throws Exception {
69 String separator = FileSystems.getDefault().getSeparator();
70 assertEquals(3, ConfigHelper.loadConfig("target"+separator+"test-classes"+separator+"configHelperTest.properties").size());
74 public void propertyFetch() throws Exception {
75 Properties p=new Properties();
76 p.setProperty("key1","value1");
77 assertEquals(ConfigHelper.propertyFetch(p,"key1","value2"),"value1");
78 assertEquals(ConfigHelper.propertyFetch(p,"key2","value2"),"value2");