Class GlobalEmbeddedKafkaTestExecutionListener

java.lang.Object
org.springframework.kafka.test.junit.GlobalEmbeddedKafkaTestExecutionListener
All Implemented Interfaces:
org.junit.platform.launcher.TestExecutionListener

public class GlobalEmbeddedKafkaTestExecutionListener extends Object implements org.junit.platform.launcher.TestExecutionListener
The TestExecutionListener to start an EmbeddedKafkaBroker in the beginning of the test plan and stop in the end. This approach ensures one global Kafka cluster for all the unit tests to execute.

The GlobalEmbeddedKafkaTestExecutionListener is disabled by default. Set LISTENER_ENABLED_PROPERTY_NAME system property (or respective ConfigurationParameters.CONFIG_FILE_NAME entry) to enable it.

Since:
3.0
Author:
Artem Bilan, Gary Russell
  • Field Details

    • LISTENER_ENABLED_PROPERTY_NAME

      public static final String LISTENER_ENABLED_PROPERTY_NAME
      Property name used to enable the GlobalEmbeddedKafkaTestExecutionListener. The GlobalEmbeddedKafkaTestExecutionListener is registered automatically via Java's ServiceLoader mechanism but disabled by default. Set the value of this property to true to enable this listener.
      See Also:
    • COUNT_PROPERTY_NAME

      public static final String COUNT_PROPERTY_NAME
      The number of brokers for EmbeddedKafkaBroker.
      See Also:
    • PORTS_PROPERTY_NAME

      public static final String PORTS_PROPERTY_NAME
      The port(s) to expose embedded broker(s).
      See Also:
    • TOPICS_PROPERTY_NAME

      public static final String TOPICS_PROPERTY_NAME
      The topics to create on the embedded broker(s).
      See Also:
    • PARTITIONS_PROPERTY_NAME

      public static final String PARTITIONS_PROPERTY_NAME
      The number of partitions on topics to create on the embedded broker(s).
      See Also:
    • KRAFT_PROPERTY_NAME

      public static final String KRAFT_PROPERTY_NAME
      The number of partitions on topics to create on the embedded broker(s).
      See Also:
    • BROKER_PROPERTIES_LOCATION_PROPERTY_NAME

      public static final String BROKER_PROPERTIES_LOCATION_PROPERTY_NAME
      The location for a properties file with Kafka broker configuration.
      See Also:
  • Constructor Details

    • GlobalEmbeddedKafkaTestExecutionListener

      public GlobalEmbeddedKafkaTestExecutionListener()
  • Method Details

    • testPlanExecutionStarted

      public void testPlanExecutionStarted(org.junit.platform.launcher.TestPlan testPlan)
      Specified by:
      testPlanExecutionStarted in interface org.junit.platform.launcher.TestExecutionListener
    • testPlanExecutionFinished

      public void testPlanExecutionFinished(org.junit.platform.launcher.TestPlan testPlan)
      Specified by:
      testPlanExecutionFinished in interface org.junit.platform.launcher.TestExecutionListener