Skip to content

Commit 85855ec

Browse files
committed
Merge branch '6.2.x'
2 parents 2f6d142 + 9797bc0 commit 85855ec

13 files changed

+170
-41
lines changed

spring-test/src/main/java/org/springframework/test/context/TestContextManager.java

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 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.
@@ -389,8 +389,8 @@ public void beforeTestExecution(Object testInstance, Method testMethod) throws E
389389
* have executed, the first caught exception will be rethrown with any
390390
* subsequent exceptions {@linkplain Throwable#addSuppressed suppressed} in
391391
* the first exception.
392-
* <p>Note that registered listeners will be executed in the opposite
393-
* order in which they were registered.
392+
* <p>Note that listeners will be executed in the opposite order in which they
393+
* were registered.
394394
* @param testInstance the current test instance
395395
* @param testMethod the test method which has just been executed on the
396396
* test instance
@@ -459,7 +459,8 @@ public void afterTestExecution(Object testInstance, Method testMethod, @Nullable
459459
* have executed, the first caught exception will be rethrown with any
460460
* subsequent exceptions {@linkplain Throwable#addSuppressed suppressed} in
461461
* the first exception.
462-
* <p>Note that registered listeners will be executed in the opposite
462+
* <p>Note that listeners will be executed in the opposite order in which they
463+
* were registered.
463464
* @param testInstance the current test instance
464465
* @param testMethod the test method which has just been executed on the
465466
* test instance
@@ -517,7 +518,8 @@ public void afterTestMethod(Object testInstance, Method testMethod, @Nullable Th
517518
* have executed, the first caught exception will be rethrown with any
518519
* subsequent exceptions {@linkplain Throwable#addSuppressed suppressed} in
519520
* the first exception.
520-
* <p>Note that registered listeners will be executed in the opposite
521+
* <p>Note that listeners will be executed in the opposite order in which they
522+
* were registered.
521523
* @throws Exception if a registered TestExecutionListener throws an exception
522524
* @since 3.0
523525
* @see #getTestExecutionListeners()

spring-test/src/main/java/org/springframework/test/context/bean/override/BeanOverrideTestExecutionListener.java

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 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,15 +37,21 @@
3737
public class BeanOverrideTestExecutionListener extends AbstractTestExecutionListener {
3838

3939
/**
40-
* Returns {@code 1950}, which ensures that the {@code BeanOverrideTestExecutionListener}
40+
* The {@link #getOrder() order} value for this listener: {@value}.
41+
* @since 6.2.3
42+
*/
43+
public static final int ORDER = 1950;
44+
45+
/**
46+
* Returns {@value #ORDER}, which ensures that the {@code BeanOverrideTestExecutionListener}
4147
* is ordered after the
4248
* {@link org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener
43-
* DirtiesContextBeforeModesTestExecutionListener} and just before the
49+
* DirtiesContextBeforeModesTestExecutionListener} and before the
4450
* {@link DependencyInjectionTestExecutionListener}.
4551
*/
4652
@Override
4753
public int getOrder() {
48-
return 1950;
54+
return ORDER;
4955
}
5056

5157
/**

spring-test/src/main/java/org/springframework/test/context/bean/override/mockito/MockitoResetTestExecutionListener.java

+11-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@
4949
*/
5050
public class MockitoResetTestExecutionListener extends AbstractTestExecutionListener {
5151

52+
/**
53+
* The {@link #getOrder() order} value for this listener
54+
* ({@code Ordered.LOWEST_PRECEDENCE - 100}): {@value}.
55+
* @since 6.2.3
56+
*/
57+
public static final int ORDER = Ordered.LOWEST_PRECEDENCE - 100;
58+
5259
private static final Log logger = LogFactory.getLog(MockitoResetTestExecutionListener.class);
5360

5461
/**
@@ -73,7 +80,10 @@ public class MockitoResetTestExecutionListener extends AbstractTestExecutionList
7380

7481

7582
/**
76-
* Returns {@code Ordered.LOWEST_PRECEDENCE - 100}.
83+
* Returns {@value #ORDER}, which ensures that the
84+
* {@code MockitoResetTestExecutionListener} is ordered after all standard
85+
* {@code TestExecutionListener} implementations.
86+
* @see #ORDER
7787
*/
7888
@Override
7989
public int getOrder() {

spring-test/src/main/java/org/springframework/test/context/event/ApplicationEventsTestExecutionListener.java

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2025 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.
@@ -48,6 +48,12 @@
4848
*/
4949
public class ApplicationEventsTestExecutionListener extends AbstractTestExecutionListener {
5050

51+
/**
52+
* The {@link #getOrder() order} value for this listener: {@value}.
53+
* @since 6.2.3
54+
*/
55+
public static final int ORDER = 1800;
56+
5157
/**
5258
* Attribute name for a {@link TestContext} attribute which indicates
5359
* whether the test class for the given test context is annotated with
@@ -61,11 +67,18 @@ public class ApplicationEventsTestExecutionListener extends AbstractTestExecutio
6167

6268

6369
/**
64-
* Returns {@code 1800}.
70+
* Returns {@value #ORDER}, which ensures that the {@code ApplicationEventsTestExecutionListener}
71+
* is ordered after the
72+
* {@link org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener
73+
* DirtiesContextBeforeModesTestExecutionListener} and before the
74+
* {@link org.springframework.test.context.bean.override.BeanOverrideTestExecutionListener
75+
* BeanOverrideTestExecutionListener} and the
76+
* {@link org.springframework.test.context.support.DependencyInjectionTestExecutionListener
77+
* DependencyInjectionTestExecutionListener}.
6578
*/
6679
@Override
6780
public final int getOrder() {
68-
return 1800;
81+
return ORDER;
6982
}
7083

7184
@Override

spring-test/src/main/java/org/springframework/test/context/event/EventPublishingTestExecutionListener.java

+14-3
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-2025 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.
@@ -98,11 +98,22 @@
9898
public class EventPublishingTestExecutionListener extends AbstractTestExecutionListener {
9999

100100
/**
101-
* Returns {@code 10000}.
101+
* The {@link #getOrder() order} value for this listener: {@value}.
102+
* @since 6.2.3
103+
*/
104+
public static final int ORDER = 10_000;
105+
106+
/**
107+
* Returns {@value #ORDER}, which ensures that the {@code EventPublishingTestExecutionListener}
108+
* is ordered after the
109+
* {@link org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener
110+
* SqlScriptsTestExecutionListener} and before the
111+
* {@link org.springframework.test.context.bean.override.mockito.MockitoResetTestExecutionListener
112+
* MockitoResetTestExecutionListener}.
102113
*/
103114
@Override
104115
public final int getOrder() {
105-
return 10_000;
116+
return ORDER;
106117
}
107118

108119
/**

spring-test/src/main/java/org/springframework/test/context/jdbc/SqlScriptsTestExecutionListener.java

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 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.
@@ -117,6 +117,12 @@
117117
*/
118118
public class SqlScriptsTestExecutionListener extends AbstractTestExecutionListener implements AotTestExecutionListener {
119119

120+
/**
121+
* The {@link #getOrder() order} value for this listener: {@value}.
122+
* @since 6.2.3
123+
*/
124+
public static final int ORDER = 5000;
125+
120126
private static final String SLASH = "/";
121127

122128
private static final Log logger = LogFactory.getLog(SqlScriptsTestExecutionListener.class);
@@ -126,11 +132,16 @@ public class SqlScriptsTestExecutionListener extends AbstractTestExecutionListen
126132

127133

128134
/**
129-
* Returns {@code 5000}.
135+
* Returns {@value #ORDER}, which ensures that the {@code SqlScriptsTestExecutionListener}
136+
* is ordered after the
137+
* {@link org.springframework.test.context.transaction.TransactionalTestExecutionListener
138+
* TransactionalTestExecutionListener} and before the
139+
* {@link org.springframework.test.context.event.EventPublishingTestExecutionListener
140+
* EventPublishingTestExecutionListener}.
130141
*/
131142
@Override
132143
public final int getOrder() {
133-
return 5000;
144+
return ORDER;
134145
}
135146

136147
/**

spring-test/src/main/java/org/springframework/test/context/observation/MicrometerObservationRegistryTestExecutionListener.java

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 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,12 @@
4444
*/
4545
class MicrometerObservationRegistryTestExecutionListener extends AbstractTestExecutionListener {
4646

47+
/**
48+
* The {@link #getOrder() order} value for this listener: {@value}.
49+
* @since 6.2.3
50+
*/
51+
public static final int ORDER = 2500;
52+
4753
private static final Log logger = LogFactory.getLog(MicrometerObservationRegistryTestExecutionListener.class);
4854

4955
/**
@@ -106,11 +112,16 @@ public MicrometerObservationRegistryTestExecutionListener() {
106112

107113

108114
/**
109-
* Returns {@code 2500}.
115+
* Returns {@value #ORDER}, which ensures that the
116+
* {@code MicrometerObservationRegistryTestExecutionListener} is ordered after the
117+
* {@link org.springframework.test.context.support.DependencyInjectionTestExecutionListener
118+
* DependencyInjectionTestExecutionListener} and before the
119+
* {@link org.springframework.test.context.support.DirtiesContextTestExecutionListener
120+
* DirtiesContextTestExecutionListener}.
110121
*/
111122
@Override
112123
public final int getOrder() {
113-
return 2500;
124+
return ORDER;
114125
}
115126

116127
/**

spring-test/src/main/java/org/springframework/test/context/support/CommonCachesTestExecutionListener.java

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 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.
@@ -36,14 +36,24 @@
3636
public class CommonCachesTestExecutionListener extends AbstractTestExecutionListener {
3737

3838
/**
39-
* Returns {@code 3005}.
39+
* The {@link #getOrder() order} value for this listener: {@value}.
40+
* @since 6.2.3
41+
*/
42+
public static final int ORDER = 3005;
43+
44+
45+
/**
46+
* Returns {@value #ORDER}, which ensures that the {@code CommonCachesTestExecutionListener}
47+
* is ordered after the
48+
* {@link DirtiesContextTestExecutionListener DirtiesContextTestExecutionListener} and before the
49+
* {@link org.springframework.test.context.transaction.TransactionalTestExecutionListener
50+
* TransactionalTestExecutionListener}.
4051
*/
4152
@Override
4253
public final int getOrder() {
43-
return 3005;
54+
return ORDER;
4455
}
4556

46-
4757
@Override
4858
public void afterTestClass(TestContext testContext) throws Exception {
4959
if (testContext.hasApplicationContext()) {

spring-test/src/main/java/org/springframework/test/context/support/DependencyInjectionTestExecutionListener.java

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 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.
@@ -39,6 +39,12 @@
3939
*/
4040
public class DependencyInjectionTestExecutionListener extends AbstractTestExecutionListener {
4141

42+
/**
43+
* The {@link #getOrder() order} value for this listener: {@value}.
44+
* @since 6.2.3
45+
*/
46+
public static final int ORDER = 2000;
47+
4248
/**
4349
* Attribute name for a {@link TestContext} attribute which indicates
4450
* whether the dependencies of a test instance should be
@@ -63,11 +69,18 @@ public class DependencyInjectionTestExecutionListener extends AbstractTestExecut
6369

6470

6571
/**
66-
* Returns {@code 2000}.
72+
* Returns {@value #ORDER}, which ensures that the {@code DependencyInjectionTestExecutionListener}
73+
* is ordered after the
74+
* {@link DirtiesContextBeforeModesTestExecutionListener DirtiesContextBeforeModesTestExecutionListener}
75+
* and the {@link org.springframework.test.context.bean.override.BeanOverrideTestExecutionListener
76+
* BeanOverrideTestExecutionListener} and before the
77+
* {@link org.springframework.test.context.observation.MicrometerObservationRegistryTestExecutionListener
78+
* MicrometerObservationRegistryTestExecutionListener} and the
79+
* {@link DirtiesContextTestExecutionListener DirtiesContextTestExecutionListener}.
6780
*/
6881
@Override
6982
public final int getOrder() {
70-
return 2000;
83+
return ORDER;
7184
}
7285

7386
/**

spring-test/src/main/java/org/springframework/test/context/support/DirtiesContextBeforeModesTestExecutionListener.java

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2025 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.
@@ -55,11 +55,24 @@
5555
public class DirtiesContextBeforeModesTestExecutionListener extends AbstractDirtiesContextTestExecutionListener {
5656

5757
/**
58-
* Returns {@code 1500}.
58+
* The {@link #getOrder() order} value for this listener: {@value}.
59+
* @since 6.2.3
60+
*/
61+
public static final int ORDER = 1500;
62+
63+
/**
64+
* Returns {@value #ORDER}, which ensures that the
65+
* {@code DirtiesContextBeforeModesTestExecutionListener} is ordered after the
66+
* {@link org.springframework.test.context.web.ServletTestExecutionListener
67+
* ServletTestExecutionListener} and before the
68+
* {@link org.springframework.test.context.event.ApplicationEventsTestExecutionListener
69+
* ApplicationEventsTestExecutionListener} and the
70+
* {@link org.springframework.test.context.bean.override.BeanOverrideTestExecutionListener
71+
* BeanOverrideTestExecutionListener}.
5972
*/
6073
@Override
6174
public final int getOrder() {
62-
return 1500;
75+
return ORDER;
6376
}
6477

6578
/**

spring-test/src/main/java/org/springframework/test/context/support/DirtiesContextTestExecutionListener.java

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2025 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.
@@ -55,11 +55,20 @@
5555
public class DirtiesContextTestExecutionListener extends AbstractDirtiesContextTestExecutionListener {
5656

5757
/**
58-
* Returns {@code 3000}.
58+
* The {@link #getOrder() order} value for this listener: {@value}.
59+
* @since 6.2.3
60+
*/
61+
public static final int ORDER = 3000;
62+
63+
/**
64+
* Returns {@value #ORDER}, which ensures that the {@code DirtiesContextTestExecutionListener}
65+
* is ordered after the
66+
* {@link DependencyInjectionTestExecutionListener DependencyInjectionTestExecutionListener}
67+
* and before the {@link CommonCachesTestExecutionListener CommonCachesTestExecutionListener}.
5968
*/
6069
@Override
6170
public final int getOrder() {
62-
return 3000;
71+
return ORDER;
6372
}
6473

6574
/**

0 commit comments

Comments
 (0)