You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by rd...@apache.org on 2003/11/19 23:17:17 UTC

cvs commit: jakarta-commons/digester/src/test/org/apache/commons/digester/plugins TestInline.java

rdonkin     2003/11/19 14:17:17

  Modified:    digester/src/test/org/apache/commons/digester/plugins
                        TestInline.java
  Log:
  Test case for missing slash in plugin patterns. Submitted by Simon Kitching.
  
  Revision  Changes    Path
  1.4       +50 -3     jakarta-commons/digester/src/test/org/apache/commons/digester/plugins/TestInline.java
  
  Index: TestInline.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/digester/src/test/org/apache/commons/digester/plugins/TestInline.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestInline.java	9 Oct 2003 21:09:49 -0000	1.3
  +++ TestInline.java	19 Nov 2003 22:17:17 -0000	1.4
  @@ -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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org