Browse Source

Remove references to AsyncConfigurerSupport

Closes gh-27812
pull/27832/head
Stephane Nicoll 3 years ago
parent
commit
b06d267232
  1. 8
      spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncConfigurer.java
  2. 8
      spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncAnnotationBeanPostProcessorTests.java
  3. 18
      spring-test/src/test/java/org/springframework/test/context/event/EventPublishingTestExecutionListenerIntegrationTests.java

8
spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncConfigurer.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2021 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.
@ -28,11 +28,6 @@ import org.springframework.lang.Nullable; @@ -28,11 +28,6 @@ import org.springframework.lang.Nullable;
* {@link AsyncUncaughtExceptionHandler} instance used to process exception thrown from
* async method with {@code void} return type.
*
* <p>Consider using {@link AsyncConfigurerSupport} providing default implementations for
* both methods if only one element needs to be customized. Furthermore, backward compatibility
* of this interface will be insured in case new customization options are introduced
* in the future.
*
* <p>See @{@link EnableAsync} for usage examples.
*
* @author Chris Beams
@ -40,7 +35,6 @@ import org.springframework.lang.Nullable; @@ -40,7 +35,6 @@ import org.springframework.lang.Nullable;
* @since 3.1
* @see AbstractAsyncConfiguration
* @see EnableAsync
* @see AsyncConfigurerSupport
*/
public interface AsyncConfigurer {

8
spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncAnnotationBeanPostProcessorTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 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.
@ -218,8 +218,8 @@ public class AsyncAnnotationBeanPostProcessorTests { @@ -218,8 +218,8 @@ public class AsyncAnnotationBeanPostProcessorTests {
private void assertFutureWithException(Future<Object> result,
TestableAsyncUncaughtExceptionHandler exceptionHandler) {
assertThatExceptionOfType(ExecutionException.class).isThrownBy(
result::get)
.withCauseExactlyInstanceOf(UnsupportedOperationException.class);
result::get)
.withCauseExactlyInstanceOf(UnsupportedOperationException.class);
assertThat(exceptionHandler.isCalled()).as("handler should never be called with Future return type").isFalse();
}
@ -343,7 +343,7 @@ public class AsyncAnnotationBeanPostProcessorTests { @@ -343,7 +343,7 @@ public class AsyncAnnotationBeanPostProcessorTests {
@Configuration
@EnableAsync
static class ConfigWithExceptionHandler extends AsyncConfigurerSupport {
static class ConfigWithExceptionHandler implements AsyncConfigurer {
@Bean
public ITestBean target() {

18
spring-test/src/test/java/org/springframework/test/context/event/EventPublishingTestExecutionListenerIntegrationTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 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.
@ -31,7 +31,7 @@ import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler; @@ -31,7 +31,7 @@ import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncConfigurerSupport;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component;
@ -73,13 +73,17 @@ public class EventPublishingTestExecutionListenerIntegrationTests { @@ -73,13 +73,17 @@ public class EventPublishingTestExecutionListenerIntegrationTests {
private static final CountDownLatch countDownLatch = new CountDownLatch(1);
private final TestContextManager testContextManager = new TestContextManager(ExampleTestCase.class);
private final TestContext testContext = testContextManager.getTestContext();
// Note that the following invocation of getApplicationContext() forces eager
// loading of the test's ApplicationContext which consequently results in the
// publication of all test execution events. Otherwise, TestContext#publishEvent
// would never fire any events for ExampleTestCase.
private final TestExecutionListener listener = testContext.getApplicationContext().getBean(TestExecutionListener.class);
private final Object testInstance = new ExampleTestCase();
private final Method traceableTestMethod = ReflectionUtils.findMethod(ExampleTestCase.class, "traceableTest");
@ -127,8 +131,8 @@ public class EventPublishingTestExecutionListenerIntegrationTests { @@ -127,8 +131,8 @@ public class EventPublishingTestExecutionListenerIntegrationTests {
public void beforeTestMethodAnnotationWithFailingEventListener() throws Exception {
Method method = ReflectionUtils.findMethod(ExampleTestCase.class, "testWithFailingEventListener");
assertThatExceptionOfType(RuntimeException.class).isThrownBy(() ->
testContextManager.beforeTestMethod(testInstance, method))
.withMessageContaining("Boom!");
testContextManager.beforeTestMethod(testInstance, method))
.withMessageContaining("Boom!");
verify(listener, only()).beforeTestMethod(testContext);
}
@ -149,7 +153,7 @@ public class EventPublishingTestExecutionListenerIntegrationTests { @@ -149,7 +153,7 @@ public class EventPublishingTestExecutionListenerIntegrationTests {
verify(listener, only()).beforeTestMethod(testContext);
assertThat(TrackingAsyncUncaughtExceptionHandler.asyncException.getMessage())
.startsWith("Asynchronous exception for test method [" + methodName + "] in thread [" + THREAD_NAME_PREFIX);
.startsWith("Asynchronous exception for test method [" + methodName + "] in thread [" + THREAD_NAME_PREFIX);
}
@Test
@ -211,7 +215,7 @@ public class EventPublishingTestExecutionListenerIntegrationTests { @@ -211,7 +215,7 @@ public class EventPublishingTestExecutionListenerIntegrationTests {
@Configuration
@EnableAsync(proxyTargetClass = true)
static class TestEventListenerConfiguration extends AsyncConfigurerSupport {
static class TestEventListenerConfiguration implements AsyncConfigurer {
@Override
public Executor getAsyncExecutor() {
@ -306,7 +310,7 @@ public class EventPublishingTestExecutionListenerIntegrationTests { @@ -306,7 +310,7 @@ public class EventPublishingTestExecutionListenerIntegrationTests {
public void beforeTestMethodWithAsyncFailure(BeforeTestMethodEvent event) throws Exception {
this.listener.beforeTestMethod(event.getSource());
throw new RuntimeException(String.format("Asynchronous exception for test method [%s] in thread [%s]",
event.getTestContext().getTestMethod().getName(), Thread.currentThread().getName()));
event.getTestContext().getTestMethod().getName(), Thread.currentThread().getName()));
}
}

Loading…
Cancel
Save