Class AdminClientUnitTestEnv

java.lang.Object
org.apache.kafka.clients.admin.AdminClientUnitTestEnv
All Implemented Interfaces:
AutoCloseable

public class AdminClientUnitTestEnv extends Object implements AutoCloseable
Simple utility for setting up a mock KafkaAdminClient that uses a MockClient for a supplied Cluster. Create a Cluster manually or use TestUtils methods to easily create a simple cluster.

To use in a test, create an instance and prepare its MockClient with the expected responses for the Admin. Then, use the AdminClient in the test, which will then use the MockClient and receive the responses you provided. Since MockClient is not thread-safe, users should be wary of calling its methods after the AdminClient is instantiated.

When finished, be sure to close the environment object.

  • Constructor Details

    • AdminClientUnitTestEnv

      public AdminClientUnitTestEnv(org.apache.kafka.common.Cluster cluster, String... vals)
    • AdminClientUnitTestEnv

      public AdminClientUnitTestEnv(org.apache.kafka.common.utils.Time time, org.apache.kafka.common.Cluster cluster, String... vals)
    • AdminClientUnitTestEnv

      public AdminClientUnitTestEnv(org.apache.kafka.common.utils.Time time, org.apache.kafka.common.Cluster cluster)
    • AdminClientUnitTestEnv

      public AdminClientUnitTestEnv(org.apache.kafka.common.utils.Time time, org.apache.kafka.common.Cluster cluster, Map<String,Object> config)
    • AdminClientUnitTestEnv

      public AdminClientUnitTestEnv(org.apache.kafka.common.utils.Time time, org.apache.kafka.common.Cluster cluster, Map<String,Object> config, Map<org.apache.kafka.common.Node, Long> unreachableNodes)
    • AdminClientUnitTestEnv

      public AdminClientUnitTestEnv(org.apache.kafka.common.utils.Time time, org.apache.kafka.common.Cluster cluster, Map<String,Object> config, Map<org.apache.kafka.common.Node, Long> unreachableNodes, org.apache.kafka.clients.admin.internals.AdminRequestInterceptor.Factory interceptorFactory)
  • Method Details

    • time

      public org.apache.kafka.common.utils.Time time()
    • cluster

      public org.apache.kafka.common.Cluster cluster()
    • adminClient

      public io.confluent.kafka.clients.CloudAdmin adminClient()
    • kafkaClient

      public MockClient kafkaClient()
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • kafkaAdminClientNetworkThreadPrefix

      public static String kafkaAdminClientNetworkThreadPrefix()