use of org.jbpm.test.util.PoolingDataSource in project jbpm by kiegroup.
the class JbpmJUnitTestCase method setupPoolingDataSource.
public static PoolingDataSource setupPoolingDataSource() {
PoolingDataSource pds = new PoolingDataSource();
pds.setUniqueName("jdbc/jbpm-ds");
pds.setClassName("org.h2.jdbcx.JdbcDataSource");
pds.getDriverProperties().put("user", "sa");
pds.getDriverProperties().put("password", "");
pds.getDriverProperties().put("url", "jdbc:h2:tcp://localhost/~/jbpm-db;MVCC=true");
pds.getDriverProperties().put("driverClassName", "org.h2.Driver");
pds.init();
return pds;
}
use of org.jbpm.test.util.PoolingDataSource in project jbpm by kiegroup.
the class ParallelAsyncJobsTest method setupPoolingDataSource.
@Override
protected PoolingDataSource setupPoolingDataSource() {
Properties dsProps = PersistenceUtil.getDatasourceProperties();
String jdbcUrl = dsProps.getProperty("url");
String driverClass = dsProps.getProperty("driverClassName");
// Setup the datasource
PoolingDataSource ds1 = PersistenceUtil.setupPoolingDataSource(dsProps, "jdbc/jbpm-ds", false);
if (driverClass.startsWith("org.h2")) {
ds1.getDriverProperties().setProperty("url", jdbcUrl);
}
ds1.getDriverProperties().setProperty("POOL_CONNECTIONS", "false");
ds1.init();
return ds1;
}
use of org.jbpm.test.util.PoolingDataSource in project jbpm by kiegroup.
the class DBUserGroupCallbackImplTest method setup.
@Before
public void setup() {
Properties dsProps = loadDataSourceProperties();
pds = new PoolingDataSource();
pds.setUniqueName("jdbc/jbpm-ds");
pds.setClassName(dsProps.getProperty("className"));
for (String propertyName : new String[] { "user", "password" }) {
pds.getDriverProperties().put(propertyName, dsProps.getProperty(propertyName));
}
setDatabaseSpecificDataSourceProperties(pds, dsProps);
pds.init();
prepareDb();
props = new Properties();
props.setProperty(DBUserGroupCallbackImpl.DS_JNDI_NAME, "jdbc/jbpm-ds");
props.setProperty(DBUserGroupCallbackImpl.PRINCIPAL_QUERY, "select userId from Users where userId = ?");
props.setProperty(DBUserGroupCallbackImpl.ROLES_QUERY, "select groupId from Groups where groupId = ?");
props.setProperty(DBUserGroupCallbackImpl.USER_ROLES_QUERY, "select groupId from Groups where userId = ?");
}
use of org.jbpm.test.util.PoolingDataSource in project jbpm by kiegroup.
the class PersistenceUtil method setupWithPoolingDataSource.
/**
* This method does all of the setup for the test and returns a HashMap
* containing the persistence objects that the test might need.
*
* @param persistenceUnitName
* The name of the persistence unit used by the test.
* @return HashMap<String Object> with persistence objects, such as the
* EntityManagerFactory and DataSource
*/
public static HashMap<String, Object> setupWithPoolingDataSource(final String persistenceUnitName, String dataSourceName) {
HashMap<String, Object> context = new HashMap<String, Object>();
// set the right jdbc url
Properties dsProps = getDatasourceProperties();
String jdbcUrl = dsProps.getProperty("url");
String driverClass = dsProps.getProperty("driverClassName");
boolean startH2TcpServer = false;
if (jdbcUrl.matches("jdbc:h2:tcp:.*")) {
startH2TcpServer = true;
}
// Setup the datasource
PoolingDataSource ds1 = setupPoolingDataSource(dsProps, dataSourceName, startH2TcpServer);
if (driverClass.startsWith("org.h2")) {
ds1.getDriverProperties().setProperty("url", jdbcUrl);
}
ds1.init();
context.put(DATASOURCE, ds1);
// Setup persistence
EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnitName);
context.put(ENTITY_MANAGER_FACTORY, emf);
return context;
}
use of org.jbpm.test.util.PoolingDataSource in project jbpm by kiegroup.
the class AsyncTaskTransactionTest method setupPoolingDataSource.
@Override
protected PoolingDataSource setupPoolingDataSource() {
Properties dsProps = PersistenceUtil.getDatasourceProperties();
String jdbcUrl = dsProps.getProperty("url");
String driverClass = dsProps.getProperty("driverClassName");
// Setup the datasource
PoolingDataSource ds1 = PersistenceUtil.setupPoolingDataSource(dsProps, "jdbc/jbpm-ds", false);
if (driverClass.startsWith("org.h2")) {
ds1.getDriverProperties().setProperty("url", jdbcUrl);
}
ds1.getDriverProperties().setProperty("POOL_CONNECTIONS", "false");
ds1.init();
return ds1;
}
Aggregations