Example #1
0
  protected void initializeProcessEngine() {
    final String url = "jdbc:h2:mem:" + System.currentTimeMillis() + ";MODE=PostgreSQL;MVCC=true";
    Map props = new HashMap();
    props.put(
        PersistenceUnitProperties.TRANSACTION_TYPE,
        PersistenceUnitTransactionType.RESOURCE_LOCAL.name());
    props.put(PersistenceUnitProperties.JDBC_DRIVER, "org.h2.Driver");
    props.put(PersistenceUnitProperties.JDBC_URL, url);
    props.put(PersistenceUnitProperties.JDBC_USER, "sa");
    props.put(PersistenceUnitProperties.JDBC_PASSWORD, "");
    props.put(PersistenceUnitProperties.JDBC_READ_CONNECTIONS_MIN, "1");
    props.put(PersistenceUnitProperties.JDBC_WRITE_CONNECTIONS_MIN, "1");
    props.put(
        "eclipselink.ddl-generation",
        "drop-and-create-tables"); // "create-tables" | "create-or-extend-tables"
    props.put("eclipselink.ddl-generation.output-mode", "database");
    props.put("eclipselink.logging.level", "SEVERE");
    emf = Persistence.createEntityManagerFactory("myPU", props);
    emf.createEntityManager().close();

    processEngine =
        new CustomStandaloneProcessEngineConfiguration() {
          {
            jdbcUrl = url;
            jpaEntityManagerFactory = emf;
            jpaHandleTransaction = true;
            databaseSchemaUpdate = "true";
            formTypes = new VariableTypes();
          }
        }.buildProcessEngine();
  }
  @Override
  protected EntityManager createEntityManager() throws Exception {
    HashMap<String, String> properties = new HashMap<String, String>();

    properties.put(TRANSACTION_TYPE, PersistenceUnitTransactionType.RESOURCE_LOCAL.name());

    properties.put(JDBC_DRIVER, "org.hsqldb.jdbcDriver");
    properties.put(JDBC_URL, getDatabaseUrl());
    properties.put(JDBC_USER, "sa");
    properties.put(JDBC_PASSWORD, "");
    properties.put(JDBC_READ_CONNECTIONS_MIN, "1");
    properties.put(JDBC_WRITE_CONNECTIONS_MIN, "1");
    properties.put(TARGET_DATABASE, TargetDatabase.HSQL);
    properties.put(TARGET_SERVER, TargetServer.None);
    properties.put(DDL_GENERATION, CREATE_ONLY);

    // properties.put(LOGGING_LEVEL, "FINE");

    PersistenceProvider pp = new PersistenceProvider();
    EntityManagerFactory emf = pp.createEntityManagerFactory("eclipselink-pu", properties);
    Assert.assertNotNull("EntityManagerFactory should not be null", emf);
    return emf.createEntityManager();
  }