Skip to content

Commit dd7e83a

Browse files
committed
Update tests
1 parent 7c52efb commit dd7e83a

3 files changed

Lines changed: 17 additions & 9 deletions

File tree

clients/src/test/java/org/apache/kafka/clients/NetworkClientTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import org.apache.kafka.common.Node;
2222
import org.apache.kafka.common.errors.AuthenticationException;
2323
import org.apache.kafka.common.errors.RebootstrapRequiredException;
24-
import org.apache.kafka.common.errors.UnsupportedVersionException;
24+
import org.apache.kafka.common.errors.UnsupportedProtocolFieldException;
2525
import org.apache.kafka.common.internals.ClusterResourceListeners;
2626
import org.apache.kafka.common.message.ApiMessageType;
2727
import org.apache.kafka.common.message.ApiVersionsResponseData;
@@ -241,7 +241,7 @@ public void testUnsupportedVersionDuringInternalMetadataRequest() {
241241
// disabling auto topic creation for versions less than 4 is not supported
242242
MetadataRequest.Builder builder = new MetadataRequest.Builder(topics, false, (short) 3);
243243
client.sendInternalMetadataRequest(builder, node.idString(), time.milliseconds());
244-
assertEquals(UnsupportedVersionException.class, metadataUpdater.getAndClearFailure().getClass());
244+
assertEquals(UnsupportedProtocolFieldException.class, metadataUpdater.getAndClearFailure().getClass());
245245
}
246246

247247
@Test

clients/src/test/java/org/apache/kafka/clients/consumer/internals/ConsumerHeartbeatRequestManagerTest.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.apache.kafka.common.errors.AuthenticationException;
3232
import org.apache.kafka.common.errors.DisconnectException;
3333
import org.apache.kafka.common.errors.TimeoutException;
34+
import org.apache.kafka.common.errors.UnsupportedProtocolFieldException;
3435
import org.apache.kafka.common.errors.UnsupportedVersionException;
3536
import org.apache.kafka.common.message.ConsumerGroupHeartbeatRequestData;
3637
import org.apache.kafka.common.message.ConsumerGroupHeartbeatResponseData;
@@ -714,9 +715,9 @@ public void testUnsupportedVersionFromBroker(String errorMsg) {
714715
* REGEX_RESOLUTION_NOT_SUPPORTED_MSG only generated on the client side.
715716
*/
716717
@ParameterizedTest
717-
@ValueSource(strings = {CONSUMER_PROTOCOL_NOT_SUPPORTED_MSG, REGEX_RESOLUTION_NOT_SUPPORTED_MSG})
718-
public void testUnsupportedVersionFromClient(String errorMsg) {
719-
mockResponseWithException(new UnsupportedVersionException(errorMsg), false);
718+
@MethodSource("unsupportedVersionFromClientCases")
719+
public void testUnsupportedVersionFromClient(UnsupportedVersionException thrown, String errorMsg) {
720+
mockResponseWithException(thrown, false);
720721
ArgumentCaptor<ErrorEvent> errorEventArgumentCaptor = ArgumentCaptor.forClass(ErrorEvent.class);
721722
verify(backgroundEventHandler).add(errorEventArgumentCaptor.capture());
722723
ErrorEvent errorEvent = errorEventArgumentCaptor.getValue();
@@ -725,6 +726,13 @@ public void testUnsupportedVersionFromClient(String errorMsg) {
725726
clearInvocations(backgroundEventHandler);
726727
}
727728

729+
private static Stream<Arguments> unsupportedVersionFromClientCases() {
730+
return Stream.of(
731+
Arguments.of(new UnsupportedVersionException(CONSUMER_PROTOCOL_NOT_SUPPORTED_MSG), CONSUMER_PROTOCOL_NOT_SUPPORTED_MSG),
732+
Arguments.of(new UnsupportedProtocolFieldException(REGEX_RESOLUTION_NOT_SUPPORTED_MSG), REGEX_RESOLUTION_NOT_SUPPORTED_MSG)
733+
);
734+
}
735+
728736
private void mockResponseWithException(UnsupportedVersionException exception, boolean isFromBroker) {
729737
time.sleep(DEFAULT_HEARTBEAT_INTERVAL_MS);
730738
NetworkClientDelegate.PollResult result = heartbeatRequestManager.poll(time.milliseconds());

clients/src/test/java/org/apache/kafka/common/requests/RequestResponseTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.apache.kafka.common.errors.NotEnoughReplicasException;
3636
import org.apache.kafka.common.errors.SecurityDisabledException;
3737
import org.apache.kafka.common.errors.UnknownServerException;
38+
import org.apache.kafka.common.errors.UnsupportedProtocolFieldException;
3839
import org.apache.kafka.common.errors.UnsupportedVersionException;
3940
import org.apache.kafka.common.message.AddOffsetsToTxnRequestData;
4041
import org.apache.kafka.common.message.AddOffsetsToTxnResponseData;
@@ -683,8 +684,8 @@ public void testCreateTopicRequestV0FailsIfValidateOnly() {
683684

684685
@Test
685686
public void testCreateTopicRequestV3FailsIfNoPartitionsOrReplicas() {
686-
final UnsupportedVersionException exception = assertThrows(
687-
UnsupportedVersionException.class, () -> {
687+
final UnsupportedProtocolFieldException exception = assertThrows(
688+
UnsupportedProtocolFieldException.class, () -> {
688689
CreateTopicsRequestData data = new CreateTopicsRequestData()
689690
.setTimeoutMs(123)
690691
.setValidateOnly(false);
@@ -699,8 +700,7 @@ public void testCreateTopicRequestV3FailsIfNoPartitionsOrReplicas() {
699700

700701
new Builder(data).build((short) 3);
701702
});
702-
assertTrue(exception.getMessage().contains("supported in CreateTopicRequest version 4+"));
703-
assertTrue(exception.getMessage().contains("[foo, bar]"));
703+
assertTrue(exception.getMessage().contains("does not support [foo,bar] in CREATE_TOPICS API version 3"));
704704
}
705705

706706
@Test

0 commit comments

Comments
 (0)