1 Reply Latest reply on Mar 3, 2006 2:29 PM by aguizar

    Problem with ActionHandler

    ken1

      Hello,

      i have the following TestCase:

      public void testActionHandler() throws Exception
       {
       ProcessDefinition definition = ProcessDefinition.parseXmlResource("hello.par/processdefinition.xml");
      
       ProcessInstance instance = new ProcessInstance(definition);
       assertNotNull("Greeting should not exist!",instance.getContextInstance().getVariable("greeting"));
      
       instance.signal();
       assertEquals("Exists!",instance.getContextInstance().getVariable("greeting"),"Gruesse vom Handler");
       }


      And this ProcessDefinition:
      <process-definition
       xmlns="urn:jbpm.org:jpdl-3.1" name="jbay">
       <start-state name="start">
       <transition name="to_auction" to="auction">
       <action name="action1" class="com.jbay.HelloActionHandler"></action>
      
       </transition>
       </start-state>
       <state name="auction">
       <transition name="to_end" to="end1">
      
       </transition>
       </state>
       <end-state name="end1"></end-state>
      </process-definition>
      

      The ActionHandler is like that:
       public void execute(ExecutionContext context) throws Exception {
       context.getContextInstance().createVariable("greeting","Gruesse vom Handler");
       }
      


      And the Error by JUnit is this:

      junit.framework.AssertionFailedError: Greeting should not exist!
      at junit.framework.Assert.fail(Assert.java:47)
      at junit.framework.Assert.assertTrue(Assert.java:20)
      at junit.framework.Assert.assertNotNull(Assert.java:220)
      at com.jbay.HelloTest.testActionHandler(HelloTest.java:33)
      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.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

      What is wrong? Can anybody help?
      Thanks and regards



        • 1. Re: Problem with ActionHandler
          aguizar

          Err... shouldn't your test be:

          assertNull("Greeting should not exist!",instance.getContextInstance().getVariable("greeting"));

          You are asserting the opposite of what you intend to assert.