}\r
\r
public static String getConsulAddrInfo() {\r
- return getEnv(CONSUL_HOST) + CONSUL_ADDR_SUF;\r
+ return "http://" + getEnv(CONSUL_HOST) + CONSUL_ADDR_SUF;\r
}\r
\r
- public static String getConfigBindingServiceAddrInfo() {\r
+ public static String getServiceAddrInfoFromDcaeConsulByHostName(String hostname) {\r
String ret = null;\r
- String queryString = getConsulAddrInfo() + CONFIG_BINDING_SERVICE;\r
- log.info("Query the CBS address using the URL: " + queryString);\r
+ String queryString = getConsulAddrInfo() + hostname;\r
+ log.info("Query the " + hostname + " address using the URL: " + queryString);\r
try {\r
JSONObject addrJson = (JSONObject) JSONArray.fromObject(execQuery(queryString)).get(0);\r
if (addrJson.has("ServiceAddress") && addrJson.has("ServicePort")) {\r
- ret = addrJson.getString("ServiceAddress") + ":" + addrJson.getString("ServicePort");\r
+ ret = "http://" + addrJson.getString("ServiceAddress") + ":" + addrJson.getString("ServicePort");\r
}\r
} catch (Exception e) {\r
log.warn(e.getMessage(), e);\r
}\r
- log.info("The CBS address is " + ret);\r
+ log.info("The " + hostname + " address is " + ret);\r
return ret;\r
}\r
\r
return response.readEntity(String.class);\r
}\r
\r
- public static String getServiceAddrInfoFromCBS(String serviceName) {\r
+ public static String getServiceConfigInfoFromCBS(String hostname) {\r
String ret = null;\r
- String url = getConfigBindingServiceAddrInfo() + "/service_component/" +serviceName;\r
+ String url = getServiceAddrInfoFromDcaeConsulByHostName(getEnv(CONFIG_BINDING_SERVICE)) + "/service_component/" + hostname;\r
try {\r
- JSONObject jsonObject = JSONObject.fromObject(execQuery(url));\r
- log.info("The origin configurations (" + url + ") returned by DCAE is: " + jsonObject.toString());\r
- if (jsonObject.has(serviceName)) {\r
- ret = (String) jsonObject.getJSONArray(serviceName).get(0);\r
- }\r
+ ret = execQuery(url);\r
} catch (Exception e) {\r
log.warn(e.getMessage(), e);\r
}\r
+ log.info("The query url is: " + url + ". The corresponding configurations are " + ret);\r
return ret;\r
}\r
\r
- public static String getMsbServerAddr() {\r
- String[] addrInfo = getMsbAddrInfo();\r
+ public static String getMsbServerAddrWithHttpPrefix() {\r
+ String[] addrInfo = getMsbIpAndPort();\r
String ret = addrInfo[0] + ":" + addrInfo[1];\r
if (!ret.startsWith(AlarmConst.HTTP) || !ret.startsWith(AlarmConst.HTTPS)){\r
ret = AlarmConst.HTTP + ret;\r
return ret;\r
}\r
\r
- public static String[] getMsbAddrInfo() {\r
- String[] msbServerInfo = null;\r
-\r
- //String info = getServiceAddrInfoFromCBS(MSB_ADDR);\r
- String info = getServiceAddrInfoFromCBS(getEnv(HOSTNAME));\r
- log.info("Got the service information of \"" + getEnv(HOSTNAME) + "\" from CBS. The response is " + info + ".");\r
-\r
- if (info != null){\r
- JSONObject infoObj = JSONObject.fromObject(info);\r
- String msbInfoTmp = infoObj.has("msb.hostname") ? infoObj.getString("msb.hostname") : null;\r
- if (msbInfoTmp != null) {\r
- msbServerInfo = split(msbInfoTmp);\r
- } else {\r
- msbServerInfo = split(getEnv(MSB_ADDR));\r
- }\r
- } else {\r
- msbServerInfo = split(getEnv(MSB_ADDR));\r
- }\r
-\r
- return msbServerInfo;\r
+ public static String[] getMsbIpAndPort() {\r
+ return split(getEnv(MSB_ADDR));\r
}\r
\r
- public static String[] getServiceAddrInfo() {\r
+ public static String[] getMicroServiceIpAndPort() {\r
String[] serviceAddrInfo = null;\r
- String info = getServiceAddrInfoFromCBS(getEnv(HOSTNAME));\r
- log.info("Got the service information of \"" + getEnv(HOSTNAME) + "\" from CBS. The response is " + info + ".");\r
- if (info != null){\r
+ String info = getServiceAddrInfoFromDcaeConsulByHostName(getEnv(HOSTNAME));\r
+ log.info("Got the service information of \"" + getEnv(HOSTNAME) + "\" from Consul. The response is " + info + ".");\r
+ if (info != null && !info.isEmpty()){\r
serviceAddrInfo = split(info);\r
} else {\r
serviceAddrInfo = split(getEnv(HOSTNAME));\r
when(HttpsUtils.get(url, headers)).thenReturn("{}");
PowerMockito.mockStatic(MicroServiceConfig.class);
- when(MicroServiceConfig.getMsbServerAddr()).thenReturn("http://10.96.33.33:80");
+ when(MicroServiceConfig.getMsbServerAddrWithHttpPrefix()).thenReturn("http://10.96.33.33:80");
PowerMock.expectPrivate(aaiQuery, "getVmResourceLinks", "test1", "test2")
.andReturn("/aai/v11/cloud-infrastructure");
when(HttpsUtils.get(url, headers)).thenReturn("");
PowerMockito.mockStatic(MicroServiceConfig.class);
- when(MicroServiceConfig.getMsbServerAddr()).thenReturn("http://10.96.33.33:80");
+ when(MicroServiceConfig.getMsbServerAddrWithHttpPrefix()).thenReturn("http://10.96.33.33:80");
PowerMock.expectPrivate(aaiQuery, "getVmResourceLinks", "test1", "test2")
.andReturn("/aai/v11/cloud-infrastructure");
when(HttpsUtils.get(url, headers)).thenThrow(new CorrelationException(""));
PowerMockito.mockStatic(MicroServiceConfig.class);
- when(MicroServiceConfig.getMsbServerAddr()).thenReturn("http://10.96.33.33:80");
+ when(MicroServiceConfig.getMsbServerAddrWithHttpPrefix()).thenReturn("http://10.96.33.33:80");
PowerMock.expectPrivate(aaiQuery, "getVmResourceLinks", "test1", "test2")
.andReturn("/aai/v11/cloud-infrastructure");
Whitebox.setInternalState(aaiQuery, "aaiResponseUtil", aaiResponseUtil);
PowerMockito.mockStatic(MicroServiceConfig.class);
- when(MicroServiceConfig.getMsbServerAddr()).thenReturn("host_url");
+ when(MicroServiceConfig.getMsbServerAddrWithHttpPrefix()).thenReturn("host_url");
PowerMock.expectPrivate(aaiQuery, "getResponse", anyObject(String.class)).andReturn("").anyTimes();
PowerMock.replayAll();
Whitebox.setInternalState(aaiQuery, "aaiResponseUtil", aaiResponseUtil);
PowerMockito.mockStatic(MicroServiceConfig.class);
- when(MicroServiceConfig.getMsbServerAddr()).thenReturn("host_url");
+ when(MicroServiceConfig.getMsbServerAddrWithHttpPrefix()).thenReturn("host_url");
PowerMock.expectPrivate(aaiQuery, "getResponse", anyObject(String.class)).andReturn("").anyTimes();
PowerMock.replayAll();
aaiQuery = new AaiQuery();
PowerMockito.mockStatic(MicroServiceConfig.class);
- when(MicroServiceConfig.getMsbServerAddr()).thenReturn("http://10.96.33.33:80");
- when(MicroServiceConfig.getServiceAddrInfoFromCBS("nihao")).thenReturn("");
+ when(MicroServiceConfig.getMsbServerAddrWithHttpPrefix()).thenReturn("http://10.96.33.33:80");
+ when(MicroServiceConfig.getServiceConfigInfoFromCBS("nihao")).thenReturn("");
PowerMock.replayAll();
String actual = Whitebox.invokeMethod(aaiQuery,"getBaseUrl", "/url");
aaiQuery = new AaiQuery();
PowerMockito.mockStatic(MicroServiceConfig.class);
- when(MicroServiceConfig.getMsbServerAddr()).thenThrow(new NullPointerException());
- when(MicroServiceConfig.getServiceAddrInfoFromCBS("aai_config")).thenReturn("aai");
+ when(MicroServiceConfig.getMsbServerAddrWithHttpPrefix()).thenThrow(new NullPointerException());
+ when(MicroServiceConfig.getServiceConfigInfoFromCBS("aai_config")).thenReturn("aai");
PowerMock.replayAll();
String actual = Whitebox.invokeMethod(aaiQuery,"getBaseUrl", "url");
aaiQuery = new AaiQuery();
PowerMockito.mockStatic(MicroServiceConfig.class);
- when(MicroServiceConfig.getMsbServerAddr()).thenThrow(new NullPointerException());
- when(MicroServiceConfig.getServiceAddrInfoFromCBS("aai_config"))
+ when(MicroServiceConfig.getMsbServerAddrWithHttpPrefix()).thenThrow(new NullPointerException());
+ when(MicroServiceConfig.getServiceConfigInfoFromCBS("aai_config"))
.thenThrow(new NullPointerException());
PowerMock.replayAll();
import static org.onap.holmes.common.config.MicroServiceConfig.*;\r
\r
import org.easymock.EasyMock;\r
+import org.junit.Ignore;\r
import org.junit.Rule;\r
import org.junit.Test;\r
import org.powermock.api.easymock.PowerMock;\r
@Test\r
public void getMsbServerAddrTest() {\r
System.setProperty(MSB_ADDR, "test:80");\r
- System.setProperty(HOSTNAME, "rule-mgmt");\r
- PowerMock.mockStaticPartial(MicroServiceConfig.class, "getServiceAddrInfoFromCBS", String.class);\r
- EasyMock.expect(MicroServiceConfig.getServiceAddrInfoFromCBS(System.getProperty(HOSTNAME)))\r
- .andReturn("{\"msb.hostname\": \"test:80\"}");\r
- PowerMock.replayAll();\r
- assertThat("http://test:80", equalTo(getMsbServerAddr()));\r
- PowerMock.verifyAll();\r
- System.clearProperty(MicroServiceConfig.HOSTNAME);\r
+ assertThat("http://test:80", equalTo(getMsbServerAddrWithHttpPrefix()));\r
System.clearProperty(MicroServiceConfig.MSB_ADDR);\r
}\r
\r
public void getMsbServerIpTest() {\r
System.setProperty(MSB_ADDR, "10.54.23.79:80");\r
System.setProperty(HOSTNAME, "rule-mgmt");\r
- PowerMock.mockStaticPartial(MicroServiceConfig.class, "getServiceAddrInfoFromCBS", String.class);\r
- EasyMock.expect(MicroServiceConfig.getServiceAddrInfoFromCBS(System.getProperty(HOSTNAME)))\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
PowerMock.replayAll();\r
- assertThat("10.54.23.79", equalTo(getMsbAddrInfo()[0]));\r
- assertThat("80", equalTo(getMsbAddrInfo()[1]));\r
+ assertThat("10.54.23.79", equalTo(getMsbIpAndPort()[0]));\r
+ assertThat("80", equalTo(getMsbIpAndPort()[1]));\r
System.clearProperty(MicroServiceConfig.HOSTNAME);\r
System.clearProperty(MSB_ADDR);\r
}\r
@Test\r
public void getServiceIpTest() {\r
System.setProperty(HOSTNAME, "127.0.0.1");\r
- assertThat("127.0.0.1", equalTo(getServiceAddrInfo()[0]));\r
- assertThat("80", equalTo(getServiceAddrInfo()[1]));\r
+ assertThat("127.0.0.1", equalTo(getMicroServiceIpAndPort()[0]));\r
+ assertThat("80", equalTo(getMicroServiceIpAndPort()[1]));\r
System.clearProperty(HOSTNAME);\r
}\r
\r
@Test\r
public void getConsulAddrInfoTest() {\r
System.setProperty(CONSUL_HOST, "127.0.0.1");\r
- assertThat("127.0.0.1:8500/v1/catalog/service/", equalTo(getConsulAddrInfo()));\r
+ assertThat("http://127.0.0.1:8500/v1/catalog/service/", equalTo(getConsulAddrInfo()));\r
System.clearProperty(CONSUL_HOST);\r
}\r
\r
@Test\r
public void getConfigBindingServiceAddrInfoTest_consul_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
.andThrow(new RuntimeException("Invalid URL."));\r
\r
PowerMock.replayAll();\r
\r
- assertThat(getConfigBindingServiceAddrInfo(), is(nullValue()));\r
+ assertThat(getServiceAddrInfoFromDcaeConsulByHostName(System.getProperty(CONFIG_BINDING_SERVICE))\r
+ , is(nullValue()));\r
\r
PowerMock.verifyAll();\r
+ System.clearProperty(CONFIG_BINDING_SERVICE);\r
}\r
\r
@Test\r
- public void getConfigBindingServiceAddrInfoTest_consul_exists() throws Exception {\r
+ public void getServiceAddrInfoFromDcaeConsulByHostName_consul_exists() 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("[{\"ServiceAddress\": \"127.0.0.2\", \"ServicePort\": \"8080\"}]");\r
\r
PowerMock.replayAll();\r
\r
- assertThat(getConfigBindingServiceAddrInfo(), equalTo("127.0.0.2:8080"));\r
+ assertThat(getServiceAddrInfoFromDcaeConsulByHostName(System.getProperty(CONFIG_BINDING_SERVICE)),\r
+ equalTo("http://127.0.0.2:8080"));\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_propertie_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
.andReturn("[{\"ServiceAddress\": \"127.0.0.2\"}]");\r
\r
PowerMock.replayAll();\r
\r
- assertThat(getConfigBindingServiceAddrInfo(), is(nullValue()));\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
\r
PowerMock.replayAll();\r
\r
- assertThat(getServiceAddrInfoFromCBS(HOSTNAME), is(nullValue()));\r
+ assertThat(getServiceConfigInfoFromCBS(HOSTNAME), is(nullValue()));\r
\r
PowerMock.verifyAll();\r
}\r
\r
@Test\r
- public void getServiceAddrInfoFromCBS_consul_exists_service_not_exist() throws Exception {\r
+ public void getServiceAddrInfoFromDcaeConsulByHostName_consul_exists_service_not_exist() throws Exception {\r
PowerMock.mockStaticPartial(MicroServiceConfig.class, "execQuery", String.class);\r
PowerMock.expectPrivate(MicroServiceConfig.class, "execQuery", EasyMock.anyObject())\r
- .andReturn("[{\"ServiceAddress\": \"127.0.0.2\", \"ServicePort\": \"8080\"}]");\r
- PowerMock.expectPrivate(MicroServiceConfig.class, "execQuery", EasyMock.anyObject())\r
- .andReturn("{}");\r
+ .andReturn("[]");\r
\r
PowerMock.replayAll();\r
- assertThat(getServiceAddrInfoFromCBS(HOSTNAME), is(nullValue()));\r
- PowerMock.verifyAll();\r
- }\r
-\r
- @Test\r
- public void getServiceAddrInfoFromCBS_normal() throws Exception {\r
- System.setProperty(HOSTNAME, "rule-mgmt");\r
- PowerMock.mockStaticPartial(MicroServiceConfig.class, "execQuery", String.class);\r
- PowerMock.expectPrivate(MicroServiceConfig.class, "execQuery", EasyMock.anyObject())\r
- .andReturn("[{\"ServiceAddress\": \"127.0.0.2\", \"ServicePort\": \"8080\"}]");\r
- PowerMock.expectPrivate(MicroServiceConfig.class, "execQuery", EasyMock.anyObject())\r
- .andReturn("{\"rule-mgmt\": \"[\\\"127.0.0.3:5432\\\"]\"}");\r
-\r
- PowerMock.replayAll();\r
-\r
- assertThat(getServiceAddrInfoFromCBS("rule-mgmt"), equalTo("127.0.0.3:5432"));\r
-\r
+ assertThat(getServiceAddrInfoFromDcaeConsulByHostName(HOSTNAME), is(nullValue()));\r
PowerMock.verifyAll();\r
-\r
- System.clearProperty(HOSTNAME);\r
}\r
\r
- @Test\r
+ @Ignore\r
public void getMsbAddrInfo_msb_registered() throws Exception {\r
System.setProperty(MSB_ADDR, "10.74.5.8:1545");\r
System.setProperty(HOSTNAME, "rule-mgmt");\r
- PowerMock.mockStaticPartial(MicroServiceConfig.class, "getServiceAddrInfoFromCBS", String.class);\r
- EasyMock.expect(MicroServiceConfig.getServiceAddrInfoFromCBS(System.getProperty(HOSTNAME)))\r
+ PowerMock.mockStaticPartial(MicroServiceConfig.class, "getServiceConfigInfoFromCBS", String.class);\r
+ EasyMock.expect(MicroServiceConfig.getServiceConfigInfoFromCBS(System.getProperty(HOSTNAME)))\r
.andReturn("{\"msb.hostname\": \"127.0.0.3:5432\"}");\r
\r
PowerMock.replayAll();\r
- String[] msbInfo = getMsbAddrInfo();\r
+ String[] msbInfo = getMsbIpAndPort();\r
PowerMock.verifyAll();\r
\r
assertThat(msbInfo[0], equalTo("127.0.0.3"));\r
System.clearProperty(MSB_ADDR);\r
}\r
\r
- @Test\r
+ @Ignore\r
public void getMsbAddrInfo_msb_not_registered() throws Exception {\r
System.setProperty(MSB_ADDR, "10.74.5.8:1545");\r
System.setProperty(HOSTNAME, "rule-mgmt");\r
- PowerMock.mockStaticPartial(MicroServiceConfig.class, "getServiceAddrInfoFromCBS", String.class);\r
- EasyMock.expect(MicroServiceConfig.getServiceAddrInfoFromCBS(System.getProperty(HOSTNAME)))\r
+ PowerMock.mockStaticPartial(MicroServiceConfig.class, "getServiceConfigInfoFromCBS", String.class);\r
+ EasyMock.expect(MicroServiceConfig.getServiceConfigInfoFromCBS(System.getProperty(HOSTNAME)))\r
.andReturn("{}");\r
\r
PowerMock.replayAll();\r
- String[] msbInfo = getMsbAddrInfo();\r
+ String[] msbInfo = getMsbIpAndPort();\r
PowerMock.verifyAll();\r
\r
assertThat(msbInfo[0], equalTo("10.74.5.8"));\r
}\r
\r
@Test\r
- public void getServiceAddrInfo_msb_registered() throws Exception {\r
+ public void getMicroServiceIpAndPort_service_registered_to_consul() throws Exception {\r
System.setProperty(HOSTNAME, "rule-mgmt");\r
PowerMock.mockStaticPartial(MicroServiceConfig.class, "execQuery", String.class);\r
PowerMock.expectPrivate(MicroServiceConfig.class, "execQuery", EasyMock.anyObject())\r
- .andReturn("[{\"ServiceAddress\": \"127.0.0.2\", \"ServicePort\": \"8080\"}]");\r
- PowerMock.expectPrivate(MicroServiceConfig.class, "execQuery", EasyMock.anyObject())\r
- .andReturn("{\"rule-mgmt\": \"[\\\"127.0.0.3:5432\\\"]\"}");\r
+ .andReturn("[{\"ServiceAddress\": \"127.0.0.3\", \"ServicePort\": \"5432\"}]");\r
\r
PowerMock.replayAll();\r
- String[] msbInfo = getServiceAddrInfo();\r
+ String[] msbInfo = getMicroServiceIpAndPort();\r
PowerMock.verifyAll();\r
\r
assertThat(msbInfo[0], equalTo("127.0.0.3"));\r
}\r
\r
@Test\r
- public void getServiceAddrInfo_msb_not_registered() throws Exception {\r
+ public void getMicroServiceIpAndPort_service_not_registered_to_consul() throws Exception {\r
System.setProperty(HOSTNAME, "10.74.5.8:1545");\r
PowerMock.mockStaticPartial(MicroServiceConfig.class, "execQuery", String.class);\r
PowerMock.expectPrivate(MicroServiceConfig.class, "execQuery", EasyMock.anyObject())\r
- .andReturn("[{\"ServiceAddress\": \"127.0.0.2\", \"ServicePort\": \"8080\"}]");\r
- PowerMock.expectPrivate(MicroServiceConfig.class, "execQuery", EasyMock.anyObject())\r
- .andReturn("{}");\r
+ .andReturn("[]");\r
\r
PowerMock.replayAll();\r
- String[] msbInfo = getServiceAddrInfo();\r
+ String[] msbInfo = getMicroServiceIpAndPort();\r
PowerMock.verifyAll();\r
\r
assertThat(msbInfo[0], equalTo("10.74.5.8"));\r
}\r
\r
@Test\r
- public void getServiceAddrInfo_msb_not_registered_full_addr() throws Exception {\r
+ public void getMicroServiceIpAndPort_service_not_registered_full_addr() throws Exception {\r
System.setProperty(HOSTNAME, "http://10.74.5.8:1545");\r
PowerMock.mockStaticPartial(MicroServiceConfig.class, "execQuery", String.class);\r
- PowerMock.expectPrivate(MicroServiceConfig.class, "execQuery", EasyMock.anyObject())\r
- .andReturn("[{\"ServiceAddress\": \"127.0.0.2\", \"ServicePort\": \"8080\"}]");\r
PowerMock.expectPrivate(MicroServiceConfig.class, "execQuery", EasyMock.anyObject())\r
.andReturn("{}");\r
\r
PowerMock.replayAll();\r
- String[] msbInfo = getServiceAddrInfo();\r
+ String[] msbInfo = getMicroServiceIpAndPort();\r
PowerMock.verifyAll();\r
\r
assertThat(msbInfo[0], equalTo("10.74.5.8"));\r
}\r
\r
@Test\r
- public void getServiceAddrInfo_msb_not_registered_no_port() throws Exception {\r
+ public void getMicroServiceIpAndPort_service_not_registered_no_port() throws Exception {\r
System.setProperty(HOSTNAME, "http://10.74.5.8");\r
PowerMock.mockStaticPartial(MicroServiceConfig.class, "execQuery", String.class);\r
- PowerMock.expectPrivate(MicroServiceConfig.class, "execQuery", EasyMock.anyObject())\r
- .andReturn("[{\"ServiceAddress\": \"127.0.0.2\", \"ServicePort\": \"8080\"}]");\r
PowerMock.expectPrivate(MicroServiceConfig.class, "execQuery", EasyMock.anyObject())\r
.andReturn("{}");\r
\r
PowerMock.replayAll();\r
- String[] msbInfo = getServiceAddrInfo();\r
+ String[] msbInfo = getMicroServiceIpAndPort();\r
PowerMock.verifyAll();\r
\r
assertThat(msbInfo[0], equalTo("10.74.5.8"));\r
}\r
\r
@Test\r
- public void getServiceAddrInfo_msb_not_registered_only_ip() throws Exception {\r
+ public void getMicroServiceIpAndPort_service_not_registered_only_ip() throws Exception {\r
System.setProperty(HOSTNAME, "10.74.5.8");\r
PowerMock.mockStaticPartial(MicroServiceConfig.class, "execQuery", String.class);\r
- PowerMock.expectPrivate(MicroServiceConfig.class, "execQuery", EasyMock.anyObject())\r
- .andReturn("[{\"ServiceAddress\": \"127.0.0.2\", \"ServicePort\": \"8080\"}]");\r
PowerMock.expectPrivate(MicroServiceConfig.class, "execQuery", EasyMock.anyObject())\r
.andReturn("{}");\r
\r
PowerMock.replayAll();\r
- String[] msbInfo = getServiceAddrInfo();\r
+ String[] msbInfo = getMicroServiceIpAndPort();\r
PowerMock.verifyAll();\r
\r
assertThat(msbInfo[0], equalTo("10.74.5.8"));\r
}\r
\r
@Test\r
- public void getServiceAddrInfo_msb_not_registered_full_addr_https() throws Exception {\r
+ public void getMicroServiceIpAndPort_service_not_registered_full_addr_https() throws Exception {\r
System.setProperty(HOSTNAME, "https://10.74.5.8:5432");\r
PowerMock.mockStaticPartial(MicroServiceConfig.class, "execQuery", String.class);\r
PowerMock.expectPrivate(MicroServiceConfig.class, "execQuery", EasyMock.anyObject())\r
- .andReturn("[{\"ServiceAddress\": \"127.0.0.2\", \"ServicePort\": \"8080\"}]");\r
- PowerMock.expectPrivate(MicroServiceConfig.class, "execQuery", EasyMock.anyObject())\r
- .andReturn("{}");\r
+ .andReturn("[]");\r
\r
PowerMock.replayAll();\r
- String[] msbInfo = getServiceAddrInfo();\r
+ String[] msbInfo = getMicroServiceIpAndPort();\r
PowerMock.verifyAll();\r
\r
assertThat(msbInfo[0], equalTo("10.74.5.8"));\r