1 Reply Latest reply on Aug 31, 2011 10:35 AM by Tihomir Surdilovic

    jBPM junit test error

    ssampath Newbie

      Hi,

       

      I am getting started with jBPM and am following the link http://docs.jboss.org/tools/2.0.0.GA/jbpm/en/html/Test_Drive_Proc_Development.html.

       

      I created the junit test file and am trying to test the process.  I am however getting the following error:

       

      [code]

       

      org.jbpm.jpdl.JpdlException: [[ERROR] couldn't parse process definition]

          at org.jbpm.jpdl.xml.JpdlXmlReader.readProcessDefinition(JpdlXmlReader.java:172)

          at org.jbpm.graph.def.ProcessDefinition.parseXmlInputStream(ProcessDefinition.java:180)

          at org.jbpm.graph.def.ProcessDefinition.parseXmlResource(ProcessDefinition.java:161)

          at com.jbay.HiTest.testProcess(HiTest.java:14)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

          at java.lang.reflect.Method.invoke(Unknown Source)

          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)

       

      [/code]

       

      Here is my test case code:

       

      [code]

       

      package com.jbay;

       

      import junit.framework.TestCase;

      import org.jbpm.graph.def.ProcessDefinition;

      import org.jbpm.graph.exe.ProcessInstance;

      import org.jbpm.jpdl.xml.JpdlXmlReader;

       

      import junit.framework.TestCase;

       

      public class HiTest extends TestCase {

         

          public void testProcess() throws Exception{

             

              ProcessDefinition definition = ProcessDefinition.parseXmlResource("hi/processdefinition.xml");

              assertNotNull("Definition should not be null", definition);

             

              ProcessInstance instance = new ProcessInstance(definition);

              assertEquals(

                      "Instance is in start state", instance.getRootToken().getNode().getName(), "start");

             

              instance.signal();

              assertEquals(

                      "Instance is in start1 state", instance.getRootToken().getNode().getName(), "start1");

             

              instance.signal();

              assertEquals(

                      "Instance is in end state", instance.getRootToken().getNode().getName(), "end1");

             

              assertTrue("Instance has ended", instance.hasEnded());

             

             

          }

       

      }

       

      [/code]

       

      And my process definition that I created:

       

      [code]

       

      <?xml version="1.0" encoding="UTF-8"?>

       

      <process-definition

        xmlns="urn:jbpm.org:jpdl-3.2"  name="jBay">

         <start-state name="start">

            <transition name="toauction" to="state1"></transition>

         </start-state>

         <state name="state1">

            <transition name="tr1" to="end1"></transition>

         </state>

         <end-state name="end1"></end-state>

      </process-definition>

       

      [/code]

       

      I am not sure what the error means.  I checked the exception code:

       

      [code]

       

      if (Problem.containsProblemsOfLevel(problems, Problem.LEVEL_ERROR)) {

            throw new JpdlException(problems);

          }

         

          if (problems!=null) {

            Iterator iter = problems.iterator();

            while (iter.hasNext()) {

              Problem problem = (Problem) iter.next();

              log.warn("process parse warning: "+problem.getDescription());

            }

          }

       

      [/code]

       

      I am not sure this is helping me. I renamed the states and transitions to include only letters in order to correct the parsing, but it still gave out the same error.  ANy help would be  nice.

       

      Thanks!

      ssampath