protected void setUp() throws Exception {
    EventRecorder.clear();

    // change disk journal into mock journal
    Field field = TransactionManagerServices.class.getDeclaredField("journalRef");
    field.setAccessible(true);
    AtomicReference<Journal> journalRef =
        (AtomicReference<Journal>) field.get(TransactionManagerServices.class);
    journalRef.set(new MockJournal());

    poolingDataSource1 = new PoolingDataSource();
    poolingDataSource1.setClassName(MockitoXADataSource.class.getName());
    poolingDataSource1.setUniqueName("pds1");
    poolingDataSource1.setMinPoolSize(5);
    poolingDataSource1.setMaxPoolSize(5);
    poolingDataSource1.setAutomaticEnlistingEnabled(true);
    poolingDataSource1.init();

    poolingDataSource2 = new PoolingDataSource();
    poolingDataSource2.setClassName(MockitoXADataSource.class.getName());
    poolingDataSource2.setUniqueName("pds2");
    poolingDataSource2.setMinPoolSize(5);
    poolingDataSource2.setMaxPoolSize(5);
    poolingDataSource2.setAutomaticEnlistingEnabled(true);
    poolingDataSource2.init();

    btm = TransactionManagerServices.getTransactionManager();
  }
  @Before
  public void setUp() {
    ds1 = new PoolingDataSource();
    ds1.setClassName("bitronix.tm.resource.jdbc.lrc.LrcXADataSource");
    ds1.setUniqueName("jdbc/testDS1");
    ds1.setMaxPoolSize(5);
    ds1.setAllowLocalTransactions(true);
    ds1.getDriverProperties().setProperty("driverClassName", "org.h2.Driver");
    ds1.getDriverProperties().setProperty("url", "jdbc:h2:tcp://localhost/JPADroolsFlow");
    ds1.getDriverProperties().setProperty("user", "sa");
    ds1.getDriverProperties().setProperty("password", "");

    // ds1.setUniqueName( "jdbc/testDS1" );
    // ds1.setClassName( "org.h2.Driver" );
    // ds1.setMaxPoolSize( 3 );
    // ds1.setAllowLocalTransactions( true );
    // ds1.getDriverProperties().put( "user",
    // "sa" );
    // ds1.getDriverProperties().put( "password",
    // "" );
    // ds1.getDriverProperties().put( "URL",
    // "jdbc:h2:tcp://localhost/JPADroolsFlow" );
    ds1.init();

    emf = Persistence.createEntityManagerFactory("org.drools.persistence.jpa");
  }
Exemplo n.º 3
0
  public void testPoolNotStartingTransactionManager() throws Exception {
    if (log.isDebugEnabled()) {
      log.debug("*** Starting testPoolNotStartingTransactionManager");
    }
    // make sure TM is not running
    TransactionManagerServices.getTransactionManager().shutdown();

    PoolingDataSource pds = new PoolingDataSource();
    pds.setMinPoolSize(1);
    pds.setMaxPoolSize(2);
    pds.setMaxIdleTime(1);
    pds.setClassName(MockitoXADataSource.class.getName());
    pds.setUniqueName("pds2");
    pds.setAllowLocalTransactions(true);
    pds.setAcquisitionTimeout(1);
    pds.init();

    assertFalse(TransactionManagerServices.isTransactionManagerRunning());

    Connection c = pds.getConnection();
    Statement stmt = c.createStatement();
    stmt.close();
    c.close();

    assertFalse(TransactionManagerServices.isTransactionManagerRunning());

    pds.close();

    assertFalse(TransactionManagerServices.isTransactionManagerRunning());
  }
Exemplo n.º 4
0
  @Before
  public void setup() {

    Properties dsProps = loadDataSourceProperties();

    pds = new PoolingDataSource();
    pds.setUniqueName("jdbc/jbpm-ds");
    pds.setClassName(dsProps.getProperty("className"));
    pds.setMaxPoolSize(Integer.parseInt(dsProps.getProperty("maxPoolSize")));
    pds.setAllowLocalTransactions(
        Boolean.parseBoolean(dsProps.getProperty("allowLocalTransactions")));
    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 = ?");
  }
