diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/config/AbstractMessageBrokerConfiguration.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/config/AbstractMessageBrokerConfiguration.java
index b1a6a6f41b..1ef5c4e286 100644
--- a/spring-messaging/src/main/java/org/springframework/messaging/simp/config/AbstractMessageBrokerConfiguration.java
+++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/config/AbstractMessageBrokerConfiguration.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2018 the original author or authors.
+ * Copyright 2002-2019 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.
@@ -67,18 +67,20 @@ import org.springframework.validation.Validator;
* protocols such as STOMP.
*
*
{@link #clientInboundChannel()} and {@link #clientOutboundChannel()} deliver
- * messages to and from remote clients to several message handlers such as
+ * messages to and from remote clients to several message handlers such as the
+ * following.
*
* - {@link #simpAnnotationMethodMessageHandler()}
* - {@link #simpleBrokerMessageHandler()}
* - {@link #stompBrokerRelayMessageHandler()}
* - {@link #userDestinationMessageHandler()}
*
- * while {@link #brokerChannel()} delivers messages from within the application to the
+ *
+ * {@link #brokerChannel()} delivers messages from within the application to the
* the respective message handlers. {@link #brokerMessagingTemplate()} can be injected
* into any application component to send messages.
*
- *
Subclasses are responsible for the part of the configuration that feed messages
+ *
Subclasses are responsible for the parts of the configuration that feed messages
* to and from the client inbound/outbound channels (e.g. STOMP over WebSocket).
*
* @author Rossen Stoyanchev
@@ -403,7 +405,7 @@ public abstract class AbstractMessageBrokerConfiguration implements ApplicationC
* Override this method to add custom message converters.
* @param messageConverters the list to add converters to, initially empty
* @return {@code true} if default message converters should be added to list,
- * {@code false} if no more converters should be added.
+ * {@code false} if no more converters should be added
*/
protected boolean configureMessageConverters(List messageConverters) {
return true;
@@ -448,9 +450,8 @@ public abstract class AbstractMessageBrokerConfiguration implements ApplicationC
protected abstract SimpUserRegistry createLocalUserRegistry(@Nullable Integer order);
/**
- * Return a {@link org.springframework.validation.Validator
- * org.springframework.validation.Validators} instance for validating
- * {@code @Payload} method arguments.
+ * Return an {@link org.springframework.validation.Validator} instance for
+ * validating {@code @Payload} method arguments.
* In order, this method tries to get a Validator instance:
*
* - delegating to getValidator() first
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 b5a8fe6fbc..3f527f5a2a 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
@@ -23,7 +23,7 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
-import org.junit.Before;
+import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@@ -60,9 +60,7 @@ import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.only;
-import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;
-import static org.springframework.test.context.TestExecutionListeners.MergeMode.MERGE_WITH_DEFAULTS;
/**
* Integration tests for {@link EventPublishingTestExecutionListener} and
@@ -88,11 +86,9 @@ public class EventPublishingTestExecutionListenerIntegrationTests {
public final ExpectedException exception = ExpectedException.none();
- @Before
- public void resetMock() {
- // The mocked listener is a bean in the ApplicationContext that is stored
- // in a static cache by the Spring TestContext Framework.
- reset(listener);
+ @After
+ public void closeApplicationContext() {
+ this.testContext.markApplicationContextDirty(null);
}
@Test
@@ -113,6 +109,12 @@ public class EventPublishingTestExecutionListenerIntegrationTests {
verify(listener, only()).beforeTestMethod(testContext);
}
+ /**
+ * The {@code @BeforeTestMethod} condition in
+ * {@link TestEventListenerConfiguration#beforeTestMethod(BeforeTestMethodEvent)}
+ * only matches if the test method is annotated with {@code @Traceable}, and
+ * {@link ExampleTestCase#standardTest()} is not.
+ */
@Test
public void beforeTestMethodAnnotationWithFailingCondition() throws Exception {
Method standardTest = ReflectionUtils.findMethod(ExampleTestCase.class, "standardTest");
@@ -120,6 +122,10 @@ public class EventPublishingTestExecutionListenerIntegrationTests {
verify(listener, never()).beforeTestMethod(testContext);
}
+ /**
+ * An exception thrown from an event listener executed in the current thread
+ * should fail the test method.
+ */
@Test
public void beforeTestMethodAnnotationWithFailingEventListener() throws Exception {
Method method = ReflectionUtils.findMethod(ExampleTestCase.class, "testWithFailingEventListener");
@@ -135,6 +141,10 @@ public class EventPublishingTestExecutionListenerIntegrationTests {
}
}
+ /**
+ * An exception thrown from an event listener that is executed asynchronously
+ * should not fail the test method.
+ */
@Test
public void beforeTestMethodAnnotationWithFailingAsyncEventListener() throws Exception {
TrackingAsyncUncaughtExceptionHandler.asyncException = null;
@@ -183,7 +193,7 @@ public class EventPublishingTestExecutionListenerIntegrationTests {
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = TestEventListenerConfiguration.class)
- @TestExecutionListeners(listeners = EventPublishingTestExecutionListener.class, mergeMode = MERGE_WITH_DEFAULTS)
+ @TestExecutionListeners(EventPublishingTestExecutionListener.class)
public static class ExampleTestCase {
@Traceable