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 1/4] 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 c2362297e0..1cf69c055e 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 953b5710ce..419298c0c1 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 0b0534dd04..313c26bfc3 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 18bf72b672..3796682d63 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 34436b929e..6c803ff987 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 916dbd50d0..d0df2d8d96 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 54fca1b8e1..276c58e70f 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 91aa1e794d..d1f40a56ec 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 8322a84b60..b37f5cc905 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 6992cf0628..650ce10dda 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() { From 09086fc648b44d20615bcf3620b6a767d1f1223f Mon Sep 17 00:00:00 2001 From: Sam Brannen <104798+sbrannen@users.noreply.github.com> Date: Tue, 11 Feb 2025 11:18:57 +0100 Subject: [PATCH 2/4] Revise TestExecutionListener order values documentation See gh-34265 --- .../BeanOverrideTestExecutionListener.java | 4 ++-- .../mockito/MockitoResetTestExecutionListener.java | 4 +++- .../ApplicationEventsTestExecutionListener.java | 8 +++++--- .../EventPublishingTestExecutionListener.java | 6 ++++-- .../jdbc/SqlScriptsTestExecutionListener.java | 4 ++-- ...erObservationRegistryTestExecutionListener.java | 8 ++++---- .../support/CommonCachesTestExecutionListener.java | 5 ++--- .../DependencyInjectionTestExecutionListener.java | 14 ++++++++------ ...iesContextBeforeModesTestExecutionListener.java | 6 ++++-- .../DirtiesContextTestExecutionListener.java | 8 +++----- .../TransactionalTestExecutionListener.java | 4 ++-- .../context/web/ServletTestExecutionListener.java | 2 +- 12 files changed, 40 insertions(+), 33 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/test/context/bean/override/BeanOverrideTestExecutionListener.java b/spring-test/src/main/java/org/springframework/test/context/bean/override/BeanOverrideTestExecutionListener.java index 802d9cf977..7bfc2cdb8c 100644 --- a/spring-test/src/main/java/org/springframework/test/context/bean/override/BeanOverrideTestExecutionListener.java +++ b/spring-test/src/main/java/org/springframework/test/context/bean/override/BeanOverrideTestExecutionListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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. @@ -40,7 +40,7 @@ public class BeanOverrideTestExecutionListener extends AbstractTestExecutionList * Returns {@code 1950}, which ensures that the {@code BeanOverrideTestExecutionListener} * is ordered after the * {@link org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener - * DirtiesContextBeforeModesTestExecutionListener} and just before the + * DirtiesContextBeforeModesTestExecutionListener} and before the * {@link DependencyInjectionTestExecutionListener}. */ @Override diff --git a/spring-test/src/main/java/org/springframework/test/context/bean/override/mockito/MockitoResetTestExecutionListener.java b/spring-test/src/main/java/org/springframework/test/context/bean/override/mockito/MockitoResetTestExecutionListener.java index a93be56a19..b87b8f6a5b 100644 --- a/spring-test/src/main/java/org/springframework/test/context/bean/override/mockito/MockitoResetTestExecutionListener.java +++ b/spring-test/src/main/java/org/springframework/test/context/bean/override/mockito/MockitoResetTestExecutionListener.java @@ -74,7 +74,9 @@ public class MockitoResetTestExecutionListener extends AbstractTestExecutionList /** - * Returns {@code Ordered.LOWEST_PRECEDENCE - 100}. + * Returns {@code Ordered.LOWEST_PRECEDENCE - 100}, which ensures that the + * {@code MockitoResetTestExecutionListener} is ordered after all standard + * {@code TestExecutionListener} implementations. */ @Override public int getOrder() { 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 1cf69c055e..f6f3b49375 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2025 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. @@ -64,9 +64,11 @@ public class ApplicationEventsTestExecutionListener extends AbstractTestExecutio * 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 + * DirtiesContextBeforeModesTestExecutionListener} and before the * {@link org.springframework.test.context.bean.override.BeanOverrideTestExecutionListener - * BeanOverrideTestExecutionListener}. + * BeanOverrideTestExecutionListener} and the + * {@link org.springframework.test.context.support.DependencyInjectionTestExecutionListener + * DependencyInjectionTestExecutionListener}. */ @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 419298c0c1..986f97c2d4 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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. @@ -101,7 +101,9 @@ public class EventPublishingTestExecutionListener extends AbstractTestExecutionL * Returns {@code 10000}, which ensures that the {@code EventPublishingTestExecutionListener} * is ordered after the * {@link org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener - * SqlScriptsTestExecutionListener}. + * SqlScriptsTestExecutionListener} and before the + * {@link org.springframework.test.context.bean.override.mockito.MockitoResetTestExecutionListener + * MockitoResetTestExecutionListener}. */ @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 313c26bfc3..b25b4ec051 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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. @@ -129,7 +129,7 @@ public class SqlScriptsTestExecutionListener extends AbstractTestExecutionListen * 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 + * TransactionalTestExecutionListener} and before the * {@link org.springframework.test.context.event.EventPublishingTestExecutionListener * EventPublishingTestExecutionListener}. */ 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 3796682d63..fdc3402d9c 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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. @@ -107,10 +107,10 @@ class MicrometerObservationRegistryTestExecutionListener extends AbstractTestExe /** - * Returns {@code 2500}, which ensures that the {@code MicrometerObservationRegistryTestExecutionListener} - * is ordered after the + * 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 + * DependencyInjectionTestExecutionListener} and before the * {@link org.springframework.test.context.support.DirtiesContextTestExecutionListener * DirtiesContextTestExecutionListener}. */ 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 6c803ff987..5b4f0156d5 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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,8 +38,7 @@ public class CommonCachesTestExecutionListener extends AbstractTestExecutionList /** * 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 DirtiesContextTestExecutionListener DirtiesContextTestExecutionListener} and before the * {@link org.springframework.test.context.transaction.TransactionalTestExecutionListener * TransactionalTestExecutionListener}. */ 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 d0df2d8d96..a79cd782ea 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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. @@ -63,12 +63,14 @@ public class DependencyInjectionTestExecutionListener extends AbstractTestExecut /** - * Returns {@code 2000}, which ensures that the {@code ApplicationEventsTestExecutionListener} + * Returns {@code 2000}, which ensures that the {@code DependencyInjectionTestExecutionListener} * 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}. + * {@link DirtiesContextBeforeModesTestExecutionListener DirtiesContextBeforeModesTestExecutionListener} + * and the {@link org.springframework.test.context.bean.override.BeanOverrideTestExecutionListener + * BeanOverrideTestExecutionListener} and before the + * {@link org.springframework.test.context.observation.MicrometerObservationRegistryTestExecutionListener + * MicrometerObservationRegistryTestExecutionListener} and the + * {@link 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 276c58e70f..78b8574bb9 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2025 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. @@ -58,7 +58,9 @@ public class DirtiesContextBeforeModesTestExecutionListener extends AbstractDirt * 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 + * ServletTestExecutionListener} and before the + * {@link org.springframework.test.context.event.ApplicationEventsTestExecutionListener + * ApplicationEventsTestExecutionListener} and the * {@link org.springframework.test.context.bean.override.BeanOverrideTestExecutionListener * BeanOverrideTestExecutionListener}. */ 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 d1f40a56ec..8ee7df26eb 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2025 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. @@ -57,10 +57,8 @@ public class DirtiesContextTestExecutionListener extends AbstractDirtiesContextT /** * 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}. + * {@link DependencyInjectionTestExecutionListener DependencyInjectionTestExecutionListener} + * and before the {@link 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 b37f5cc905..e4a060dad2 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2025 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. @@ -180,7 +180,7 @@ public class TransactionalTestExecutionListener extends AbstractTestExecutionLis * 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 + * CommonCachesTestExecutionListener} and before the * {@link org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener * SqlScriptsTestExecutionListener}. */ 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 650ce10dda..edb84c7567 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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. From 9d3374b28df667f6e1e0af51f4f74f9448bed4e5 Mon Sep 17 00:00:00 2001 From: Sam Brannen <104798+sbrannen@users.noreply.github.com> Date: Tue, 11 Feb 2025 11:33:23 +0100 Subject: [PATCH 3/4] Finish incomplete sentences --- .../test/context/TestContextManager.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/test/context/TestContextManager.java b/spring-test/src/main/java/org/springframework/test/context/TestContextManager.java index 48a6079f94..8664d8d61c 100644 --- a/spring-test/src/main/java/org/springframework/test/context/TestContextManager.java +++ b/spring-test/src/main/java/org/springframework/test/context/TestContextManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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. @@ -389,8 +389,8 @@ public class TestContextManager { * have executed, the first caught exception will be rethrown with any * subsequent exceptions {@linkplain Throwable#addSuppressed suppressed} in * the first exception. - *
Note that registered listeners will be executed in the opposite - * order in which they were registered. + *
Note that listeners will be executed in the opposite order in which they + * were registered. * @param testInstance the current test instance * @param testMethod the test method which has just been executed on the * test instance @@ -459,7 +459,8 @@ public class TestContextManager { * have executed, the first caught exception will be rethrown with any * subsequent exceptions {@linkplain Throwable#addSuppressed suppressed} in * the first exception. - *
Note that registered listeners will be executed in the opposite + *
Note that listeners will be executed in the opposite order in which they + * were registered. * @param testInstance the current test instance * @param testMethod the test method which has just been executed on the * test instance @@ -517,7 +518,8 @@ public class TestContextManager { * have executed, the first caught exception will be rethrown with any * subsequent exceptions {@linkplain Throwable#addSuppressed suppressed} in * the first exception. - *
Note that registered listeners will be executed in the opposite + *
Note that listeners will be executed in the opposite order in which they + * were registered. * @throws Exception if a registered TestExecutionListener throws an exception * @since 3.0 * @see #getTestExecutionListeners() From 9797bc0acd11be924ce4501bb1f421939c31cc09 Mon Sep 17 00:00:00 2001 From: Sam Brannen <104798+sbrannen@users.noreply.github.com> Date: Tue, 11 Feb 2025 11:53:14 +0100 Subject: [PATCH 4/4] Expose order values of TestExecutionListener implementations as constants Prior to this commit, the order values of TestExecutionListener implementations were hard-coded in their getOrder() methods. To benefit users and integrators, this commit exposes those order values as an ORDER constant in each TestExecutionListener. See gh-34225 Closes gh-34404 --- .../override/BeanOverrideTestExecutionListener.java | 10 ++++++++-- .../mockito/MockitoResetTestExecutionListener.java | 10 +++++++++- .../ApplicationEventsTestExecutionListener.java | 10 ++++++++-- .../event/EventPublishingTestExecutionListener.java | 10 ++++++++-- .../jdbc/SqlScriptsTestExecutionListener.java | 10 ++++++++-- ...eterObservationRegistryTestExecutionListener.java | 10 ++++++++-- .../support/CommonCachesTestExecutionListener.java | 12 +++++++++--- .../DependencyInjectionTestExecutionListener.java | 10 ++++++++-- ...rtiesContextBeforeModesTestExecutionListener.java | 12 +++++++++--- .../support/DirtiesContextTestExecutionListener.java | 10 ++++++++-- .../TransactionalTestExecutionListener.java | 10 ++++++++-- .../context/web/ServletTestExecutionListener.java | 10 ++++++++-- 12 files changed, 99 insertions(+), 25 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/test/context/bean/override/BeanOverrideTestExecutionListener.java b/spring-test/src/main/java/org/springframework/test/context/bean/override/BeanOverrideTestExecutionListener.java index 7bfc2cdb8c..736223358c 100644 --- a/spring-test/src/main/java/org/springframework/test/context/bean/override/BeanOverrideTestExecutionListener.java +++ b/spring-test/src/main/java/org/springframework/test/context/bean/override/BeanOverrideTestExecutionListener.java @@ -37,7 +37,13 @@ import org.springframework.test.context.support.DependencyInjectionTestExecution public class BeanOverrideTestExecutionListener extends AbstractTestExecutionListener { /** - * Returns {@code 1950}, which ensures that the {@code BeanOverrideTestExecutionListener} + * The {@link #getOrder() order} value for this listener: {@value}. + * @since 6.2.3 + */ + public static final int ORDER = 1950; + + /** + * Returns {@value #ORDER}, which ensures that the {@code BeanOverrideTestExecutionListener} * is ordered after the * {@link org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener * DirtiesContextBeforeModesTestExecutionListener} and before the @@ -45,7 +51,7 @@ public class BeanOverrideTestExecutionListener extends AbstractTestExecutionList */ @Override public int getOrder() { - return 1950; + return ORDER; } /** diff --git a/spring-test/src/main/java/org/springframework/test/context/bean/override/mockito/MockitoResetTestExecutionListener.java b/spring-test/src/main/java/org/springframework/test/context/bean/override/mockito/MockitoResetTestExecutionListener.java index b87b8f6a5b..c704da0e79 100644 --- a/spring-test/src/main/java/org/springframework/test/context/bean/override/mockito/MockitoResetTestExecutionListener.java +++ b/spring-test/src/main/java/org/springframework/test/context/bean/override/mockito/MockitoResetTestExecutionListener.java @@ -49,6 +49,13 @@ import org.springframework.util.ClassUtils; */ public class MockitoResetTestExecutionListener extends AbstractTestExecutionListener { + /** + * The {@link #getOrder() order} value for this listener + * ({@code Ordered.LOWEST_PRECEDENCE - 100}): {@value}. + * @since 6.2.3 + */ + public static final int ORDER = Ordered.LOWEST_PRECEDENCE - 100; + private static final Log logger = LogFactory.getLog(MockitoResetTestExecutionListener.class); /** @@ -74,9 +81,10 @@ public class MockitoResetTestExecutionListener extends AbstractTestExecutionList /** - * Returns {@code Ordered.LOWEST_PRECEDENCE - 100}, which ensures that the + * Returns {@value #ORDER}, which ensures that the * {@code MockitoResetTestExecutionListener} is ordered after all standard * {@code TestExecutionListener} implementations. + * @see #ORDER */ @Override public int getOrder() { 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 f6f3b49375..4e890e661f 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 @@ -48,6 +48,12 @@ import org.springframework.util.Assert; */ public class ApplicationEventsTestExecutionListener extends AbstractTestExecutionListener { + /** + * The {@link #getOrder() order} value for this listener: {@value}. + * @since 6.2.3 + */ + public static final int ORDER = 1800; + /** * Attribute name for a {@link TestContext} attribute which indicates * whether the test class for the given test context is annotated with @@ -61,7 +67,7 @@ public class ApplicationEventsTestExecutionListener extends AbstractTestExecutio /** - * Returns {@code 1800}, which ensures that the {@code ApplicationEventsTestExecutionListener} + * Returns {@value #ORDER}, which ensures that the {@code ApplicationEventsTestExecutionListener} * is ordered after the * {@link org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener * DirtiesContextBeforeModesTestExecutionListener} and before the @@ -72,7 +78,7 @@ public class ApplicationEventsTestExecutionListener extends AbstractTestExecutio */ @Override public final int getOrder() { - return 1800; + return ORDER; } @Override 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 986f97c2d4..7988745320 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,13 @@ import org.springframework.test.context.support.AbstractTestExecutionListener; public class EventPublishingTestExecutionListener extends AbstractTestExecutionListener { /** - * Returns {@code 10000}, which ensures that the {@code EventPublishingTestExecutionListener} + * The {@link #getOrder() order} value for this listener: {@value}. + * @since 6.2.3 + */ + public static final int ORDER = 10_000; + + /** + * Returns {@value #ORDER}, which ensures that the {@code EventPublishingTestExecutionListener} * is ordered after the * {@link org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener * SqlScriptsTestExecutionListener} and before the @@ -107,7 +113,7 @@ public class EventPublishingTestExecutionListener extends AbstractTestExecutionL */ @Override public final int getOrder() { - return 10_000; + return ORDER; } /** 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 b25b4ec051..1a8cb23bf0 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 @@ -117,6 +117,12 @@ import static org.springframework.util.ResourceUtils.CLASSPATH_URL_PREFIX; */ public class SqlScriptsTestExecutionListener extends AbstractTestExecutionListener implements AotTestExecutionListener { + /** + * The {@link #getOrder() order} value for this listener: {@value}. + * @since 6.2.3 + */ + public static final int ORDER = 5000; + private static final String SLASH = "/"; private static final Log logger = LogFactory.getLog(SqlScriptsTestExecutionListener.class); @@ -126,7 +132,7 @@ public class SqlScriptsTestExecutionListener extends AbstractTestExecutionListen /** - * Returns {@code 5000}, which ensures that the {@code SqlScriptsTestExecutionListener} + * Returns {@value #ORDER}, which ensures that the {@code SqlScriptsTestExecutionListener} * is ordered after the * {@link org.springframework.test.context.transaction.TransactionalTestExecutionListener * TransactionalTestExecutionListener} and before the @@ -135,7 +141,7 @@ public class SqlScriptsTestExecutionListener extends AbstractTestExecutionListen */ @Override public final int getOrder() { - return 5000; + return ORDER; } /** 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 fdc3402d9c..8178d825c4 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 @@ -44,6 +44,12 @@ import org.springframework.util.ReflectionUtils; */ class MicrometerObservationRegistryTestExecutionListener extends AbstractTestExecutionListener { + /** + * The {@link #getOrder() order} value for this listener: {@value}. + * @since 6.2.3 + */ + public static final int ORDER = 2500; + private static final Log logger = LogFactory.getLog(MicrometerObservationRegistryTestExecutionListener.class); /** @@ -107,7 +113,7 @@ class MicrometerObservationRegistryTestExecutionListener extends AbstractTestExe /** - * Returns {@code 2500}, which ensures that the + * Returns {@value #ORDER}, which ensures that the * {@code MicrometerObservationRegistryTestExecutionListener} is ordered after the * {@link org.springframework.test.context.support.DependencyInjectionTestExecutionListener * DependencyInjectionTestExecutionListener} and before the @@ -116,7 +122,7 @@ class MicrometerObservationRegistryTestExecutionListener extends AbstractTestExe */ @Override public final int getOrder() { - return 2500; + return ORDER; } /** 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 5b4f0156d5..a3bd7bed77 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,14 @@ import org.springframework.test.context.TestContext; public class CommonCachesTestExecutionListener extends AbstractTestExecutionListener { /** - * Returns {@code 3005}, which ensures that the {@code CommonCachesTestExecutionListener} + * The {@link #getOrder() order} value for this listener: {@value}. + * @since 6.2.3 + */ + public static final int ORDER = 3005; + + + /** + * Returns {@value #ORDER}, which ensures that the {@code CommonCachesTestExecutionListener} * is ordered after the * {@link DirtiesContextTestExecutionListener DirtiesContextTestExecutionListener} and before the * {@link org.springframework.test.context.transaction.TransactionalTestExecutionListener @@ -44,10 +51,9 @@ public class CommonCachesTestExecutionListener extends AbstractTestExecutionList */ @Override public final int getOrder() { - return 3005; + return ORDER; } - @Override public void afterTestClass(TestContext testContext) throws Exception { if (testContext.hasApplicationContext()) { 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 a79cd782ea..6504fd8686 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 @@ -39,6 +39,12 @@ import org.springframework.test.context.aot.AotTestContextInitializers; */ public class DependencyInjectionTestExecutionListener extends AbstractTestExecutionListener { + /** + * The {@link #getOrder() order} value for this listener: {@value}. + * @since 6.2.3 + */ + public static final int ORDER = 2000; + /** * Attribute name for a {@link TestContext} attribute which indicates * whether the dependencies of a test instance should be @@ -63,7 +69,7 @@ public class DependencyInjectionTestExecutionListener extends AbstractTestExecut /** - * Returns {@code 2000}, which ensures that the {@code DependencyInjectionTestExecutionListener} + * Returns {@value #ORDER}, which ensures that the {@code DependencyInjectionTestExecutionListener} * is ordered after the * {@link DirtiesContextBeforeModesTestExecutionListener DirtiesContextBeforeModesTestExecutionListener} * and the {@link org.springframework.test.context.bean.override.BeanOverrideTestExecutionListener @@ -74,7 +80,7 @@ public class DependencyInjectionTestExecutionListener extends AbstractTestExecut */ @Override public final int getOrder() { - return 2000; + return ORDER; } /** 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 78b8574bb9..cb21dcd953 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,8 +55,14 @@ import static org.springframework.test.annotation.DirtiesContext.MethodMode.BEFO public class DirtiesContextBeforeModesTestExecutionListener extends AbstractDirtiesContextTestExecutionListener { /** - * Returns {@code 1500}, which ensures that the {@code DirtiesContextBeforeModesTestExecutionListener} - * is ordered after the + * The {@link #getOrder() order} value for this listener: {@value}. + * @since 6.2.3 + */ + public static final int ORDER = 1500; + + /** + * Returns {@value #ORDER}, which ensures that the + * {@code DirtiesContextBeforeModesTestExecutionListener} is ordered after the * {@link org.springframework.test.context.web.ServletTestExecutionListener * ServletTestExecutionListener} and before the * {@link org.springframework.test.context.event.ApplicationEventsTestExecutionListener @@ -66,7 +72,7 @@ public class DirtiesContextBeforeModesTestExecutionListener extends AbstractDirt */ @Override public final int getOrder() { - return 1500; + return ORDER; } /** 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 8ee7df26eb..290103c030 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,14 +55,20 @@ import static org.springframework.test.annotation.DirtiesContext.MethodMode.AFTE public class DirtiesContextTestExecutionListener extends AbstractDirtiesContextTestExecutionListener { /** - * Returns {@code 3000}, which ensures that the {@code DirtiesContextTestExecutionListener} + * The {@link #getOrder() order} value for this listener: {@value}. + * @since 6.2.3 + */ + public static final int ORDER = 3000; + + /** + * Returns {@value #ORDER}, which ensures that the {@code DirtiesContextTestExecutionListener} * is ordered after the * {@link DependencyInjectionTestExecutionListener DependencyInjectionTestExecutionListener} * and before the {@link CommonCachesTestExecutionListener CommonCachesTestExecutionListener}. */ @Override public final int getOrder() { - return 3000; + return ORDER; } /** 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 e4a060dad2..279e1b6b8b 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 @@ -148,6 +148,12 @@ import org.springframework.util.StringUtils; */ public class TransactionalTestExecutionListener extends AbstractTestExecutionListener { + /** + * The {@link #getOrder() order} value for this listener: {@value}. + * @since 6.2.3 + */ + public static final int ORDER = 4000; + private static final Log logger = LogFactory.getLog(TransactionalTestExecutionListener.class); // Do not require @Transactional test methods to be public. @@ -177,7 +183,7 @@ public class TransactionalTestExecutionListener extends AbstractTestExecutionLis /** - * Returns {@code 4000}, which ensures that the {@code TransactionalTestExecutionListener} + * Returns {@value #ORDER}, which ensures that the {@code TransactionalTestExecutionListener} * is ordered after the * {@link org.springframework.test.context.support.CommonCachesTestExecutionListener * CommonCachesTestExecutionListener} and before the @@ -186,7 +192,7 @@ public class TransactionalTestExecutionListener extends AbstractTestExecutionLis */ @Override public final int getOrder() { - return 4000; + return ORDER; } /** 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 edb84c7567..5bdc11fe14 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 @@ -64,6 +64,12 @@ import org.springframework.web.context.request.ServletWebRequest; */ public class ServletTestExecutionListener extends AbstractTestExecutionListener { + /** + * The {@link #getOrder() order} value for this listener: {@value}. + * @since 6.2.3 + */ + public static final int ORDER = 1000; + /** * Attribute name for a {@link TestContext} attribute which indicates * whether the {@code ServletTestExecutionListener} should {@linkplain @@ -110,14 +116,14 @@ public class ServletTestExecutionListener extends AbstractTestExecutionListener /** - * Returns {@code 1000}, which ensures that the {@code ServletTestExecutionListener} + * Returns {@value #ORDER}, which ensures that the {@code ServletTestExecutionListener} * is ordered before the * {@link org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener * DirtiesContextBeforeModesTestExecutionListener}. */ @Override public final int getOrder() { - return 1000; + return ORDER; } /**