stephan     2003/04/29 03:45:03

  Modified:    src/test/org/apache/cocoon/generation
                        FileGeneratorTestCase.java
               src/test/org/apache/cocoon/xml/dom
                        DOMBuilderStreamerTestCase.java
  Added:       src/test/org/apache/cocoon/generation filetest-input1.xml
                        filetest-result1.xml
  Log:
  Try to reproduce BUG 17763, but the current mechanism throws all
  comment away, the bad ones, and also the good ones.
  
  Revision  Changes    Path
  1.4       +34 -16    
cocoon-2.1/src/test/org/apache/cocoon/generation/FileGeneratorTestCase.java
  
  Index: FileGeneratorTestCase.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/test/org/apache/cocoon/generation/FileGeneratorTestCase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- FileGeneratorTestCase.java        16 Apr 2003 10:56:44 -0000      1.3
  +++ FileGeneratorTestCase.java        29 Apr 2003 10:45:03 -0000      1.4
  @@ -55,24 +55,42 @@
   
   import org.apache.avalon.framework.parameters.Parameters;
   
  +import org.apache.cocoon.AbstractCompositeTestCase;
  +
   /**
    *
    * @version CVS $Id$
    */
  -public class FileGeneratorTestCase extends AbstractGeneratorTestCase
  -{
  -  public FileGeneratorTestCase(String name)
  -  {
  -    super(name);
  -  }
  -
  -  public void testFileGenerator() {
  -
  -    String type = "file";
  -    String src = 
"resource://org/apache/cocoon/generation/FileGeneratorTestCase.source.xml";
  -    Parameters parameters = new Parameters();
  -    String result = 
"resource://org/apache/cocoon/generation/FileGeneratorTestCase.source.xml";
  +public class FileGeneratorTestCase extends AbstractCompositeTestCase {
  +
  +    public FileGeneratorTestCase(String name) {
  +        super(name);
  +    }
  +
  +    public void testFileGenerator() {
  +
  +        String type = "file";
  +        String src = 
"resource://org/apache/cocoon/generation/FileGeneratorTestCase.source.xml";
  +        Parameters parameters = new Parameters();
  +        String result = 
"resource://org/apache/cocoon/generation/FileGeneratorTestCase.source.xml";
  +
  +        assertEqual(load(result), generate(type, src, parameters));
  +    }
  +
  +    /*
  +      All comments get lost. The comments within the doctype and _also_ the 
comments 
  +      within the document.
  +
  +    public void testBUG17763() {
  +        String type = "file";
  +        String src = 
"resource://org/apache/cocoon/generation/filetest-input1.xml";
  +        Parameters parameters = new Parameters();
  +        String result = 
"resource://org/apache/cocoon/generation/filetest-result1.xml";
  +
  +        //print(generate(type, src, parameters));
   
  -    assertEqual(load(result), generate(type, src, parameters));
  -  }
  +        //print(load(result));
  +    
  +        //assertEqual(load(result), generate(type, src, parameters));
  +    }*/
   }
  
  
  
  1.1                  
cocoon-2.1/src/test/org/apache/cocoon/generation/filetest-input1.xml
  
  Index: filetest-input1.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <!--
  Skin configuration file. This file contains details of your project, which 
will
  be used to configure the chosen Forrest skin.
  -->
  
  <!DOCTYPE skinconfig [
  
    <!ENTITY % links.att 'name CDATA #REQUIRED'>
    <!ENTITY % link.att 'name CDATA #REQUIRED href CDATA #REQUIRED'>
    <!ELEMENT skinconfig (disable-search?, disable-compliance-links?, 
searchsite-domain?, searchsite-name?,
    project-name, project-url, project-logo, group-name?, group-url?, 
group-logo?,
    host-url?, host-logo?, year?, vendor?, trail?, credits?)*>
    <!ELEMENT credits (credit*)>
    <!ELEMENT credit (name, url, image?, width?, height?)>
    <!-- id uniquely identifies the tool, and role indicates its function -->
    <!ATTLIST credit id   CDATA #IMPLIED
                     role CDATA #IMPLIED>
    <!ELEMENT disable-search (#PCDATA)>
    <!ELEMENT disable-compliance-links (#PCDATA)>
    <!ELEMENT searchsite-domain (#PCDATA)>
    <!ELEMENT searchsite-name (#PCDATA)>  
    <!ELEMENT project-name (#PCDATA)>
    <!ELEMENT project-url (#PCDATA)>
    <!ELEMENT project-logo (#PCDATA)>
    <!ELEMENT group-name (#PCDATA)>
    <!ELEMENT group-url (#PCDATA)>
    <!ELEMENT group-logo (#PCDATA)>
    <!ELEMENT host-url (#PCDATA)>
    <!ELEMENT host-logo (#PCDATA)>
    <!ELEMENT year (#PCDATA)>
    <!ELEMENT vendor (#PCDATA)>
    <!ELEMENT trail (link1, link2, link3)>
    <!ELEMENT link1 EMPTY>
    <!-- Seems we can't use param entity refs until this is DTDified -->
    <!ATTLIST link1 name CDATA #REQUIRED href CDATA #IMPLIED>
    <!ELEMENT link2 EMPTY>
    <!ATTLIST link2 name CDATA #REQUIRED href CDATA #IMPLIED>
    <!ELEMENT link3 EMPTY>
    <!ATTLIST link3 name CDATA #REQUIRED href CDATA #IMPLIED>
    <!ELEMENT name (#PCDATA)>
    <!ELEMENT url (#PCDATA)>
    <!ELEMENT image (#PCDATA)>
    <!ELEMENT width (#PCDATA)>
    <!ELEMENT height (#PCDATA)>
    ]>
  
  <skinconfig>
    <!-- Do we want to disable the Google search box? -->
    <disable-search>false</disable-search>
    <disable-compliance-links>false</disable-compliance-links>
  
    <searchsite-domain>xml.apache.org</searchsite-domain>
    <searchsite-name>Apache XML</searchsite-name>  
  
    <!-- mandatory project logo
         skin: forrest-site renders it at the top -->
    <project-name>Forrest</project-name>
    <project-url>http://xml.apache.org/forrest/</project-url>
    <project-logo>images/project-logo.gif</project-logo>
  
    <!-- optional group logo
         skin: forrest-site renders it at the top-left corner -->
    <group-name>Apache XML</group-name>
    <group-url>http://xml.apache.org/</group-url>
    <group-logo>images/group-logo.gif</group-logo>
  
    <!-- optional host logo (e.g. sourceforge logo)
         skin: forrest-site renders it at the bottom-left corner -->
    <host-url></host-url>
    <host-logo></host-logo>
  
    <!-- The following are used to construct a copyright statement -->
    <year>2002</year>
    <vendor>The Apache Software Foundation.</vendor>
  
    <!-- Some skins use this to form a 'breadcrumb trail' of links. If you don't
    want these, set the attributes to blank. The DTD purposefully requires them.
    -->
    <trail>
      <link1 name="apache" href="http://www.apache.org/"/>
      <link2 name="xml.apache" href="http://xml.apache.org/"/>
      <link3 name="" href=""/>
    </trail>
  
    <!-- Credits are typically rendered as a set of small clickable images in 
the
    page footer -->
    <credits>
      <credit>
        <name>Built with Cocoon</name>
        <url>http://xml.apache.org/cocoon/</url>
        <image>images/built-with-cocoon.gif</image>
        <width>88</width>
        <height>31</height>
      </credit>
      <credit>
        <name>Krysalis Centipede</name>
        <url>http://www.krysalis.org/centipede/</url>
        <image>images/centipede-logo-small.gif</image>
        <width>138</width>
        <height>31</height>
      </credit>
    </credits>
  </skinconfig>
  
  
  
  1.1                  
cocoon-2.1/src/test/org/apache/cocoon/generation/filetest-result1.xml
  
  Index: filetest-result1.xml
  ===================================================================
  <?xml version="1.0"?>
  <skinconfig>
  <!-- Do we want to disable the Google search box? -->
    <disable-search>false</disable-search>
    <disable-compliance-links>false</disable-compliance-links>
    <searchsite-domain>xml.apache.org</searchsite-domain>
    <searchsite-name>Apache XML</searchsite-name>
  <!-- mandatory project logo
         skin: forrest-site renders it at the top -->
    <project-name>Forrest</project-name>
    <project-url>http://xml.apache.org/forrest/</project-url>
    <project-logo>images/project-logo.gif</project-logo>
  <!-- optional group logo
         skin: forrest-site renders it at the top-left corner -->
    <group-name>Apache XML</group-name>
    <group-url>http://xml.apache.org/</group-url>
    <group-logo>images/group-logo.gif</group-logo>
  <!-- optional host logo (e.g. sourceforge logo)
         skin: forrest-site renders it at the bottom-left corner -->
    <host-url/>
    <host-logo/>
  <!-- The following are used to construct a copyright statement -->
    <year>2002</year>
    <vendor>The Apache Software Foundation.</vendor>
  <!-- Some skins use this to form a 'breadcrumb trail' of links. If you don't
    want these, set the attributes to blank. The DTD purposefully requires them.
    -->
    <trail>
      <link1 name="apache" href="http://www.apache.org/"/>
      <link2 name="xml.apache" href="http://xml.apache.org/"/>
      <link3 name="" href=""/>
    </trail>
  <!-- Credits are typically rendered as a set of small clickable images in the
    page footer -->
    <credits>
      <credit>
        <name>Built with Cocoon</name>
        <url>http://xml.apache.org/cocoon/</url>
        <image>images/built-with-cocoon.gif</image>
        <width>88</width>
        <height>31</height>
      </credit>
      <credit>
        <name>Krysalis Centipede</name>
        <url>http://www.krysalis.org/centipede/</url>
        <image>images/centipede-logo-small.gif</image>
        <width>138</width>
        <height>31</height>
      </credit>
    </credits>
  </skinconfig>
  
  
  
  1.4       +55 -1     
cocoon-2.1/src/test/org/apache/cocoon/xml/dom/DOMBuilderStreamerTestCase.java
  
  Index: DOMBuilderStreamerTestCase.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/test/org/apache/cocoon/xml/dom/DOMBuilderStreamerTestCase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DOMBuilderStreamerTestCase.java   23 Apr 2003 06:44:50 -0000      1.3
  +++ DOMBuilderStreamerTestCase.java   29 Apr 2003 10:45:03 -0000      1.4
  @@ -53,6 +53,11 @@
   import org.custommonkey.xmlunit.XMLTestCase;
   import org.custommonkey.xmlunit.XMLUnit;
   
  +import javax.xml.transform.TransformerException;
  +import javax.xml.transform.TransformerFactory;
  +import javax.xml.transform.dom.DOMSource;
  +import javax.xml.transform.stream.StreamResult;
  +
   import org.w3c.dom.Document;
   import org.w3c.dom.Element;
   
  @@ -166,6 +171,55 @@
               // nothing
           }
       }*/
  +
  +    public void testBuilderWithComments() throws Exception {
  +        AttributesImpl atts = new AttributesImpl();
  +
  +        DOMBuilder builder = new DOMBuilder();
  +        builder.startDocument();
  +        builder.startElement("", "root", "root", atts);
  +        builder.comment("abcd".toCharArray(), 0, 4);
  +        builder.endElement("", "root", "node");
  +        builder.endDocument();
  +
  +        Document document = 
XMLUnit.buildControlDocument("<root><!--abcd--></root>");
  +
  +        assertXMLEqual(document, builder.getDocument());
  +    }
  +
  +    public void testBuilderWithCommentWithinDocType() throws Exception {
  +        AttributesImpl atts = new AttributesImpl();
  +
  +        DOMBuilder builder = new DOMBuilder();
  +        builder.startDocument();
  +        builder.startDTD("skinconfig", null, null);
  +        builder.comment("abcd".toCharArray(), 0, 4);
  +        builder.endDTD();
  +        builder.startElement("", "root", "root", atts);
  +        builder.endElement("", "root", "node");
  +        builder.endDocument();
  +
  +        Document document = XMLUnit.buildControlDocument("<!DOCTYPE 
skinconfig [<!--abcd-->]><root></root>");
  +
  +        print(document);
  +        print(builder.getDocument());
  +
  +        assertXMLEqual(document, builder.getDocument());
  +    }
  +
  +    public final void print(Document document) {
  +        TransformerFactory factory = (TransformerFactory) 
TransformerFactory.newInstance();
  +        try
  +        {
  +          javax.xml.transform.Transformer serializer = 
factory.newTransformer();
  +          serializer.transform(new DOMSource(document), new 
StreamResult(System.out));
  +          System.out.println();
  +        }
  +        catch (TransformerException te)
  +        {
  +          te.printStackTrace();
  +        }
  +    }
   
   
       public void testTestFacility() throws Exception {
  
  
  

Reply via email to