Search in sources :

Example 1 with Builder

use of org.apache.kafka.common.requests.CreateTopicsRequest.Builder in project kafka by apache.

the class RequestResponseTest method cannotUseFindCoordinatorV0ToFindTransactionCoordinator.

@Test
public void cannotUseFindCoordinatorV0ToFindTransactionCoordinator() {
    FindCoordinatorRequest.Builder builder = new FindCoordinatorRequest.Builder(new FindCoordinatorRequestData().setKeyType(CoordinatorType.TRANSACTION.id).setKey("foobar"));
    assertThrows(UnsupportedVersionException.class, () -> builder.build((short) 0));
}
Also used : Builder(org.apache.kafka.common.requests.CreateTopicsRequest.Builder) FindCoordinatorRequestData(org.apache.kafka.common.message.FindCoordinatorRequestData) Test(org.junit.jupiter.api.Test)

Example 2 with Builder

use of org.apache.kafka.common.requests.CreateTopicsRequest.Builder in project kafka by apache.

the class RequestResponseTest method testCreateTopicRequestV3FailsIfNoPartitionsOrReplicas.

@Test
public void testCreateTopicRequestV3FailsIfNoPartitionsOrReplicas() {
    final UnsupportedVersionException exception = assertThrows(UnsupportedVersionException.class, () -> {
        CreateTopicsRequestData data = new CreateTopicsRequestData().setTimeoutMs(123).setValidateOnly(false);
        data.topics().add(new CreatableTopic().setName("foo").setNumPartitions(CreateTopicsRequest.NO_NUM_PARTITIONS).setReplicationFactor((short) 1));
        data.topics().add(new CreatableTopic().setName("bar").setNumPartitions(1).setReplicationFactor(CreateTopicsRequest.NO_REPLICATION_FACTOR));
        new Builder(data).build((short) 3);
    });
    assertTrue(exception.getMessage().contains("supported in CreateTopicRequest version 4+"));
    assertTrue(exception.getMessage().contains("[foo, bar]"));
}
Also used : CreatableTopic(org.apache.kafka.common.message.CreateTopicsRequestData.CreatableTopic) CreateTopicsRequestData(org.apache.kafka.common.message.CreateTopicsRequestData) Builder(org.apache.kafka.common.requests.CreateTopicsRequest.Builder) UnsupportedVersionException(org.apache.kafka.common.errors.UnsupportedVersionException) Test(org.junit.jupiter.api.Test)

Aggregations

Builder (org.apache.kafka.common.requests.CreateTopicsRequest.Builder)2 Test (org.junit.jupiter.api.Test)2 UnsupportedVersionException (org.apache.kafka.common.errors.UnsupportedVersionException)1 CreateTopicsRequestData (org.apache.kafka.common.message.CreateTopicsRequestData)1 CreatableTopic (org.apache.kafka.common.message.CreateTopicsRequestData.CreatableTopic)1 FindCoordinatorRequestData (org.apache.kafka.common.message.FindCoordinatorRequestData)1