Consistent validation of annotated methods behind AOP proxies

Issue: SPR-13816
This commit is contained in:
Juergen Hoeller
2015-12-23 20:47:28 +01:00
parent 63958ac0ff
commit 470ea977e1
6 changed files with 59 additions and 35 deletions

View File

@@ -284,6 +284,17 @@ public class AnnotationDrivenEventListenerTests {
this.eventCollector.assertTotalEventsCount(1);
}
@Test
public void privateMethodOnCglibProxyFails() throws Exception {
try {
load(CglibProxyWithPrivateMethod.class);
fail("Should have thrown BeanInitializationException");
}
catch (BeanInitializationException ex) {
assertTrue(ex.getCause() instanceof IllegalStateException);
}
}
@Test
public void eventListenerWorksWithCustomScope() throws Exception {
load(CustomScopeTestBean.class);
@@ -790,6 +801,17 @@ public class AnnotationDrivenEventListenerTests {
}
@Component
@Scope(proxyMode = ScopedProxyMode.TARGET_CLASS)
static class CglibProxyWithPrivateMethod extends AbstractTestEventListener {
@EventListener
private void handleIt(TestEvent event) {
collectEvent(event);
}
}
@Component
@Scope(scopeName = "custom", proxyMode = ScopedProxyMode.TARGET_CLASS)
static class CustomScopeTestBean extends AbstractTestEventListener {