rdonkin 2003/10/28 14:31:54 Modified: digester/src/test/org/apache/commons/digester/xmlrules DigesterLoaderTestSuite.java Added: digester/src/test/org/apache/commons/digester/xmlrules IncludeTest.java Log: Test case for the adapted version of the contributed patch. It should ensure that the current behaviour is preserved (allowing rules to be added that begin with a slash) whilst also ensure that the documented behaviour is also allowed. Original patch contributed by Henning P. Schmiedehausen. Revision Changes Path 1.7 +4 -3 jakarta-commons/digester/src/test/org/apache/commons/digester/xmlrules/DigesterLoaderTestSuite.java Index: DigesterLoaderTestSuite.java =================================================================== RCS file: /home/cvs/jakarta-commons/digester/src/test/org/apache/commons/digester/xmlrules/DigesterLoaderTestSuite.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- DigesterLoaderTestSuite.java 23 Oct 2003 20:07:02 -0000 1.6 +++ DigesterLoaderTestSuite.java 28 Oct 2003 22:31:54 -0000 1.7 @@ -88,6 +88,7 @@ suite.addTestSuite(DigesterLoaderTest.class); suite.addTestSuite(DigesterPatternStackTest.class); suite.addTestSuite(DigesterLoaderRulesTest.class); + suite.addTestSuite(IncludeTest.class); return suite; } 1.1 jakarta-commons/digester/src/test/org/apache/commons/digester/xmlrules/IncludeTest.java Index: IncludeTest.java =================================================================== /* * $Header: /home/cvs/jakarta-commons/digester/src/test/org/apache/commons/digester/xmlrules/IncludeTest.java,v 1.1 2003/10/28 22:31:54 rdonkin Exp $ * $Revision: 1.1 $ * $Date: 2003/10/28 22:31:54 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 2001-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgement may appear in the software itself, * if and wherever such third-party acknowledgements normally appear. * * 4. The names "Apache", "The Jakarta Project", "Commons", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache", * "Apache" nor may "Apache" appear in their names without prior * written permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * */ package org.apache.commons.digester.xmlrules; import java.util.ArrayList; import java.io.StringReader; import junit.framework.TestCase; import junit.framework.TestSuite; import org.xml.sax.InputSource; import org.apache.commons.digester.Digester; import org.apache.commons.digester.Rule; /** * Test for the include class functionality */ public class IncludeTest extends TestCase { public static class TestDigesterRuleSource implements DigesterRulesSource { public void getRules(Digester digester) { digester.addRule("bar", new Rule() { public void body(String namespace, String name, String text) { ((ArrayList) this.digester.peek()).add(text); } }); } } public IncludeTest(String testName) { super(testName); } public void testBasicInclude() throws Exception { String rulesXml = "<?xml version='1.0'?>" + "<digester-rules>" + " <pattern value='root/foo'>" + " <include class='org.apache.commons.digester.xmlrules.IncludeTest$TestDigesterRuleSource'/>" + " </pattern>" + "</digester-rules>"; String xml = "<?xml version='1.0' ?><root><foo><bar>short</bar></foo></root>"; ArrayList list = new ArrayList(); Digester digester = DigesterLoader.createDigester(new InputSource(new StringReader(rulesXml))); digester.push(list); digester.parse(new StringReader(xml)); assertEquals("Number of entries", 1, list.size()); assertEquals("Entry value", "short", list.get(0)); } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]