Exemplo n.º 5
0
  public void testInitFailure() throws Exception {
    if (log.isDebugEnabled()) {
      log.debug("*** Starting testInitFailure");
    }
    pds.close();

    pds = new PoolingDataSource();
    pds.setMinPoolSize(0);
    pds.setMaxPoolSize(2);
    pds.setMaxIdleTime(1);
    pds.setClassName(MockitoXADataSource.class.getName());
    pds.setUniqueName("pds");
    pds.setAllowLocalTransactions(true);
    pds.setAcquisitionTimeout(1);

    TransactionManagerServices.getTransactionManager().begin();

    MockitoXADataSource.setStaticGetXAConnectionException(new SQLException("not yet started"));
    try {
      pds.init();
      fail("expected ResourceConfigurationException");
    } catch (ResourceConfigurationException ex) {
      Throwable rootCause = ex.getCause().getCause();
      assertEquals(SQLException.class, rootCause.getClass());
      assertEquals("not yet started", rootCause.getMessage());
    }

    MockitoXADataSource.setStaticGetXAConnectionException(null);
    pds.init();

    pds.getConnection().prepareStatement("");

    TransactionManagerServices.getTransactionManager().commit();
  }
Exemplo n.º 6
0
  public void testObjectProperties() throws Exception {
    pds.close();

    pds = new PoolingDataSource();
    pds.setUniqueName("pds");
    pds.setClassName(MockitoXADataSource.class.getName());
    pds.setMinPoolSize(1);
    pds.setMaxPoolSize(1);
    pds.getDriverProperties().put("uselessThing", new Object());
    pds.init();
  }
 @Before
 public void setUp() throws Exception {
   ds1 = new PoolingDataSource();
   ds1.setUniqueName("jdbc/testDS1");
   ds1.setClassName("org.h2.jdbcx.JdbcDataSource");
   ds1.setMaxPoolSize(3);
   ds1.setAllowLocalTransactions(true);
   ds1.getDriverProperties().put("user", "sa");
   ds1.getDriverProperties().put("password", "sasa");
   ds1.getDriverProperties().put("URL", "jdbc:h2:mem:mydb");
   ds1.init();
   emf = Persistence.createEntityManagerFactory("org.drools.persistence.jpa");
 }
 protected PoolingDataSource setupPoolingDataSource() {
   PoolingDataSource pds = new PoolingDataSource();
   pds.setUniqueName("jdbc/jbpm-ds");
   pds.setClassName("bitronix.tm.resource.jdbc.lrc.LrcXADataSource");
   pds.setMaxPoolSize(5);
   pds.setAllowLocalTransactions(true);
   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;
 }
  private void setupDataSource() {
    if (null != pds) return;

    pds = new PoolingDataSource();
    pds.setUniqueName("java:/accounts-ds");
    pds.setClassName("bitronix.tm.resource.jdbc.lrc.LrcXADataSource");
    pds.setMaxPoolSize(5);
    pds.setAllowLocalTransactions(true);
    pds.getDriverProperties().put("user", "sa");
    pds.getDriverProperties().put("password", "sa");
    pds.getDriverProperties().put("url", "jdbc:h2:mem://localhost/~/test");
    pds.getDriverProperties().put("driverClassName", "org.h2.Driver");
    pds.init();
  }
Exemplo n.º 10
0
  protected void setUp() throws Exception {
    Properties conf = new Properties();
    conf.setProperty("mail.smtp.host", "localhost");
    conf.setProperty("mail.smtp.port", "2345");
    conf.setProperty("from", "*****@*****.**");
    conf.setProperty("replyTo", "*****@*****.**");
    conf.setProperty("defaultLanguage", "en-UK");
    SendIcal.initInstance(conf);

    Properties dsProps = loadDataSourceProperties();
    String txType = dsProps.getProperty("txType", "RESOURCE_LOCAL");
    if ("RESOURCE_LOCAL".equals(txType)) {
      useJTA = false;
    } else if ("JTA".equals(txType)) {
      useJTA = true;
    }

    if (useJTA) {
      pds = new PoolingDataSource();
      pds.setUniqueName("jdbc/taskDS");
      pds.setClassName(dsProps.getProperty("className"));
      pds.setMaxPoolSize(Integer.parseInt(dsProps.getProperty("maxPoolSize")));
      pds.setAllowLocalTransactions(
          Boolean.parseBoolean(dsProps.getProperty("allowLocalTransactions")));
      for (String propertyName : new String[] {"user", "password"}) {
        pds.getDriverProperties().put(propertyName, dsProps.getProperty(propertyName));
      }

      setDatabaseSpecificDataSourceProperties(pds, dsProps);

      pds.init();
    }

    // Use persistence.xml configuration
    emf = createEntityManagerFactory();

    taskService = new TaskService(emf, SystemEventListenerFactory.getSystemEventListener());
    MockUserInfo userInfo = new MockUserInfo();
    taskService.setUserinfo(userInfo);
    users = fillUsersOrGroups("LoadUsers.mvel");
    groups = fillUsersOrGroups("LoadGroups.mvel");
    taskService.addUsersAndGroups(users, groups);
    disableUserGroupCallback();

    logger = LoggerFactory.getLogger(getClass());

    taskSession = taskService.createSession();
  }
