* `StorageStrategy` depends on Spring to call the method
`ChatBackendApplication#onExit()`, that is annotated with `@PreDestroy`.
* If this method is not called, the strategy is not applied, which leads
to errors in the integration-tests.
* This happens, if all tests are run through Maven, because Spring
recycles the application-context and only tears down the context after
all tests have run.
* The addition of `@DirtiesContext` on those tests forces Spring to tear
down the application completely after each so annotated test.
* Hence, the method is called as expected, which fixes the described
errors.
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.http.MediaType;
+import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.web.reactive.server.WebTestClient;
import org.testcontainers.shaded.org.awaitility.Awaitility;
@Slf4j
+@DirtiesContext
public abstract class AbstractConfigurationIT
{
final static String EXISTING_CHATROOM = "5c73531c-6fc4-426c-adcb-afc5c140a0f7";