5 Replies Latest reply on Aug 24, 2006 6:07 PM by kukeltje

    Easy One : Creating Testcase Swimlane Assignments

    jerwah

      Ok,

      I apologize in advance. I have been searching around for hours and haven't come up with anything, since this has got to be something easy, I can only conclude that I am being stupid.

      So I am trying to setup a very simple Junit testcase for a process which includes a couple of task nodes assigned to a swimlane.

      I setup things using the eclipse "Process Project" template, which it nicely sets up a hibernate.cfg.xml to pointing to:
      jdbc:hsqldb:mem:.
      (One time use memory db??)

      When I run my testcase I get the DelegationException below which I am quite sure is because it can't find the user I specified in the swimlane

      So the question is, how do I set it up so that the users get added each time I run the JUnit test?

      org.jbpm.graph.def.DelegationException
       at org.jbpm.taskmgmt.exe.TaskMgmtInstance.performAssignment(TaskMgmtInstance.java:208)
       at org.jbpm.taskmgmt.exe.TaskMgmtInstance.getInitializedSwimlaneInstance(TaskMgmtInstance.java:176)
       at org.jbpm.taskmgmt.exe.TaskInstance.assign(TaskInstance.java:192)
       at org.jbpm.taskmgmt.exe.TaskMgmtInstance.createTaskInstance(TaskMgmtInstance.java:148)
       at org.jbpm.graph.node.TaskNode.execute(TaskNode.java:167)
       at org.jbpm.graph.def.Node.enter(Node.java:316)
       at org.jbpm.graph.def.Transition.take(Transition.java:119)
       at org.jbpm.graph.def.Node.leave(Node.java:383)
       at org.jbpm.graph.def.Node.leave(Node.java:358)
       at org.jbpm.graph.node.Fork.execute(Fork.java:134)
       at org.jbpm.graph.def.Node.enter(Node.java:316)
       at org.jbpm.graph.def.Transition.take(Transition.java:119)
       at org.jbpm.graph.def.Node.leave(Node.java:383)
       at org.jbpm.graph.node.StartState.leave(StartState.java:70)
       at org.jbpm.graph.exe.Token.signal(Token.java:174)
       at org.jbpm.graph.exe.Token.signal(Token.java:123)
       at org.jbpm.graph.exe.ProcessInstance.signal(ProcessInstance.java:217)
       at org.kbtoys.jrw.SimpleTest.testProcess(SimpleTest.java:25)
       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:585)
       at junit.framework.TestCase.runTest(TestCase.java:154)
       at junit.framework.TestCase.runBare(TestCase.java:127)
       at junit.framework.TestResult$1.protect(TestResult.java:106)
       at junit.framework.TestResult.runProtected(TestResult.java:124)
       at junit.framework.TestResult.run(TestResult.java:109)
       at junit.framework.TestCase.run(TestCase.java:118)
       at junit.framework.TestSuite.runTest(TestSuite.java:208)
       at junit.framework.TestSuite.run(TestSuite.java:203)
       at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
       at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
       at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
       at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
       at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
       at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
      Caused by: org.jbpm.identity.assignment.ExpressionAssignmentException: couldn't resolve assignment expression 'user(grover)'
       at org.jbpm.identity.assignment.ExpressionAssignmentHandler.assign(ExpressionAssignmentHandler.java:97)
       at org.jbpm.taskmgmt.exe.TaskMgmtInstance.performAssignmentDelegation(TaskMgmtInstance.java:217)
       at org.jbpm.taskmgmt.exe.TaskMgmtInstance.performAssignment(TaskMgmtInstance.java:193)
       ... 35 more
      Caused by: java.lang.RuntimeException: no active JbpmContext for resolving assignment expression'user(grover)'
       at org.jbpm.identity.assignment.ExpressionAssignmentHandler.getExpressionSession(ExpressionAssignmentHandler.java:109)
       at org.jbpm.identity.assignment.ExpressionAssignmentHandler.assign(ExpressionAssignmentHandler.java:69)
       ... 37 more
      
      


      Thanks!
      Jeremy

        • 1. Re: Easy One : Creating Testcase Swimlane Assignments
          kukeltje

          do you have a unit test for this? If so, please post it, and the version of jbpm etc...

          Could be that the identity tables do not exist and that the execption is wrapped. Try with debug on

          • 2. Re: Easy One : Creating Testcase Swimlane Assignments
            jerwah

            Answers:
            Version: bpm 3.1.2

            This is the testcase I am trying to run:

            public void testProcess() throws Exception {
            
            // Extract a process definition from the processdefinition.xml file.
             FileInputStream fis = new FileInputStream("processes/Hello/processdefinition.xml");
             ProcessDefinition MyDef = ProcessDefinition.parseXmlInputStream(fis);
             assertNotNull("Definition should not be null",MyDef);
            
            // Start the Instance
             ProcessInstance MyInstance=new ProcessInstance(MyDef);
            
             assertEquals(
             "Instance is now in the start state",
             MyInstance.getRootToken().getNode().getName(), "start");
             MyInstance.signal();
            
            // Brings us to the FORK so we should now have active children
             assertEquals(
             "Should have Children",
             MyInstance.getRootToken().hasActiveChildren(), true );
             //Dump Children list to out.
            
             System.out.println(MyInstance.getRootToken().getChildren().toString());
            
            // Signal the left hand side
             MyInstance.signal("B1");
            // Signal the right hand side
             MyInstance.signal("S1");
            
             System.out.println("BLAH");
            
            // Should put us back past the join
            // MyInstance.signal();
            // assertEquals(
            // "Instance is now in the end state",
            // MyInstance.getRootToken().getNode().getName(), "end1");
            //
            // assertTrue("Instance is ended", MyInstance.hasEnded());
            
             }
            


            process definition:
            <?xml version="1.0" encoding="UTF-8"?>
            
            <process-definition
             xmlns="urn:jbpm.org:jpdl-3.1" name="Hello">
             <swimlane name="ME">
             <assignment expression="user(Karl Taylor)"></assignment>
             </swimlane>
             <start-state name="start">
            
             <transition name="tr0" to="fork1"></transition>
             </start-state>
             <end-state name="end1"></end-state>
             <fork name="fork1">
             <transition name="tr1" to="BOBBY">
             </transition>
             <transition name="tr2" to="SALLY"></transition>
             </fork>
             <task-node name="BOBBY">
             <task name="task1" blocking="true" swimlane="ME">
             </task>
             <transition name="B1" to="join1"></transition>
             </task-node>
             <task-node name="SALLY">
             <task name="task1" blocking="true" swimlane="ME">
             </task>
             <transition name="S1" to="join1"></transition>
             </task-node>
             <join name="join1">
             <transition name="" to="end1"></transition>
             </join>
            </process-definition>
            


            Debug output
            12:29:14,403 [main] INFO JbpmConfiguration : using jbpm configuration resource 'jbpm.cfg.xml'
            12:29:14,410 [main] DEBUG JbpmConfiguration : loading defaults in jbpm configuration
            12:29:14,683 [main] DEBUG ObjectFactoryImpl : adding object info 'default.jbpm.context'
            12:29:14,686 [main] DEBUG ObjectFactoryImpl : adding object info 'resource.hibernate.cfg.xml'
            12:29:14,688 [main] DEBUG ObjectFactoryImpl : adding object info 'resource.business.calendar'
            12:29:14,690 [main] DEBUG ObjectFactoryImpl : adding object info 'resource.default.modules'
            12:29:14,692 [main] DEBUG ObjectFactoryImpl : adding object info 'resource.converter'
            12:29:14,694 [main] DEBUG ObjectFactoryImpl : adding object info 'resource.action.types'
            12:29:14,697 [main] DEBUG ObjectFactoryImpl : adding object info 'resource.node.types'
            12:29:14,698 [main] DEBUG ObjectFactoryImpl : adding object info 'resource.parsers'
            12:29:14,700 [main] DEBUG ObjectFactoryImpl : adding object info 'resource.varmapping'
            12:29:14,702 [main] DEBUG ObjectFactoryImpl : adding object info 'jbpm.msg.wait.timout'
            12:29:14,704 [main] DEBUG ObjectFactoryImpl : adding object info 'jbpm.byte.block.size'
            12:29:14,706 [main] DEBUG ObjectFactoryImpl : adding object info 'mail.smtp.host'
            12:29:14,710 [main] DEBUG ObjectFactoryImpl : adding object info 'jbpm.task.instance.factory'
            12:29:14,712 [main] DEBUG ObjectFactoryImpl : adding object info 'jbpm.variable.resolver'
            12:29:14,714 [main] DEBUG ObjectFactoryImpl : adding object info 'jbpm.mail.address.resolver'
            12:29:14,715 [main] DEBUG JbpmConfiguration : loading specific configuration...
            12:29:15,012 [main] DEBUG JpdlParser$JpdlEntityResolver : resolving schema reference publicId(null) systemId(http://jbpm.org/jpdl-3.1.xsd)
            12:29:15,014 [main] DEBUG JpdlParser$JpdlEntityResolver : providing input source to local 'jpdl-3.1.xsd' resource
            12:29:15,201 [main] DEBUG NodeTypes : node 'page' will not be available. class 'org.jboss.seam.pageflow.Page' couldn't be loaded
            12:29:15,203 [main] DEBUG NodeTypes : node 'start-page' will not be available. class 'org.jboss.seam.pageflow.Page' couldn't be loaded
            12:29:15,238 [main] DEBUG GraphElement : event 'process-start' on 'ProcessDefinition(Hello)' for 'Token(/)'
            12:29:15,241 [main] DEBUG GraphElement : event 'before-signal' on 'StartState(start)' for 'Token(/)'
            12:29:15,242 [main] DEBUG GraphElement : event 'node-leave' on 'StartState(start)' for 'Token(/)'
            12:29:15,243 [main] DEBUG GraphElement : event 'transition' on 'Transition(tr0)' for 'Token(/)'
            12:29:15,244 [main] DEBUG GraphElement : event 'node-enter' on 'Fork(fork1)' for 'Token(/)'
            12:29:15,247 [main] DEBUG GraphElement : event 'node-leave' on 'Fork(fork1)' for 'Token(/tr1)'
            12:29:15,248 [main] DEBUG GraphElement : event 'transition' on 'Transition(tr1)' for 'Token(/tr1)'
            12:29:15,249 [main] DEBUG GraphElement : event 'node-enter' on 'TaskNode(BOBBY)' for 'Token(/tr1)'
            12:29:15,260 [main] DEBUG GraphElement : event 'task-create' on 'Task(task1)' for 'Token(/tr1)'
            




            • 3. Re: Easy One : Creating Testcase Swimlane Assignments
              kukeltje

              uhhmm.... (thanks for the info btw)

              The error you get in the first post refers to an assignment which is not available in the process in the second post. Besides that, in the login the second post, there is no error. Third thing, there is no assignment taking place in the process. Could you send correct information?

              • 4. Re: Easy One : Creating Testcase Swimlane Assignments
                jerwah

                Many apologies, I had been flailing at it and forgot to back out some changes before re-posting. Anyway, as I had suspected all along, I was being stupid.

                Your comment about no assignment taking place made me go back and look at some other examples and so I changed the process to use :

                 <assignment actor-id='grover'></assignment>
                
                Instead of:
                 <assignment expression="user(grover)"></assignment>
                


                And I now have my test working.

                Thanks for your patience and help, I figured it had to be me :-)

                Jeremy


                • 5. Re: Easy One : Creating Testcase Swimlane Assignments
                  kukeltje

                  hmm... the expression should work as well afaik, but.... I'm not the expert and sometimes (not often, but to often) wrong :-)