From 128e90064e2ec33fc0db3357e1bf7c7d31d9600b Mon Sep 17 00:00:00 2001 From: Mengqi Xu <2663479778@qq.com> Date: Wed, 15 Jan 2025 22:30:43 +0800 Subject: [PATCH] Document order values for TestExecutionListener implementations Closes gh-34265 Signed-off-by: Mengqi Xu <2663479778@qq.com> --- .../event/ApplicationEventsTestExecutionListener.java | 7 ++++++- .../event/EventPublishingTestExecutionListener.java | 5 ++++- .../test/context/jdbc/SqlScriptsTestExecutionListener.java | 7 ++++++- ...MicrometerObservationRegistryTestExecutionListener.java | 7 ++++++- .../context/support/CommonCachesTestExecutionListener.java | 7 ++++++- .../support/DependencyInjectionTestExecutionListener.java | 7 ++++++- .../DirtiesContextBeforeModesTestExecutionListener.java | 7 ++++++- .../support/DirtiesContextTestExecutionListener.java | 7 ++++++- .../transaction/TransactionalTestExecutionListener.java | 7 ++++++- .../test/context/web/ServletTestExecutionListener.java | 5 ++++- 10 files changed, 56 insertions(+), 10 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/test/context/event/ApplicationEventsTestExecutionListener.java b/spring-test/src/main/java/org/springframework/test/context/event/ApplicationEventsTestExecutionListener.java index c2362297e0a..1cf69c055e2 100644 --- a/spring-test/src/main/java/org/springframework/test/context/event/ApplicationEventsTestExecutionListener.java +++ b/spring-test/src/main/java/org/springframework/test/context/event/ApplicationEventsTestExecutionListener.java @@ -61,7 +61,12 @@ public class ApplicationEventsTestExecutionListener extends AbstractTestExecutio /** - * Returns {@code 1800}. + * Returns {@code 1800}, which ensures that the {@code ApplicationEventsTestExecutionListener} + * is ordered after the + * {@link org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener + * DirtiesContextBeforeModesTestExecutionListener} and just before the + * {@link org.springframework.test.context.bean.override.BeanOverrideTestExecutionListener + * BeanOverrideTestExecutionListener}. */ @Override public final int getOrder() { diff --git a/spring-test/src/main/java/org/springframework/test/context/event/EventPublishingTestExecutionListener.java b/spring-test/src/main/java/org/springframework/test/context/event/EventPublishingTestExecutionListener.java index 953b5710ce8..419298c0c14 100644 --- a/spring-test/src/main/java/org/springframework/test/context/event/EventPublishingTestExecutionListener.java +++ b/spring-test/src/main/java/org/springframework/test/context/event/EventPublishingTestExecutionListener.java @@ -98,7 +98,10 @@ import org.springframework.test.context.support.AbstractTestExecutionListener; public class EventPublishingTestExecutionListener extends AbstractTestExecutionListener { /** - * Returns {@code 10000}. + * Returns {@code 10000}, which ensures that the {@code EventPublishingTestExecutionListener} + * is ordered after the + * {@link org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener + * SqlScriptsTestExecutionListener}. */ @Override public final int getOrder() { diff --git a/spring-test/src/main/java/org/springframework/test/context/jdbc/SqlScriptsTestExecutionListener.java b/spring-test/src/main/java/org/springframework/test/context/jdbc/SqlScriptsTestExecutionListener.java index 0b0534dd049..313c26bfc31 100644 --- a/spring-test/src/main/java/org/springframework/test/context/jdbc/SqlScriptsTestExecutionListener.java +++ b/spring-test/src/main/java/org/springframework/test/context/jdbc/SqlScriptsTestExecutionListener.java @@ -126,7 +126,12 @@ public class SqlScriptsTestExecutionListener extends AbstractTestExecutionListen /** - * Returns {@code 5000}. + * Returns {@code 5000}, which ensures that the {@code SqlScriptsTestExecutionListener} + * is ordered after the + * {@link org.springframework.test.context.transaction.TransactionalTestExecutionListener + * TransactionalTestExecutionListener} and just before the + * {@link org.springframework.test.context.event.EventPublishingTestExecutionListener + * EventPublishingTestExecutionListener}. */ @Override public final int getOrder() { diff --git a/spring-test/src/main/java/org/springframework/test/context/observation/MicrometerObservationRegistryTestExecutionListener.java b/spring-test/src/main/java/org/springframework/test/context/observation/MicrometerObservationRegistryTestExecutionListener.java index 18bf72b6721..3796682d63d 100644 --- a/spring-test/src/main/java/org/springframework/test/context/observation/MicrometerObservationRegistryTestExecutionListener.java +++ b/spring-test/src/main/java/org/springframework/test/context/observation/MicrometerObservationRegistryTestExecutionListener.java @@ -107,7 +107,12 @@ class MicrometerObservationRegistryTestExecutionListener extends AbstractTestExe /** - * Returns {@code 2500}. + * Returns {@code 2500}, which ensures that the {@code MicrometerObservationRegistryTestExecutionListener} + * is ordered after the + * {@link org.springframework.test.context.support.DependencyInjectionTestExecutionListener + * DependencyInjectionTestExecutionListener} and just before the + * {@link org.springframework.test.context.support.DirtiesContextTestExecutionListener + * DirtiesContextTestExecutionListener}. */ @Override public final int getOrder() { diff --git a/spring-test/src/main/java/org/springframework/test/context/support/CommonCachesTestExecutionListener.java b/spring-test/src/main/java/org/springframework/test/context/support/CommonCachesTestExecutionListener.java index 34436b929ea..6c803ff9877 100644 --- a/spring-test/src/main/java/org/springframework/test/context/support/CommonCachesTestExecutionListener.java +++ b/spring-test/src/main/java/org/springframework/test/context/support/CommonCachesTestExecutionListener.java @@ -36,7 +36,12 @@ import org.springframework.test.context.TestContext; public class CommonCachesTestExecutionListener extends AbstractTestExecutionListener { /** - * Returns {@code 3005}. + * Returns {@code 3005}, which ensures that the {@code CommonCachesTestExecutionListener} + * is ordered after the + * {@link org.springframework.test.context.support.DirtiesContextTestExecutionListener + * DirtiesContextTestExecutionListener} and just before the + * {@link org.springframework.test.context.transaction.TransactionalTestExecutionListener + * TransactionalTestExecutionListener}. */ @Override public final int getOrder() { diff --git a/spring-test/src/main/java/org/springframework/test/context/support/DependencyInjectionTestExecutionListener.java b/spring-test/src/main/java/org/springframework/test/context/support/DependencyInjectionTestExecutionListener.java index 916dbd50d06..d0df2d8d96e 100644 --- a/spring-test/src/main/java/org/springframework/test/context/support/DependencyInjectionTestExecutionListener.java +++ b/spring-test/src/main/java/org/springframework/test/context/support/DependencyInjectionTestExecutionListener.java @@ -63,7 +63,12 @@ public class DependencyInjectionTestExecutionListener extends AbstractTestExecut /** - * Returns {@code 2000}. + * Returns {@code 2000}, which ensures that the {@code ApplicationEventsTestExecutionListener} + * is ordered after the + * {@link org.springframework.test.context.bean.override.BeanOverrideTestExecutionListener + * BeanOverrideTestExecutionListener} and just before the + * {@link org.springframework.test.context.support.DirtiesContextTestExecutionListener + * DirtiesContextTestExecutionListener}. */ @Override public final int getOrder() { diff --git a/spring-test/src/main/java/org/springframework/test/context/support/DirtiesContextBeforeModesTestExecutionListener.java b/spring-test/src/main/java/org/springframework/test/context/support/DirtiesContextBeforeModesTestExecutionListener.java index 54fca1b8e10..276c58e70f4 100644 --- a/spring-test/src/main/java/org/springframework/test/context/support/DirtiesContextBeforeModesTestExecutionListener.java +++ b/spring-test/src/main/java/org/springframework/test/context/support/DirtiesContextBeforeModesTestExecutionListener.java @@ -55,7 +55,12 @@ import static org.springframework.test.annotation.DirtiesContext.MethodMode.BEFO public class DirtiesContextBeforeModesTestExecutionListener extends AbstractDirtiesContextTestExecutionListener { /** - * Returns {@code 1500}. + * Returns {@code 1500}, which ensures that the {@code DirtiesContextBeforeModesTestExecutionListener} + * is ordered after the + * {@link org.springframework.test.context.web.ServletTestExecutionListener + * ServletTestExecutionListener} and just before the + * {@link org.springframework.test.context.bean.override.BeanOverrideTestExecutionListener + * BeanOverrideTestExecutionListener}. */ @Override public final int getOrder() { diff --git a/spring-test/src/main/java/org/springframework/test/context/support/DirtiesContextTestExecutionListener.java b/spring-test/src/main/java/org/springframework/test/context/support/DirtiesContextTestExecutionListener.java index 91aa1e794d3..d1f40a56ece 100644 --- a/spring-test/src/main/java/org/springframework/test/context/support/DirtiesContextTestExecutionListener.java +++ b/spring-test/src/main/java/org/springframework/test/context/support/DirtiesContextTestExecutionListener.java @@ -55,7 +55,12 @@ import static org.springframework.test.annotation.DirtiesContext.MethodMode.AFTE public class DirtiesContextTestExecutionListener extends AbstractDirtiesContextTestExecutionListener { /** - * Returns {@code 3000}. + * Returns {@code 3000}, which ensures that the {@code DirtiesContextTestExecutionListener} + * is ordered after the + * {@link org.springframework.test.context.support.DependencyInjectionTestExecutionListener + * DependencyInjectionTestExecutionListener} and just before the + * {@link org.springframework.test.context.support.CommonCachesTestExecutionListener + * CommonCachesTestExecutionListener}. */ @Override public final int getOrder() { diff --git a/spring-test/src/main/java/org/springframework/test/context/transaction/TransactionalTestExecutionListener.java b/spring-test/src/main/java/org/springframework/test/context/transaction/TransactionalTestExecutionListener.java index 8322a84b605..b37f5cc9055 100644 --- a/spring-test/src/main/java/org/springframework/test/context/transaction/TransactionalTestExecutionListener.java +++ b/spring-test/src/main/java/org/springframework/test/context/transaction/TransactionalTestExecutionListener.java @@ -177,7 +177,12 @@ public class TransactionalTestExecutionListener extends AbstractTestExecutionLis /** - * Returns {@code 4000}. + * Returns {@code 4000}, which ensures that the {@code TransactionalTestExecutionListener} + * is ordered after the + * {@link org.springframework.test.context.support.CommonCachesTestExecutionListener + * CommonCachesTestExecutionListener} and just before the + * {@link org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener + * SqlScriptsTestExecutionListener}. */ @Override public final int getOrder() { diff --git a/spring-test/src/main/java/org/springframework/test/context/web/ServletTestExecutionListener.java b/spring-test/src/main/java/org/springframework/test/context/web/ServletTestExecutionListener.java index 6992cf06285..650ce10dda1 100644 --- a/spring-test/src/main/java/org/springframework/test/context/web/ServletTestExecutionListener.java +++ b/spring-test/src/main/java/org/springframework/test/context/web/ServletTestExecutionListener.java @@ -110,7 +110,10 @@ public class ServletTestExecutionListener extends AbstractTestExecutionListener /** - * Returns {@code 1000}. + * Returns {@code 1000}, which ensures that the {@code ServletTestExecutionListener} + * is ordered before the + * {@link org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener + * DirtiesContextBeforeModesTestExecutionListener}. */ @Override public final int getOrder() {