On Wed, 2003-11-19 at 11:35, robert burrell donkin wrote:
> hi simon
> 
> i've committed both patches.
> 
> would you be willing to knock up a test case for the second?

You're keeping me honest here :-)

Test case attached.


Index: org/apache/commons/digester/plugins/TestInline.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons/digester/src/test/org/apache/commons/digester/plugins/TestInline.java,v
retrieving revision 1.3
diff -u -r1.3 TestInline.java
--- org/apache/commons/digester/plugins/TestInline.java	9 Oct 2003 21:09:49 -0000	1.3
+++ org/apache/commons/digester/plugins/TestInline.java	19 Nov 2003 03:18:22 -0000
@@ -142,4 +142,51 @@
         assertEquals("L1", label2.getId());
         assertEquals("2", label2.getLabel());
     }
+    
+    public void testLeadingSlash() throws Exception {
+        // Tests that PluginRules handles patterns with a leading slash.
+        // 
+        // This test doesn't really belong in this class. If a separate test 
+        // case class is created for PluginRules, then this method should be
+        // moved there.
+
+        Digester digester = new Digester();
+        PluginRules rc = new PluginRules();
+        digester.setRules(rc);
+        
+        PluginCreateRule pcr = new PluginCreateRule(Widget.class);
+        digester.addRule("/root/widget", pcr);
+        digester.addSetNext("/root/widget", "addChild");
+
+        Container root = new Container();
+        digester.push(root);
+        
+        try {
+            digester.parse(
+                TestAll.getInputStream(this, "test1.xml"));
+        }
+        catch(Exception e) {
+            throw e;
+        }
+        
+        Object child;
+        List children = root.getChildren();
+        assertTrue(children != null);
+        assertEquals(2, children.size());
+        
+        child = children.get(0);
+        assertTrue(child != null);
+        assertEquals(TextLabel.class, child.getClass());
+        TextLabel label1 = (TextLabel) child;
+        assertEquals("anonymous", label1.getId());
+        assertEquals("1", label1.getLabel());
+        
+        child = children.get(1);
+        assertTrue(child != null);
+        assertEquals(TextLabel.class, child.getClass());
+        TextLabel label2 = (TextLabel) child;
+        assertEquals("L1", label2.getId());
+        assertEquals("2", label2.getLabel());
+    }
+    
 }

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to