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