Skip to content

Commit db59442

Browse files
committed
Add @DirtiesContext to tests to clean up app ctx cache
And attempt to mitigate out of memory error on CI/CD
1 parent 162ef4a commit db59442

File tree

14 files changed

+39
-12
lines changed

14 files changed

+39
-12
lines changed

spring-amqp/src/test/java/org/springframework/amqp/support/converter/Jackson2JsonMessageConverterTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -34,6 +34,7 @@
3434
import org.springframework.beans.factory.annotation.Autowired;
3535
import org.springframework.core.ParameterizedTypeReference;
3636
import org.springframework.data.web.JsonPath;
37+
import org.springframework.test.annotation.DirtiesContext;
3738
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
3839
import org.springframework.util.MimeTypeUtils;
3940

@@ -54,6 +55,7 @@
5455
* @author Artem Bilan
5556
*/
5657
@SpringJUnitConfig
58+
@DirtiesContext
5759
public class Jackson2JsonMessageConverterTests {
5860

5961
public static final String TRUSTED_PACKAGE = Jackson2JsonMessageConverterTests.class.getPackage().getName();

spring-amqp/src/test/java/org/springframework/amqp/support/converter/Jackson2XmlMessageConverterTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018-2019 the original author or authors.
2+
* Copyright 2018-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@
3131
import org.springframework.amqp.core.MessageProperties;
3232
import org.springframework.beans.factory.annotation.Autowired;
3333
import org.springframework.core.ParameterizedTypeReference;
34+
import org.springframework.test.annotation.DirtiesContext;
3435
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
3536

3637
import com.fasterxml.jackson.databind.ser.BeanSerializerFactory;
@@ -43,6 +44,7 @@
4344
* @since 2.1
4445
*/
4546
@SpringJUnitConfig
47+
@DirtiesContext
4648
public class Jackson2XmlMessageConverterTests {
4749

4850
public static final String TRUSTED_PACKAGE = Jackson2XmlMessageConverterTests.class.getPackage().getName();

spring-rabbit-stream/src/test/java/org/springframework/rabbit/stream/config/SuperStreamProvisioningTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2022 the original author or authors.
2+
* Copyright 2022-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -32,6 +32,7 @@
3232
import org.springframework.beans.factory.annotation.Autowired;
3333
import org.springframework.context.annotation.Bean;
3434
import org.springframework.context.annotation.Configuration;
35+
import org.springframework.test.annotation.DirtiesContext;
3536
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
3637

3738
/**
@@ -40,6 +41,7 @@
4041
*
4142
*/
4243
@SpringJUnitConfig
44+
@DirtiesContext
4345
public class SuperStreamProvisioningTests extends AbstractTestContainerTests {
4446

4547
@Test

spring-rabbit-stream/src/test/java/org/springframework/rabbit/stream/listener/SuperStreamConcurrentSACTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2022-2023 the original author or authors.
2+
* Copyright 2022-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -37,6 +37,7 @@
3737
import org.springframework.context.annotation.Bean;
3838
import org.springframework.context.annotation.Configuration;
3939
import org.springframework.rabbit.stream.config.SuperStream;
40+
import org.springframework.test.annotation.DirtiesContext;
4041
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
4142

4243
import com.rabbitmq.stream.Environment;
@@ -49,6 +50,7 @@
4950
*
5051
*/
5152
@SpringJUnitConfig
53+
@DirtiesContext
5254
public class SuperStreamConcurrentSACTests extends AbstractTestContainerTests {
5355

5456
@Test

spring-rabbit-stream/src/test/java/org/springframework/rabbit/stream/listener/SuperStreamSACTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2022-2023 the original author or authors.
2+
* Copyright 2022-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -45,6 +45,7 @@
4545
import org.springframework.context.annotation.Configuration;
4646
import org.springframework.context.annotation.Scope;
4747
import org.springframework.rabbit.stream.config.SuperStream;
48+
import org.springframework.test.annotation.DirtiesContext;
4849
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
4950

5051
import com.rabbitmq.stream.Environment;
@@ -57,6 +58,7 @@
5758
*
5859
*/
5960
@SpringJUnitConfig
61+
@DirtiesContext
6062
public class SuperStreamSACTests extends AbstractTestContainerTests {
6163

6264
@Test

spring-rabbit-test/src/test/java/org/springframework/amqp/rabbit/test/context/SpringRabbitTestTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020 the original author or authors.
2+
* Copyright 2020-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@
2929
import org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistry;
3030
import org.springframework.beans.factory.annotation.Autowired;
3131
import org.springframework.context.annotation.Configuration;
32+
import org.springframework.test.annotation.DirtiesContext;
3233
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
3334

3435
/**
@@ -39,6 +40,7 @@
3940
@RabbitAvailable
4041
@SpringJUnitConfig
4142
@SpringRabbitTest
43+
@DirtiesContext
4244
public class SpringRabbitTestTests {
4345

4446
@Autowired

spring-rabbit-test/src/test/java/org/springframework/amqp/rabbit/test/examples/TestRabbitTemplateTests.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import org.springframework.beans.factory.annotation.Autowired;
4040
import org.springframework.context.annotation.Bean;
4141
import org.springframework.context.annotation.Configuration;
42+
import org.springframework.test.annotation.DirtiesContext;
4243
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
4344

4445
import com.rabbitmq.client.AMQP;
@@ -53,6 +54,7 @@
5354
*
5455
*/
5556
@SpringJUnitConfig
57+
@DirtiesContext
5658
public class TestRabbitTemplateTests {
5759

5860
@Autowired

spring-rabbit/src/test/java/org/springframework/amqp/rabbit/annotation/ContentTypeDelegatingMessageConverterIntegrationTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020 the original author or authors.
2+
* Copyright 2020-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -44,6 +44,7 @@
4444
import org.springframework.messaging.MessageHeaders;
4545
import org.springframework.messaging.handler.annotation.SendTo;
4646
import org.springframework.messaging.support.MessageBuilder;
47+
import org.springframework.test.annotation.DirtiesContext;
4748
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
4849
import org.springframework.util.MimeType;
4950

@@ -54,6 +55,7 @@
5455
*/
5556
@RabbitAvailable
5657
@SpringJUnitConfig
58+
@DirtiesContext
5759
public class ContentTypeDelegatingMessageConverterIntegrationTests {
5860

5961
@Autowired

spring-rabbit/src/test/java/org/springframework/amqp/rabbit/annotation/OptionalPayloadTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2022 the original author or authors.
2+
* Copyright 2022-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -40,6 +40,7 @@
4040
import org.springframework.context.annotation.Bean;
4141
import org.springframework.context.annotation.Configuration;
4242
import org.springframework.messaging.handler.annotation.Payload;
43+
import org.springframework.test.annotation.DirtiesContext;
4344
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
4445

4546
import com.fasterxml.jackson.core.JsonProcessingException;
@@ -52,6 +53,7 @@
5253
*/
5354
@SpringJUnitConfig
5455
@RabbitAvailable(queues = { "op.1", "op.2" })
56+
@DirtiesContext
5557
public class OptionalPayloadTests {
5658

5759
@Test

spring-rabbit/src/test/java/org/springframework/amqp/rabbit/listener/AsyncReplyToTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021-2022 the original author or authors.
2+
* Copyright 2021-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -44,6 +44,7 @@
4444
import org.springframework.beans.factory.annotation.Autowired;
4545
import org.springframework.context.annotation.Bean;
4646
import org.springframework.context.annotation.Configuration;
47+
import org.springframework.test.annotation.DirtiesContext;
4748
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
4849

4950
import com.rabbitmq.client.Channel;
@@ -55,6 +56,7 @@
5556
*/
5657
@SpringJUnitConfig
5758
@RabbitAvailable(queues = { "async1", "async2" })
59+
@DirtiesContext
5860
public class AsyncReplyToTests {
5961

6062
@Test

0 commit comments

Comments
 (0)