stop the cluster after each test to ensure no cross-contamination.
@@ -27,6 +27,7 @@ import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.common.serialization.Deserializer;
import org.apache.kafka.streams.KeyValue;
import org.apache.kafka.test.TestUtils;
+import org.junit.AfterClass;
import org.junit.ClassRule;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -47,6 +48,14 @@ public class MicroserviceTestUtils {
new KeyValue<>(KafkaConfig.TransactionsTopicPartitionsProp(), "1")
));
+ @AfterClass
+ public static void stopCluster() {
+ log.info("stopping cluster");
+ if (CLUSTER.isRunning()) {
+ CLUSTER.stop();
+ }
+ }
+
protected static Properties producerConfig(EmbeddedSingleNodeKafkaCluster cluster) {
Properties producerConfig = new Properties();
producerConfig.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, cluster.bootstrapServers());