Exemplo n.º 11
0
  @BeforeClass
  public static void setUp() {

    ds = new PoolingDataSource();
    ds.setUniqueName("jdbc/testDS1");

    // NON XA CONFIGS
    ds.setClassName("org.h2.jdbcx.JdbcDataSource");
    ds.setMaxPoolSize(3);
    ds.setAllowLocalTransactions(true);
    ds.getDriverProperties().put("user", "sa");
    ds.getDriverProperties().put("password", "sasa");
    ds.getDriverProperties().put("URL", "jdbc:h2:mem:mydb");

    ds.init();
  }
Exemplo n.º 12
0
  protected void setUp() throws Exception {
    TransactionManagerServices.getConfiguration().setJournal("null").setGracefulShutdownInterval(2);
    TransactionManagerServices.getTransactionManager();

    MockitoXADataSource.setStaticCloseXAConnectionException(null);
    MockitoXADataSource.setStaticGetXAConnectionException(null);

    pds = new PoolingDataSource();
    pds.setMinPoolSize(1);
    pds.setMaxPoolSize(2);
    pds.setMaxIdleTime(1);
    pds.setClassName(MockitoXADataSource.class.getName());
    pds.setUniqueName("pds");
    pds.setAllowLocalTransactions(true);
    pds.setAcquisitionTimeout(1);
    pds.init();
  }
