use of cn.taketoday.context.annotation.AnnotationConfigApplicationContext in project today-infrastructure by TAKETODAY.
the class AnnotatedServiceWithoutInterface method annotatedService_PTC_true.
@Test
void annotatedService_PTC_true() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.register(PTCTrue.class, NonAnnotatedServiceImpl.class);
ctx.refresh();
AnnotatedService s = ctx.getBean(AnnotatedService.class);
assertThat(AopUtils.isCglibProxy(s)).isTrue();
assertThat(s).isInstanceOf(NonAnnotatedServiceImpl.class);
}
use of cn.taketoday.context.annotation.AnnotationConfigApplicationContext in project today-infrastructure by TAKETODAY.
the class AnnotatedServiceWithoutInterface method nonAnnotatedService_PTC_false.
@Test
void nonAnnotatedService_PTC_false() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.register(PTCFalse.class, AnnotatedServiceImpl.class);
ctx.refresh();
NonAnnotatedService s = ctx.getBean(NonAnnotatedService.class);
assertThat(AopUtils.isJdkDynamicProxy(s)).isTrue();
assertThat(s).isNotInstanceOf(AnnotatedServiceImpl.class);
}
use of cn.taketoday.context.annotation.AnnotationConfigApplicationContext in project today-infrastructure by TAKETODAY.
the class EnableTransactionManagementIntegrationTests method repositoryUsesAspectJAdviceMode.
@Test
void repositoryUsesAspectJAdviceMode() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.register(Config.class, AspectJTxConfig.class);
// this test is a bit fragile, but gets the job done, proving that an
// attempt was made to look up the AJ aspect. It's due to classpath issues
// in .integration-tests that it's not found.
assertThatExceptionOfType(NestedRuntimeException.class).isThrownBy(ctx::refresh).satisfies(ex -> {
assertThat(ex.getNestedMessage()).contains("AspectJJtaTransactionManagementConfiguration");
});
}
use of cn.taketoday.context.annotation.AnnotationConfigApplicationContext in project today-infrastructure by TAKETODAY.
the class EnableTransactionManagementIntegrationTests method explicitTxManager.
@Test
void explicitTxManager() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(ExplicitTxManagerConfig.class);
FooRepository fooRepository = ctx.getBean(FooRepository.class);
fooRepository.findAll();
CallCountingTransactionManager txManager1 = ctx.getBean("txManager1", CallCountingTransactionManager.class);
assertThat(txManager1.begun).isEqualTo(1);
assertThat(txManager1.commits).isEqualTo(1);
assertThat(txManager1.rollbacks).isEqualTo(0);
CallCountingTransactionManager txManager2 = ctx.getBean("txManager2", CallCountingTransactionManager.class);
assertThat(txManager2.begun).isEqualTo(0);
assertThat(txManager2.commits).isEqualTo(0);
assertThat(txManager2.rollbacks).isEqualTo(0);
}
use of cn.taketoday.context.annotation.AnnotationConfigApplicationContext in project today-infrastructure by TAKETODAY.
the class EnableTransactionManagementIntegrationTests method implicitTxManager.
@Test
void implicitTxManager() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(ImplicitTxManagerConfig.class);
FooRepository fooRepository = ctx.getBean(FooRepository.class);
fooRepository.findAll();
CallCountingTransactionManager txManager = ctx.getBean(CallCountingTransactionManager.class);
assertThat(txManager.begun).isEqualTo(1);
assertThat(txManager.commits).isEqualTo(1);
assertThat(txManager.rollbacks).isEqualTo(0);
}
Aggregations