update link to upper-constraints.txt
[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.core.classloader.annotations.PowerMockIgnore;
39 import org.powermock.modules.junit4.PowerMockRunner;
40
41 import com.fasterxml.jackson.core.type.TypeReference;
42 import com.fasterxml.jackson.databind.ObjectMapper;
43
44 @RunWith(PowerMockRunner.class)
45 @PowerMockIgnore("jdk.internal.reflect.*")
46 public class ServicePropertiesMapTest {
47
48         @InjectMocks
49         ServicePropertiesMap map;
50
51
52         @Before
53         public void setUp() throws Exception {
54         }
55
56         @After
57         public void tearDown() throws Exception {
58         }
59
60         /*@Test
61         public void testRefresh() {
62
63                 try {
64                         map.refresh(new File(":/file"));
65                 } catch (Exception e) {
66                         e.printStackTrace();
67                 }
68
69                 assertTrue(true);
70
71         }
72
73         @Test()
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()));
79                 
80                 assertTrue(true);
81         }
82         
83         @Test
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()));
89                         assertTrue(true);
90         }*/
91
92         @Test
93         public void testGetProperty() {
94
95                 try {
96                         map.getProperty("filename", "propertykey");
97                 } catch (Exception e) {
98                         e.printStackTrace();
99                 }
100
101                 assertTrue(true);
102         }
103
104         @Test
105         public void testGetProperties() {
106
107                 try {
108                         map.getProperties("filename");
109                 } catch (Exception e) {
110                         e.printStackTrace();
111                 }
112
113                 assertTrue(true);
114
115         }
116
117         @Test
118         public void testIfNullThenEmpty() {
119
120                 try {
121                         map.getProperties("filename");
122                 } catch (Exception e) {
123                         e.printStackTrace();
124                 }
125
126                 assertTrue(true);
127
128         }
129
130 }