diff --git a/jbpm-services/jbpm-services-cdi/pom.xml b/jbpm-services/jbpm-services-cdi/pom.xml
index 1223661a32..93a5e6f378 100644
--- a/jbpm-services/jbpm-services-cdi/pom.xml
+++ b/jbpm-services/jbpm-services-cdi/pom.xml
@@ -104,7 +104,6 @@
dashbuilder-dataset-api
-
org.jboss.weld
@@ -132,11 +131,23 @@
org.hibernate
hibernate-entitymanager
test
+
+
+ org.apache.geronimo.specs
+ geronimo-jta_1.1_spec
+
+
org.hibernate
hibernate-core
test
+
+
+ org.apache.geronimo.specs
+ geronimo-jta_1.1_spec
+
+
org.hibernate
@@ -175,7 +186,7 @@
test
-
+
diff --git a/jbpm-services/jbpm-services-cdi/src/test/java/org/jbpm/services/cdi/test/humantaskservice/CustomHumanTaskServiceProducer.java b/jbpm-services/jbpm-services-cdi/src/test/java/org/jbpm/services/cdi/test/humantaskservice/CustomHumanTaskServiceProducer.java
index 6957642cb2..d8df8aba85 100644
--- a/jbpm-services/jbpm-services-cdi/src/test/java/org/jbpm/services/cdi/test/humantaskservice/CustomHumanTaskServiceProducer.java
+++ b/jbpm-services/jbpm-services-cdi/src/test/java/org/jbpm/services/cdi/test/humantaskservice/CustomHumanTaskServiceProducer.java
@@ -15,45 +15,34 @@
*/
package org.jbpm.services.cdi.test.humantaskservice;
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import javax.enterprise.inject.Alternative;
import javax.enterprise.inject.Produces;
-import javax.inject.Qualifier;
import org.drools.core.impl.EnvironmentFactory;
import org.drools.persistence.jta.JtaTransactionManager;
import org.jbpm.services.cdi.producer.HumanTaskServiceProducer;
import org.jbpm.services.task.HumanTaskConfigurator;
import org.jbpm.services.task.impl.command.CommandBasedTaskService;
-import org.jbpm.services.task.persistence.JPATaskPersistenceContextManager;
import org.kie.api.runtime.Environment;
import org.kie.api.runtime.EnvironmentName;
+import org.mockito.Mockito;
+import org.mockito.invocation.InvocationOnMock;
-/**
- *
- *
- */
public class CustomHumanTaskServiceProducer extends HumanTaskServiceProducer {
@Produces
@CustomHumanTaskService
@Override
public CommandBasedTaskService produceTaskService() {
- return super.produceTaskService();
+ CommandBasedTaskService taskServiceMock = Mockito.mock(CommandBasedTaskService.class);
+ Mockito.when(taskServiceMock.execute(Mockito.any())).thenAnswer((InvocationOnMock invocation) -> {
+ throw new CustomTaskServiceInUse();
+ });
+ return taskServiceMock;
}
@Override
protected void configureHumanTaskConfigurator(HumanTaskConfigurator configurator) {
Environment environment = EnvironmentFactory.newEnvironment();
- environment.set(EnvironmentName.TASK_PERSISTENCE_CONTEXT_MANAGER, new CustomTaskPersistenceContextManager());
environment.set(EnvironmentName.TRANSACTION_MANAGER, new CustomTransactionManager());
super.configureHumanTaskConfigurator(configurator.environment(environment));
}
@@ -65,21 +54,10 @@ public CustomTransactionManager() {
}
- public static class CustomTaskPersistenceContextManager extends JPATaskPersistenceContextManager {
- public CustomTaskPersistenceContextManager() {
- super(EnvironmentFactory.newEnvironment());
- }
-
- @Override
- public void beginCommandScopedEntityManager() {
- throw new CustomTaskPersistenceContextManagerInUse();
- }
- }
-
/**
- * Exception throw to show the CustomTaskPersistenceContextManager is in use.
+ * Exception throw to show the custom service task is in use.
*/
@SuppressWarnings("serial")
- public static class CustomTaskPersistenceContextManagerInUse extends RuntimeException {}
+ public static class CustomTaskServiceInUse extends RuntimeException {}
}
diff --git a/jbpm-services/jbpm-services-cdi/src/test/java/org/jbpm/services/cdi/test/humantaskservice/CustomHumanTaskServiceTest.java b/jbpm-services/jbpm-services-cdi/src/test/java/org/jbpm/services/cdi/test/humantaskservice/CustomHumanTaskServiceTest.java
index 73a7d83fb4..bdc8a56446 100644
--- a/jbpm-services/jbpm-services-cdi/src/test/java/org/jbpm/services/cdi/test/humantaskservice/CustomHumanTaskServiceTest.java
+++ b/jbpm-services/jbpm-services-cdi/src/test/java/org/jbpm/services/cdi/test/humantaskservice/CustomHumanTaskServiceTest.java
@@ -23,7 +23,7 @@
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jbpm.kie.test.util.AbstractKieServicesBaseTest;
-import org.jbpm.services.cdi.test.humantaskservice.CustomHumanTaskServiceProducer.CustomTaskPersistenceContextManagerInUse;
+import org.jbpm.services.cdi.test.humantaskservice.CustomHumanTaskServiceProducer.CustomTaskServiceInUse;
import org.jbpm.services.task.commands.TaskCommand;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -147,13 +147,12 @@ public void testDefaultTaskService() throws Exception {
}
/**
- * The CustomHumanTaskService is configured with a TaskPersistenceContextManager
- * implementation that throws an exception to prove that the custom environment
- * is in use.
+ * The CustomHumanTaskService is configured as a mock which throws an exception
+ * when the the execute() method is called.
*
* @throws Exception
*/
- @Test(expected=CustomTaskPersistenceContextManagerInUse.class)
+ @Test(expected=CustomTaskServiceInUse.class)
public void testCustomTaskService() throws Exception {
customTaskService.execute(new TestCommand());
}