commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@apache.org
Subject cvs commit: jakarta-commons/digester/src/test/org/apache/commons/digester Address.java RuleTestCase.java
Date Mon, 14 Jan 2002 02:12:23 GMT
craigmcc    02/01/13 18:12:23

  Modified:    digester/src/test/org/apache/commons/digester Address.java
                        RuleTestCase.java
  Log:
  Add tests for SetTopRule.
  
  Submitted by:	Janek Bogucki <janekdb@yahoo.co.uk>
  
  Revision  Changes    Path
  1.3       +7 -3      jakarta-commons/digester/src/test/org/apache/commons/digester/Address.java
  
  Index: Address.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/digester/src/test/org/apache/commons/digester/Address.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Address.java	9 Jan 2002 20:22:50 -0000	1.2
  +++ Address.java	14 Jan 2002 02:12:23 -0000	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/digester/src/test/org/apache/commons/digester/Address.java,v
1.2 2002/01/09 20:22:50 sanders Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/01/09 20:22:50 $
  + * $Header: /home/cvs/jakarta-commons/digester/src/test/org/apache/commons/digester/Address.java,v
1.3 2002/01/14 02:12:23 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/01/14 02:12:23 $
    *
    * ====================================================================
    *
  @@ -119,6 +119,10 @@
       }
       public void setZipCode(String zipCode) {
           this.zipCode = zipCode;
  +    }
  +
  +    public void setEmployee(Employee employee) {
  +        employee.addAddress(this);
       }
   
       public String toString() {
  
  
  
  1.8       +66 -4     jakarta-commons/digester/src/test/org/apache/commons/digester/RuleTestCase.java
  
  Index: RuleTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/digester/src/test/org/apache/commons/digester/RuleTestCase.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- RuleTestCase.java	9 Jan 2002 20:22:50 -0000	1.7
  +++ RuleTestCase.java	14 Jan 2002 02:12:23 -0000	1.8
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/digester/src/test/org/apache/commons/digester/RuleTestCase.java,v
1.7 2002/01/09 20:22:50 sanders Exp $
  - * $Revision: 1.7 $
  - * $Date: 2002/01/09 20:22:50 $
  + * $Header: /home/cvs/jakarta-commons/digester/src/test/org/apache/commons/digester/RuleTestCase.java,v
1.8 2002/01/14 02:12:23 craigmcc Exp $
  + * $Revision: 1.8 $
  + * $Date: 2002/01/14 02:12:23 $
    *
    * ====================================================================
    *
  @@ -75,7 +75,8 @@
    * XML documents to exercise the built-in rules.</p>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.7 $ $Date: 2002/01/09 20:22:50 $
  + * @author Janek Bogucki
  + * @version $Revision: 1.8 $ $Date: 2002/01/14 02:12:23 $
    */
   
   public class RuleTestCase extends TestCase {
  @@ -438,6 +439,67 @@
                      employee.getAddress("home"));
           assertNull("Can not retrieve office address",
                      employee.getAddress("office"));
  +
  +    }
  +
  +
  +    /**
  +     * Test the two argument version of the SetTopRule rule. This test is
  +     * based on testObjectCreate3 and should result in the same tree of
  +     * objects.  Instead of using the SetNextRule rule which results in
  +     * a method invocation on the (top-1) (parent) object with the top
  +     * object (child) as an argument, this test uses the SetTopRule rule
  +     * which results in a method invocation on the top object (child)
  +     * with the top-1 (parent) object as an argument.  The three argument
  +     * form is tested in <code>testSetTopRule2</code>.
  +     */
  +    public void testSetTopRule1() {
  +
  +        // Configure the digester as required
  +        digester.addObjectCreate("employee",
  +                                 "org.apache.commons.digester.Employee");
  +        digester.addSetProperties("employee");
  +        digester.addObjectCreate("employee/address",
  +                                 "org.apache.commons.digester.Address");
  +        digester.addSetProperties("employee/address");
  +        digester.addSetTop("employee/address", "setEmployee");
  +
  +        // Parse our test input.
  +        Object root = null;
  +        try {
  +            root = digester.parse(getInputStream("Test1.xml"));
  +        } catch (Exception t) {
  +            fail("Digester threw Exception: " + t);
  +        }
  +        validateObjectCreate3(root);
  +
  +    }
  +
  +
  +    /**
  +     * Same as <code>testSetTopRule1</code> except using the three argument
  +     * form of the SetTopRule rule.
  +     */
  +    public void testSetTopRule2() {
  +
  +        // Configure the digester as required
  +        digester.addObjectCreate("employee",
  +                                 "org.apache.commons.digester.Employee");
  +        digester.addSetProperties("employee");
  +        digester.addObjectCreate("employee/address",
  +                                 "org.apache.commons.digester.Address");
  +        digester.addSetProperties("employee/address");
  +        digester.addSetTop("employee/address", "setEmployee",
  +                           "org.apache.commons.digester.Employee");
  +
  +        // Parse our test input.
  +        Object root = null;
  +        try {
  +            root = digester.parse(getInputStream("Test1.xml"));
  +        } catch (Exception t) {
  +            fail("Digester threw Exception: " + t);
  +        }
  +        validateObjectCreate3(root);
   
       }
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message