Package com.salesforce.kafka.test.junit5
Class SharedKafkaTestResource
java.lang.Object
com.salesforce.kafka.test.AbstractKafkaTestResource<SharedKafkaTestResource>
com.salesforce.kafka.test.junit5.SharedKafkaTestResource
- All Implemented Interfaces:
org.junit.jupiter.api.extension.AfterAllCallback,org.junit.jupiter.api.extension.BeforeAllCallback,org.junit.jupiter.api.extension.Extension
public class SharedKafkaTestResource
extends AbstractKafkaTestResource<SharedKafkaTestResource>
implements org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.AfterAllCallback
Creates and stands up an internal test kafka server to be shared across test cases within the same test class.
Example within your Test class.
@RegisterExtension
public static final SharedKafkaTestResource sharedKafkaTestResource = new SharedKafkaTestResource();
Within your test case method:
sharedKafkaTestResource.getKafkaTestServer()...
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.SharedKafkaTestResource(Properties brokerProperties)Constructor allowing passing additional broker properties. -
Method Summary
Modifier and TypeMethodDescriptionvoidafterAll(org.junit.jupiter.api.extension.ExtensionContext context)Here we shut down the internal test kafka and zookeeper services.voidbeforeAll(org.junit.jupiter.api.extension.ExtensionContext context)Here we stand up an internal test kafka and zookeeper service.Methods inherited from class com.salesforce.kafka.test.AbstractKafkaTestResource
getBrokerProperties, getKafkaBrokers, getKafkaCluster, getKafkaConnectString, getKafkaTestUtils, getNumberOfBrokers, getRegisteredListener, getZookeeperConnectString, registerListener, setKafkaCluster, validateState, withBrokerProperty, withBrokers
-
Constructor Details
-
SharedKafkaTestResource
public SharedKafkaTestResource()Default constructor. -
SharedKafkaTestResource
Constructor allowing passing additional broker properties.- Parameters:
brokerProperties- properties for Kafka broker.
-
-
Method Details
-
beforeAll
Here we stand up an internal test kafka and zookeeper service. Once for all tests that use this shared resource.- Specified by:
beforeAllin interfaceorg.junit.jupiter.api.extension.BeforeAllCallback- Throws:
Exception
-
afterAll
public void afterAll(org.junit.jupiter.api.extension.ExtensionContext context)Here we shut down the internal test kafka and zookeeper services.- Specified by:
afterAllin interfaceorg.junit.jupiter.api.extension.AfterAllCallback
-