From f7a5b3013e3e1b0db75950faecf1dcb04fcb534d Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Thu, 4 Apr 2019 18:57:27 +0200 Subject: [PATCH] Revert "Register EventPublishingTestExecutionListener by default" This reverts commit 13543f5e0fce10f87753a16754fe6f6cc7847b0f. --- .../event/EventPublishingTestExecutionListener.java | 8 ++++++++ .../src/main/resources/META-INF/spring.factories | 1 - ...lishingTestExecutionListenerIntegrationTests.java | 2 ++ src/docs/asciidoc/testing.adoc | 12 +++++++----- 4 files changed, 17 insertions(+), 6 deletions(-) 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 6e4f4603d9..ed8812783a 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 @@ -61,6 +61,14 @@ import org.springframework.test.context.support.AbstractTestExecutionListener; * support. For further details, consult the class-level Javadoc for * {@link org.springframework.context.event.EventListener @EventListener}. * + *

Listener Registration

+ *

Note that this {@code TestExecutionListener} is not registered by default, + * but it may be registered for a given test class via + * {@link org.springframework.test.context.TestExecutionListeners @TestExecutionListeners} + * or globally via the {@link org.springframework.core.io.support.SpringFactoriesLoader + * SpringFactoriesLoader} mechanism (consult the Javadoc and Spring reference manual for + * details). + * * @author Frank Scheffler * @author Sam Brannen * @since 5.2 diff --git a/spring-test/src/main/resources/META-INF/spring.factories b/spring-test/src/main/resources/META-INF/spring.factories index a9352201e9..30cd85a182 100644 --- a/spring-test/src/main/resources/META-INF/spring.factories +++ b/spring-test/src/main/resources/META-INF/spring.factories @@ -1,7 +1,6 @@ # Default TestExecutionListeners for the Spring TestContext Framework # org.springframework.test.context.TestExecutionListener = \ - org.springframework.test.context.event.EventPublishingTestExecutionListener,\ org.springframework.test.context.web.ServletTestExecutionListener,\ org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener,\ org.springframework.test.context.support.DependencyInjectionTestExecutionListener,\ diff --git a/spring-test/src/test/java/org/springframework/test/context/event/EventPublishingTestExecutionListenerIntegrationTests.java b/spring-test/src/test/java/org/springframework/test/context/event/EventPublishingTestExecutionListenerIntegrationTests.java index 687e99be51..0b49bfbbac 100644 --- a/spring-test/src/test/java/org/springframework/test/context/event/EventPublishingTestExecutionListenerIntegrationTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/event/EventPublishingTestExecutionListenerIntegrationTests.java @@ -41,6 +41,7 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestContext; import org.springframework.test.context.TestContextManager; import org.springframework.test.context.TestExecutionListener; +import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.event.annotation.AfterTestClass; import org.springframework.test.context.event.annotation.AfterTestExecution; import org.springframework.test.context.event.annotation.AfterTestMethod; @@ -192,6 +193,7 @@ public class EventPublishingTestExecutionListenerIntegrationTests { @RunWith(SpringRunner.class) @ContextConfiguration(classes = TestEventListenerConfiguration.class) + @TestExecutionListeners(EventPublishingTestExecutionListener.class) public static class ExampleTestCase { @Traceable diff --git a/src/docs/asciidoc/testing.adoc b/src/docs/asciidoc/testing.adoc index d9d4f7e28d..bf4c220fc7 100644 --- a/src/docs/asciidoc/testing.adoc +++ b/src/docs/asciidoc/testing.adoc @@ -1659,7 +1659,8 @@ subclasses instead. ==== `TestExecutionListener` Configuration Spring provides the following `TestExecutionListener` implementations that are registered -by default, exactly in the following order: +exactly in the following order. Except for the `EventPublishingTestExecutionListener`, +each of these listeners is registered by default. * `EventPublishingTestExecutionListener`: Publishes test execution events to the test's `ApplicationContext` (see <>). @@ -1785,10 +1786,11 @@ be replaced with the following: ==== Test Execution Events The `EventPublishingTestExecutionListener` introduced in Spring Framework 5.2 offers an -alternative approach to implementing a custom `TestExecutionListener`. Components in the -test `ApplicationContext` can listen to the following events published by the -`EventPublishingTestExecutionListener`, each of which corresponds to a method in the -`TestExecutionListener` API. +alternative approach to implementing a custom `TestExecutionListener`. If the +`EventPublishingTestExecutionListener` is <>, components in the `ApplicationContext` can listen to the following events +published by the `EventPublishingTestExecutionListener`. Each of these events corresponds +to a method in the `TestExecutionListener` API. * `BeforeTestClassEvent` * `PrepareTestInstanceEvent`