Introduce MSB Java SDK
[holmes/common.git] / holmes-actions / src / test / java / org / onap / holmes / common / config / MicroServiceConfigTest.java
1 /**\r
2  * Copyright 2017 ZTE Corporation.\r
3  *\r
4  * Licensed under the Apache License, Version 2.0 (the "License");\r
5  * you may not use this file except in compliance with the License.\r
6  * You may obtain a copy of the License at\r
7  *\r
8  *     http://www.apache.org/licenses/LICENSE-2.0\r
9  *\r
10  * Unless required by applicable law or agreed to in writing, software\r
11  * distributed under the License is distributed on an "AS IS" BASIS,\r
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  * See the License for the specific language governing permissions and\r
14  * limitations under the License.\r
15  */\r
16 \r
17 package org.onap.holmes.common.config;\r
18 \r
19 import static org.hamcrest.core.IsEqual.equalTo;\r
20 import static org.junit.Assert.assertThat;\r
21 import static org.junit.Assert.assertTrue;\r
22 \r
23 import org.junit.Test;\r
24 \r
25 public class MicroServiceConfigTest {\r
26 \r
27     @Test\r
28     public void getMsbServerAddrTest() {\r
29         System.setProperty("MSB_ADDR", "test");\r
30         assertThat("http://test", equalTo(MicroServiceConfig.getMsbServerAddr()));\r
31         System.clearProperty("MSB_ADDR");\r
32     }\r
33 \r
34     @Test\r
35     public void getMsbServerIpTest() {\r
36         System.setProperty("MSB_ADDR", "10.54.23.79");\r
37         assertThat("10.54.23.79", equalTo(MicroServiceConfig.getMsbServerIp()));\r
38         System.clearProperty("MSB_ADDR");\r
39     }\r
40 \r
41     @Test\r
42     public void getMsbPortTest() {\r
43         System.setProperty("MSB_PORT", "110");\r
44         assertTrue(110 == MicroServiceConfig.getMsbServerPort());\r
45         System.clearProperty("MSB_PORT");\r
46     }\r
47 \r
48     @Test\r
49     public void getMsbPortTestNonnumeric() {\r
50         System.setProperty("MSB_PORT", "test");\r
51         assertTrue(80 == MicroServiceConfig.getMsbServerPort());\r
52         System.clearProperty("MSB_PORT");\r
53     }\r
54 \r
55     @Test\r
56     public void getMsbPortTestNullValue() {\r
57         assertTrue(80 == MicroServiceConfig.getMsbServerPort());\r
58     }\r
59 \r
60     @Test\r
61     public void getServiceIpTest() {\r
62         System.setProperty("SERVICE_IP", "test");\r
63         assertThat("test", equalTo(MicroServiceConfig.getServiceIp()));\r
64         System.clearProperty("SERVICE_IP");\r
65     }\r
66 }