You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Janek Bogucki <ja...@yahoo.co.uk> on 2002/01/14 01:34:34 UTC

[DIGESTER] Two tests cases for SetTopRule

Hi,

I have created two patches for the digester package
which add two test cases for the SetTopRule rule.


The patches apply to the current development version
of the classes:

org.apache.commons.digester.RuleTestCase.java v 1.7 
org.apache.commons.digester.Address.java v 1.1

Can someone review these for me and if they are okay,
commit them. I hope
I have created the patches in the right way and that
my email sender has
not messed them up to much by wrapping the lines. I
can resend from a different account which might be
better if that would help.

Thanks,
Janek

Patch for org.apache.commons.digester.Address.java v
1.1
--------------------------------------------------------


--- Address-old.java-	Sun Jan 13 23:58:10 2002
+++ Address.java	Mon Jan 14 00:00:46 2002
@@ -121,6 +121,10 @@
         this.zipCode = zipCode;
     }
 
+    public void setEmployee ( Employee employee ) {
+        employee.addAddress ( this ) ;
+    }
+
     public String toString() {
         StringBuffer sb = new
StringBuffer("Address[");
         sb.append("street=");


Patch for
org.apache.commons.digester.RuleTestCase.java v 1.7
-------------------------------------------------------------

--- RuleTestCase-old.java-	Sun Jan 13 23:58:47 2002
+++ RuleTestCase.java	Mon Jan 14 00:15:18 2002
@@ -289,6 +289,69 @@
 
 
     /**
+     * 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
of the rule 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);
+
+    }
+
+    
+    /**
      * It should be possible to parse the same input
twice, and get trees
      * of objects that are isomorphic but not be
identical object instances.
      */



__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [DIGESTER] Two tests cases for SetTopRule

Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Mon, 14 Jan 2002, Janek Bogucki wrote:

> Date: Mon, 14 Jan 2002 00:34:34 +0000 (GMT)
> From: Janek Bogucki <ja...@yahoo.co.uk>
> Reply-To: Jakarta Commons Developers List <co...@jakarta.apache.org>
> To: Jakarta Commons Developers List <co...@jakarta.apache.org>
> Subject: [DIGESTER] Two tests cases for SetTopRule
>
> Hi,
>
> I have created two patches for the digester package
> which add two test cases for the SetTopRule rule.
>
>

I've committed these test enhancements ... thanks for the updates!

Craig


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>