public class PersistenceUtil extends Object
Modifier and Type | Field and Description |
---|---|
static String |
DATASOURCE |
protected static String |
DATASOURCE_PROPERTIES |
static String |
ENTITY_MANAGER_FACTORY |
static String |
TRANSACTION_MANAGER |
Constructor and Description |
---|
PersistenceUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
cleanUp(Map<String,Object> context)
This method should be called in the @After method of a test to clean up
the persistence unit and datasource.
|
static Properties |
getDatasourceProperties()
This reads in the (maven filtered) datasource properties from the test
resource directory.
|
static PoolingDataSourceWrapper |
setupPoolingDataSource()
This method creates default pooling datasource
|
static PoolingDataSourceWrapper |
setupPoolingDataSource(Properties dsProps)
This method uses the "jdbc/testDS1" datasource, which is the default.
|
static PoolingDataSourceWrapper |
setupPoolingDataSource(Properties dsProps,
String datasourceName)
This sets up a PoolingDataSource.
|
static Map<String,Object> |
setupWithPoolingDataSource(String persistenceUnitName) |
static Map<String,Object> |
setupWithPoolingDataSource(String persistenceUnitName,
boolean testMarshalling) |
static Map<String,Object> |
setupWithPoolingDataSource(String persistenceUnitName,
String dataSourceName,
boolean testMarshalling)
This method does all of the setup for the test and returns a HashMap
containing the persistence objects that the test might need.
|
static boolean |
useTransactions()
This method returns whether or not transactions should be used when
dealing with the SessionInfo object (or any other persisted entity that
contains @Lob's )
|
public static final String ENTITY_MANAGER_FACTORY
public static final String TRANSACTION_MANAGER
protected static final String DATASOURCE_PROPERTIES
public static String DATASOURCE
public static Map<String,Object> setupWithPoolingDataSource(String persistenceUnitName)
persistenceUnitName
- The name of the persistence unit to be used.setupWithPoolingDataSource(String, String, boolean)
public static Map<String,Object> setupWithPoolingDataSource(String persistenceUnitName, boolean testMarshalling)
persistenceUnitName
- The name of the persistence unit to be used.setupWithPoolingDataSource(String, String, boolean)
public static Map<String,Object> setupWithPoolingDataSource(String persistenceUnitName, String dataSourceName, boolean testMarshalling)
persistenceUnitName
- The name of the persistence unit used by the test.public static void cleanUp(Map<String,Object> context)
context
- A HashMappublic static PoolingDataSourceWrapper setupPoolingDataSource()
public static PoolingDataSourceWrapper setupPoolingDataSource(Properties dsProps)
dsProps
- The properties used to setup the data source.public static PoolingDataSourceWrapper setupPoolingDataSource(Properties dsProps, String datasourceName)
public static Properties getDatasourceProperties()
public static boolean useTransactions()
Copyright © 2001–2020 JBoss by Red Hat. All rights reserved.