bugfix - IndexOutOfBoundsException in MicroServiceConfig
[holmes/common.git] / holmes-actions / src / test / java / org / onap / holmes / common / config / MicroServiceConfigTest.java
index fbc22e5..316f09f 100644 (file)
@@ -119,7 +119,26 @@ public class MicroServiceConfigTest {
     }\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