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 Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe location for a properties file with Kafka broker configuration.static final StringThe number of brokers forEmbeddedKafkaBroker.static final StringProperty name used to enable theGlobalEmbeddedKafkaTestExecutionListener.static final StringThe number of partitions on topics to create on the embedded broker(s).static final StringThe port(s) to expose embedded broker(s).static final StringThe topics to create on the embedded broker(s). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidtestPlanExecutionFinished(org.junit.platform.launcher.TestPlan testPlan) voidtestPlanExecutionStarted(org.junit.platform.launcher.TestPlan testPlan) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.junit.platform.launcher.TestExecutionListener
dynamicTestRegistered, executionFinished, executionSkipped, executionStarted, reportingEntryPublished
-
Field Details
-
LISTENER_ENABLED_PROPERTY_NAME
Property name used to enable theGlobalEmbeddedKafkaTestExecutionListener. TheGlobalEmbeddedKafkaTestExecutionListeneris registered automatically via Java'sServiceLoadermechanism but disabled by default. Set the value of this property totrueto enable this listener.- See Also:
-
COUNT_PROPERTY_NAME
The number of brokers forEmbeddedKafkaBroker.- See Also:
-
PORTS_PROPERTY_NAME
The port(s) to expose embedded broker(s).- See Also:
-
TOPICS_PROPERTY_NAME
The topics to create on the embedded broker(s).- See Also:
-
PARTITIONS_PROPERTY_NAME
The number of partitions on topics to create on the embedded broker(s).- See Also:
-
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:
testPlanExecutionStartedin interfaceorg.junit.platform.launcher.TestExecutionListener
-
testPlanExecutionFinished
public void testPlanExecutionFinished(org.junit.platform.launcher.TestPlan testPlan) - Specified by:
testPlanExecutionFinishedin interfaceorg.junit.platform.launcher.TestExecutionListener
-