difin commented on code in PR #5729:
URL: https://github.com/apache/hive/pull/5729#discussion_r2034046508


##########
common/src/test/org/apache/hive/common/IPStackUtilsTest.java:
##########
@@ -164,20 +142,68 @@ void 
testWildcardWhenIPv6IsNotPreferredAndIPv6WildcardProvided() {
   }
 
   @Test
-  void testWildcardWhenNonWildcardIPv4AddressProvided() {
-    String result = IPStackUtils.adaptWildcardAddress("192.168.1.1");
-    assertEquals("192.168.1.1", result);
+  void testAdaptWildcardAddress() {
+    assertEquals("192.168.1.1", 
IPStackUtils.adaptWildcardAddress("192.168.1.1"));
+    assertEquals("2001:db8::1", 
IPStackUtils.adaptWildcardAddress("2001:db8::1"));
+    assertEquals("example.com", 
IPStackUtils.adaptWildcardAddress("example.com"));
+  }
+
+    // Test cases for splitHostPort method
+
+  @Test
+  void testGetHostAndPortWithIPv4() {
+    IPStackUtils.HostPort result = 
IPStackUtils.getHostAndPort("192.168.1.1:8080");
+    assertEquals("192.168.1.1", result.getHostname());
+    assertEquals(8080, result.getPort());
+  }
+
+  @Test
+  void testGetHostAndPortWithValidIPv6WithSquaredBrackets() {
+    IPStackUtils.HostPort result = 
IPStackUtils.getHostAndPort("[2001:0db8::1]:8080");
+    assertEquals("2001:0db8::1", result.getHostname());
+    assertEquals(8080, result.getPort());
+  }
+
+  @Test
+  void testGetHostAndPortWithValidIPv6WithoutSquaredBrackets() {
+    IPStackUtils.HostPort result = 
IPStackUtils.getHostAndPort("2001:0db8::1:8080");
+    assertEquals("2001:0db8::1", result.getHostname());
+    assertEquals(8080, result.getPort());
+  }
+
+  @Test
+  void testGetHostAndPortWithHostname() {
+    IPStackUtils.HostPort result = 
IPStackUtils.getHostAndPort("example.com:80");
+    assertEquals("example.com", result.getHostname());
+    assertEquals(80, result.getPort());
   }
 
   @Test
-  void testWildcardWhenNonWildcardIPv6AddressProvided() {
-    String result = IPStackUtils.adaptWildcardAddress("2001:db8::1");
-    assertEquals("2001:db8::1", result);
+  void testGetHostPortWithInvalidAndPort() {
+    assertEquals("Port number out of range (0-65535).",
+        assertThrows(IllegalArgumentException.class, () -> 
IPStackUtils.getHostAndPort("192.168.1.1:70000")).getMessage());
+    assertEquals("Input does not contain a port.",
+        assertThrows(IllegalArgumentException.class, () -> 
IPStackUtils.getHostAndPort("192.168.1.1")).getMessage());
+    assertEquals("Host address is null or empty.",
+        assertThrows(IllegalArgumentException.class, () -> 
IPStackUtils.getHostAndPort(":8080")).getMessage());
+  }
+
+  // Test cases for isValidPort method

Review Comment:
   Fixed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org
For additional commands, e-mail: gitbox-h...@hive.apache.org

Reply via email to