diff --git a/jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/concurrent/EventHnadlingTest.java b/jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/concurrent/EventHnadlingTest.java index e63d7592ed..d15f2b47f5 100644 --- a/jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/concurrent/EventHnadlingTest.java +++ b/jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/concurrent/EventHnadlingTest.java @@ -173,6 +173,8 @@ public void testRunMultiEventProcessPerProcessInstanceRuntimeManager() { processInstance = ksession.getProcessInstance(processInstance.getId()); assertNull(processInstance); + + manager.disposeRuntimeEngine(runtime); // close manager which will close session maintained by the manager manager.close(); diff --git a/jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/impl/PerCaseRuntimeManagerTest.java b/jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/impl/PerCaseRuntimeManagerTest.java index f474479511..8de30f6337 100644 --- a/jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/impl/PerCaseRuntimeManagerTest.java +++ b/jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/impl/PerCaseRuntimeManagerTest.java @@ -364,6 +364,7 @@ public void beforeProcessStarted(ProcessStartedEvent event) { assertEquals(ksession1Id, ksessionUsed.iterator().next().longValue()); + manager.disposeRuntimeEngine(runtime); manager.close(); } diff --git a/jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/impl/PerRequestRuntimeManagerTest.java b/jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/impl/PerRequestRuntimeManagerTest.java index 97c92b500b..c038c156a3 100644 --- a/jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/impl/PerRequestRuntimeManagerTest.java +++ b/jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/impl/PerRequestRuntimeManagerTest.java @@ -557,7 +557,7 @@ public void testMultiplePerRequestManagerFromSingleThread() { assertEquals(ProcessInstance.STATE_ACTIVE, processInstance2.getState()); manager.disposeRuntimeEngine(runtime1); - manager.disposeRuntimeEngine(runtime2); + manager2.disposeRuntimeEngine(runtime2); // close manager which will close session maintained by the manager manager.close(); diff --git a/jbpm-services/jbpm-executor/src/test/java/org/jbpm/executor/impl/wih/AsyncWorkItemHandlerTest.java b/jbpm-services/jbpm-executor/src/test/java/org/jbpm/executor/impl/wih/AsyncWorkItemHandlerTest.java index e844246f3d..4410236537 100644 --- a/jbpm-services/jbpm-executor/src/test/java/org/jbpm/executor/impl/wih/AsyncWorkItemHandlerTest.java +++ b/jbpm-services/jbpm-executor/src/test/java/org/jbpm/executor/impl/wih/AsyncWorkItemHandlerTest.java @@ -498,6 +498,7 @@ public Map getWorkItemHandlers(RuntimeEngine runtime) { @Test(timeout=10000) public void testRunProcessWithAsyncHandlerCallbackErrorRetry() throws Exception { + int initialIncrement = IncrementService.get(); final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Task 1", 1); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder() .userGroupCallback(userGroupCallback) @@ -527,7 +528,7 @@ public List getProcessEventListeners( RuntimeEngine runtim KieSession ksession = runtime.getKieSession(); assertNotNull(ksession); - assertEquals(0, IncrementService.get()); + assertEquals(initialIncrement, IncrementService.get()); Map params = new HashMap(); params.put("retryAsync", "1s, 2s, 4s"); @@ -548,7 +549,7 @@ public List getProcessEventListeners( RuntimeEngine runtim processInstance = ksession.getProcessInstance(processInstance.getId()); assertNull(processInstance); - assertEquals(1, IncrementService.get()); + assertEquals(initialIncrement + 1, IncrementService.get()); } @Test(timeout=10000) diff --git a/jbpm-services/jbpm-kie-services/src/test/java/org/jbpm/kie/services/test/FilteredKModuleDeploymentServiceTest.java b/jbpm-services/jbpm-kie-services/src/test/java/org/jbpm/kie/services/test/FilteredKModuleDeploymentServiceTest.java index cb3b5afc77..cd31501d95 100644 --- a/jbpm-services/jbpm-kie-services/src/test/java/org/jbpm/kie/services/test/FilteredKModuleDeploymentServiceTest.java +++ b/jbpm-services/jbpm-kie-services/src/test/java/org/jbpm/kie/services/test/FilteredKModuleDeploymentServiceTest.java @@ -356,6 +356,7 @@ public void testSerializationClassesLimitedInDeploymentItself() { limitDeploymentUnit.setDeploymentDescriptor(depDesc); deploymentService.deploy(limitDeploymentUnit); + units.add(limitDeploymentUnit); verifyDeployedUnitContainsCorrectClasses(limitDeploymentUnit); depDesc = new DeploymentDescriptorImpl().getBuilder() @@ -364,6 +365,7 @@ public void testSerializationClassesLimitedInDeploymentItself() { allDeploymentUnit.setDeploymentDescriptor(depDesc); deploymentService.deploy(allDeploymentUnit); + units.add(allDeploymentUnit); verifyDeployedUnitContainsCorrectClasses(allDeploymentUnit); } @@ -427,6 +429,7 @@ public void testSerializationClassesLimitedInDeploymentDependencies() { .get(); childDeploymentUnit.setDeploymentDescriptor(depDesc); deploymentService.deploy(childDeploymentUnit); + units.add(childDeploymentUnit); KModuleDeploymentUnit parentDeploymentUnit = new KModuleDeploymentUnit(groupId, parentArtifactId, version); DeploymentDescriptor parentDepDesc = new DeploymentDescriptorImpl().getBuilder() @@ -435,6 +438,7 @@ public void testSerializationClassesLimitedInDeploymentDependencies() { parentDeploymentUnit.setDeploymentDescriptor(parentDepDesc); deploymentService.deploy(parentDeploymentUnit); + units.add(parentDeploymentUnit); verifyDeployedUnitContainsCorrectClasses(parentDeploymentUnit); } diff --git a/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/async/AsyncMultisubprocessTest.java b/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/async/AsyncMultisubprocessTest.java index 490c910cf8..571383889e 100644 --- a/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/async/AsyncMultisubprocessTest.java +++ b/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/async/AsyncMultisubprocessTest.java @@ -42,7 +42,7 @@ */ public class AsyncMultisubprocessTest extends JbpmTestCase { - private static CountDownLatch latch = new CountDownLatch(1); + private CountDownLatch latch; private static final String BPMN_AICS = "org/jbpm/test/functional/async/AsyncSubMultiprocess.bpmn2"; private static final String PROCESS_AICS = "TestSubMult"; @@ -55,6 +55,7 @@ public class AsyncMultisubprocessTest extends JbpmTestCase { public void setUp() throws Exception { setupDataSource = true; super.setUp(); + latch = new CountDownLatch(1); executorService = ExecutorServiceFactory.newExecutorService(getEmf()); executorService.setInterval(1); diff --git a/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/jpa/ParentChildMarshallingJpaTest.java b/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/jpa/ParentChildMarshallingJpaTest.java index 492c3bc131..f0b1b7a1e2 100644 --- a/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/jpa/ParentChildMarshallingJpaTest.java +++ b/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/jpa/ParentChildMarshallingJpaTest.java @@ -33,6 +33,7 @@ import org.jbpm.test.JbpmTestCase; import org.jbpm.test.entity.Application; import org.jbpm.test.entity.Person; +import org.junit.After; import org.junit.Test; import org.kie.api.marshalling.ObjectMarshallingStrategy; import org.kie.api.runtime.EnvironmentName; @@ -59,6 +60,16 @@ public ParentChildMarshallingJpaTest() { super(true, true); } + @After + public void tearDown() { + EntityManager em = emfDomain.createEntityManager(); + em.getTransaction().begin(); + em.createQuery("DELETE FROM Application WHERE person IS NOT NULL").executeUpdate(); + em.createQuery("DELETE FROM Person").executeUpdate(); + em.getTransaction().commit(); + em.close(); + } + @Test public void testProcess() throws Exception { @@ -120,6 +131,9 @@ public void testProcess() throws Exception { int size = em.createQuery("select i from Person i").getResultList().size(); assertEquals(1, size); + // close manager which will close session maintained by the manager + manager.close(); + } } \ No newline at end of file diff --git a/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/monitoring/MBeansMonitoringWithJBpmTest.java b/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/monitoring/MBeansMonitoringWithJBpmTest.java index 5eb5f6a68e..30997544f5 100644 --- a/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/monitoring/MBeansMonitoringWithJBpmTest.java +++ b/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/monitoring/MBeansMonitoringWithJBpmTest.java @@ -299,6 +299,8 @@ public void testRulesAndProcesses() throws Exception { checkTotalSessions(aggrMonitor2, 3); checkStatsForProcess(aggrMonitor2, "com.sample.HelloWorld" ,6,6,18); checkStatsForProcess(aggrMonitor2, "com.sample.CiaoWorld" ,3,3,9); + + kc.dispose(); } private void checkStatsForProcess(GenericKieSessionMonitoringMXBean mb, String ruleName, long iStarted, long iCompleted, long nodesTriggered) { diff --git a/jbpm-test-coverage/src/test/java/org/jbpm/test/regression/async/AsyncWIHOnOracleTest.java b/jbpm-test-coverage/src/test/java/org/jbpm/test/regression/async/AsyncWIHOnOracleTest.java index 03f33a88d6..83e9ce0102 100644 --- a/jbpm-test-coverage/src/test/java/org/jbpm/test/regression/async/AsyncWIHOnOracleTest.java +++ b/jbpm-test-coverage/src/test/java/org/jbpm/test/regression/async/AsyncWIHOnOracleTest.java @@ -81,6 +81,7 @@ public void tearDown() { } catch (Exception ex) { ex.printStackTrace(); } + CounterCommand.resetCounter(); } public static class CounterCommand implements Command { @@ -97,6 +98,10 @@ public static int getCounter() { return counter; } + public static void resetCounter() { + counter = 0; + } + } } diff --git a/jbpm-workitems/jbpm-workitems-rest/src/test/java/org/jbpm/process/workitem/rest/RestWorkitemHandlerClientCreationTest.java b/jbpm-workitems/jbpm-workitems-rest/src/test/java/org/jbpm/process/workitem/rest/RestWorkitemHandlerClientCreationTest.java index 6f98b36d66..9bcec4a437 100644 --- a/jbpm-workitems/jbpm-workitems-rest/src/test/java/org/jbpm/process/workitem/rest/RestWorkitemHandlerClientCreationTest.java +++ b/jbpm-workitems/jbpm-workitems-rest/src/test/java/org/jbpm/process/workitem/rest/RestWorkitemHandlerClientCreationTest.java @@ -78,6 +78,9 @@ public void setClientApiVersion() { @Test public void testPooledClientCreationWithDefaultTimeouts() { + // clear cached client to ensure starting from fresh state + RESTWorkItemHandler.cachedClient = null; + RESTWorkItemHandler handler = spy(RESTWorkItemHandler.class); when(handler.getDoCacheClient()).thenReturn(true);