Package org.kie.test.util.db
Class PersistenceUtil
java.lang.Object
org.kie.test.util.db.PersistenceUtil
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidThis method should be called in the @After method of a test to clean up the persistence unit and datasource.static PropertiesThis reads in the (maven filtered) datasource properties from the test resource directory.static PoolingDataSourceWrapperThis method creates default pooling datasourcestatic PoolingDataSourceWrappersetupPoolingDataSource(Properties dsProps) This method uses the "jdbc/testDS1" datasource, which is the default.static PoolingDataSourceWrappersetupPoolingDataSource(Properties dsProps, String datasourceName) This sets up a PoolingDataSource.setupWithPoolingDataSource(String persistenceUnitName) setupWithPoolingDataSource(String persistenceUnitName, boolean testMarshalling) 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 booleanThis method returns whether or not transactions should be used when dealing with the SessionInfo object (or any other persisted entity that contains @Lob's )
-
Field Details
-
ENTITY_MANAGER_FACTORY
- See Also:
-
TRANSACTION_MANAGER
- See Also:
-
DATASOURCE_PROPERTIES
- See Also:
-
DATASOURCE
-
-
Constructor Details
-
PersistenceUtil
public PersistenceUtil()
-
-
Method Details
-
setupWithPoolingDataSource
- Parameters:
persistenceUnitName- The name of the persistence unit to be used.- Returns:
- test context
- See Also:
-
setupWithPoolingDataSource
public static Map<String,Object> setupWithPoolingDataSource(String persistenceUnitName, boolean testMarshalling) - Parameters:
persistenceUnitName- The name of the persistence unit to be used.- Returns:
- test context
- See Also:
-
setupWithPoolingDataSource
public 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.- Parameters:
persistenceUnitName- The name of the persistence unit used by the test.- Returns:
- Map with persistence objects, such as the EntityManagerFactory and DataSource
-
cleanUp
This method should be called in the @After method of a test to clean up the persistence unit and datasource.- Parameters:
context- A HashMap
-
setupPoolingDataSource
This method creates default pooling datasource- Returns:
- a PoolingDataSource
-
setupPoolingDataSource
This method uses the "jdbc/testDS1" datasource, which is the default.- Parameters:
dsProps- The properties used to setup the data source.- Returns:
- a PoolingDataSource
-
setupPoolingDataSource
public static PoolingDataSourceWrapper setupPoolingDataSource(Properties dsProps, String datasourceName) This sets up a PoolingDataSource.- Returns:
- PoolingDataSource that has been set up but _not_ initialized.
-
getDatasourceProperties
This reads in the (maven filtered) datasource properties from the test resource directory.- Returns:
- Properties containing the datasource properties.
-
useTransactions
public 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 )- Returns:
- boolean Whether or not to use transactions
-