Remove APIs marked as deprecated for removal
Closes gh-33809
This commit is contained in:
@@ -279,25 +279,6 @@ class AnnotationDrivenEventListenerTests {
|
||||
this.eventCollector.assertTotalEventsCount(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({"deprecation", "removal"})
|
||||
void listenableFutureReply() {
|
||||
load(TestEventListener.class, ReplyEventListener.class);
|
||||
org.springframework.util.concurrent.SettableListenableFuture<String> future =
|
||||
new org.springframework.util.concurrent.SettableListenableFuture<>();
|
||||
future.set("dummy");
|
||||
AnotherTestEvent event = new AnotherTestEvent(this, future);
|
||||
ReplyEventListener replyEventListener = this.context.getBean(ReplyEventListener.class);
|
||||
TestEventListener listener = this.context.getBean(TestEventListener.class);
|
||||
|
||||
this.eventCollector.assertNoEventReceived(listener);
|
||||
this.eventCollector.assertNoEventReceived(replyEventListener);
|
||||
this.context.publishEvent(event);
|
||||
this.eventCollector.assertEvent(replyEventListener, event);
|
||||
this.eventCollector.assertEvent(listener, "dummy"); // reply
|
||||
this.eventCollector.assertTotalEventsCount(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
void completableFutureReply() {
|
||||
load(TestEventListener.class, ReplyEventListener.class);
|
||||
|
||||
@@ -200,20 +200,6 @@ class AsyncAnnotationBeanPostProcessorTests {
|
||||
assertFutureWithException(result, exceptionHandler);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void handleExceptionWithListenableFuture() {
|
||||
ConfigurableApplicationContext context =
|
||||
new AnnotationConfigApplicationContext(ConfigWithExceptionHandler.class);
|
||||
ITestBean testBean = context.getBean("target", ITestBean.class);
|
||||
|
||||
TestableAsyncUncaughtExceptionHandler exceptionHandler =
|
||||
context.getBean("exceptionHandler", TestableAsyncUncaughtExceptionHandler.class);
|
||||
assertThat(exceptionHandler.isCalled()).as("handler should not have been called yet").isFalse();
|
||||
Future<Object> result = testBean.failWithListenableFuture();
|
||||
assertFutureWithException(result, exceptionHandler);
|
||||
}
|
||||
|
||||
private void assertFutureWithException(Future<Object> result,
|
||||
TestableAsyncUncaughtExceptionHandler exceptionHandler) {
|
||||
assertThatExceptionOfType(ExecutionException.class).isThrownBy(
|
||||
@@ -275,9 +261,6 @@ class AsyncAnnotationBeanPostProcessorTests {
|
||||
|
||||
Future<Object> failWithFuture();
|
||||
|
||||
@SuppressWarnings({"deprecation", "removal"})
|
||||
org.springframework.util.concurrent.ListenableFuture<Object> failWithListenableFuture();
|
||||
|
||||
void failWithVoid();
|
||||
|
||||
void await(long timeout);
|
||||
@@ -308,13 +291,6 @@ class AsyncAnnotationBeanPostProcessorTests {
|
||||
throw new UnsupportedOperationException("failWithFuture");
|
||||
}
|
||||
|
||||
@Async
|
||||
@Override
|
||||
@SuppressWarnings({"deprecation", "removal"})
|
||||
public org.springframework.util.concurrent.ListenableFuture<Object> failWithListenableFuture() {
|
||||
throw new UnsupportedOperationException("failWithListenableFuture");
|
||||
}
|
||||
|
||||
@Async
|
||||
@Override
|
||||
public void failWithVoid() {
|
||||
|
||||
@@ -42,7 +42,6 @@ import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.support.GenericApplicationContext;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.util.concurrent.ListenableFuture;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
@@ -51,7 +50,6 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
* @author Juergen Hoeller
|
||||
* @author Chris Beams
|
||||
*/
|
||||
@SuppressWarnings({"resource", "deprecation", "removal"})
|
||||
class AsyncExecutionTests {
|
||||
|
||||
private static String originalThreadName;
|
||||
@@ -81,8 +79,6 @@ class AsyncExecutionTests {
|
||||
asyncTest.doSomething(10);
|
||||
Future<String> future = asyncTest.returnSomething(20);
|
||||
assertThat(future.get()).isEqualTo("20");
|
||||
ListenableFuture<String> listenableFuture = asyncTest.returnSomethingListenable(20);
|
||||
assertThat(listenableFuture.get()).isEqualTo("20");
|
||||
CompletableFuture<String> completableFuture = asyncTest.returnSomethingCompletable(20);
|
||||
assertThat(completableFuture.get()).isEqualTo("20");
|
||||
|
||||
@@ -94,14 +90,6 @@ class AsyncExecutionTests {
|
||||
asyncTest.returnSomething(-1).get())
|
||||
.withCauseInstanceOf(IOException.class);
|
||||
|
||||
assertThatExceptionOfType(ExecutionException.class).isThrownBy(() ->
|
||||
asyncTest.returnSomethingListenable(0).get())
|
||||
.withCauseInstanceOf(IllegalArgumentException.class);
|
||||
|
||||
assertThatExceptionOfType(ExecutionException.class).isThrownBy(() ->
|
||||
asyncTest.returnSomethingListenable(-1).get())
|
||||
.withCauseInstanceOf(IOException.class);
|
||||
|
||||
assertThatExceptionOfType(ExecutionException.class).isThrownBy(() ->
|
||||
asyncTest.returnSomethingCompletable(0).get())
|
||||
.withCauseInstanceOf(IllegalArgumentException.class);
|
||||
@@ -174,8 +162,6 @@ class AsyncExecutionTests {
|
||||
asyncTest.doSomething(10);
|
||||
Future<String> future = asyncTest.returnSomething(20);
|
||||
assertThat(future.get()).isEqualTo("20");
|
||||
ListenableFuture<String> listenableFuture = asyncTest.returnSomethingListenable(20);
|
||||
assertThat(listenableFuture.get()).isEqualTo("20");
|
||||
CompletableFuture<String> completableFuture = asyncTest.returnSomethingCompletable(20);
|
||||
assertThat(completableFuture.get()).isEqualTo("20");
|
||||
|
||||
@@ -183,10 +169,6 @@ class AsyncExecutionTests {
|
||||
asyncTest.returnSomething(0).get())
|
||||
.withCauseInstanceOf(IllegalArgumentException.class);
|
||||
|
||||
assertThatExceptionOfType(ExecutionException.class).isThrownBy(() ->
|
||||
asyncTest.returnSomethingListenable(0).get())
|
||||
.withCauseInstanceOf(IllegalArgumentException.class);
|
||||
|
||||
assertThatExceptionOfType(ExecutionException.class).isThrownBy(() ->
|
||||
asyncTest.returnSomethingCompletable(0).get())
|
||||
.withCauseInstanceOf(IllegalArgumentException.class);
|
||||
@@ -419,18 +401,6 @@ class AsyncExecutionTests {
|
||||
return AsyncResult.forValue(Integer.toString(i));
|
||||
}
|
||||
|
||||
@Async
|
||||
public ListenableFuture<String> returnSomethingListenable(int i) {
|
||||
assertThat(Thread.currentThread().getName()).isNotEqualTo(originalThreadName);
|
||||
if (i == 0) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
else if (i < 0) {
|
||||
return AsyncResult.forExecutionException(new IOException());
|
||||
}
|
||||
return new AsyncResult<>(Integer.toString(i));
|
||||
}
|
||||
|
||||
@Async
|
||||
public CompletableFuture<String> returnSomethingCompletable(int i) {
|
||||
assertThat(Thread.currentThread().getName()).isNotEqualTo(originalThreadName);
|
||||
@@ -505,14 +475,6 @@ class AsyncExecutionTests {
|
||||
return new AsyncResult<>(Integer.toString(i));
|
||||
}
|
||||
|
||||
public ListenableFuture<String> returnSomethingListenable(int i) {
|
||||
assertThat(Thread.currentThread().getName()).isNotEqualTo(originalThreadName);
|
||||
if (i == 0) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
return new AsyncResult<>(Integer.toString(i));
|
||||
}
|
||||
|
||||
@Async
|
||||
public CompletableFuture<String> returnSomethingCompletable(int i) {
|
||||
assertThat(Thread.currentThread().getName()).isNotEqualTo(originalThreadName);
|
||||
|
||||
@@ -1,110 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2024 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.scheduling.annotation;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
/**
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
class AsyncResultTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "deprecation", "removal" })
|
||||
public void asyncResultWithCallbackAndValue() throws Exception {
|
||||
String value = "val";
|
||||
final Set<String> values = new HashSet<>(1);
|
||||
org.springframework.util.concurrent.ListenableFuture<String> future = AsyncResult.forValue(value);
|
||||
future.addCallback(new org.springframework.util.concurrent.ListenableFutureCallback<>() {
|
||||
@Override
|
||||
public void onSuccess(String result) {
|
||||
values.add(result);
|
||||
}
|
||||
@Override
|
||||
public void onFailure(Throwable ex) {
|
||||
throw new AssertionError("Failure callback not expected: " + ex, ex);
|
||||
}
|
||||
});
|
||||
assertThat(values).singleElement().isSameAs(value);
|
||||
assertThat(future.get()).isSameAs(value);
|
||||
assertThat(future.completable().get()).isSameAs(value);
|
||||
future.completable().thenAccept(v -> assertThat(v).isSameAs(value));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "deprecation", "removal" })
|
||||
public void asyncResultWithCallbackAndException() {
|
||||
IOException ex = new IOException();
|
||||
final Set<Throwable> values = new HashSet<>(1);
|
||||
org.springframework.util.concurrent.ListenableFuture<String> future = AsyncResult.forExecutionException(ex);
|
||||
future.addCallback(new org.springframework.util.concurrent.ListenableFutureCallback<>() {
|
||||
@Override
|
||||
public void onSuccess(String result) {
|
||||
throw new AssertionError("Success callback not expected: " + result);
|
||||
}
|
||||
@Override
|
||||
public void onFailure(Throwable ex) {
|
||||
values.add(ex);
|
||||
}
|
||||
});
|
||||
assertThat(values).singleElement().isSameAs(ex);
|
||||
assertThatExceptionOfType(ExecutionException.class)
|
||||
.isThrownBy(future::get)
|
||||
.withCause(ex);
|
||||
assertThatExceptionOfType(ExecutionException.class)
|
||||
.isThrownBy(future.completable()::get)
|
||||
.withCause(ex);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "deprecation", "removal" })
|
||||
public void asyncResultWithSeparateCallbacksAndValue() throws Exception {
|
||||
String value = "val";
|
||||
final Set<String> values = new HashSet<>(1);
|
||||
org.springframework.util.concurrent.ListenableFuture<String> future = AsyncResult.forValue(value);
|
||||
future.addCallback(values::add, ex -> new AssertionError("Failure callback not expected: " + ex));
|
||||
assertThat(values).singleElement().isSameAs(value);
|
||||
assertThat(future.get()).isSameAs(value);
|
||||
assertThat(future.completable().get()).isSameAs(value);
|
||||
future.completable().thenAccept(v -> assertThat(v).isSameAs(value));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "deprecation", "removal" })
|
||||
public void asyncResultWithSeparateCallbacksAndException() {
|
||||
IOException ex = new IOException();
|
||||
final Set<Throwable> values = new HashSet<>(1);
|
||||
org.springframework.util.concurrent.ListenableFuture<String> future = AsyncResult.forExecutionException(ex);
|
||||
future.addCallback(result -> new AssertionError("Success callback not expected: " + result), values::add);
|
||||
assertThat(values).singleElement().isSameAs(ex);
|
||||
assertThatExceptionOfType(ExecutionException.class)
|
||||
.isThrownBy(future::get)
|
||||
.withCause(ex);
|
||||
assertThatExceptionOfType(ExecutionException.class)
|
||||
.isThrownBy(future.completable()::get)
|
||||
.withCause(ex);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -35,6 +35,7 @@ import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInfo;
|
||||
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.core.task.AsyncTaskExecutor;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -47,8 +48,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
*/
|
||||
abstract class AbstractSchedulingTaskExecutorTests {
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
private org.springframework.core.task.AsyncListenableTaskExecutor executor;
|
||||
private AsyncTaskExecutor executor;
|
||||
|
||||
protected String testName;
|
||||
|
||||
@@ -64,8 +64,7 @@ abstract class AbstractSchedulingTaskExecutorTests {
|
||||
this.executor = buildExecutor();
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
protected abstract org.springframework.core.task.AsyncListenableTaskExecutor buildExecutor();
|
||||
protected abstract AsyncTaskExecutor buildExecutor();
|
||||
|
||||
@AfterEach
|
||||
void shutdownExecutor() throws Exception {
|
||||
@@ -124,22 +123,6 @@ abstract class AbstractSchedulingTaskExecutorTests {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "deprecation", "removal" })
|
||||
void submitListenableRunnable() {
|
||||
TestTask task = new TestTask(this.testName, 1);
|
||||
// Act
|
||||
org.springframework.util.concurrent.ListenableFuture<?> future = executor.submitListenable(task);
|
||||
future.addCallback(result -> outcome = result, ex -> outcome = ex);
|
||||
// Assert
|
||||
Awaitility.await()
|
||||
.atMost(5, TimeUnit.SECONDS)
|
||||
.pollInterval(10, TimeUnit.MILLISECONDS)
|
||||
.until(future::isDone);
|
||||
assertThat(outcome).isNull();
|
||||
assertThreadNamePrefix(task);
|
||||
}
|
||||
|
||||
@Test
|
||||
void submitCompletableRunnable() {
|
||||
TestTask task = new TestTask(this.testName, 1);
|
||||
@@ -155,21 +138,6 @@ abstract class AbstractSchedulingTaskExecutorTests {
|
||||
assertThreadNamePrefix(task);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "deprecation", "removal" })
|
||||
void submitFailingListenableRunnable() {
|
||||
TestTask task = new TestTask(this.testName, 0);
|
||||
org.springframework.util.concurrent.ListenableFuture<?> future = executor.submitListenable(task);
|
||||
future.addCallback(result -> outcome = result, ex -> outcome = ex);
|
||||
|
||||
Awaitility.await()
|
||||
.dontCatchUncaughtExceptions()
|
||||
.atMost(5, TimeUnit.SECONDS)
|
||||
.pollInterval(10, TimeUnit.MILLISECONDS)
|
||||
.until(() -> future.isDone() && outcome != null);
|
||||
assertThat(outcome.getClass()).isSameAs(RuntimeException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void submitFailingCompletableRunnable() {
|
||||
TestTask task = new TestTask(this.testName, 0);
|
||||
@@ -184,43 +152,15 @@ abstract class AbstractSchedulingTaskExecutorTests {
|
||||
assertThat(outcome.getClass()).isSameAs(CompletionException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "deprecation", "removal" })
|
||||
void submitListenableRunnableWithGetAfterShutdown() throws Exception {
|
||||
org.springframework.util.concurrent.ListenableFuture<?> future1 = executor.submitListenable(new TestTask(this.testName, -1));
|
||||
org.springframework.util.concurrent.ListenableFuture<?> future2 = executor.submitListenable(new TestTask(this.testName, -1));
|
||||
shutdownExecutor();
|
||||
|
||||
try {
|
||||
future1.get(1000, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// ignore
|
||||
}
|
||||
Awaitility.await()
|
||||
.atMost(5, TimeUnit.SECONDS)
|
||||
.pollInterval(10, TimeUnit.MILLISECONDS)
|
||||
.untilAsserted(() -> assertThatExceptionOfType(CancellationException.class)
|
||||
.isThrownBy(() -> future2.get(1000, TimeUnit.MILLISECONDS)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void submitCompletableRunnableWithGetAfterShutdown() throws Exception {
|
||||
CompletableFuture<?> future1 = executor.submitCompletable(new TestTask(this.testName, -1));
|
||||
CompletableFuture<?> future2 = executor.submitCompletable(new TestTask(this.testName, -1));
|
||||
shutdownExecutor();
|
||||
|
||||
try {
|
||||
assertThatExceptionOfType(TimeoutException.class).isThrownBy(() -> {
|
||||
future1.get(1000, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// ignore
|
||||
}
|
||||
Awaitility.await()
|
||||
.atMost(5, TimeUnit.SECONDS)
|
||||
.pollInterval(10, TimeUnit.MILLISECONDS)
|
||||
.untilAsserted(() -> assertThatExceptionOfType(TimeoutException.class)
|
||||
.isThrownBy(() -> future2.get(1000, TimeUnit.MILLISECONDS)));
|
||||
future2.get(1000, TimeUnit.MILLISECONDS);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -245,57 +185,6 @@ abstract class AbstractSchedulingTaskExecutorTests {
|
||||
Future<?> future1 = executor.submit(new TestCallable(this.testName, -1));
|
||||
Future<?> future2 = executor.submit(new TestCallable(this.testName, -1));
|
||||
shutdownExecutor();
|
||||
|
||||
try {
|
||||
future1.get(1000, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// ignore
|
||||
}
|
||||
Awaitility.await()
|
||||
.atMost(5, TimeUnit.SECONDS)
|
||||
.pollInterval(10, TimeUnit.MILLISECONDS)
|
||||
.untilAsserted(() -> assertThatExceptionOfType(CancellationException.class)
|
||||
.isThrownBy(() -> future2.get(1000, TimeUnit.MILLISECONDS)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "deprecation", "removal" })
|
||||
void submitListenableCallable() {
|
||||
TestCallable task = new TestCallable(this.testName, 1);
|
||||
// Act
|
||||
org.springframework.util.concurrent.ListenableFuture<String> future = executor.submitListenable(task);
|
||||
future.addCallback(result -> outcome = result, ex -> outcome = ex);
|
||||
// Assert
|
||||
Awaitility.await()
|
||||
.atMost(5, TimeUnit.SECONDS)
|
||||
.pollInterval(10, TimeUnit.MILLISECONDS)
|
||||
.until(() -> future.isDone() && outcome != null);
|
||||
assertThat(outcome.toString().substring(0, this.threadNamePrefix.length())).isEqualTo(this.threadNamePrefix);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "deprecation", "removal" })
|
||||
void submitFailingListenableCallable() {
|
||||
TestCallable task = new TestCallable(this.testName, 0);
|
||||
// Act
|
||||
org.springframework.util.concurrent.ListenableFuture<String> future = executor.submitListenable(task);
|
||||
future.addCallback(result -> outcome = result, ex -> outcome = ex);
|
||||
// Assert
|
||||
Awaitility.await()
|
||||
.dontCatchUncaughtExceptions()
|
||||
.atMost(5, TimeUnit.SECONDS)
|
||||
.pollInterval(10, TimeUnit.MILLISECONDS)
|
||||
.until(() -> future.isDone() && outcome != null);
|
||||
assertThat(outcome.getClass()).isSameAs(RuntimeException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "deprecation", "removal" })
|
||||
void submitListenableCallableWithGetAfterShutdown() throws Exception {
|
||||
org.springframework.util.concurrent.ListenableFuture<?> future1 = executor.submitListenable(new TestCallable(this.testName, -1));
|
||||
org.springframework.util.concurrent.ListenableFuture<?> future2 = executor.submitListenable(new TestCallable(this.testName, -1));
|
||||
shutdownExecutor();
|
||||
assertThatExceptionOfType(CancellationException.class).isThrownBy(() -> {
|
||||
future1.get(1000, TimeUnit.MILLISECONDS);
|
||||
future2.get(1000, TimeUnit.MILLISECONDS);
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.concurrent.TimeUnit;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.task.AsyncTaskExecutor;
|
||||
import org.springframework.core.task.NoOpRunnable;
|
||||
import org.springframework.core.task.TaskDecorator;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -42,8 +43,7 @@ class ConcurrentTaskExecutorTests extends AbstractSchedulingTaskExecutorTests {
|
||||
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("removal")
|
||||
protected org.springframework.core.task.AsyncListenableTaskExecutor buildExecutor() {
|
||||
protected AsyncTaskExecutor buildExecutor() {
|
||||
concurrentExecutor.setThreadFactory(new CustomizableThreadFactory(this.threadNamePrefix));
|
||||
return new ConcurrentTaskExecutor(concurrentExecutor);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.RepeatedTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.task.AsyncTaskExecutor;
|
||||
import org.springframework.scheduling.Trigger;
|
||||
import org.springframework.scheduling.TriggerContext;
|
||||
import org.springframework.util.ErrorHandler;
|
||||
@@ -52,8 +53,7 @@ class ConcurrentTaskSchedulerTests extends AbstractSchedulingTaskExecutorTests {
|
||||
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("removal")
|
||||
protected org.springframework.core.task.AsyncListenableTaskExecutor buildExecutor() {
|
||||
protected AsyncTaskExecutor buildExecutor() {
|
||||
threadFactory.setThreadNamePrefix(this.threadNamePrefix);
|
||||
scheduler.setTaskDecorator(runnable -> () -> {
|
||||
taskRun.set(true);
|
||||
@@ -79,26 +79,12 @@ class ConcurrentTaskSchedulerTests extends AbstractSchedulingTaskExecutorTests {
|
||||
// decorated Future cannot be cancelled on shutdown with ConcurrentTaskScheduler (see above)
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
void submitListenableRunnableWithGetAfterShutdown() {
|
||||
// decorated Future cannot be cancelled on shutdown with ConcurrentTaskScheduler (see above)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
void submitCallableWithGetAfterShutdown() {
|
||||
// decorated Future cannot be cancelled on shutdown with ConcurrentTaskScheduler (see above)
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
void submitListenableCallableWithGetAfterShutdown() {
|
||||
// decorated Future cannot be cancelled on shutdown with ConcurrentTaskScheduler (see above)
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void executeFailingRunnableWithErrorHandler() {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.scheduling.concurrent;
|
||||
|
||||
import org.springframework.core.task.AsyncTaskExecutor;
|
||||
import org.springframework.scheduling.support.DelegatingErrorHandlingRunnable;
|
||||
import org.springframework.scheduling.support.TaskUtils;
|
||||
|
||||
@@ -26,8 +27,7 @@ import org.springframework.scheduling.support.TaskUtils;
|
||||
class DecoratedThreadPoolTaskExecutorTests extends AbstractSchedulingTaskExecutorTests {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("removal")
|
||||
protected org.springframework.core.task.AsyncListenableTaskExecutor buildExecutor() {
|
||||
protected AsyncTaskExecutor buildExecutor() {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
executor.setTaskDecorator(runnable ->
|
||||
new DelegatingErrorHandlingRunnable(runnable, TaskUtils.LOG_AND_PROPAGATE_ERROR_HANDLER));
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
import org.junit.jupiter.api.RepeatedTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.task.AsyncTaskExecutor;
|
||||
import org.springframework.scheduling.Trigger;
|
||||
import org.springframework.scheduling.TriggerContext;
|
||||
import org.springframework.util.ErrorHandler;
|
||||
@@ -45,8 +46,7 @@ class SimpleAsyncTaskSchedulerTests extends AbstractSchedulingTaskExecutorTests
|
||||
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("removal")
|
||||
protected org.springframework.core.task.AsyncListenableTaskExecutor buildExecutor() {
|
||||
protected AsyncTaskExecutor buildExecutor() {
|
||||
scheduler.setTaskDecorator(runnable -> () -> {
|
||||
taskRun.set(true);
|
||||
runnable.run();
|
||||
@@ -62,12 +62,6 @@ class SimpleAsyncTaskSchedulerTests extends AbstractSchedulingTaskExecutorTests
|
||||
// decorated Future cannot be cancelled on shutdown with SimpleAsyncTaskScheduler
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
void submitListenableRunnableWithGetAfterShutdown() {
|
||||
// decorated Future cannot be cancelled on shutdown with SimpleAsyncTaskScheduler
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
void submitCompletableRunnableWithGetAfterShutdown() {
|
||||
@@ -80,13 +74,6 @@ class SimpleAsyncTaskSchedulerTests extends AbstractSchedulingTaskExecutorTests
|
||||
// decorated Future cannot be cancelled on shutdown with SimpleAsyncTaskScheduler
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
void submitListenableCallableWithGetAfterShutdown() {
|
||||
// decorated Future cannot be cancelled on shutdown with SimpleAsyncTaskScheduler
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
void submitCompletableCallableWithGetAfterShutdown() {
|
||||
|
||||
@@ -23,6 +23,8 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.task.AsyncTaskExecutor;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
@@ -41,8 +43,7 @@ class ThreadPoolTaskExecutorTests extends AbstractSchedulingTaskExecutorTests {
|
||||
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("removal")
|
||||
protected org.springframework.core.task.AsyncListenableTaskExecutor buildExecutor() {
|
||||
protected AsyncTaskExecutor buildExecutor() {
|
||||
executor.setThreadNamePrefix(this.threadNamePrefix);
|
||||
executor.setMaxPoolSize(1);
|
||||
executor.afterPropertiesSet();
|
||||
|
||||
@@ -28,6 +28,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
import org.junit.jupiter.api.RepeatedTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.task.AsyncTaskExecutor;
|
||||
import org.springframework.scheduling.Trigger;
|
||||
import org.springframework.scheduling.TriggerContext;
|
||||
import org.springframework.util.ErrorHandler;
|
||||
@@ -49,8 +50,7 @@ class ThreadPoolTaskSchedulerTests extends AbstractSchedulingTaskExecutorTests {
|
||||
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("removal")
|
||||
protected org.springframework.core.task.AsyncListenableTaskExecutor buildExecutor() {
|
||||
protected AsyncTaskExecutor buildExecutor() {
|
||||
scheduler.setTaskDecorator(runnable -> () -> {
|
||||
taskRun.set(true);
|
||||
runnable.run();
|
||||
|
||||
Reference in New Issue
Block a user