@Test public void undecorated() { VoidService delegate = newMock(VoidService.class); PlatformTransactionManager transactionManager = newMock(PlatformTransactionManager.class); TransactionInterceptor transactionInterceptor = TransactionModule.buildTransactionInterceptor(transactionManager); TransactionAdvisor advisor = new SpringTransactionAdvisor(transactionInterceptor); TransactionDecorator decorator = new TransactionDecoratorImpl(aspectDecorator, advisor); VoidService interceptor = decorator.build(VoidService.class, delegate, "foo.Bar"); delegate.undecorated(); replay(); interceptor.undecorated(); verify(); }
@Test public void void_method() { VoidService delegate = newMock(VoidService.class); PlatformTransactionManager transactionManager = newMock(PlatformTransactionManager.class); TransactionInterceptor transactionInterceptor = TransactionModule.buildTransactionInterceptor(transactionManager); TransactionAdvisor advisor = new SpringTransactionAdvisor(transactionInterceptor); TransactionDecorator decorator = new TransactionDecoratorImpl(aspectDecorator, advisor); VoidService interceptor = decorator.build(VoidService.class, delegate, "foo.Bar"); TransactionStatus transactionStatus = new SimpleTransactionStatus(); expect(transactionManager.getTransaction(EasyMock.isA(TransactionAttribute.class))) .andReturn(transactionStatus); // TransactionDefinition.PROPAGATION_REQUIRED); transactionManager.commit(transactionStatus); delegate.voidMethod(); replay(); interceptor.voidMethod(); verify(); }