提交 581ab18b 编写于 作者: J Juergen Hoeller

Test for Java 8's CompletableFuture with Spring's async execution aspect

Issue: SPR-13128
上级 c8fcdadb
......@@ -18,6 +18,7 @@ package org.springframework.scheduling.aspectj;
import java.lang.reflect.Method;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
......@@ -140,8 +141,11 @@ public class AnnotationAsyncExecutionAspectTests {
assertThat(defaultThread.get(), not(Thread.currentThread()));
assertThat(defaultThread.get().getName(), not(startsWith("e1-")));
Future<Thread> e1Thread = obj.e1Work();
ListenableFuture<Thread> e1Thread = obj.e1Work();
assertThat(e1Thread.get().getName(), startsWith("e1-"));
CompletableFuture<Thread> e1OtherThread = obj.e1OtherWork();
assertThat(e1OtherThread.get().getName(), startsWith("e1-"));
}
@Test
......@@ -278,6 +282,11 @@ public class AnnotationAsyncExecutionAspectTests {
public ListenableFuture<Thread> e1Work() {
return new AsyncResult<Thread>(Thread.currentThread());
}
@Async("e1")
public CompletableFuture<Thread> e1OtherWork() {
return CompletableFuture.completedFuture(Thread.currentThread());
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册