\r
private static String ACTUAL_HOSTNAME = System.getenv(HOSTNAME);\r
\r
-\r
@Test\r
public void getMsbServerAddrTest() {\r
- System.setProperty(MSB_ADDR, "test:80");\r
- assertThat("http://test:80", equalTo(getMsbServerAddrWithHttpPrefix()));\r
- System.clearProperty(MicroServiceConfig.MSB_ADDR);\r
+ System.setProperty(MSB_IAG_SERVICE_HOST, "test");\r
+ System.setProperty(MSB_IAG_SERVICE_PORT, "443");\r
+ assertThat("http://test:443", equalTo(getMsbServerAddrWithHttpPrefix()));\r
+ System.clearProperty(MicroServiceConfig.MSB_IAG_SERVICE_PORT);\r
+ System.clearProperty(MicroServiceConfig.MSB_IAG_SERVICE_HOST);\r
}\r
\r
@Test\r
public void getMsbServerIpTest() {\r
- System.setProperty(MSB_ADDR, "10.54.23.79:80");\r
+ System.setProperty(MSB_IAG_SERVICE_HOST, "10.54.23.79");\r
+ System.setProperty(MSB_IAG_SERVICE_PORT, "443");\r
System.setProperty(HOSTNAME, "rule-mgmt");\r
PowerMock.mockStaticPartial(MicroServiceConfig.class, "getServiceConfigInfoFromCBS", String.class);\r
EasyMock.expect(MicroServiceConfig.getServiceConfigInfoFromCBS(System.getProperty(HOSTNAME)))\r
- .andReturn("{\"msb.hostname\": \"10.54.23.79:80\"}").times(2);\r
+ .andReturn("{\"msb.hostname\": \"10.54.23.79:443\"}").times(2);\r
PowerMock.replayAll();\r
assertThat("10.54.23.79", equalTo(getMsbIpAndPort()[0]));\r
- assertThat("80", equalTo(getMsbIpAndPort()[1]));\r
+ assertThat("443", equalTo(getMsbIpAndPort()[1]));\r
System.clearProperty(MicroServiceConfig.HOSTNAME);\r
- System.clearProperty(MSB_ADDR);\r
+ System.clearProperty(MicroServiceConfig.MSB_IAG_SERVICE_PORT);\r
+ System.clearProperty(MicroServiceConfig.MSB_IAG_SERVICE_HOST);\r
}\r
\r
@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
@Ignore\r
public void getMsbAddrInfo_msb_registered() throws Exception {\r
- System.setProperty(MSB_ADDR, "10.74.5.8:1545");\r
+ System.setProperty(MSB_IAG_SERVICE_HOST, "10.74.5.8");\r
+ System.setProperty(MSB_IAG_SERVICE_PORT, "1545");\r
System.setProperty(HOSTNAME, "rule-mgmt");\r
PowerMock.mockStaticPartial(MicroServiceConfig.class, "getServiceConfigInfoFromCBS", String.class);\r
EasyMock.expect(MicroServiceConfig.getServiceConfigInfoFromCBS(System.getProperty(HOSTNAME)))\r
assertThat(msbInfo[1], equalTo("5432"));\r
\r
System.clearProperty(HOSTNAME);\r
- System.clearProperty(MSB_ADDR);\r
+ System.clearProperty(MSB_IAG_SERVICE_PORT);\r
+ System.clearProperty(MSB_IAG_SERVICE_HOST);\r
}\r
\r
@Ignore\r
public void getMsbAddrInfo_msb_not_registered() throws Exception {\r
- System.setProperty(MSB_ADDR, "10.74.5.8:1545");\r
+ System.setProperty(MSB_IAG_SERVICE_HOST, "10.74.5.8");\r
+ System.setProperty(MSB_IAG_SERVICE_PORT, "1545");\r
System.setProperty(HOSTNAME, "rule-mgmt");\r
PowerMock.mockStaticPartial(MicroServiceConfig.class, "getServiceConfigInfoFromCBS", String.class);\r
EasyMock.expect(MicroServiceConfig.getServiceConfigInfoFromCBS(System.getProperty(HOSTNAME)))\r
assertThat(msbInfo[1], equalTo("1545"));\r
\r
System.clearProperty(HOSTNAME);\r
- System.clearProperty(MSB_ADDR);\r
+ System.clearProperty(MSB_IAG_SERVICE_PORT);\r
+ System.clearProperty(MSB_IAG_SERVICE_HOST);\r
}\r
\r
@Test\r
assertThat(msbInfo[0], equalTo(ip));\r
assertThat(msbInfo[1], equalTo(port));\r
\r
- System.clearProperty(MSB_ADDR);\r
+ System.clearProperty(HOSTNAME);\r
}\r
\r
@Test\r
assertThat(msbInfo[0], equalTo(ip));\r
assertThat(msbInfo[1], equalTo("80"));\r
\r
- System.clearProperty(MSB_ADDR);\r
+ System.clearProperty(HOSTNAME);\r
}\r
\r
@Test\r
assertThat(msbInfo[0], equalTo(ip));\r
assertThat(msbInfo[1], equalTo("80"));\r
\r
- System.clearProperty(MSB_ADDR);\r
+ System.clearProperty(HOSTNAME);\r
}\r
\r
@Test\r
assertThat(msbInfo[0], equalTo(ip));\r
assertThat(msbInfo[1], equalTo(port));\r
\r
- System.clearProperty(MSB_ADDR);\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:80");\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:80");\r
- assertThat(res, is(false));\r
+ System.clearProperty(HOSTNAME);\r
}\r
}
\ No newline at end of file