You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by js...@apache.org on 2002/11/12 09:39:50 UTC

cvs commit: jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml ElementTag.java

jstrachan    2002/11/12 00:39:50

  Modified:    jelly    project.xml
               jelly/src/java/org/apache/commons/jelly/tags/xml
                        ElementTag.java
  Added:       jelly/src/test/org/apache/commons/jelly/xml TestJelly.java
                        suite.jelly
  Log:
  Added a JUnit test case to demonstrate the bug spotted by J. Matthew Pryor, then added a fix for the bug.
  
  The <x:attribute> when used inside an <x:element> was not working correctly. Now we've a JellyUnit test case to ensure this works correctly.
  
  Revision  Changes    Path
  1.88      +8 -0      jakarta-commons-sandbox/jelly/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/project.xml,v
  retrieving revision 1.87
  retrieving revision 1.88
  diff -u -r1.87 -r1.88
  --- project.xml	12 Nov 2002 08:13:09 -0000	1.87
  +++ project.xml	12 Nov 2002 08:39:50 -0000	1.88
  @@ -191,6 +191,14 @@
         	<role>Developer</role>
         </roles>
       </contributor>    
  +    <contributor>
  +      <name>J. Matthew Pryor</name>
  +      <email>matthew_pryor@versata.com</email>
  +      <organization></organization>
  +      <roles>
  +      	<role>Developer</role>
  +      </roles>
  +    </contributor>        
     </contributors>
   	
     <dependencies>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/xml/TestJelly.java
  
  Index: TestJelly.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/JellyTestSuite.java,v 1.8 2002/07/06 13:53:39 dion Exp $
   * $Revision: 1.8 $
   * $Date: 2002/07/06 13:53:39 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 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 acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "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 apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * 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/>.
   * 
   * $Id: JellyTestSuite.java,v 1.8 2002/07/06 13:53:39 dion Exp $
   */
  package org.apache.commons.jelly.xml;
  
  import junit.framework.TestSuite;
  import junit.textui.TestRunner;
  
  import org.apache.commons.jelly.tags.junit.JellyTestSuite;
  
  /** 
   * A helper class to run jelly test cases as part of Ant's JUnit tests
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.8 $
   */
  public class TestJelly extends JellyTestSuite {
  
      public static void main( String[] args ) throws Exception {
          TestRunner.run( suite() );
      }
      
      public static TestSuite suite() throws Exception {
          return createTestSuite(TestJelly.class, "suite.jelly");        
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/xml/suite.jelly
  
  Index: suite.jelly
  ===================================================================
  <?xml version="1.0"?>
  <test:suite 
  	xmlns:j="jelly:core" 
  	xmlns:x="jelly:xml" 
  	xmlns:test="jelly:junit" 
  	xmlns:log="jelly:log">
  
    <test:case name="testElementAndAttribute">
    	
    	<x:parse var="doc">
    		<x:element name="foo">
    			<x:attribute name="x">1234</x:attribute>
    		</x:element>
    	</x:parse>
  	
  		<test:assert xpath="$doc/foo"/>
  		<test:assert xpath="$doc/foo[@x='1234']"/>
  		<test:assert xpath="count($doc/bar) = 0"/>
  		
    </test:case>
  </test:suite>
  
  
  
  1.4       +10 -2     jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/ElementTag.java
  
  Index: ElementTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/ElementTag.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ElementTag.java	30 Oct 2002 19:16:23 -0000	1.3
  +++ ElementTag.java	12 Nov 2002 08:39:50 -0000	1.4
  @@ -100,7 +100,7 @@
           }
           // treat null values as no attribute 
           if (value != null) {
  -            attributes.addAttribute("", name, name, "CDATA", value.toString());
  +            attributes.addAttribute("", name, name, "CDATA", value);
           }
       }
   
  @@ -115,9 +115,17 @@
           else {
               localName = name;
           }
  +        
  +        /** 
  +         * @todo we should buffer up any SAX events and replay then
  +         * inside the startElement/endElement block
         */
  +        invokeBody(output);
           output.startElement(namespace, localName, name, attributes);
  -        invokeBody(  output);
  +        
  +        /** @todo we should replay the cached SAX events (if any) here */
  +        
           output.endElement(namespace, localName, name);
  +        attributes.clear();
       }
       
       // Properties
  
  
  

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