Skip to content

Commit 35154a6

Browse files
committed
test: clean up state
1 parent 1436ec2 commit 35154a6

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

api/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,13 @@
155155
<artifactId>testcontainers</artifactId>
156156
<scope>test</scope>
157157
</dependency>
158+
159+
<dependency>
160+
<groupId>org.springframework</groupId>
161+
<artifactId>spring-test</artifactId>
162+
<scope>test</scope>
163+
</dependency>
164+
158165
<dependency>
159166
<groupId>org.testcontainers</groupId>
160167
<artifactId>kafka</artifactId>

api/src/test/java/io/kafbat/ui/AbstractIntegrationTest.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@
1212
import org.apache.kafka.clients.admin.AdminClientConfig;
1313
import org.apache.kafka.clients.admin.NewTopic;
1414
import org.jetbrains.annotations.NotNull;
15+
import org.junit.jupiter.api.AfterEach;
16+
import org.junit.jupiter.api.BeforeEach;
1517
import org.junit.jupiter.api.function.ThrowingConsumer;
1618
import org.junit.jupiter.api.io.TempDir;
1719
import org.springframework.beans.factory.annotation.Autowired;
1820
import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient;
1921
import org.springframework.boot.test.context.SpringBootTest;
2022
import org.springframework.context.ApplicationContextInitializer;
2123
import org.springframework.context.ConfigurableApplicationContext;
24+
import org.springframework.test.annotation.DirtiesContext;
2225
import org.springframework.test.context.ActiveProfiles;
2326
import org.springframework.test.context.ContextConfiguration;
2427
import org.springframework.test.util.TestSocketUtils;
@@ -31,6 +34,7 @@
3134
@ActiveProfiles("test")
3235
@AutoConfigureWebTestClient(timeout = "60000")
3336
@ContextConfiguration(initializers = {AbstractIntegrationTest.Initializer.class})
37+
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_EACH_TEST_METHOD)
3438
public abstract class AbstractIntegrationTest {
3539
public static final String LOCAL = "local";
3640
public static final String SECOND_LOCAL = "secondLocal";
@@ -63,7 +67,15 @@ public abstract class AbstractIntegrationTest {
6367
@TempDir
6468
public static Path tmpDir;
6569

66-
static {
70+
@AfterEach
71+
void afterEach() {
72+
kafka.stop();
73+
schemaRegistry.stop();
74+
kafkaConnect.stop();
75+
}
76+
77+
@BeforeEach
78+
void beforeEach() {
6779
kafka.start();
6880
schemaRegistry.start();
6981
kafkaConnect.start();

0 commit comments

Comments
 (0)