use of org.apache.kafka.clients.admin.MockAdminClient in project apache-kafka-on-k8s by banzaicloud.
the class ConnectUtilsTest method testLookupKafkaClusterIdTimeout.
@Test(expected = ConnectException.class)
public void testLookupKafkaClusterIdTimeout() {
final Node broker1 = new Node(0, "dummyHost-1", 1234);
final Node broker2 = new Node(1, "dummyHost-2", 1234);
List<Node> cluster = Arrays.asList(broker1, broker2);
MockAdminClient adminClient = new MockAdminClient(cluster, broker1);
adminClient.timeoutNextRequest(1);
ConnectUtils.lookupKafkaClusterId(adminClient);
}
use of org.apache.kafka.clients.admin.MockAdminClient in project apache-kafka-on-k8s by banzaicloud.
the class TopicAdminTest method shouldCreateTopicWhenItDoesNotExist.
@Test
public void shouldCreateTopicWhenItDoesNotExist() {
NewTopic newTopic = TopicAdmin.defineTopic("myTopic").partitions(1).compacted().build();
Cluster cluster = createCluster(1);
try (MockAdminClient mockAdminClient = new MockAdminClient(cluster.nodes(), cluster.nodeById(0))) {
TopicAdmin admin = new TopicAdmin(null, mockAdminClient);
assertTrue(admin.createTopic(newTopic));
}
}
use of org.apache.kafka.clients.admin.MockAdminClient in project apache-kafka-on-k8s by banzaicloud.
the class StreamsResetterTest method shouldDeleteTopic.
@Test
public void shouldDeleteTopic() throws InterruptedException, ExecutionException {
Cluster cluster = createCluster(1);
try (MockAdminClient adminClient = new MockAdminClient(cluster.nodes(), cluster.nodeById(0))) {
TopicPartitionInfo topicPartitionInfo = new TopicPartitionInfo(0, cluster.nodeById(0), cluster.nodes(), Collections.<Node>emptyList());
adminClient.addTopic(false, TOPIC, Collections.singletonList(topicPartitionInfo), null);
streamsResetter.doDelete(Collections.singletonList(TOPIC), adminClient);
assertEquals(Collections.emptySet(), adminClient.listTopics().names().get());
}
}
use of org.apache.kafka.clients.admin.MockAdminClient in project apache-kafka-on-k8s by banzaicloud.
the class InternalTopicManagerTest method init.
@Before
public void init() {
mockAdminClient = new MockAdminClient(cluster, broker1);
internalTopicManager = new InternalTopicManager(mockAdminClient, new StreamsConfig(config));
}
use of org.apache.kafka.clients.admin.MockAdminClient in project apache-kafka-on-k8s by banzaicloud.
the class ConnectUtilsTest method testLookupKafkaClusterId.
@Test
public void testLookupKafkaClusterId() {
final Node broker1 = new Node(0, "dummyHost-1", 1234);
final Node broker2 = new Node(1, "dummyHost-2", 1234);
List<Node> cluster = Arrays.asList(broker1, broker2);
MockAdminClient adminClient = new MockAdminClient(cluster, broker1);
assertEquals(MockAdminClient.DEFAULT_CLUSTER_ID, ConnectUtils.lookupKafkaClusterId(adminClient));
}
Aggregations