AnsweredAssumed Answered

activiti test in Jersey (REST) test container

Question asked by hazel8 on Jul 10, 2011
Hi
I use Jersey-Testframework to simulate Rest-Webservices in activiti unit test.
The webservice (Jersey-REST) is called via RestClient by a activiti-Delegate (MedFolioProxy).
In the first version, where the RestClient (MFRestClient) was in the same project, everythin worked perfect.
After moving the RestClient to the service-project and importing this client in a .jar-file, I got the error message below.
Running the workflow in normal environment (activiti on Tomcat) also works fine.

Can somebody help me out?

Many thanks in advance
Hansueli

Activiti-Delegate invoking REST-Client
————————————
public class MedFolioProxy implements JavaDelegate  {   
   private MFRestClient medfolioClient = new MFRestClient();
   
   @Override
   public void execute(DelegateExecution execution) throws Exception {
      String fallNr = (String) execution.getVariable("fallNummer");
       Integer anzMFItems = medfolioClient.getAnzLeistungen(fallNr);
       execution.setVariable("medFolioNKgs", anzMFItems);
       System.out.println("MFProxy - medFolioNKgs: " + anzMFItems);
   }
}

Testclass
———
import static org.junit.Assert.*;

import java.util.HashMap;
import java.util.Map;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.activiti.engine.task.TaskQuery;
import org.activiti.engine.test.ActivitiRule;
import org.activiti.engine.test.Deployment;
import org.junit.Rule;
import org.junit.Test;


import com.sun.jersey.test.framework.JerseyTest;
import com.sun.jersey.test.framework.WebAppDescriptor;

public class ActivitiJerseyStubTest extends JerseyTest{

    private static final int JERSEY_TEST_PORT = 12780;
    public ActivitiJerseyStubTest() throws Exception {

       super(new WebAppDescriptor.Builder("ch.triemli.proc.hflow.srvcstub")
           .contextPath("hFlow-provider-mf")
           .servletPath("/rest/mf")
           .build());
   }

    @Override
    protected int getPort(int defaultPort) {
        return JERSEY_TEST_PORT;
    }
 
   @Rule
   public ActivitiRule activitiRule = new ActivitiRule();

      @Test
      @Deployment(resources="ch/triemli/proc/hflow/bpmn/Fall_Loeschen.bpmn20.xml")
      public void testStartProcessPatAdmin() {
         RuntimeService runtimeService = activitiRule.getRuntimeService();
         TaskService taskService = activitiRule.getTaskService();
         Map<String, Object> variableMap = new HashMap<String, Object>();
         
         variableMap.put("fallNummer", "1000000");      
         variableMap.put("zLabNOrders", "0");
         variableMap.put("hLabNOrders", "0");

         ProcessInstance pi = runtimeService.startProcessInstanceByKey("Fall_Loeschen", variableMap);
         assertNotNull(pi.getId());
         TaskQuery taskQuery = taskService.createTaskQuery();
         Task verifyCreditTask = taskQuery.singleResult();
         assertEquals("User Task Pat Admin", verifyCreditTask.getName());
      }
}