Exemplo n.º 13
0
  private void loadConfiguration() {

    InputStream is = null;
    FileInputStream fis = null;
    try {

      fis = new FileInputStream(System.getProperty("user.dir") + "/conf/bpm.properties");
      is = new BufferedInputStream(fis);
      Properties dbProps = new Properties();
      dbProps.load(is);
      guvnorRoot = dbProps.getProperty("guvnor.address");
      localBPMPath = dbProps.getProperty("bpmn.path");

      String jbpmDs = dbProps.getProperty("jbpm5.ds");
      String jbpmClassName = dbProps.getProperty("jbpm5.classname");
      int jbpmPoolSize = Integer.parseInt(dbProps.getProperty("jbpm5.poolsize"));
      boolean jbpmAllowLocalTransactions =
          "true".equals(dbProps.getProperty("jbpm5.localtransactions"));
      String jbpmUserName = dbProps.getProperty("jbpm5.user");
      String jbpmPassword = dbProps.getProperty("jbpm5.password");
      String jbpmURL = dbProps.getProperty("jbpm5.url");

      PoolingDataSource jbpmDataSource = new PoolingDataSource();
      jbpmDataSource.setUniqueName(jbpmDs);
      jbpmDataSource.setClassName(jbpmClassName);
      jbpmDataSource.setMaxPoolSize(jbpmPoolSize);
      jbpmDataSource.setAllowLocalTransactions(jbpmAllowLocalTransactions);
      jbpmDataSource.getDriverProperties().put("user", jbpmUserName);
      jbpmDataSource.getDriverProperties().put("password", jbpmPassword);
      jbpmDataSource.getDriverProperties().put("URL", jbpmURL);
      jbpmDataSource.init();

      // 配置服务器本地知识库资源

    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      try {
        if (fis != null) fis.close();
        if (is != null) is.close();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
Exemplo n.º 14
0
  protected void onSetUp() throws Exception {
    ServiceReference kbuilderRef =
        bundleContext.getServiceReference(KnowledgeBuilderFactoryService.class.getName());
    Thread.currentThread()
        .setContextClassLoader(bundleContext.getService(kbuilderRef).getClass().getClassLoader());

    // --
    Properties conf = new Properties();
    conf.setProperty("mail.smtp.host", "localhost");
    conf.setProperty("mail.smtp.port", "2345");
    conf.setProperty("from", "*****@*****.**");
    conf.setProperty("replyTo", "*****@*****.**");
    conf.setProperty("defaultLanguage", "en-UK");
    SendIcal.initInstance(conf);

    if (useJTA) {
      ds = new PoolingDataSource();
      ds.setUniqueName("jdbc/taskDS");
      ds.setClassName("bitronix.tm.resource.jdbc.lrc.LrcXADataSource");
      ds.setMaxPoolSize(3);
      ds.setAllowLocalTransactions(true);
      ds.getDriverProperties().put("user", "sa");
      ds.getDriverProperties().put("password", "sasa");
      ds.getDriverProperties().put("url", "jdbc:h2:mem:taskDb");
      ds.getDriverProperties().put("driverClassName", "org.h2.Driver");
      ds.init();
    }

    // Use persistence.xml configuration
    emfTaskJPA = createEntityManagerFactory();

    taskService = new TaskService(emfTaskJPA, SystemEventListenerFactory.getSystemEventListener());
    MockUserInfo userInfo = new MockUserInfo();
    taskService.setUserinfo(userInfo);
    users = fillUsersOrGroups("LoadUsers.mvel");
    groups = fillUsersOrGroups("LoadGroups.mvel");
    taskService.addUsersAndGroups(users, groups);
    disableUserGroupCallback();

    logger = LoggerFactory.getLogger(getClass());

    taskSession = taskService.createSession();
  }
Exemplo n.º 15
0
 public static void configure(
     Map<String, PoolingDataSource> dataSources,
     String dsName,
     String dsClass,
     Properties dsProperties) {
   bitronix.tm.Configuration btm = TransactionManagerServices.getConfiguration();
   setDefaults(btm);
   btm.setServerId("default");
   btm.setLogPart1Filename("target/btm1.tlog");
   btm.setLogPart2Filename("target/btm2.tlog");
   btm.setDisableJmx(true);
   PoolingDataSource ds = new PoolingDataSource();
   ds.setUniqueName(dsName);
   ds.setClassName(dsClass);
   ds.setAllowLocalTransactions(true);
   ds.setShareTransactionConnections(true);
   ds.setLocalAutoCommit("false");
   ds.setMaxPoolSize(10);
   ds.getDriverProperties().putAll(dsProperties);
   dataSources.put(dsName, ds);
 }
Exemplo n.º 16
0
 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("bitronix.tm.resource.jdbc.lrc.LrcXADataSource");
   pds.setMaxPoolSize(5);
   pds.setAllowLocalTransactions(true);
   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;
 }
Exemplo n.º 17
0
  @Before
  public void setUp() throws Exception {

    ds = new PoolingDataSource();
    ds.setUniqueName("jdbc/testDS1");

    // NON XA CONFIGS
    ds.setClassName("org.h2.jdbcx.JdbcDataSource");
    ds.setMaxPoolSize(3);
    ds.setAllowLocalTransactions(true);
    ds.getDriverProperties().put("user", "sa");
    ds.getDriverProperties().put("password", "sasa");
    ds.getDriverProperties().put("URL", "jdbc:h2:mem:mydb");

    ds.init();

    IOService ioService = new IOServiceNio2WrapperImpl();

    EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.domain");
    EntityManager em = emf.createEntityManager();

    Logger logger = LogManager.getLogManager().getLogger("");
    JbpmServicesTransactionManager jbpmJTATransactionManager = new JbpmJTATransactionManager();
    JbpmServicesPersistenceManager pm = new JbpmServicesPersistenceManagerImpl();
    ((JbpmServicesPersistenceManagerImpl) pm).setEm(em);
    ((JbpmServicesPersistenceManagerImpl) pm).setTransactionManager(jbpmJTATransactionManager);

    this.fs = new TestVFSFileServiceImpl();
    fs.init();

    MVELWorkItemHandlerProducer workItemProducer = new MVELWorkItemHandlerProducer();
    workItemProducer.setFs(fs);

    TestIdentityProvider identityProvider = new TestIdentityProvider();
    ServicesAwareAuditEventBuilder auditEventBuilder = new ServicesAwareAuditEventBuilder();
    auditEventBuilder.setIdentityProvider(identityProvider);

    adminDataService = new KnowledgeAdminDataServiceImpl();
    ((KnowledgeAdminDataServiceImpl) adminDataService).setPm(pm);

    bpmn2Service = new BPMN2DataServiceImpl();
    ProcessDescriptionRepository repo = new ProcessDescriptionRepository();
    ((BPMN2DataServiceImpl) bpmn2Service).setRepository(repo);
    BPMN2DataServiceSemanticModule semanticModule = new BPMN2DataServiceSemanticModule();

    ProcessGetInformationHandler processHandler = new ProcessGetInformationHandler();
    processHandler.setRepository(repo);
    semanticModule.setProcessHandler(processHandler);

    ProcessGetInputHandler inputHandler = new ProcessGetInputHandler();
    inputHandler.setRepository(repo);
    semanticModule.setProcessInputHandler(inputHandler);

    GetReusableSubProcessesHandler subProcessHandler = new GetReusableSubProcessesHandler();
    subProcessHandler.setRepository(repo);
    semanticModule.setReusableSubprocessHandler(subProcessHandler);

    HumanTaskGetInformationHandler taskHandler = new HumanTaskGetInformationHandler();
    taskHandler.setRepository(repo);
    semanticModule.setTaskHandler(taskHandler);

    semanticModule.init();

    ((BPMN2DataServiceImpl) bpmn2Service).setSemanticModule(semanticModule);
    ((BPMN2DataServiceImpl) bpmn2Service).init();

    HumanTaskServiceFactory.setEntityManagerFactory(emf);

    HumanTaskServiceFactory.setJbpmServicesTransactionManager(jbpmJTATransactionManager);
    taskService = HumanTaskServiceFactory.newTaskService();

    deploymentService = new VFSDeploymentService();
    ((VFSDeploymentService) deploymentService).setBpmn2Service(bpmn2Service);
    ((VFSDeploymentService) deploymentService).setEmf(emf);
    ((VFSDeploymentService) deploymentService).setFs(fs);
    ((VFSDeploymentService) deploymentService).setIdentityProvider(identityProvider);
    ((VFSDeploymentService) deploymentService).setManagerFactory(new RuntimeManagerFactoryImpl());
    ((VFSDeploymentService) deploymentService).setPm(pm);
  }
Exemplo n.º 18
0
  /**
   * This sets up a Bitronix 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"));

    pds.setMaxPoolSize(Integer.parseInt(dsProps.getProperty("maxPoolSize")));
    pds.setAllowLocalTransactions(
        Boolean.parseBoolean(dsProps.getProperty("allowLocalTransactions")));
    for (String propertyName : new String[] {"user", "password"}) {
      pds.getDriverProperties().put(propertyName, dsProps.getProperty(propertyName));
    }

    String driverClass = dsProps.getProperty("driverClassName");
    if (driverClass.startsWith("org.h2")) {
      if (startServer) {
        h2Server.start();
      }
      for (String propertyName : new String[] {"url", "driverClassName"}) {
        pds.getDriverProperties().put(propertyName, dsProps.getProperty(propertyName));
      }
    } else {
      pds.setClassName(dsProps.getProperty("className"));

      if (driverClass.startsWith("oracle")) {
        pds.getDriverProperties().put("driverType", "thin");
        pds.getDriverProperties().put("URL", dsProps.getProperty("url"));
      } else if (driverClass.startsWith("com.ibm.db2")) {
        // http://docs.codehaus.org/display/BTM/JdbcXaSupportEvaluation#JdbcXaSupportEvaluation-IBMDB2
        pds.getDriverProperties().put("databaseName", dsProps.getProperty("databaseName"));
        pds.getDriverProperties().put("driverType", "4");
        pds.getDriverProperties().put("serverName", dsProps.getProperty("serverName"));
        pds.getDriverProperties().put("portNumber", dsProps.getProperty("portNumber"));
      } else if (driverClass.startsWith("com.microsoft")) {
        for (String propertyName : new String[] {"serverName", "portNumber", "databaseName"}) {
          pds.getDriverProperties().put(propertyName, dsProps.getProperty(propertyName));
        }
        pds.getDriverProperties().put("URL", dsProps.getProperty("url"));
        pds.getDriverProperties().put("selectMethod", "cursor");
        pds.getDriverProperties().put("InstanceName", "MSSQL01");
      } else if (driverClass.startsWith("com.mysql")) {
        for (String propertyName :
            new String[] {"databaseName", "serverName", "portNumber", "url"}) {
          pds.getDriverProperties().put(propertyName, dsProps.getProperty(propertyName));
        }
      } else if (driverClass.startsWith("com.sybase")) {
        for (String propertyName : new String[] {"databaseName", "portNumber", "serverName"}) {
          pds.getDriverProperties().put(propertyName, dsProps.getProperty(propertyName));
        }
        pds.getDriverProperties().put("REQUEST_HA_SESSION", "false");
        pds.getDriverProperties().put("networkProtocol", "Tds");
      } else if (driverClass.startsWith("org.postgresql")) {
        for (String propertyName : new String[] {"databaseName", "portNumber", "serverName"}) {
          pds.getDriverProperties().put(propertyName, dsProps.getProperty(propertyName));
        }
      } else {
        throw new RuntimeException("Unknown driver class: " + driverClass);
      }
    }

    return pds;
  }
Exemplo n.º 19
0
  @Before
  public void setUp() throws Exception {

    ds = new PoolingDataSource();
    ds.setUniqueName("jdbc/testDS1");

    // NON XA CONFIGS
    ds.setClassName("org.h2.jdbcx.JdbcDataSource");
    ds.setMaxPoolSize(3);
    ds.setAllowLocalTransactions(true);
    ds.getDriverProperties().put("user", "sa");
    ds.getDriverProperties().put("password", "sasa");
    ds.getDriverProperties().put("URL", "jdbc:h2:mem:mydb");

    ds.init();

    // Persistence Manager Start Up

    emf = Persistence.createEntityManagerFactory("org.jbpm.domain");

    Logger logger = LogManager.getLogManager().getLogger("");
    JbpmServicesTransactionManager jbpmJTATransactionManager = new JbpmJTATransactionManager();
    JbpmServicesPersistenceManager pm = new JbpmServicesPersistenceManagerImpl();

    // Task Service Start up

    HumanTaskServiceFactory.setEntityManagerFactory(emf);

    HumanTaskServiceFactory.setJbpmServicesTransactionManager(jbpmJTATransactionManager);
    taskService = HumanTaskServiceFactory.newTaskService();

    ExternalTaskEventListener externalTaskEventListener = new ExternalTaskEventListener();
    externalTaskEventListener.setTaskService(taskService);
    externalTaskEventListener.setLogger(logger);

    // Session Manager Start up

    sessionManager = new SessionManagerImpl();
    ((SessionManagerImpl) sessionManager).setPm(pm);

    BPMN2DataService bpmn2DataService = new BPMN2DataServiceImpl();
    ProcessDescriptionRepository repo = new ProcessDescriptionRepository();
    ((BPMN2DataServiceImpl) bpmn2DataService).setRepository(repo);
    BPMN2DataServiceSemanticModule semanticModule = new BPMN2DataServiceSemanticModule();

    ProcessGetInformationHandler processHandler = new ProcessGetInformationHandler();
    processHandler.setRepository(repo);
    semanticModule.setProcessHandler(processHandler);

    ProcessGetInputHandler inputHandler = new ProcessGetInputHandler();
    inputHandler.setRepository(repo);
    semanticModule.setProcessInputHandler(inputHandler);

    GetReusableSubProcessesHandler subProcessHandler = new GetReusableSubProcessesHandler();
    subProcessHandler.setRepository(repo);
    semanticModule.setReusableSubprocessHandler(subProcessHandler);

    HumanTaskGetInformationHandler taskHandler = new HumanTaskGetInformationHandler();
    taskHandler.setRepository(repo);
    semanticModule.setTaskHandler(taskHandler);

    semanticModule.init();

    ((BPMN2DataServiceImpl) bpmn2DataService).setSemanticModule(semanticModule);
    ((BPMN2DataServiceImpl) bpmn2DataService).init();

    ((SessionManagerImpl) sessionManager).setBpmn2Service(bpmn2DataService);

    htWorkItemHandler = new LocalHTWorkItemHandler();
    htWorkItemHandler.setSessionManager(sessionManager);
    htWorkItemHandler.setTaskService(taskService);
    htWorkItemHandler.setTaskEventListener(externalTaskEventListener);
    htWorkItemHandler.addSession(ksession);

    ((SessionManagerImpl) sessionManager).setHTWorkItemHandler(htWorkItemHandler);

    TestIdentityProvider identityProvider = new TestIdentityProvider();
    IdentityAwareAuditEventBuilder auditEventBuilder = new IdentityAwareAuditEventBuilder();
    auditEventBuilder.setIdentityProvider(identityProvider);

    ((SessionManagerImpl) sessionManager).setAuditEventBuilder(auditEventBuilder);

    CDIRuleAwareProcessEventListener ruleAwareEventListener =
        new CDIRuleAwareProcessEventListener();
    ((SessionManagerImpl) sessionManager).setProcessFactsListener(ruleAwareEventListener);

    ((SessionManagerImpl) sessionManager).init();

    // TEST Start up
    setTaskService(taskService);
    setSessionManager(sessionManager);
    setHandler(htWorkItemHandler);
  }