2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.dmaap.filemonitor;
23 import static org.junit.Assert.*;
26 import java.io.FileNotFoundException;
27 import java.nio.file.Path;
28 import java.nio.file.Paths;
29 import java.util.HashMap;
31 import org.junit.After;
32 import org.junit.Before;
33 import org.junit.Test;
34 import org.junit.runner.RunWith;
35 import org.mockito.InjectMocks;
36 import org.mockito.Mock;
37 import org.powermock.api.mockito.PowerMockito;
38 import org.powermock.core.classloader.annotations.PowerMockIgnore;
39 import org.powermock.modules.junit4.PowerMockRunner;
41 import com.fasterxml.jackson.core.type.TypeReference;
42 import com.fasterxml.jackson.databind.ObjectMapper;
44 @RunWith(PowerMockRunner.class)
45 @PowerMockIgnore("jdk.internal.reflect.*")
46 public class ServicePropertiesMapTest {
49 ServicePropertiesMap map;
53 public void setUp() throws Exception {
57 public void tearDown() throws Exception {
61 public void testRefresh() {
64 map.refresh(new File(":/file"));
65 } catch (Exception e) {
74 public void testRefreshJsonFile() throws Exception {
75 //Path resourceDirectory = Paths.get("src/test/resources");
76 // map.refresh(new File(resourceDirectory+"\\"+"test.json"));
77 ClassLoader classLoader = getClass().getClassLoader();
78 map.refresh(new File(classLoader.getResource("test.json").getFile()));
84 public void testRefreshPropsFile() throws Exception {
85 Path resourceDirectory = Paths.get("src/test/resources");
86 map.refresh(new File(resourceDirectory+"\\"+"test.properties"));
87 ClassLoader classLoader = getClass().getClassLoader();
88 map.refresh(new File(classLoader.getResource("test.json").getFile()));
93 public void testGetProperty() {
96 map.getProperty("filename", "propertykey");
97 } catch (Exception e) {
105 public void testGetProperties() {
108 map.getProperties("filename");
109 } catch (Exception e) {
118 public void testIfNullThenEmpty() {
121 map.getProperties("filename");
122 } catch (Exception e) {