Source:
public void testPersistedProcess(String type) throws IOException, ParseException, SQLException { TestsUtil.clearSchema(); final TestPersistenceContext scriptRunnerContext = new TestPersistenceContext(); scriptRunnerContext.init(PersistenceUnit.SCRIPT_RUNNER); try { scriptRunnerContext.executeScripts(new File(getClass().getResource("/ddl60").getFile())); scriptRunnerContext.persistOldProcessAndSession(TEST_SESSION_ID, TEST_PROCESS_ID, TEST_PROCESS_INSTANCE_ID); scriptRunnerContext.createSomeTask(); scriptRunnerContext.executeScripts(new File(getClass().getResource("/db/upgrade-scripts").getFile()), type); } finally { scriptRunnerContext.clean(); } final TestPersistenceContext dbTestingContext = new TestPersistenceContext(); dbTestingContext.init(PersistenceUnit.DB_TESTING); try { Assert.assertTrue(dbTestingContext.getStoredProcessesCount() == 1); Assert.assertTrue(dbTestingContext.getStoredSessionsCount() == 1); final StatefulKnowledgeSession persistedSession = dbTestingContext.loadPersistedSession( TEST_SESSION_ID.longValue(), TEST_PROCESS_ID); Assert.assertNotNull(persistedSession); persistedSession.startProcess(TEST_PROCESS_ID); Assert.assertTrue(dbTestingContext.getStoredProcessesCount() == 2); ProcessInstance processInstance = persistedSession.getProcessInstance(TEST_PROCESS_INSTANCE_ID); Assert.assertNotNull(processInstance); persistedSession.signalEvent("test", null); processInstance = persistedSession.getProcessInstance(TEST_PROCESS_INSTANCE_ID); Assert.assertNull(processInstance); Assert.assertTrue(dbTestingContext.getStoredProcessesCount() == 0); persistedSession.dispose(); persistedSession.destroy(); Assert.assertTrue(dbTestingContext.getStoredSessionsCount() == 0); } finally { dbTestingContext.clean(); } }

Target:
public void testPersistedProcess(String type) throws IOException, ParseException, SQLException { TestsUtil.clearSchema(); final TestPersistenceContext scriptRunnerContext = new TestPersistenceContext(); scriptRunnerContext.init(PersistenceUnit.SCRIPT_RUNNER); try { scriptRunnerContext.executeScripts(new File(getClass().getResource("/ddl60").getFile())); scriptRunnerContext.persistOldProcessAndSession(TEST_SESSION_ID, TEST_PROCESS_ID, TEST_PROCESS_INSTANCE_ID); scriptRunnerContext.createSomeTask(); scriptRunnerContext.executeScripts(new File(getClass().getResource(DB_UPGRADE_SCRIPTS_RESOURCE_PATH).getFile()), type); } finally { scriptRunnerContext.clean(); } final TestPersistenceContext dbTestingContext = new TestPersistenceContext(); dbTestingContext.init(PersistenceUnit.DB_TESTING); try { Assert.assertTrue(dbTestingContext.getStoredProcessesCount() == 1); Assert.assertTrue(dbTestingContext.getStoredSessionsCount() == 1); final StatefulKnowledgeSession persistedSession = dbTestingContext.loadPersistedSession( TEST_SESSION_ID.longValue(), TEST_PROCESS_ID); Assert.assertNotNull(persistedSession); persistedSession.startProcess(TEST_PROCESS_ID); Assert.assertTrue(dbTestingContext.getStoredProcessesCount() == 2); ProcessInstance processInstance = persistedSession.getProcessInstance(TEST_PROCESS_INSTANCE_ID); Assert.assertNotNull(processInstance); persistedSession.signalEvent("test", null); processInstance = persistedSession.getProcessInstance(TEST_PROCESS_INSTANCE_ID); Assert.assertNull(processInstance); Assert.assertTrue(dbTestingContext.getStoredProcessesCount() == 0); persistedSession.dispose(); persistedSession.destroy(); Assert.assertTrue(dbTestingContext.getStoredSessionsCount() == 0); } finally { dbTestingContext.clean(); } }