@Test
  public void testPersistenceTimer2() throws Exception {
    KieSession service = (KieSession) ctx.getBean("jpaSingleSessionCommandService2");

    int sessionId = service.getId();

    ProcessInstance processInstance = service.startProcess("org.drools.test.ProcessTimer2");
    log.info("Started process instance {}", processInstance.getId());

    Thread.sleep(2000);

    final Environment env = (Environment) ctx.getBean("env");
    /*
    Environment env = KnowledgeBaseFactory.newEnvironment();
    env.set( EnvironmentName.ENTITY_MANAGER_FACTORY,
             ctx.getBean( "myEmf" ) );
    env.set( EnvironmentName.TRANSACTION_MANAGER,
             ctx.getBean( "txManager" ) );
    */
    KieStoreServices kstore = (KieStoreServices) ctx.getBean("kstore1");
    KieBase kbase1 = (KieBase) ctx.getBean("kb_persistence");
    service = kstore.loadKieSession(sessionId, kbase1, null, env);

    processInstance = service.getProcessInstance(processInstance.getId());
    assertNull(processInstance);
  }
  @Test
  public void testPersistenceTimer() throws Exception {
    System.out.println("TMPDIR == " + TMPDIR);
    log.info("---> get bean jpaSingleSessionCommandService2");
    KieSession service = (KieSession) ctx.getBean("jpaSingleSessionCommandService2");

    int sessionId = service.getId();
    log.info("---> created SingleSessionCommandService id: " + sessionId);

    ProcessInstance processInstance = service.startProcess("org.drools.test.ProcessTimer");
    long procId = processInstance.getId();
    log.info("---> Started ProcessTimer id: {}", procId);

    service.dispose();
    log.info("---> session disposed");

    final Environment env = (Environment) ctx.getBean("env");
    /*
    Environment env = KnowledgeBaseFactory.newEnvironment();
    env.set( EnvironmentName.ENTITY_MANAGER_FACTORY,
             ctx.getBean( "myEmf" ) );
    env.set( EnvironmentName.TRANSACTION_MANAGER,
             ctx.getBean( "txManager" ) );
    */
    KieStoreServices kstore = (KieStoreServices) ctx.getBean("kstore1");
    KieBase kbase1 = (KieBase) ctx.getBean("kb_persistence");
    service = kstore.loadKieSession(sessionId, kbase1, null, env);

    log.info("---> load session: " + sessionId);
    processInstance = service.getProcessInstance(procId);
    log.info("---> GetProcessInstanceCommand id: " + procId);
    assertNotNull(processInstance);

    Thread.sleep(1000);
    log.info("---> session disposed");
    service.dispose();

    service = kstore.loadKieSession(sessionId, kbase1, null, env);
    log.info("---> load session: " + sessionId);
    Thread.sleep(3000);

    log.info("---> GetProcessInstanceCommand id: " + procId);
    processInstance = service.getProcessInstance(procId);
    log.info("---> session disposed");
    assertNull(processInstance);
  }