craigmcc    01/09/03 13:18:10

  Modified:    workflow/src/test/org/apache/commons/workflow/core
                        CoreExecuteTestCase.java
  Log:
  Make sure we can get and set a bean (into a new scope), and not just
  properties.
  
  Revision  Changes    Path
  1.8       +84 -4     
jakarta-commons-sandbox/workflow/src/test/org/apache/commons/workflow/core/CoreExecuteTestCase.java
  
  Index: CoreExecuteTestCase.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/workflow/src/test/org/apache/commons/workflow/core/CoreExecuteTestCase.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- CoreExecuteTestCase.java  2001/09/03 20:09:27     1.7
  +++ CoreExecuteTestCase.java  2001/09/03 20:18:10     1.8
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-commons-sandbox/workflow/src/test/org/apache/commons/workflow/core/CoreExecuteTestCase.java,v
 1.7 2001/09/03 20:09:27 craigmcc Exp $
  - * $Revision: 1.7 $
  - * $Date: 2001/09/03 20:09:27 $
  + * $Header: 
/home/cvs/jakarta-commons-sandbox/workflow/src/test/org/apache/commons/workflow/core/CoreExecuteTestCase.java,v
 1.8 2001/09/03 20:18:10 craigmcc Exp $
  + * $Revision: 1.8 $
  + * $Date: 2001/09/03 20:18:10 $
    *
    * ====================================================================
    *
  @@ -86,7 +86,7 @@
    * implementations.</p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.7 $ $Date: 2001/09/03 20:09:27 $
  + * @version $Revision: 1.8 $ $Date: 2001/09/03 20:18:10 $
    */
   
   public class CoreExecuteTestCase extends TestCase
  @@ -775,6 +775,86 @@
                            (String) context.pop());
               assertTrue("Stack is now empty",
                          context.isEmpty());
  +        } catch (StepException e) {
  +            e.printStackTrace(System.out);
  +            if (e.getCause() != null) {
  +                System.out.println("ROOT CAUSE");
  +                e.getCause().printStackTrace(System.out);
  +            }
  +            fail("Threw StepException " + e);
  +        } catch (Throwable e) {
  +            e.printStackTrace();
  +            fail("Threw exception " + e);
  +        }
  +
  +    }
  +
  +
  +    /**
  +     * Test getting and setting beans through XPath expressions.
  +     */
  +    public void testXpathBean() {
  +
  +        // Configure an extra scope and put one object in each scope
  +        Scope extra = new BaseScope();
  +        context.addScope(Context.LOCAL_SCOPE + 1, "extra", extra);
  +
  +        // Push a bean onto the evaluation stack
  +        Employee employee = new Employee();
  +        context.push(employee);
  +
  +        // Configure the steps in this activity
  +        activity.addStep(new PutStep("01",
  +                                     new BaseDescriptor("extra/employee")));
  +        activity.addStep(new SuspendStep("02"));
  +        activity.addStep(new GetStep("03",
  +                                     new BaseDescriptor("extra/employee")));
  +        activity.addStep(new SuspendStep("04"));
  +
  +        // Execute the activity and validate results #1
  +        try {
  +            context.execute();
  +            assertEquals("Trail contents 1",
  +                         "beforeActivity()/" +
  +                         "beforeStep(01)/afterStep(01)/" +
  +                         "beforeStep(02)/afterStep(02)/" +
  +                         "afterActivity()/",
  +                         trail.toString());
  +            assertTrue("Context is suspended",
  +                       context.getSuspend());
  +            assertTrue("Stack is empty",
  +                       context.isEmpty());
  +        } catch (StepException e) {
  +            e.printStackTrace(System.out);
  +            if (e.getCause() != null) {
  +                System.out.println("ROOT CAUSE");
  +                e.getCause().printStackTrace(System.out);
  +            }
  +            fail("Threw StepException " + e);
  +        } catch (Throwable e) {
  +            e.printStackTrace();
  +            fail("Threw exception " + e);
  +        }
  +
  +        // Execute the activity and validate results #2
  +        try {
  +            context.execute();
  +            assertEquals("Trail contents 2",
  +                         "beforeActivity()/" +
  +                         "beforeStep(03)/afterStep(03)/" +
  +                         "beforeStep(04)/afterStep(04)/" +
  +                         "afterActivity()/",
  +                         trail.toString());
  +            assertTrue("Context is suspended",
  +                       context.getSuspend());
  +            assertTrue("Stack is not empty",
  +                       !context.isEmpty());
  +            Object top = context.peek();
  +            assertNotNull("Top object is not null", top);
  +            assertTrue("Top object is an Employee",
  +                       top instanceof Employee);
  +            assertEquals("Top object is our employee",
  +                         employee, (Employee) top);
           } catch (StepException e) {
               e.printStackTrace(System.out);
               if (e.getCause() != null) {
  
  
  

Reply via email to