More @DirtiesContext in tests to mitigate memory

* Some other cleanups and modernizations for affected test class and their configurations
This commit is contained in:
Artem Bilan
2024-08-28 14:25:38 -04:00
parent eb07fda61b
commit 730e49adec
22 changed files with 185 additions and 303 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-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.
@@ -38,7 +38,7 @@ import org.springframework.integration.test.util.TestUtils;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.event.ApplicationEvents;
import org.springframework.test.context.event.RecordApplicationEvents;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
@@ -55,7 +55,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@SpringJUnitConfig
@RecordApplicationEvents
@ContextConfiguration
@DirtiesContext
public class EventOutboundChannelAdapterParserTests {
@Autowired

View File

@@ -76,6 +76,7 @@ public class ApplicationEventListeningMessageProducerTests {
Message<?> message3 = channel.receive(20);
assertThat(message3).isNotNull();
assertThat(((ApplicationEvent) message3.getPayload()).getSource()).isEqualTo("event2");
adapter.stop();
}
@Test
@@ -106,6 +107,7 @@ public class ApplicationEventListeningMessageProducerTests {
adapter.setEventTypes(null, null);
assertThat(adapter.supportsEventType(ResolvableType.forClass(TestApplicationEvent1.class))).isTrue();
assertThat(adapter.supportsEventType(ResolvableType.forClass(TestApplicationEvent2.class))).isTrue();
adapter.stop();
}
@Test
@@ -178,6 +180,7 @@ public class ApplicationEventListeningMessageProducerTests {
Message<?> message2 = channel.receive(20);
assertThat(message2).isNotNull();
assertThat(message2.getPayload()).isEqualTo("test");
adapter.stop();
}
@Test
@@ -192,6 +195,7 @@ public class ApplicationEventListeningMessageProducerTests {
Message<?> message2 = channel.receive(20);
assertThat(message2).isNotNull();
assertThat(message2.getPayload()).isEqualTo("test");
adapter.stop();
}
@Test
@@ -216,6 +220,7 @@ public class ApplicationEventListeningMessageProducerTests {
adapter.setErrorChannel(null);
assertThatExceptionOfType(MessageHandlingException.class)
.isThrownBy(() -> adapter.onApplicationEvent(new TestApplicationEvent1()));
adapter.stop();
}
@Test