\r
private static String ACTUAL_HOSTNAME = System.getenv(HOSTNAME);\r
\r
-\r
@Test\r
public void getMsbServerAddrTest() {\r
System.setProperty(MSB_IAG_SERVICE_HOST, "test");\r
}\r
\r
@Test\r
- public void getConfigBindingServiceAddrInfoTest_consul_exists_propertie_not_exist() throws Exception {\r
+ public void getConfigBindingServiceAddrInfoTest_consul_return_empty_array() throws Exception {\r
+ System.setProperty(CONFIG_BINDING_SERVICE, "config_binding_service");\r
+ PowerMock.mockStaticPartial(MicroServiceConfig.class, "execQuery", String.class);\r
+ PowerMock.expectPrivate(MicroServiceConfig.class, "execQuery", EasyMock.anyObject())\r
+ .andReturn("[]");\r
+ System.setProperty(CONSUL_HOST, "127.0.0.1");\r
+\r
+ PowerMock.replayAll();\r
+\r
+ assertThat(getServiceAddrInfoFromDcaeConsulByHostName(System.getProperty(CONFIG_BINDING_SERVICE)),\r
+ is(nullValue()));\r
+\r
+ PowerMock.verifyAll();\r
+\r
+ System.clearProperty(CONSUL_HOST);\r
+ System.clearProperty(CONFIG_BINDING_SERVICE);\r
+ }\r
+\r
+ @Test\r
+ public void getConfigBindingServiceAddrInfoTest_consul_exists_property_not_exist() throws Exception {\r
System.setProperty(CONFIG_BINDING_SERVICE, "config_binding_service");\r
PowerMock.mockStaticPartial(MicroServiceConfig.class, "execQuery", String.class);\r
PowerMock.expectPrivate(MicroServiceConfig.class, "execQuery", EasyMock.anyObject())\r
\r
System.clearProperty(HOSTNAME);\r
}\r
-\r
- @Test\r
- public void isValidIpAddress_with_port() throws Exception {\r
- boolean res = WhiteboxImpl.invokeMethod(MicroServiceConfig.class, "isIpAddress", "10.75.13.21:90");\r
- assertThat(res, is(true));\r
- }\r
-\r
- @Test\r
- public void isValidIpAddress_without_port() throws Exception {\r
- boolean res = WhiteboxImpl.invokeMethod(MicroServiceConfig.class, "isIpAddress", "10.75.13.21");\r
- assertThat(res, is(true));\r
- }\r
-\r
- @Test\r
- public void isValidIpAddress_with_port_with_http_prefix() throws Exception {\r
- boolean res = WhiteboxImpl.invokeMethod(MicroServiceConfig.class, "isIpAddress", "http://10.75.13.21:90");\r
- assertThat(res, is(true));\r
- }\r
-\r
- @Test\r
- public void isValidIpAddress_without_port_with_https_prefix() throws Exception {\r
- boolean res = WhiteboxImpl.invokeMethod(MicroServiceConfig.class, "isIpAddress", "https://10.75.13.21");\r
- assertThat(res, is(true));\r
- }\r
-\r
- @Test\r
- public void isValidIpAddress_invalid_ip_without_port() throws Exception {\r
- boolean res = WhiteboxImpl.invokeMethod(MicroServiceConfig.class, "isIpAddress", "holmes-rule-mgmt");\r
- assertThat(res, is(false));\r
- }\r
-\r
- @Test\r
- public void isValidIpAddress_invalid_ip_with_port() throws Exception {\r
- boolean res = WhiteboxImpl.invokeMethod(MicroServiceConfig.class, "isIpAddress", "holmes-rule-mgmt:443");\r
- assertThat(res, is(false));\r
- }\r
-\r
- @Test\r
- public void isValidIpAddress_invalid_ip_without_port_with_http_prefix() throws Exception {\r
- boolean res = WhiteboxImpl.invokeMethod(MicroServiceConfig.class, "isIpAddress", "http://holmes-rule-mgmt");\r
- assertThat(res, is(false));\r
- }\r
-\r
- @Test\r
- public void isValidIpAddress_invalid_ip_with_port_with_https_prefix() throws Exception {\r
- boolean res = WhiteboxImpl.invokeMethod(MicroServiceConfig.class, "isIpAddress", "https://holmes-rule-mgmt:443");\r
- assertThat(res, is(false));\r
- }\r
}
\ No newline at end of file