Error Message:
————–
10.07.2011 11:55:53 com.sun.jersey.test.framework.JerseyTest getDefaultTestContainerFactory
WARNUNG: Found multiple TestContainerFactory implementations, using com.sun.jersey.test.framework.spi.container.grizzly.web.GrizzlyWebTestContainerFactory
10.07.2011 11:55:53 com.sun.jersey.test.framework.spi.container.grizzly.web.GrizzlyWebTestContainerFactory$GrizzlyWebTestContainer <init>
INFO: Creating Grizzly Web Container configured at the base URI http://localhost:12780/hFlow-provider-mf/rest/mf
10.07.2011 11:55:53 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [activiti.cfg.xml]
10.07.2011 11:55:55 org.activiti.engine.impl.db.DbSqlSession executeSchemaResource
INFO: performing create on engine with resource org/activiti/db/create/activiti.h2.create.engine.sql
10.07.2011 11:55:55 org.activiti.engine.impl.db.DbSqlSession executeSchemaResource
INFO: performing create on history with resource org/activiti/db/create/activiti.h2.create.history.sql
10.07.2011 11:55:55 org.activiti.engine.impl.db.DbSqlSession executeSchemaResource
INFO: performing create on identity with resource org/activiti/db/create/activiti.h2.create.identity.sql
10.07.2011 11:55:55 org.activiti.engine.impl.ProcessEngineImpl <init>
INFO: ProcessEngine default created
10.07.2011 11:55:55 org.activiti.engine.impl.bpmn.deployer.BpmnDeployer deploy
INFO: Processing resource ch/triemli/proc/hflow/bpmn/Fall_Loeschen.bpmn20.xml
10.07.2011 11:55:55 org.activiti.engine.impl.bpmn.parser.BpmnParse parseDefinitionsAttributes
INFO: XMLSchema currently not supported as typeLanguage
10.07.2011 11:55:55 org.activiti.engine.impl.bpmn.parser.BpmnParse parseDefinitionsAttributes
INFO: XPath currently not supported as expressionLanguage
10.07.2011 11:55:56 com.sun.jersey.test.framework.spi.container.grizzly.web.GrizzlyWebTestContainerFactory$GrizzlyWebTestContainer start
INFO: Starting the Grizzly Web Container…
10.07.2011 11:55:56 com.sun.grizzly.Controller logVersion
INFO: Starting Grizzly Framework 1.9.18-i - Sun Jul 10 11:55:56 CEST 2011
baseUri: http://localhost:12780
contextPath: /hflow-provider-mf
10.07.2011 11:55:57 org.activiti.engine.impl.interceptor.CommandContext close
SCHWERWIEGEND: Error while closing command context
javax.ws.rs.WebApplicationException
   at ch.triemli.comp.provsrvc.mf.client.MFRestClient.getAnzLeistungen(Unknown Source)
   at ch.triemli.proc.hflow.tasksrvc.MedFolioProxy.execute(MedFolioProxy.java:19)
   at org.activiti.engine.impl.bpmn.behavior.ServiceTaskJavaDelegateActivityBehavior.execute(ServiceTaskJavaDelegateActivityBehavior.java:47)
   at org.activiti.engine.impl.bpmn.behavior.ServiceTaskJavaDelegateActivityBehavior.execute(ServiceTaskJavaDelegateActivityBehavior.java:38)
   at org.activiti.engine.impl.bpmn.helper.ClassDelegate.execute(ClassDelegate.java:99)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:40)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:63)
   at org.activiti.engine.impl.runtime.ExecutionEntity.performOperation(ExecutionEntity.java:496)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerStart.eventNotificationsCompleted(AtomicOperationTransitionNotifyListenerStart.java:48)
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:52)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:63)
   at org.activiti.engine.impl.runtime.ExecutionEntity.performOperation(ExecutionEntity.java:496)
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:45)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:63)
   at org.activiti.engine.impl.runtime.ExecutionEntity.performOperation(ExecutionEntity.java:496)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionCreateScope.execute(AtomicOperationTransitionCreateScope.java:44)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:63)
   at org.activiti.engine.impl.runtime.ExecutionEntity.performOperation(ExecutionEntity.java:496)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerTake.execute(AtomicOperationTransitionNotifyListenerTake.java:61)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:63)
   at org.activiti.engine.impl.runtime.ExecutionEntity.performOperation(ExecutionEntity.java:496)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionDestroyScope.execute(AtomicOperationTransitionDestroyScope.java:111)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:63)
   at org.activiti.engine.impl.runtime.ExecutionEntity.performOperation(ExecutionEntity.java:496)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerEnd.eventNotificationsCompleted(AtomicOperationTransitionNotifyListenerEnd.java:36)
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:52)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:63)
   at org.activiti.engine.impl.runtime.ExecutionEntity.performOperation(ExecutionEntity.java:496)
   at org.activiti.engine.impl.runtime.ExecutionEntity.take(ExecutionEntity.java:341)
   at org.activiti.engine.impl.pvm.runtime.OutgoingExecution.take(OutgoingExecution.java:38)
   at org.activiti.engine.impl.runtime.ExecutionEntity.takeAll(ExecutionEntity.java:473)
   at org.activiti.engine.impl.bpmn.behavior.ParallelGatewayActivityBehavior.execute(ParallelGatewayActivityBehavior.java:70)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:40)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:63)
   at org.activiti.engine.impl.runtime.ExecutionEntity.performOperation(ExecutionEntity.java:496)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerStart.eventNotificationsCompleted(AtomicOperationTransitionNotifyListenerStart.java:48)
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:52)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:63)
   at org.activiti.engine.impl.runtime.ExecutionEntity.performOperation(ExecutionEntity.java:496)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionCreateScope.execute(AtomicOperationTransitionCreateScope.java:44)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:63)
   at org.activiti.engine.impl.runtime.ExecutionEntity.performOperation(ExecutionEntity.java:496)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerTake.execute(AtomicOperationTransitionNotifyListenerTake.java:61)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:63)
   at org.activiti.engine.impl.runtime.ExecutionEntity.performOperation(ExecutionEntity.java:496)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionDestroyScope.execute(AtomicOperationTransitionDestroyScope.java:111)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:63)
   at org.activiti.engine.impl.runtime.ExecutionEntity.performOperation(ExecutionEntity.java:496)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerEnd.eventNotificationsCompleted(AtomicOperationTransitionNotifyListenerEnd.java:36)
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:52)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:63)
   at org.activiti.engine.impl.runtime.ExecutionEntity.performOperation(ExecutionEntity.java:496)
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:45)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:63)
   at org.activiti.engine.impl.runtime.ExecutionEntity.performOperation(ExecutionEntity.java:496)
   at org.activiti.engine.impl.runtime.ExecutionEntity.take(ExecutionEntity.java:341)
   at org.activiti.engine.impl.bpmn.behavior.BpmnActivityBehavior.performOutgoingBehavior(BpmnActivityBehavior.java:92)
   at org.activiti.engine.impl.bpmn.behavior.BpmnActivityBehavior.performDefaultOutgoingBehavior(BpmnActivityBehavior.java:49)
   at org.activiti.engine.impl.bpmn.behavior.FlowNodeActivityBehavior.leave(FlowNodeActivityBehavior.java:44)
   at org.activiti.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior.leave(AbstractBpmnActivityBehavior.java:37)
   at org.activiti.engine.impl.bpmn.behavior.ScriptTaskActivityBehavior.execute(ScriptTaskActivityBehavior.java:49)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:40)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:63)
   at org.activiti.engine.impl.runtime.ExecutionEntity.performOperation(ExecutionEntity.java:496)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerStart.eventNotificationsCompleted(AtomicOperationTransitionNotifyListenerStart.java:48)
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:52)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:63)
   at org.activiti.engine.impl.runtime.ExecutionEntity.performOperation(ExecutionEntity.java:496)
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:45)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:63)
   at org.activiti.engine.impl.runtime.ExecutionEntity.performOperation(ExecutionEntity.java:496)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionCreateScope.execute(AtomicOperationTransitionCreateScope.java:44)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:63)
   at org.activiti.engine.impl.runtime.ExecutionEntity.performOperation(ExecutionEntity.java:496)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerTake.execute(AtomicOperationTransitionNotifyListenerTake.java:61)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:63)
   at org.activiti.engine.impl.runtime.ExecutionEntity.performOperation(ExecutionEntity.java:496)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionDestroyScope.execute(AtomicOperationTransitionDestroyScope.java:111)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:63)
   at org.activiti.engine.impl.runtime.ExecutionEntity.performOperation(ExecutionEntity.java:496)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerEnd.eventNotificationsCompleted(AtomicOperationTransitionNotifyListenerEnd.java:36)
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:52)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:63)
   at org.activiti.engine.impl.runtime.ExecutionEntity.performOperation(ExecutionEntity.java:496)
   at org.activiti.engine.impl.runtime.ExecutionEntity.take(ExecutionEntity.java:341)
   at org.activiti.engine.impl.bpmn.behavior.BpmnActivityBehavior.performOutgoingBehavior(BpmnActivityBehavior.java:92)
   at org.activiti.engine.impl.bpmn.behavior.BpmnActivityBehavior.performDefaultOutgoingBehavior(BpmnActivityBehavior.java:49)
   at org.activiti.engine.impl.bpmn.behavior.FlowNodeActivityBehavior.leave(FlowNodeActivityBehavior.java:44)
   at org.activiti.engine.impl.bpmn.behavior.FlowNodeActivityBehavior.execute(FlowNodeActivityBehavior.java:36)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:40)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:63)
   at org.activiti.engine.impl.runtime.ExecutionEntity.performOperation(ExecutionEntity.java:496)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationProcessStartInitial.eventNotificationsCompleted(AtomicOperationProcessStartInitial.java:44)
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:52)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:63)
   at org.activiti.engine.impl.runtime.ExecutionEntity.performOperation(ExecutionEntity.java:496)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationProcessStart.eventNotificationsCompleted(AtomicOperationProcessStart.java:44)
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:52)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:63)
   at org.activiti.engine.impl.runtime.ExecutionEntity.performOperation(ExecutionEntity.java:496)
   at org.activiti.engine.impl.runtime.ExecutionEntity.start(ExecutionEntity.java:289)
   at org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:66)
   at org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:29)
   at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:42)
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
   at org.activiti.engine.impl.RuntimeServiceImpl.startProcessInstanceByKey(RuntimeServiceImpl.java:49)
   at ch.triemli.proc.hflow.test.ActivitiJerseyStubTest.testStartProcessPatAdmin(ActivitiJerseyStubTest.java:73)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
   at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
   at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
   at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
   at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
   at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
   at org.junit.rules.TestWatchman$1.evaluate(TestWatchman.java:48)
   at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
   at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
   at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
   at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
   at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
   at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
   at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
   at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
   at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
   at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
10.07.2011 11:55:57 com.sun.jersey.test.framework.spi.container.grizzly.web.GrizzlyWebTestContainerFactory$GrizzlyWebTestContainer stop
INFO: Stopping the Grizzly Web Container…

Outcomes