2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 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
21 package com.att.nsa.dmaap.filemonitor;
\r
23 import static org.junit.Assert.*;
\r
25 import java.io.File;
\r
26 import java.io.FileNotFoundException;
\r
27 import java.nio.file.Path;
\r
28 import java.nio.file.Paths;
\r
29 import java.util.HashMap;
\r
31 import org.junit.After;
\r
32 import org.junit.Before;
\r
33 import org.junit.Test;
\r
34 import org.junit.runner.RunWith;
\r
35 import org.mockito.InjectMocks;
\r
36 import org.mockito.Mock;
\r
37 import org.powermock.api.mockito.PowerMockito;
\r
38 import org.powermock.modules.junit4.PowerMockRunner;
\r
40 import com.fasterxml.jackson.core.type.TypeReference;
\r
41 import com.fasterxml.jackson.databind.ObjectMapper;
\r
43 @RunWith(PowerMockRunner.class)
\r
44 public class ServicePropertiesMapTest {
\r
47 ServicePropertiesMap map;
\r
51 public void setUp() throws Exception {
\r
55 public void tearDown() throws Exception {
\r
59 public void testRefresh() {
\r
62 map.refresh(new File(":/file"));
\r
63 } catch (Exception e) {
\r
64 e.printStackTrace();
\r
72 public void testRefreshJsonFile() throws Exception {
\r
73 //Path resourceDirectory = Paths.get("src/test/resources");
\r
74 // map.refresh(new File(resourceDirectory+"\\"+"test.json"));
\r
75 ClassLoader classLoader = getClass().getClassLoader();
\r
76 map.refresh(new File(classLoader.getResource("test.json").getFile()));
\r
82 public void testRefreshPropsFile() throws Exception {
\r
83 /*Path resourceDirectory = Paths.get("src/test/resources");
\r
84 map.refresh(new File(resourceDirectory+"\\"+"test.properties"));*/
\r
85 ClassLoader classLoader = getClass().getClassLoader();
\r
86 map.refresh(new File(classLoader.getResource("test.json").getFile()));
\r
91 public void testGetProperty() {
\r
94 map.getProperty("filename", "propertykey");
\r
95 } catch (Exception e) {
\r
96 e.printStackTrace();
\r
103 public void testGetProperties() {
\r
106 map.getProperties("filename");
\r
107 } catch (Exception e) {
\r
108 e.printStackTrace();
\r
116 public void testIfNullThenEmpty() {
\r
119 map.getProperties("filename");
\r
120 } catch (Exception e) {
\r
121 e.printStackTrace();
\r