diff options
author | GuangrongFu <fu.guangrong@zte.com.cn> | 2018-10-18 14:44:52 +0800 |
---|---|---|
committer | GuangrongFu <fu.guangrong@zte.com.cn> | 2018-10-18 14:44:52 +0800 |
commit | f0ae1a9f8d1464782a041c2361400dddbf1e890a (patch) | |
tree | ec3a2344a3d6f9c4805038cab1ffadc126ada7d9 /holmes-actions/src/test/java/org | |
parent | 746543151309d116aac2ba78093574138cf26095 (diff) |
Geted Holmes IP from Env Var1.2.2
Change-Id: Idf803dd37a33cf325af71dbf43fca3fe2dacaefe
Issue-ID: HOLMES-175
Signed-off-by: GuangrongFu <fu.guangrong@zte.com.cn>
Diffstat (limited to 'holmes-actions/src/test/java/org')
-rw-r--r-- | holmes-actions/src/test/java/org/onap/holmes/common/config/MicroServiceConfigTest.java | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/holmes-actions/src/test/java/org/onap/holmes/common/config/MicroServiceConfigTest.java b/holmes-actions/src/test/java/org/onap/holmes/common/config/MicroServiceConfigTest.java index 59af9d3..a5d6597 100644 --- a/holmes-actions/src/test/java/org/onap/holmes/common/config/MicroServiceConfigTest.java +++ b/holmes-actions/src/test/java/org/onap/holmes/common/config/MicroServiceConfigTest.java @@ -31,6 +31,7 @@ import org.powermock.api.easymock.PowerMock; import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.rule.PowerMockRule;
+import org.powermock.reflect.internal.WhiteboxImpl;
@PrepareForTest(MicroServiceConfig.class)
@PowerMockIgnore({"javax.ws.*"})
@@ -292,4 +293,52 @@ public class MicroServiceConfigTest { System.clearProperty(MSB_ADDR);
}
+
+ @Test
+ public void isValidIpAddress_with_port() throws Exception {
+ boolean res = WhiteboxImpl.invokeMethod(MicroServiceConfig.class, "isIpAddress", "10.75.13.21:90");
+ assertThat(res, is(true));
+ }
+
+ @Test
+ public void isValidIpAddress_without_port() throws Exception {
+ boolean res = WhiteboxImpl.invokeMethod(MicroServiceConfig.class, "isIpAddress", "10.75.13.21");
+ assertThat(res, is(true));
+ }
+
+ @Test
+ public void isValidIpAddress_with_port_with_http_prefix() throws Exception {
+ boolean res = WhiteboxImpl.invokeMethod(MicroServiceConfig.class, "isIpAddress", "http://10.75.13.21:90");
+ assertThat(res, is(true));
+ }
+
+ @Test
+ public void isValidIpAddress_without_port_with_https_prefix() throws Exception {
+ boolean res = WhiteboxImpl.invokeMethod(MicroServiceConfig.class, "isIpAddress", "https://10.75.13.21");
+ assertThat(res, is(true));
+ }
+
+ @Test
+ public void isValidIpAddress_invalid_ip_without_port() throws Exception {
+ boolean res = WhiteboxImpl.invokeMethod(MicroServiceConfig.class, "isIpAddress", "holmes-rule-mgmt");
+ assertThat(res, is(false));
+ }
+
+ @Test
+ public void isValidIpAddress_invalid_ip_with_port() throws Exception {
+ boolean res = WhiteboxImpl.invokeMethod(MicroServiceConfig.class, "isIpAddress", "holmes-rule-mgmt:80");
+ assertThat(res, is(false));
+ }
+
+ @Test
+ public void isValidIpAddress_invalid_ip_without_port_with_http_prefix() throws Exception {
+ boolean res = WhiteboxImpl.invokeMethod(MicroServiceConfig.class, "isIpAddress", "http://holmes-rule-mgmt");
+ assertThat(res, is(false));
+ }
+
+ @Test
+ public void isValidIpAddress_invalid_ip_with_port_with_https_prefix() throws Exception {
+ boolean res = WhiteboxImpl.invokeMethod(MicroServiceConfig.class, "isIpAddress", "https://holmes-rule-mgmt:80");
+ assertThat(res, is(false));
+ }
}
\ No newline at end of file |