chia7712 commented on code in PR #18767: URL: https://github.com/apache/kafka/pull/18767#discussion_r1940637732
########## clients/src/test/java/org/apache/kafka/clients/ClientUtilsTest.java: ########## @@ -96,10 +100,32 @@ public void testParseAndValidateAddressesWithReverseLookup() { } } - @Test - public void testInvalidConfig() { + static Stream<List<String>> provideValidBrokerAddressTestCases() { + return Stream.of( + Arrays.asList("localhost:9997", "localhost:9998", "localhost:9999"), + // Intentionally provide a single string, as users may provide space-separated brokers, which will be parsed as a single string. + Arrays.asList("localhost:9997 localhost:9998 localhost:9999") + ); + } + + @ParameterizedTest + @MethodSource("provideValidBrokerAddressTestCases") + public void testValidBrokerAddress(List<String> addresses) { + assertDoesNotThrow(() -> ClientUtils.parseAndValidateAddresses(addresses, ClientDnsLookup.USE_ALL_DNS_IPS)); + } + + static Stream<List<String>> provideInvalidBrokerAddressTestCases() { + return Stream.of( + Collections.singletonList("localhost:9997\nlocalhost:9998\nlocalhost:9999"), + Collections.singletonList("localhost:10000") Review Comment: `localhost:10000` is valid, and the test can cause "expected" error due to "random.value" ########## clients/src/test/java/org/apache/kafka/clients/ClientUtilsTest.java: ########## @@ -96,10 +100,32 @@ public void testParseAndValidateAddressesWithReverseLookup() { } } - @Test - public void testInvalidConfig() { Review Comment: Please keep `testInvalidConfig` as it is used to test `ClientDnsLookup.forConfig` ... ########## clients/src/test/java/org/apache/kafka/clients/ClientUtilsTest.java: ########## @@ -96,10 +100,32 @@ public void testParseAndValidateAddressesWithReverseLookup() { } } - @Test - public void testInvalidConfig() { + static Stream<List<String>> provideValidBrokerAddressTestCases() { + return Stream.of( + Arrays.asList("localhost:9997", "localhost:9998", "localhost:9999"), + // Intentionally provide a single string, as users may provide space-separated brokers, which will be parsed as a single string. + Arrays.asList("localhost:9997 localhost:9998 localhost:9999") Review Comment: please add test case `Arrays.asList("localhost:9997", " localhost:9998", " localhost:9999")` -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org