Search in sources :

Example 6 with PoolingDataSource

use of org.jbpm.test.util.PoolingDataSource in project jbpm by kiegroup.

the class JbpmBpmn2TestCase method setupPoolingDataSource.

public static 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/testDS1", false);
    if (driverClass.startsWith("org.h2")) {
        ds1.getDriverProperties().setProperty("url", jdbcUrl);
    }
    ds1.init();
    return ds1;
}
Also used : PoolingDataSource(org.jbpm.test.util.PoolingDataSource) Properties(java.util.Properties)

Example 7 with PoolingDataSource

use of org.jbpm.test.util.PoolingDataSource in project jbpm by kiegroup.

the class DBUserInfoImplTest 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(DBUserInfoImpl.DS_JNDI_NAME, "jdbc/jbpm-ds");
    props.setProperty(DBUserInfoImpl.NAME_QUERY, "select name from Users where userId = ?");
    props.setProperty(DBUserInfoImpl.EMAIL_QUERY, "select email from Users where userId = ?");
    props.setProperty(DBUserInfoImpl.LANG_QUERY, "select lang from Users where userId = ?");
    props.setProperty(DBUserInfoImpl.HAS_EMAIL_QUERY, "select email from Groups where groupId = ?");
    props.setProperty(DBUserInfoImpl.MEMBERS_QUERY, "select userId from Groups where groupId = ?");
    props.setProperty(DBUserInfoImpl.ID_QUERY, "select userId from Users where email = ?");
}
Also used : PoolingDataSource(org.jbpm.test.util.PoolingDataSource) Properties(java.util.Properties) Before(org.junit.Before)

Example 8 with PoolingDataSource

use of org.jbpm.test.util.PoolingDataSource in project jbpm by kiegroup.

the class JbpmJUnitBaseTestCase method setupPoolingDataSource.

protected 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:mem:jbpm-db;MVCC=true");
    pds.getDriverProperties().put("driverClassName", "org.h2.Driver");
    try {
        pds.init();
    } catch (Exception e) {
        logger.warn("DBPOOL_MGR:Looks like there is an issue with creating db pool because of " + e.getMessage() + " cleaing up...");
        try {
            pds.close();
        } catch (Exception ex) {
        // ignore
        }
        logger.debug("DBPOOL_MGR: attempting to create db pool again...");
        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:mem:jbpm-db;MVCC=true");
        pds.getDriverProperties().put("driverClassName", "org.h2.Driver");
        pds.init();
        logger.debug("DBPOOL_MGR:Pool created after cleanup of leftover resources");
    }
    return pds;
}
Also used : PoolingDataSource(org.jbpm.test.util.PoolingDataSource)

Example 9 with PoolingDataSource

use of org.jbpm.test.util.PoolingDataSource in project jbpm by kiegroup.

the class TimerBaseTest method setupPoolingDataSource.

public static PoolingDataSource setupPoolingDataSource() {
    Properties dsProps = getDatasourceProperties();
    PoolingDataSource pds = PersistenceUtil.setupPoolingDataSource(dsProps, "jdbc/jbpm-ds", false);
    try {
        pds.init();
    } catch (Exception e) {
        logger.warn("DBPOOL_MGR:Looks like there is an issue with creating db pool because of " + e.getMessage() + " cleaing up...");
        try {
            pds.close();
        } catch (Exception ex) {
        // ignore
        }
        logger.info("DBPOOL_MGR: attempting to create db pool again...");
        pds = PersistenceUtil.setupPoolingDataSource(dsProps, "jdbc/jbpm-ds", false);
        pds.init();
        logger.info("DBPOOL_MGR:Pool created after cleanup of leftover resources");
    }
    return pds;
}
Also used : PoolingDataSource(org.jbpm.test.util.PoolingDataSource) Properties(java.util.Properties) IOException(java.io.IOException)

Example 10 with PoolingDataSource

use of org.jbpm.test.util.PoolingDataSource in project jbpm by kiegroup.

the class HTWorkItemHandlerTest method setupPoolingDataSource.

protected 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:mem:jbpm-db;MVCC=true");
    pds.getDriverProperties().put("driverClassName", "org.h2.Driver");
    pds.init();
    return pds;
}
Also used : PoolingDataSource(org.jbpm.test.util.PoolingDataSource)

Aggregations

PoolingDataSource (org.jbpm.test.util.PoolingDataSource)22 Properties (java.util.Properties)12 EntityManagerFactory (javax.persistence.EntityManagerFactory)2 Before (org.junit.Before)2 File (java.io.File)1 IOException (java.io.IOException)1 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 SQLException (java.sql.SQLException)1 HashMap (java.util.HashMap)1