update the package name
[dmaap/messagerouter/messageservice.git] / src / test / java / org / onap / dmaap / filemonitor / ServicePropertiesMapTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP Policy Engine
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21  package org.onap.dmaap.filemonitor;
22
23 import static org.junit.Assert.*;
24
25 import java.io.File;
26 import java.io.FileNotFoundException;
27 import java.nio.file.Path;
28 import java.nio.file.Paths;
29 import java.util.HashMap;
30
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;
39
40 import com.fasterxml.jackson.core.type.TypeReference;
41 import com.fasterxml.jackson.databind.ObjectMapper;
42
43 @RunWith(PowerMockRunner.class)
44 public class ServicePropertiesMapTest {
45
46         @InjectMocks
47         ServicePropertiesMap map;
48
49
50         @Before
51         public void setUp() throws Exception {
52         }
53
54         @After
55         public void tearDown() throws Exception {
56         }
57
58         /*@Test
59         public void testRefresh() {
60
61                 try {
62                         map.refresh(new File(":/file"));
63                 } catch (Exception e) {
64                         e.printStackTrace();
65                 }
66
67                 assertTrue(true);
68
69         }
70
71         @Test()
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()));
77                 
78                 assertTrue(true);
79         }
80         
81         @Test
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()));
87                         assertTrue(true);
88         }*/
89
90         @Test
91         public void testGetProperty() {
92
93                 try {
94                         map.getProperty("filename", "propertykey");
95                 } catch (Exception e) {
96                         e.printStackTrace();
97                 }
98
99                 assertTrue(true);
100         }
101
102         @Test
103         public void testGetProperties() {
104
105                 try {
106                         map.getProperties("filename");
107                 } catch (Exception e) {
108                         e.printStackTrace();
109                 }
110
111                 assertTrue(true);
112
113         }
114
115         @Test
116         public void testIfNullThenEmpty() {
117
118                 try {
119                         map.getProperties("filename");
120                 } catch (Exception e) {
121                         e.printStackTrace();
122                 }
123
124                 assertTrue(true);
125
126         }
127
128 }