Skip to content

Commit 6d6eaf8

Browse files
committed
Added test for custom async annotation
1 parent a6bcda2 commit 6d6eaf8

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

org.springframework.context/src/main/java/org/springframework/scheduling/annotation/Async.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
* @see AnnotationAsyncExecutionInterceptor
4343
* @see AsyncAnnotationAdvisor
4444
*/
45-
@Target({ElementType.TYPE, ElementType.METHOD})
45+
@Target({ElementType.METHOD, ElementType.TYPE})
4646
@Retention(RetentionPolicy.RUNTIME)
4747
@Documented
4848
public @interface Async {

org.springframework.context/src/test/java/org/springframework/scheduling/annotation/AsyncExecutionTests.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.scheduling.annotation;
1818

19+
import java.lang.annotation.Retention;
20+
import java.lang.annotation.RetentionPolicy;
1921
import java.util.concurrent.Future;
2022

2123
import org.junit.Test;
@@ -200,7 +202,7 @@ public void doSomething(int i) {
200202
assertTrue(Thread.currentThread().getName().startsWith("e1-"));
201203
}
202204

203-
@Async("e2")
205+
@MyAsync
204206
public Future<String> returnSomething(int i) {
205207
assertTrue(!Thread.currentThread().getName().equals(originalThreadName));
206208
assertTrue(Thread.currentThread().getName().startsWith("e2-"));
@@ -215,6 +217,12 @@ public Future<String> returnSomething2(int i) {
215217
}
216218

217219

220+
@Async("e2")
221+
@Retention(RetentionPolicy.RUNTIME)
222+
public @interface MyAsync {
223+
}
224+
225+
218226
@Async
219227
public static class AsyncClassBean {
220228

0 commit comments

Comments
 (0)