@ApplicationScoped public abstract class PersistenceFactory extends Object
EntityManagers for tests.
Additionally this PersistenceFactory allows to initiate Transactions according to @see TransactionAttributeType
so that normal CDI-Test-Environments can simulate EJB-Transaction-Handling.| Constructor and Description |
|---|
PersistenceFactory() |
| Modifier and Type | Method and Description |
|---|---|
static void |
clearPersistenceUnitNames()
allow to reset between Tests.
|
void |
construct()
prepare EntityManagerFactory
|
DataSource |
createDataSource()
create a jdbc-Datasource using the same driver url user and password as the entityManager
|
protected javax.persistence.EntityManagerFactory |
createEntityManagerFactory() |
void |
destroy()
make sure all connections will be closed
|
boolean |
equals(Object obj) |
protected abstract String |
getPersistenceUnitName() |
int |
hashCode() |
DataSource |
produceDataSource() |
javax.persistence.EntityManager |
produceEntityManager()
returns EntityManager, to be injected and used so that the current threadSpecific context is correctly handled
|
TestTransaction |
transaction(javax.ejb.TransactionAttributeType transactionAttribute)
Create a transaction-object as Java-Resource.
|
void |
transaction(javax.ejb.TransactionAttributeType transactionAttribute,
TestClosure runnable)
Create a transaction-object as Java-Resource.
|
public static void clearPersistenceUnitNames()
protected abstract String getPersistenceUnitName()
@PostConstruct public void construct()
@PreDestroy public void destroy()
public TestTransaction transaction(javax.ejb.TransactionAttributeType transactionAttribute)
transactionAttribute - allows to simulate the ejb-transaction-handlingpublic void transaction(javax.ejb.TransactionAttributeType transactionAttribute,
TestClosure runnable)
transactionAttribute - allows to simulate the ejb-transaction-handlingrunnable - the code to be done during the transaction.public javax.persistence.EntityManager produceEntityManager()
public DataSource createDataSource()
public DataSource produceDataSource()
protected javax.persistence.EntityManagerFactory createEntityManagerFactory()
Copyright © 2017–2018. All rights reserved.