Package org.jbpm.test.persistence.util
Class PersistenceUtil
- java.lang.Object
-
- org.jbpm.test.persistence.util.PersistenceUtil
-
public class PersistenceUtil extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static StringALLOW_LOCAL_TXSstatic StringDATABASE_NAMEstatic StringDATASOURCEstatic StringDATASOURCE_CLASS_NAMEprotected static StringDATASOURCE_PROPERTIESstatic StringDRIVER_CLASS_NAMEstatic StringDROOLS_LOCAL_PERSISTENCE_UNIT_NAMEstatic StringDROOLS_PERSISTENCE_UNIT_NAMEstatic StringJBPM_LOCAL_PERSISTENCE_UNIT_NAMEstatic StringJBPM_PERSISTENCE_UNIT_NAMEstatic StringJDBC_URLstatic StringMAX_POOL_SIZEstatic StringPASSWORDstatic StringSERVER_NAMEstatic StringSERVER_PORTstatic StringUSER
-
Constructor Summary
Constructors Constructor Description PersistenceUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcleanUp(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 org.kie.api.runtime.EnvironmentcreateEnvironment(Map<String,Object> context)static org.kie.api.runtime.KieSessioncreateKieSessionFromKBase(org.kie.api.KieBase kbase, Map<String,Object> context)static PropertiesgetDatasourceProperties()This reads in the (maven filtered) datasource properties from the test resource directory.static org.kie.test.util.db.PoolingDataSourceWrappersetupPoolingDataSource(String datasourceName)Sets up a PoolingDataSourceWrapper with the specified datasource name based on the datasource.properties file existing in the classpath.static org.kie.test.util.db.PoolingDataSourceWrappersetupPoolingDataSource(Properties dsProps)This method uses the "jdbc/testDS1" datasource, which is the default.static org.kie.test.util.db.PoolingDataSourceWrappersetupPoolingDataSource(Properties dsProps, String datasourceName)This sets up a PoolingDataSourceWrapper.static HashMap<String,Object>setupWithPoolingDataSource(String persistenceUnitName)static HashMap<String,Object>setupWithPoolingDataSource(String persistenceUnitName, String dataSourceName)This method does all of the setup for the test and returns a HashMap containing the persistence objects that the test might need.static voidstartH2TcpServer(Properties datasourceProperties)This method starts H2 database server (tcp).static voidstopH2TcpServer()This method stops H2 database server (tcp).static booleanuseTransactions()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 )
-
-
-
Field Detail
-
DROOLS_PERSISTENCE_UNIT_NAME
public static final String DROOLS_PERSISTENCE_UNIT_NAME
- See Also:
- Constant Field Values
-
DROOLS_LOCAL_PERSISTENCE_UNIT_NAME
public static final String DROOLS_LOCAL_PERSISTENCE_UNIT_NAME
- See Also:
- Constant Field Values
-
JBPM_PERSISTENCE_UNIT_NAME
public static final String JBPM_PERSISTENCE_UNIT_NAME
- See Also:
- Constant Field Values
-
JBPM_LOCAL_PERSISTENCE_UNIT_NAME
public static final String JBPM_LOCAL_PERSISTENCE_UNIT_NAME
- See Also:
- Constant Field Values
-
DATASOURCE_PROPERTIES
protected static final String DATASOURCE_PROPERTIES
- See Also:
- Constant Field Values
-
MAX_POOL_SIZE
public static final String MAX_POOL_SIZE
- See Also:
- Constant Field Values
-
ALLOW_LOCAL_TXS
public static final String ALLOW_LOCAL_TXS
- See Also:
- Constant Field Values
-
SERVER_NAME
public static final String SERVER_NAME
- See Also:
- Constant Field Values
-
SERVER_PORT
public static final String SERVER_PORT
- See Also:
- Constant Field Values
-
DATABASE_NAME
public static final String DATABASE_NAME
- See Also:
- Constant Field Values
-
DATASOURCE_CLASS_NAME
public static final String DATASOURCE_CLASS_NAME
- See Also:
- Constant Field Values
-
DRIVER_CLASS_NAME
public static final String DRIVER_CLASS_NAME
- See Also:
- Constant Field Values
-
USER
public static final String USER
- See Also:
- Constant Field Values
-
PASSWORD
public static final String PASSWORD
- See Also:
- Constant Field Values
-
JDBC_URL
public static final String JDBC_URL
- See Also:
- Constant Field Values
-
DATASOURCE
public static final String DATASOURCE
- See Also:
- Constant Field Values
-
-
Method Detail
-
setupWithPoolingDataSource
public static HashMap<String,Object> setupWithPoolingDataSource(String persistenceUnitName)
- Parameters:
persistenceUnitName- The name of the persistence unit to be used.- Returns:
- test context
- See Also:
setupWithPoolingDataSource(String, String)
-
setupWithPoolingDataSource
public static HashMap<String,Object> setupWithPoolingDataSource(String persistenceUnitName, String dataSourceName)
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:
- HashMap
with persistence objects, such as the EntityManagerFactory and DataSource
-
startH2TcpServer
public static void startH2TcpServer(Properties datasourceProperties)
This method starts H2 database server (tcp).- Parameters:
datasourceProperties- The properties used to setup the data source.
-
stopH2TcpServer
public static void stopH2TcpServer()
This method stops H2 database server (tcp).
-
cleanUp
public 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.- Parameters:
context- A HashMap generated bysetupWithPoolingDataSource(String)
-
setupPoolingDataSource
public static org.kie.test.util.db.PoolingDataSourceWrapper setupPoolingDataSource(Properties dsProps)
This method uses the "jdbc/testDS1" datasource, which is the default.- Parameters:
dsProps- The properties used to setup the data source.- Returns:
- a PoolingDataSourceWrapper
-
setupPoolingDataSource
public static org.kie.test.util.db.PoolingDataSourceWrapper setupPoolingDataSource(Properties dsProps, String datasourceName)
This sets up a PoolingDataSourceWrapper.- Returns:
- PoolingDataSourceWrapper that has been set up but _not_ initialized.
-
setupPoolingDataSource
public static org.kie.test.util.db.PoolingDataSourceWrapper setupPoolingDataSource(String datasourceName)
Sets up a PoolingDataSourceWrapper with the specified datasource name based on the datasource.properties file existing in the classpath. If not found, default H2 datasource properties will be used instead.- Parameters:
datasourceName- Datasource name to setup- Returns:
- PoolingDataSourceWrapper that has been set up but _not_ initialized.
-
getDatasourceProperties
public static Properties 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
-
createEnvironment
public static org.kie.api.runtime.Environment createEnvironment(Map<String,Object> context)
-
-