use of org.jbpm.test.util.PoolingDataSource in project jbpm by kiegroup.
the class ExecutorTestUtil method setupPoolingDataSource.
public static PoolingDataSource setupPoolingDataSource() {
Properties dsProps = getDatasourceProperties();
PoolingDataSource pds = PersistenceUtil.setupPoolingDataSource(dsProps, "jdbc/jbpm-ds", false);
pds.init();
return pds;
}
use of org.jbpm.test.util.PoolingDataSource in project jbpm-work-items by kiegroup.
the class JPAWorkItemHandlerTest method setupPoolingDataSource.
public static PoolingDataSource setupPoolingDataSource() {
h2Server = new TestH2Server();
h2Server.start();
PoolingDataSource pds = new PoolingDataSource();
pds.setUniqueName("jpaWIH");
pds.setClassName("org.h2.jdbcx.JdbcDataSource");
pds.getDriverProperties().put("user", "sa");
pds.getDriverProperties().put("url", "jdbc:h2:mem:jpa-wih;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 AbstractCaseServicesBaseTest method buildDatasource.
protected void buildDatasource() {
ds = new PoolingDataSource();
ds.setUniqueName("jdbc/testDS1");
// NON XA CONFIGS
ds.setClassName("org.h2.jdbcx.JdbcDataSource");
ds.getDriverProperties().put("user", "sa");
ds.getDriverProperties().put("password", "sasa");
ds.getDriverProperties().put("URL", "jdbc:h2:mem:mydb");
ds.init();
}
use of org.jbpm.test.util.PoolingDataSource in project jbpm by kiegroup.
the class PersistenceUtil method cleanUp.
/**
* This method should be called in the @After method of a test to clean up
* the persistence unit and datasource.
*
* @param context
* A HashMap generated by
* {@link org.drools.persistence.util.PersistenceUtil setupWithPoolingDataSource(String)}
*/
public static void cleanUp(Map<String, Object> context) {
if (context != null) {
Object emfObject = context.remove(ENTITY_MANAGER_FACTORY);
if (emfObject != null) {
try {
EntityManagerFactory emf = (EntityManagerFactory) emfObject;
emf.close();
} catch (Throwable t) {
t.printStackTrace();
}
}
Object ds1Object = context.remove(DATASOURCE);
if (ds1Object != null) {
try {
PoolingDataSource ds1 = (PoolingDataSource) ds1Object;
ds1.close();
} catch (Throwable t) {
t.printStackTrace();
}
}
}
}
use of org.jbpm.test.util.PoolingDataSource in project jbpm by kiegroup.
the class PersistenceUtil method setupPoolingDataSource.
/**
* This sets up a PoolingDataSource.
*
* @return PoolingDataSource that has been set up but _not_ initialized.
*/
public static PoolingDataSource setupPoolingDataSource(Properties dsProps, String datasourceName, boolean startServer) {
PoolingDataSource pds = new PoolingDataSource();
// The name must match what's in the persistence.xml!
pds.setUniqueName(datasourceName);
pds.setClassName(dsProps.getProperty("className"));
for (String propertyName : new String[] { "user", "password" }) {
pds.getDriverProperties().put(propertyName, dsProps.getProperty(propertyName));
}
String driverClass = dsProps.getProperty("driverClassName");
if (driverClass.startsWith("org.h2") || driverClass.startsWith("org.hsqldb")) {
if (startServer) {
h2Server.start();
}
}
setDatabaseSpecificDataSourceProperties(pds, dsProps);
return pds;
}
Aggregations