Permalink
Browse files

improve test stability

closes #368
  • Loading branch information...
1 parent 225029c commit 2e01d513102cc3d20fce84d7b35358ef7289d8b7 @mswiderski mswiderski committed Dec 4, 2015
Showing with 457 additions and 251 deletions.
  1. +0 −1 .gitignore
  2. +1 −0 jbpm-audit/src/test/resources/bitronix-default-config.properties
  3. +1 −1 jbpm-bpmn2/pom.xml
  4. +1 −8 jbpm-bpmn2/src/test/java/org/jbpm/test/util/AbstractBaseTest.java
  5. +29 −1 jbpm-bpmn2/src/test/java/org/jbpm/test/util/CountDownProcessEventListener.java
  6. +1 −0 jbpm-bpmn2/src/test/resources/bitronix-default-config.properties
  7. +1 −0 jbpm-human-task/jbpm-human-task-audit/src/test/resources/bitronix-default-config.properties
  8. +0 −6 ...man-task/jbpm-human-task-core/src/test/java/org/jbpm/services/task/HumanTaskServicesBaseTest.java
  9. +3 −4 ...ask/jbpm-human-task-core/src/test/java/org/jbpm/services/task/jaxb/JsonTaskSerializationTest.java
  10. +1 −0 jbpm-human-task/jbpm-human-task-core/src/test/resources/bitronix-default-config.properties
  11. +1 −0 jbpm-human-task/jbpm-human-task-jpa/src/test/resources/bitronix-default-config.properties
  12. +1 −0 jbpm-human-task/jbpm-human-task-performance/src/test/resources/bitronix-default-config.properties
  13. +1 −0 jbpm-human-task/jbpm-human-task-workitems/src/test/resources/bitronix-default-config.properties
  14. +1 −0 jbpm-persistence-jpa/src/test/resources/bitronix-default-config.properties
  15. +1 −0 jbpm-query-jpa/src/test/resources/bitronix-default-config.properties
  16. +0 −1 jbpm-runtime-manager/.gitignore
  17. +18 −12 jbpm-runtime-manager/src/test/java/org/jbpm/runtime/manager/concurrent/ConcurrentOperationsTest.java
  18. +29 −1 jbpm-runtime-manager/src/test/java/org/jbpm/test/util/CountDownProcessEventListener.java
  19. +1 −0 jbpm-runtime-manager/src/test/resources/bitronix-default-config.properties
  20. +0 −1 jbpm-services/jbpm-executor-cdi/.gitignore
  21. +1 −0 jbpm-services/jbpm-executor-cdi/src/test/resources/bitronix-default-config.properties
  22. +0 −8 jbpm-services/jbpm-executor/src/test/java/org/jbpm/executor/BasicExecutorBaseTest.java
  23. +0 −7 jbpm-services/jbpm-executor/src/test/java/org/jbpm/executor/ReconfiguredExecutorTest.java
  24. +1 −8 jbpm-services/jbpm-executor/src/test/java/org/jbpm/executor/impl/jms/JmsAvaiableJobExecutorTest.java
  25. +1 −7 ...ices/jbpm-executor/src/test/java/org/jbpm/executor/impl/jpa/ExecutorQueryBuilderCoverageTest.java
  26. +1 −7 jbpm-services/jbpm-executor/src/test/java/org/jbpm/test/util/AbstractExecutorBaseTest.java
  27. +30 −2 jbpm-services/jbpm-executor/src/test/java/org/jbpm/test/util/CountDownProcessEventListener.java
  28. +1 −0 jbpm-services/jbpm-executor/src/test/resources/bitronix-default-config.properties
  29. +12 −5 ...ces/jbpm-kie-services/src/test/java/org/jbpm/kie/services/test/DeploymentServiceWithSyncTest.java
  30. +57 −4 ...pm-kie-services/src/test/java/org/jbpm/kie/services/test/objects/CoundDownDeploymentListener.java
  31. +1 −0 jbpm-services/jbpm-kie-services/src/test/resources/bitronix-default-config.properties
  32. +6 −3 ...m-services-cdi/src/test/java/org/jbpm/services/cdi/test/DeploymentServiceCDIImplWithSyncTest.java
  33. +5 −1 ...ces/jbpm-services-cdi/src/test/java/org/jbpm/services/cdi/test/RuntimeDataServiceCDIImplTest.java
  34. +1 −0 jbpm-services/jbpm-services-cdi/src/test/resources/bitronix-default-config.properties
  35. +0 −1 jbpm-services/jbpm-services-ejb/jbpm-executor-ejb/.gitignore
  36. +1 −0 ...ervices/jbpm-services-ejb/jbpm-executor-ejb/src/test/resources/bitronix-default-config.properties
  37. +1 −0 ...es/jbpm-services-ejb/jbpm-services-ejb-impl/src/test/resources/bitronix-default-config.properties
  38. +1 −0 ...s/jbpm-services-ejb/jbpm-services-ejb-timer/src/test/resources/bitronix-default-config.properties
  39. +4 −0 jbpm-test-coverage/pom.xml
  40. +30 −2 jbpm-test-coverage/src/main/java/org/jbpm/test/listener/CountDownProcessEventListener.java
  41. +40 −6 jbpm-test-coverage/src/main/java/org/jbpm/test/listener/TrackingProcessEventListener.java
  42. +1 −9 jbpm-test-coverage/src/test/java/org/jbpm/test/JbpmTestCase.java
  43. +4 −4 jbpm-test-coverage/src/test/java/org/jbpm/test/functional/TransactionsTest.java
  44. +2 −2 jbpm-test-coverage/src/test/java/org/jbpm/test/functional/gateway/EventBasedGatewayTest.java
  45. +31 −21 jbpm-test-coverage/src/test/java/org/jbpm/test/functional/jobexec/AsyncTaskTest.java
  46. +37 −12 jbpm-test-coverage/src/test/java/org/jbpm/test/functional/task/ConcurrentHumanTaskTest.java
  47. +7 −18 jbpm-test-coverage/src/test/java/org/jbpm/test/functional/timer/GlobalQuartzDBTimerServiceTest.java
  48. +9 −12 ...-test-coverage/src/test/java/org/jbpm/test/functional/timer/GlobalThreadPoolTimerServiceTest.java
  49. +36 −52 jbpm-test-coverage/src/test/java/org/jbpm/test/functional/timer/GlobalTimerServiceBaseTest.java
  50. +41 −16 jbpm-test-coverage/src/test/java/org/jbpm/test/functional/timer/MultipleTimerServicesTest.java
  51. +0 −7 jbpm-test-coverage/src/test/java/org/jbpm/test/functional/timer/TimerBaseTest.java
  52. +1 −1 jbpm-test-coverage/src/test/java/org/jbpm/test/regression/task/HumanTaskTest.java
  53. +1 −0 jbpm-test-coverage/src/test/resources/bitronix-default-config.properties
  54. +1 −0 jbpm-test/src/test/resources/bitronix-default-config.properties
  55. +1 −0 jbpm-workitems/src/test/resources/bitronix-default-config.properties
