commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: jakarta-commons/jelly/src/test/org/apache/commons/jelly/test/xml TestCData.java
Date Wed, 01 Sep 2004 05:32:18 GMT
dion        2004/08/31 22:32:18

  Modified:    jelly/src/test/org/apache/commons/jelly/test/xml
                        TestCData.java
  Log:
  Add a cleaner version of the test to help dom4j guys
  
  Revision  Changes    Path
  1.4       +30 -0     jakarta-commons/jelly/src/test/org/apache/commons/jelly/test/xml/TestCData.java
  
  Index: TestCData.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jelly/src/test/org/apache/commons/jelly/test/xml/TestCData.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestCData.java	1 Sep 2004 04:52:05 -0000	1.3
  +++ TestCData.java	1 Sep 2004 05:32:17 -0000	1.4
  @@ -15,10 +15,18 @@
    */
   package org.apache.commons.jelly.test.xml;
   
  +import java.io.IOException;
  +import java.io.StringWriter;
  +
   import org.apache.commons.jelly.Jelly;
   import org.apache.commons.jelly.JellyContext;
   import org.apache.commons.jelly.Script;
   import org.apache.commons.jelly.XMLOutput;
  +import org.apache.commons.jelly.util.SafeContentHandler;
  +import org.dom4j.io.HTMLWriter;
  +import org.dom4j.io.OutputFormat;
  +import org.dom4j.io.XMLWriter;
  +import org.xml.sax.SAXException;
   
   import junit.framework.TestCase;
   
  @@ -53,6 +61,28 @@
           golden += "]><foo></foo>";
           
           assertEquals("output should contain the CDATA section", golden, output);
  +    }
  +    
  +    public void testDom4JCData() throws SAXException {
  +        StringWriter writer = new StringWriter();
  +        OutputFormat format = new OutputFormat();
  +        final XMLWriter xmlWriter = new XMLWriter(writer, format);
  +        xmlWriter.setEscapeText(false);
  +
  +        XMLOutput output = new XMLOutput(xmlWriter, xmlWriter);
  +
  +        String decl = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
  +        String golden = "<!DOCTYPE foo [\n";
  +        golden += "  <!ELEMENT foo (#PCDATA)>\n";
  +        golden += "]><foo></foo>";
  +
  +        output.startDocument();
  +        output.write(golden);
  +        output.endDocument();
  +        System.err.println("output was: '" + writer.toString() +"'");
  +        System.err.println("golden is : '" + golden +"'");
  +        assertEquals("output should contain the CDATA section", 
  +                decl + golden, writer.toString());
       }
   
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message