@EnableTransactionManagement and co get detected on superclasses as well

Issue: SPR-10864
This commit is contained in:
Juergen Hoeller
2013-12-02 10:59:30 +01:00
parent b0b40dade1
commit e8dead247c
4 changed files with 39 additions and 28 deletions

View File

@@ -52,6 +52,17 @@ public class EnableTransactionManagementTests {
assertThat("Stereotype annotation not visible", services.containsKey("testBean"), is(true));
}
@Test
public void transactionProxyIsCreatedWithEnableOnSuperclass() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.register(InheritedEnableTxConfig.class, TxManagerConfig.class);
ctx.refresh();
TransactionalTestBean bean = ctx.getBean(TransactionalTestBean.class);
assertThat("testBean is not a proxy", AopUtils.isAopProxy(bean), is(true));
Map<?,?> services = ctx.getBeansWithAnnotation(Service.class);
assertThat("Stereotype annotation not visible", services.containsKey("testBean"), is(true));
}
@Test
public void txManagerIsResolvedOnInvocationOfTransactionalMethod() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
@@ -97,6 +108,11 @@ public class EnableTransactionManagementTests {
}
@Configuration
static class InheritedEnableTxConfig extends EnableTxConfig {
}
@Configuration
@EnableTransactionManagement(mode=AdviceMode.ASPECTJ)
static class EnableAspectJTxConfig {