From ffdbf6238c24d1249373b2999dc63c5a5424d907 Mon Sep 17 00:00:00 2001 From: "A. Sophie Blee-Goldman" Date: Tue, 24 Aug 2021 18:02:44 -0700 Subject: [PATCH 1/2] use EmbeddedKAfkaCluster as ClassRule in 2.8 --- .../integration/MetricsReporterIntegrationTest.java | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/streams/src/test/java/org/apache/kafka/streams/integration/MetricsReporterIntegrationTest.java b/streams/src/test/java/org/apache/kafka/streams/integration/MetricsReporterIntegrationTest.java index a7c925ad5f5a7..a8e0abb122f3a 100644 --- a/streams/src/test/java/org/apache/kafka/streams/integration/MetricsReporterIntegrationTest.java +++ b/streams/src/test/java/org/apache/kafka/streams/integration/MetricsReporterIntegrationTest.java @@ -31,6 +31,7 @@ import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; +import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -51,6 +52,7 @@ public class MetricsReporterIntegrationTest { private static final int NUM_BROKERS = 1; + @ClassRule public static final EmbeddedKafkaCluster CLUSTER = new EmbeddedKafkaCluster(NUM_BROKERS); // topic names @@ -63,16 +65,6 @@ public class MetricsReporterIntegrationTest { @Rule public TestName testName = new TestName(); - @BeforeClass - public static void startCluster() throws IOException { - CLUSTER.start(); - } - - @AfterClass - public static void closeCluster() { - CLUSTER.stop(); - } - @Before public void before() throws InterruptedException { builder = new StreamsBuilder(); From d797245ce953ff8c7fa2d025bdf36f2d119ca3a7 Mon Sep 17 00:00:00 2001 From: "A. Sophie Blee-Goldman" Date: Tue, 24 Aug 2021 18:20:29 -0700 Subject: [PATCH 2/2] just make it public instead for future compatibility --- .../integration/MetricsReporterIntegrationTest.java | 12 ++++++++++-- .../integration/utils/EmbeddedKafkaCluster.java | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/streams/src/test/java/org/apache/kafka/streams/integration/MetricsReporterIntegrationTest.java b/streams/src/test/java/org/apache/kafka/streams/integration/MetricsReporterIntegrationTest.java index a8e0abb122f3a..a7c925ad5f5a7 100644 --- a/streams/src/test/java/org/apache/kafka/streams/integration/MetricsReporterIntegrationTest.java +++ b/streams/src/test/java/org/apache/kafka/streams/integration/MetricsReporterIntegrationTest.java @@ -31,7 +31,6 @@ import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; -import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -52,7 +51,6 @@ public class MetricsReporterIntegrationTest { private static final int NUM_BROKERS = 1; - @ClassRule public static final EmbeddedKafkaCluster CLUSTER = new EmbeddedKafkaCluster(NUM_BROKERS); // topic names @@ -65,6 +63,16 @@ public class MetricsReporterIntegrationTest { @Rule public TestName testName = new TestName(); + @BeforeClass + public static void startCluster() throws IOException { + CLUSTER.start(); + } + + @AfterClass + public static void closeCluster() { + CLUSTER.stop(); + } + @Before public void before() throws InterruptedException { builder = new StreamsBuilder(); diff --git a/streams/src/test/java/org/apache/kafka/streams/integration/utils/EmbeddedKafkaCluster.java b/streams/src/test/java/org/apache/kafka/streams/integration/utils/EmbeddedKafkaCluster.java index af83248404ae9..ec7e2e2b42207 100644 --- a/streams/src/test/java/org/apache/kafka/streams/integration/utils/EmbeddedKafkaCluster.java +++ b/streams/src/test/java/org/apache/kafka/streams/integration/utils/EmbeddedKafkaCluster.java @@ -119,7 +119,7 @@ private void putIfAbsent(final Properties props, final String propertyKey, final /** * Stop the Kafka cluster. */ - private void stop() { + public void stop() { if (brokers.length > 1) { // delete the topics first to avoid cascading leader elections while shutting down the brokers final Set topics = getAllTopicsInCluster();