Search in sources :

Example 11 with PoolingDataSource

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

the class HumanTaskServicesBaseTest method setupPoolingDataSource.

protected static PoolingDataSource setupPoolingDataSource() {
    Properties dsProps = getDatasourceProperties();
    PoolingDataSource pds = PersistenceUtil.setupPoolingDataSource(dsProps, "jdbc/jbpm-ds", false);
    pds.init();
    return pds;
}
Also used : PoolingDataSource(org.jbpm.test.util.PoolingDataSource) Properties(java.util.Properties)

Example 12 with PoolingDataSource

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

the class TestPersistenceContext method executeScripts.

public void executeScripts(final File scriptsRootFolder, String type) throws IOException, SQLException {
    testIsInitialized();
    final File[] sqlScripts = TestsUtil.getDDLScriptFilesByDatabaseType(scriptsRootFolder, databaseType, true);
    final Connection connection = ((PoolingDataSource) context.get(PersistenceUtil.DATASOURCE)).getConnection();
    connection.setAutoCommit(false);
    try {
        for (File script : sqlScripts) {
            if (type == null || script.getName().startsWith(type)) {
                logger.debug("Executing script {}", script.getName());
                final List<String> scriptCommands = SQLScriptUtil.getCommandsFromScript(script, databaseType);
                for (String command : scriptCommands) {
                    logger.debug(command);
                    final PreparedStatement statement;
                    if (databaseType == DatabaseType.SQLSERVER || databaseType == DatabaseType.SQLSERVER2008) {
                        statement = connection.prepareStatement(SQLCommandUtil.preprocessCommandSqlServer(command, dataSourceProperties));
                    } else {
                        statement = connection.prepareStatement(command);
                    }
                    statement.execute();
                    statement.close();
                }
            }
        }
        connection.commit();
    } catch (SQLException ex) {
        connection.rollback();
        throw new RuntimeException(ex.getMessage(), ex);
    } finally {
        connection.close();
    }
}
Also used : PoolingDataSource(org.jbpm.test.util.PoolingDataSource) SQLException(java.sql.SQLException) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement) File(java.io.File)

Example 13 with PoolingDataSource

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

the class TaskVariablesQueryServiceTest method buildDatasource.

protected void buildDatasource() {
    ds = new PoolingDataSource();
    ds.setUniqueName("jdbc/testDS1");
    ds.setClassName("org.postgresql.xa.PGXADataSource");
    ds.getDriverProperties().put("user", "bpms");
    ds.getDriverProperties().put("password", "bpms");
    ds.getDriverProperties().put("serverName", "localhost");
    ds.getDriverProperties().put("portNumber", "5432");
    ds.getDriverProperties().put("databaseName", "bpms");
    ds.init();
}
Also used : PoolingDataSource(org.jbpm.test.util.PoolingDataSource)

Example 14 with PoolingDataSource

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

the class AbstractKieServicesBaseTest 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();
}
Also used : PoolingDataSource(org.jbpm.test.util.PoolingDataSource)

Example 15 with PoolingDataSource

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

the class JBPMHelper method setupDataSource.

public static PoolingDataSource setupDataSource() {
    Properties properties = getProperties();
    // create data source
    PoolingDataSource pds = new PoolingDataSource();
    pds.setUniqueName(properties.getProperty("persistence.datasource.name", "jdbc/jbpm-ds"));
    pds.setClassName("org.h2.jdbcx.JdbcDataSource");
    pds.getDriverProperties().put("user", properties.getProperty("persistence.datasource.user", "sa"));
    pds.getDriverProperties().put("password", properties.getProperty("persistence.datasource.password", ""));
    pds.getDriverProperties().put("url", properties.getProperty("persistence.datasource.url", "jdbc:h2:tcp://localhost/~/jbpm-db;MVCC=TRUE"));
    pds.getDriverProperties().put("driverClassName", properties.getProperty("persistence.datasource.driverClassName", "org.h2.Driver"));
    pds.init();
    return pds;
}
Also used : PoolingDataSource(org.jbpm.test.util.PoolingDataSource) Properties(java.util.Properties)

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