Skip to content

Commit

Permalink
Adding DirtiesContext to WithNestedClassContextTests
Browse files Browse the repository at this point in the history
* To prevent a race condition on shutdown that is causing certain file operations to fail,
  we need to add `DirtiesContext` to `WithNestedClassContextTests.`
  • Loading branch information
sobychacko committed Apr 30, 2024
1 parent e547d0a commit 572d13a
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021-2023 the original author or authors.
* Copyright 2021-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,10 +28,16 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.test.context.EmbeddedKafka;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;

/**
* @author Lee Jaeheon
* @author Soby Chacko
*/
@EmbeddedKafka
@SpringJUnitConfig(WithNestedClassContextTests.Config.class)
@DirtiesContext
class WithNestedClassContextTests {

private static final AtomicInteger counter = new AtomicInteger();
Expand All @@ -56,17 +62,20 @@ void equalsSize(@Autowired List<TestClass> classes) {
void equalsCount() {
assertThat(counter.get()).isEqualTo(1);
}
}

public static class TestClass {
}

public static class TestClass { }

@Configuration
static class Config {

@Bean
public TestClass testClass() {
counter.incrementAndGet();
return new TestClass();
}

}

}

0 comments on commit 572d13a

Please sign in to comment.