use of org.apache.tapestry5.jpa.EntityTransactionManager in project tapestry-5 by apache.
the class JpaTransactionAdvisorImplTest method persistence_unit_missing.
@Test
public void persistence_unit_missing() {
final VoidService delegate = newMock(VoidService.class);
final EntityManagerManager manager = newMock(EntityManagerManager.class);
final EntityTransactionManager transactionManager = newMock(EntityTransactionManager.class);
final JpaTransactionAdvisor advisor = newJpaTransactionAdvisor(manager, transactionManager);
Map<String, EntityManager> managers = CollectionFactory.newMap();
managers.put("A", newMock(EntityManager.class));
managers.put("B", newMock(EntityManager.class));
final AspectInterceptorBuilder<VoidService> builder = aspectDecorator.createBuilder(VoidService.class, delegate, "foo.Bar");
advisor.addTransactionCommitAdvice(builder);
final VoidService interceptor = builder.build();
expect(manager.getEntityManagers()).andReturn(managers);
replay();
try {
interceptor.persistenceUnitMissing();
TestBase.unreachable();
} catch (Exception e) {
assertMessageContains(e, "Unable to locate a single EntityManager");
}
verify();
}
use of org.apache.tapestry5.jpa.EntityTransactionManager in project tapestry-5 by apache.
the class JpaTransactionAdvisorImplTest method transaction_inactive.
@Test
public void transaction_inactive() {
final VoidService delegate = newMock(VoidService.class);
final EntityManagerManager manager = newMock(EntityManagerManager.class);
final EntityTransactionManager transactionManager = newMock(EntityTransactionManager.class);
final JpaTransactionAdvisor advisor = newJpaTransactionAdvisor(manager, transactionManager);
final EntityManager entityManager = newMock(EntityManager.class);
final EntityTransaction transaction = newMock(EntityTransaction.class);
final AspectInterceptorBuilder<VoidService> builder = aspectDecorator.createBuilder(VoidService.class, delegate, "foo.Bar");
advisor.addTransactionCommitAdvice(builder);
final VoidService interceptor = builder.build();
train_getAndBeginTransaction(manager, entityManager, transaction);
delegate.voidMethod();
train_commitActiveTransaction(transaction);
replay();
interceptor.voidMethod();
verify();
}
use of org.apache.tapestry5.jpa.EntityTransactionManager in project tapestry-5 by apache.
the class JpaTransactionAdvisorImplTest method undecorated.
@Test
public void undecorated() {
final VoidService delegate = newMock(VoidService.class);
final EntityManagerManager manager = newMock(EntityManagerManager.class);
final EntityTransactionManager transactionManager = newMock(EntityTransactionManager.class);
final JpaTransactionAdvisor advisor = newJpaTransactionAdvisor(manager, transactionManager);
final AspectInterceptorBuilder<VoidService> builder = aspectDecorator.createBuilder(VoidService.class, delegate, "foo.Bar");
advisor.addTransactionCommitAdvice(builder);
final VoidService interceptor = builder.build();
delegate.undecorated();
replay();
interceptor.undecorated();
verify();
}
use of org.apache.tapestry5.jpa.EntityTransactionManager in project tapestry-5 by apache.
the class JpaTransactionAdvisorImplTest method persistence_unit_name_missing_single_unit_configured.
@Test
public void persistence_unit_name_missing_single_unit_configured() {
final VoidService delegate = newMock(VoidService.class);
final EntityManagerManager manager = newMock(EntityManagerManager.class);
final EntityTransactionManager transactionManager = newMock(EntityTransactionManager.class);
final JpaTransactionAdvisor advisor = newJpaTransactionAdvisor(manager, transactionManager);
final EntityTransaction transaction = newMock(EntityTransaction.class);
EntityManager em = newMock(EntityManager.class);
Map<String, EntityManager> managers = CollectionFactory.newMap();
managers.put("A", em);
final AspectInterceptorBuilder<VoidService> builder = aspectDecorator.createBuilder(VoidService.class, delegate, "foo.Bar");
advisor.addTransactionCommitAdvice(builder);
final VoidService interceptor = builder.build();
expect(manager.getEntityManagers()).andReturn(managers);
train_getTransaction(em, transaction, true);
delegate.persistenceUnitNameMissing();
train_commitActiveTransaction(transaction);
replay();
interceptor.persistenceUnitNameMissing();
verify();
}
use of org.apache.tapestry5.jpa.EntityTransactionManager in project tapestry-5 by apache.
the class JpaTransactionAdvisorImplTest method void_method_with_param.
@Test
public void void_method_with_param() {
final VoidService delegate = newMock(VoidService.class);
final EntityManagerManager manager = newMock(EntityManagerManager.class);
final EntityTransactionManager transactionManager = newMock(EntityTransactionManager.class);
final JpaTransactionAdvisor advisor = newJpaTransactionAdvisor(manager, transactionManager);
final EntityManager entityManager = newMock(EntityManager.class);
final EntityTransaction transaction = newMock(EntityTransaction.class);
final AspectInterceptorBuilder<VoidService> builder = aspectDecorator.createBuilder(VoidService.class, delegate, "foo.Bar");
advisor.addTransactionCommitAdvice(builder);
final VoidService interceptor = builder.build();
train_getActiveTransaction(manager, entityManager, transaction);
delegate.voidMethodWithParam(777);
train_commitActiveTransaction(transaction);
replay();
interceptor.voidMethodWithParam(777);
verify();
}
Aggregations