chia7712 commented on code in PR #18781:
URL: https://github.com/apache/kafka/pull/18781#discussion_r1941309941
##########
clients/src/test/java/org/apache/kafka/clients/ClientUtilsTest.java:
##########
@@ -95,10 +99,38 @@ public void
testParseAndValidateAddressesWithReverseLookup() {
}
}
+ static Stream<List<String>> provideValidBrokerAddressTestCases() {
+ return Stream.of(
+ List.of("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(
+ List.of("localhost:9997\nlocalhost:9998\nlocalhost:9999"),
+ List.of("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.
+ List.of("localhost:9997 localhost:9998 localhost:9999")
+ );
+ }
+
+ @ParameterizedTest
+ @MethodSource("provideInvalidBrokerAddressTestCases")
+ public void testInvalidBrokerAddress(List<String> addresses) {
+ assertThrows(ConfigException.class,
+ () -> ClientUtils.parseAndValidateAddresses(addresses,
ClientDnsLookup.USE_ALL_DNS_IPS));
+ }
+
@Test
public void testInvalidConfig() {
- assertThrows(IllegalArgumentException.class,
- () ->
ClientUtils.parseAndValidateAddresses(Collections.singletonList("localhost:10000"),
"random.value"));
+ assertThrows(ConfigException.class, () ->
checkWithoutLookup("localhost:10000", "localhost:10001"));
Review Comment:
please keep origin test case as it is definitely different to this PR.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]