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.modules.junit4.PowerMockRunner;
40 import com.fasterxml.jackson.core.type.TypeReference;
41 import com.fasterxml.jackson.databind.ObjectMapper;
43 @RunWith(PowerMockRunner.class)
44 public class ServicePropertiesMapTest {
47 ServicePropertiesMap map;
51 public void setUp() throws Exception {
55 public void tearDown() throws Exception {
59 public void testRefresh() {
62 map.refresh(new File(":/file"));
63 } catch (Exception e) {
72 public void testRefreshJsonFile() throws Exception {
73 //Path resourceDirectory = Paths.get("src/test/resources");
74 // map.refresh(new File(resourceDirectory+"\\"+"test.json"));
75 ClassLoader classLoader = getClass().getClassLoader();
76 map.refresh(new File(classLoader.getResource("test.json").getFile()));
82 public void testRefreshPropsFile() throws Exception {
83 Path resourceDirectory = Paths.get("src/test/resources");
84 map.refresh(new File(resourceDirectory+"\\"+"test.properties"));
85 ClassLoader classLoader = getClass().getClassLoader();
86 map.refresh(new File(classLoader.getResource("test.json").getFile()));
91 public void testGetProperty() {
94 map.getProperty("filename", "propertykey");
95 } catch (Exception e) {
103 public void testGetProperties() {
106 map.getProperties("filename");
107 } catch (Exception e) {
116 public void testIfNullThenEmpty() {
119 map.getProperties("filename");
120 } catch (Exception e) {