Browse Source

Added test for custom async annotation

pull/176/merge
Juergen Hoeller 13 years ago committed by unknown
parent
commit
69763fe249
  1. 2
      spring-context/src/main/java/org/springframework/scheduling/annotation/Async.java
  2. 10
      spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncExecutionTests.java

2
spring-context/src/main/java/org/springframework/scheduling/annotation/Async.java

@ -42,7 +42,7 @@ import java.lang.annotation.Target; @@ -42,7 +42,7 @@ import java.lang.annotation.Target;
* @see AnnotationAsyncExecutionInterceptor
* @see AsyncAnnotationAdvisor
*/
@Target({ElementType.TYPE, ElementType.METHOD})
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Async {

10
spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncExecutionTests.java

@ -16,6 +16,8 @@ @@ -16,6 +16,8 @@
package org.springframework.scheduling.annotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.concurrent.Future;
import org.junit.Test;
@ -200,7 +202,7 @@ public class AsyncExecutionTests { @@ -200,7 +202,7 @@ public class AsyncExecutionTests {
assertTrue(Thread.currentThread().getName().startsWith("e1-"));
}
@Async("e2")
@MyAsync
public Future<String> returnSomething(int i) {
assertTrue(!Thread.currentThread().getName().equals(originalThreadName));
assertTrue(Thread.currentThread().getName().startsWith("e2-"));
@ -215,6 +217,12 @@ public class AsyncExecutionTests { @@ -215,6 +217,12 @@ public class AsyncExecutionTests {
}
@Async("e2")
@Retention(RetentionPolicy.RUNTIME)
public @interface MyAsync {
}
@Async
public static class AsyncClassBean {

Loading…
Cancel
Save