Consistent use of AnnotatedElementUtils.findMergedAnnotation/hasAnnotation
Issue: SPR-13440
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -25,6 +25,7 @@ import org.junit.rules.ExpectedException;
|
||||
import org.springframework.context.PayloadApplicationEvent;
|
||||
import org.springframework.context.event.ApplicationListenerMethodAdapter;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.core.annotation.AnnotatedElementUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
@@ -37,15 +38,6 @@ public class ApplicationListenerMethodTransactionalAdapterTests {
|
||||
@Rule
|
||||
public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
public void noAnnotation() {
|
||||
Method m = ReflectionUtils.findMethod(SampleEvents.class,
|
||||
"noAnnotation", String.class);
|
||||
|
||||
thrown.expect(IllegalStateException.class);
|
||||
thrown.expectMessage("noAnnotation");
|
||||
ApplicationListenerMethodTransactionalAdapter.findAnnotation(m);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultPhase() {
|
||||
@@ -78,7 +70,8 @@ public class ApplicationListenerMethodTransactionalAdapterTests {
|
||||
|
||||
private void assertPhase(Method method, TransactionPhase expected) {
|
||||
assertNotNull("Method must not be null", method);
|
||||
TransactionalEventListener annotation = ApplicationListenerMethodTransactionalAdapter.findAnnotation(method);
|
||||
TransactionalEventListener annotation =
|
||||
AnnotatedElementUtils.findMergedAnnotation(method, TransactionalEventListener.class);
|
||||
assertEquals("Wrong phase for '" + method + "'", expected, annotation.phase());
|
||||
}
|
||||
|
||||
@@ -96,10 +89,8 @@ public class ApplicationListenerMethodTransactionalAdapterTests {
|
||||
return ResolvableType.forClassWithGenerics(PayloadApplicationEvent.class, payloadType);
|
||||
}
|
||||
|
||||
static class SampleEvents {
|
||||
|
||||
public void noAnnotation(String data) {
|
||||
}
|
||||
static class SampleEvents {
|
||||
|
||||
@TransactionalEventListener
|
||||
public void defaultPhase(String data) {
|
||||
@@ -117,7 +108,6 @@ public class ApplicationListenerMethodTransactionalAdapterTests {
|
||||
@TransactionalEventListener(String.class)
|
||||
public void valueSet() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user