View
@@ -19,7 +19,6 @@ bin/
# Test info
/settings*.xml
/lib-jdbc/
-bitronix-default-config.properties
*.db
*.tlog
@@ -0,0 +1 @@
+bitronix.tm.journal=null
View
@@ -18,7 +18,7 @@
<description>jBPM BPMN2</description>
<properties>
- <maven.jdbc.url>jdbc:h2:tcp://localhost/target/jbpm-bpmn-db</maven.jdbc.url>
+ <maven.jdbc.url>jdbc:h2:tcp://localhost/target/jbpm-bpmn-db;MVCC=TRUE</maven.jdbc.url>
</properties>
<dependencies>
@@ -20,16 +20,9 @@
import org.junit.Assert;
import org.junit.BeforeClass;
-import bitronix.tm.TransactionManagerServices;
-
public abstract class AbstractBaseTest extends Assert {
- static {
- if (!TransactionManagerServices.isTransactionManagerRunning()) {
- TransactionManagerServices.getConfiguration().setJournal("null");
- }
- }
-
+
@BeforeClass
public static void configure() {
LoggingPrintStream.interceptSysOutSysErr();
@@ -3,6 +3,9 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
+import org.drools.persistence.TransactionManager;
+import org.drools.persistence.TransactionManagerFactory;
+import org.drools.persistence.TransactionSynchronization;
import org.kie.api.event.process.DefaultProcessEventListener;
import org.kie.api.event.process.ProcessNodeLeftEvent;
import org.slf4j.Logger;
@@ -24,7 +27,7 @@ public CountDownProcessEventListener(String nodeName, int threads) {
@Override
public void afterNodeLeft(ProcessNodeLeftEvent event) {
if (nodeName.equals(event.getNodeInstance().getNodeName())) {
- latch.countDown();
+ countDown();
}
}
@@ -43,4 +46,29 @@ public void waitTillCompleted(long timeOut) {
logger.debug("Interrputed thread while waiting for all triggers for node {}", nodeName);
}
}
+
+ protected void countDown() {
+ try {
+ TransactionManager tm = TransactionManagerFactory.get().newTransactionManager();
+ if (tm != null && tm.getStatus() != TransactionManager.STATUS_NO_TRANSACTION
+ && tm.getStatus() != TransactionManager.STATUS_ROLLEDBACK
+ && tm.getStatus() != TransactionManager.STATUS_COMMITTED) {
+ tm.registerTransactionSynchronization(new TransactionSynchronization() {
+
+ @Override
+ public void beforeCompletion() {
+ }
+
+ @Override
+ public void afterCompletion(int status) {
+ latch.countDown();
+ }
+ });
+ } else {
+ latch.countDown();
+ }
+ } catch (Exception e) {
+ latch.countDown();
+ }
+ }
}
@@ -0,0 +1 @@
+bitronix.tm.journal=null
@@ -60,12 +60,6 @@
private static final Logger logger = LoggerFactory.getLogger(HumanTaskServicesBaseTest.class);
- static {
- if (!TransactionManagerServices.isTransactionManagerRunning()) {
- TransactionManagerServices.getConfiguration().setJournal("null");
- }
- }
-
protected InternalTaskService taskService;
@BeforeClass
@@ -16,10 +16,6 @@
package org.jbpm.services.task.jaxb;
import org.codehaus.jackson.map.ObjectMapper;
-import org.jbpm.services.task.impl.model.ContentImpl;
-import org.jbpm.services.task.impl.model.xml.JaxbContent;
-import org.junit.Test;
-import org.kie.api.task.model.Content;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -31,6 +27,9 @@
private ObjectMapper mapper = new ObjectMapper();
+ public JsonTaskSerializationTest() {
+ }
+
public TestType getType() {
return TestType.JSON;
}
@@ -0,0 +1 @@
+bitronix.tm.journal=null
@@ -0,0 +1 @@
+bitronix.tm.journal=null
@@ -20,7 +20,6 @@ bin/
# Test info
/settings*.xml
/lib-jdbc/
-bitronix-default-config.properties
*.db
# modules that don't exist in this branch
@@ -18,6 +18,7 @@
import bitronix.tm.resource.jdbc.PoolingDataSource;
import org.jbpm.runtime.manager.impl.DefaultRegisterableItemsFactory;
+import org.jbpm.runtime.manager.impl.RuntimeEngineImpl;
import org.jbpm.runtime.manager.util.TestUtil;
import org.jbpm.services.task.identity.JBossUserGroupCallbackImpl;
import org.jbpm.test.util.AbstractBaseTest;
@@ -90,7 +91,7 @@ public void testExecuteProcessWithAsyncHandler() throws Exception {
@Override
public Map<String, WorkItemHandler> getWorkItemHandlers(RuntimeEngine runtime) {
Map<String, WorkItemHandler> handlers = super.getWorkItemHandlers(runtime);
- handlers.put("Log", new AsyncWorkItemHandler(runtime.getKieSession()));
+ handlers.put("Log", new AsyncWorkItemHandler(((RuntimeEngineImpl)runtime).getManager()));
return handlers;
}
@@ -150,7 +151,7 @@ public void testExecuteHumanTaskWithAsyncHandler() throws Exception {
@Override
public Map<String, WorkItemHandler> getWorkItemHandlers(RuntimeEngine runtime) {
Map<String, WorkItemHandler> handlers = super.getWorkItemHandlers(runtime);
- handlers.put("Log", new AsyncWorkItemHandler(runtime.getKieSession()));
+ handlers.put("Log", new AsyncWorkItemHandler(((RuntimeEngineImpl)runtime).getManager()));
return handlers;
}
@@ -211,10 +212,10 @@ public void testExecuteHumanTaskWithAsyncHandler() throws Exception {
private class AsyncWorkItemHandler implements WorkItemHandler {
- private KieSession ksession;
+ private RuntimeManager runtimeManager;
- AsyncWorkItemHandler(KieSession ksession) {
- this.ksession = ksession;
+ AsyncWorkItemHandler(RuntimeManager runtimeManager) {
+ this.runtimeManager = runtimeManager;
}
@Override
@@ -224,15 +225,20 @@ public void executeWorkItem(final WorkItem workItem, WorkItemManager manager) {
@Override
public void run() {
- logger.debug("staring a thread....");
- ksession.insert("doing it async");
+
try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
-
+ Thread.sleep(1000);
+
+ RuntimeEngine engine = runtimeManager.getRuntimeEngine(EmptyContext.get());// only for singleton
+ logger.debug("staring a thread....");
+ engine.getKieSession().insert("doing it async");
+ logger.debug("Completing the work item");
+
+ engine.getKieSession().getWorkItemManager().completeWorkItem(workItem.getId(), null);
+ runtimeManager.disposeRuntimeEngine(engine);
+ } catch (Exception e) {
+ logger.error("Error when executing async operation", e);
}
- logger.debug("Completing the work item");
- ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null);
}
}.start();
@@ -3,6 +3,9 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
+import org.drools.persistence.TransactionManager;
+import org.drools.persistence.TransactionManagerFactory;
+import org.drools.persistence.TransactionSynchronization;
import org.kie.api.event.process.DefaultProcessEventListener;
import org.kie.api.event.process.ProcessNodeLeftEvent;
import org.slf4j.Logger;
@@ -24,7 +27,7 @@ public CountDownProcessEventListener(String nodeName, int threads) {
@Override
public void afterNodeLeft(ProcessNodeLeftEvent event) {
if (nodeName.equals(event.getNodeInstance().getNodeName())) {
- latch.countDown();
+ countDown();
}
}
@@ -52,4 +55,29 @@ public void reset(String nodeName, int threads) {
this.nodeName = nodeName;
this.latch = new CountDownLatch(threads);
}
+
+ protected void countDown() {
+ try {
+ TransactionManager tm = TransactionManagerFactory.get().newTransactionManager();
+ if (tm != null && tm.getStatus() != TransactionManager.STATUS_NO_TRANSACTION
+ && tm.getStatus() != TransactionManager.STATUS_ROLLEDBACK
+ && tm.getStatus() != TransactionManager.STATUS_COMMITTED) {
+ tm.registerTransactionSynchronization(new TransactionSynchronization() {
+
+ @Override
+ public void beforeCompletion() {
+ }
+
+ @Override
+ public void afterCompletion(int status) {
+ latch.countDown();
+ }
+ });
+ } else {
+ latch.countDown();
+ }
+ } catch (Exception e) {
+ latch.countDown();
+ }
+ }
}
@@ -0,0 +1 @@
+bitronix.tm.journal=null
@@ -19,7 +19,6 @@ bin/
# Test info
/settings*.xml
/lib-jdbc/
-bitronix-default-config.properties
*.db
*.tlog
@@ -49,18 +49,10 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import bitronix.tm.TransactionManagerServices;
-
public abstract class BasicExecutorBaseTest {
private static final Logger logger = LoggerFactory.getLogger(BasicExecutorBaseTest.class);
- static {
- if (!TransactionManagerServices.isTransactionManagerRunning()) {
- TransactionManagerServices.getConfiguration().setJournal("null");
- }
- }
-
protected ExecutorService executorService;
public static final Map<String, Object> cachedEntities = new HashMap<String, Object>();
@@ -37,7 +37,6 @@
import org.kie.api.executor.RequestInfo;
import org.kie.api.runtime.query.QueryContext;
-import bitronix.tm.TransactionManagerServices;
import bitronix.tm.resource.jdbc.PoolingDataSource;
@@ -46,12 +45,6 @@
protected ExecutorService executorService;
public static final Map<String, Object> cachedEntities = new HashMap<String, Object>();
- static {
- if (!TransactionManagerServices.isTransactionManagerRunning()) {
- TransactionManagerServices.getConfiguration().setJournal("null");
- }
- }
-
private PoolingDataSource pds;
private EntityManagerFactory emf = null;
@@ -51,20 +51,13 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import bitronix.tm.TransactionManagerServices;
import bitronix.tm.resource.jdbc.PoolingDataSource;
import bitronix.tm.resource.jms.PoolingConnectionFactory;
public class JmsAvaiableJobExecutorTest {
private static final Logger logger = LoggerFactory.getLogger(JmsAvaiableJobExecutorTest.class);
-
- static {
- if (!TransactionManagerServices.isTransactionManagerRunning()) {
- TransactionManagerServices.getConfiguration().setJournal("null");
- }
- }
-
+
private ConnectionFactory factory;
private Queue queue;
@@ -18,19 +18,13 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import bitronix.tm.TransactionManagerServices;
import bitronix.tm.resource.jdbc.PoolingDataSource;
public class ExecutorQueryBuilderCoverageTest {
private static final Logger logger = LoggerFactory.getLogger(ExecutorQueryBuilderCoverageTest.class);
- static {
- if (!TransactionManagerServices.isTransactionManagerRunning()) {
- TransactionManagerServices.getConfiguration().setJournal("null");
- }
- }
-
+
private static PoolingDataSource pds;
private static EntityManagerFactory emf;
@@ -22,15 +22,9 @@
import org.junit.AfterClass;
import org.junit.BeforeClass;
-import bitronix.tm.TransactionManagerServices;
-
public abstract class AbstractExecutorBaseTest {
- static {
- if (!TransactionManagerServices.isTransactionManagerRunning()) {
- TransactionManagerServices.getConfiguration().setJournal("null");
- }
- }
+
@After
public void cleanup() {
EntityManagerFactoryManager.get().clear();
Oops, something went wrong.

0 comments on commit 2e01d51

Please sign in to comment.