1 package org.apache.maven.archetype.common.util;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import junit.framework.TestCase;
23 import org.jdom.Document;
24 import org.jdom.JDOMException;
25 import org.jdom.input.SAXBuilder;
26
27 import java.io.IOException;
28 import java.io.StringReader;
29 import java.io.StringWriter;
30
31
32 public class TestXMLOutputter
33 extends TestCase
34 {
35 public void testOutput_Document_ShouldParseAndOutputCDATASection_NoMods()
36 throws
37 JDOMException,
38 IOException
39 {
40 String content =
41 "<document>" +
42 "<element1>This is some text</element1>" +
43 "<description>And then," +
44 "<![CDATA[<more content goes here>]]>" +
45 "</description><!--somecomment-->" +
46 "</document>";
47
48 Document doc = new SAXBuilder().build( new StringReader( content ) );
49
50 StringWriter sw = new StringWriter();
51 new XMLOutputter().output( doc, sw );
52
53 System.out.println( "Resulting content is:\n\n\'" + sw.toString() + "\'\n\n" );
54
55 assertTrue( sw.toString().indexOf( content ) > -1 );
56 }
57 }