Commit 23cff6fb authored by Gary Russell's avatar Gary Russell Committed by Stephane Nicoll

KafkaAutoConfigurationIntegrationTests to JUnit5

See gh-17034
parent f9f6544d
......@@ -21,9 +21,10 @@ import java.util.concurrent.TimeUnit;
import org.apache.kafka.clients.admin.NewTopic;
import org.apache.kafka.clients.producer.Producer;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
......@@ -35,7 +36,7 @@ import org.springframework.kafka.config.StreamsBuilderFactoryBean;
import org.springframework.kafka.core.DefaultKafkaProducerFactory;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.kafka.support.KafkaHeaders;
import org.springframework.kafka.test.rule.EmbeddedKafkaRule;
import org.springframework.kafka.test.EmbeddedKafkaBroker;
import org.springframework.messaging.handler.annotation.Header;
import static org.assertj.core.api.Assertions.assertThat;
......@@ -52,12 +53,16 @@ public class KafkaAutoConfigurationIntegrationTests {
private static final String ADMIN_CREATED_TOPIC = "adminCreatedTopic";
@ClassRule
public static final EmbeddedKafkaRule embeddedKafka = new EmbeddedKafkaRule(1, true,
TEST_TOPIC);
public static final EmbeddedKafkaBroker embeddedKafka = new EmbeddedKafkaBroker(1,
true, TEST_TOPIC);
private AnnotationConfigApplicationContext context;
@BeforeAll
public static void setUp() {
embeddedKafka.afterPropertiesSet();
}
@AfterEach
public void close() {
if (this.context != null) {
......@@ -65,6 +70,11 @@ public class KafkaAutoConfigurationIntegrationTests {
}
}
@AfterAll
public static void tearDown() {
embeddedKafka.destroy();
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testEndToEnd() throws Exception {
......@@ -110,7 +120,7 @@ public class KafkaAutoConfigurationIntegrationTests {
}
private String getEmbeddedKafkaBrokersAsString() {
return embeddedKafka.getEmbeddedKafka().getBrokersAsString();
return embeddedKafka.getBrokersAsString();
}
@Configuration(proxyBeanMethods = false)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment