maven-doxia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ltheu...@apache.org
Subject svn commit: r770807 - in /maven/doxia/doxia/trunk/doxia-modules: doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocParserTest.java doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkTest.java
Date Fri, 01 May 2009 20:10:56 GMT
Author: ltheussl
Date: Fri May  1 20:10:56 2009
New Revision: 770807

URL: http://svn.apache.org/viewvc?rev=770807&view=rev
Log:
Additional tests for entities in paragraphs and section titles (DOXIA-311)

Modified:
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocParserTest.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkTest.java

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocParserTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocParserTest.java?rev=770807&r1=770806&r2=770807&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocParserTest.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocParserTest.java
Fri May  1 20:10:56 2009
@@ -434,4 +434,35 @@
             assertNotNull( ex );
         }
     }
+
+        /** @throws Exception  */
+    public void testEntities()
+        throws Exception
+    {
+        final String text = "<section name=\"&amp;\" title=\"&amp;\"><p>&amp;</p></section>";
+
+        SinkEventTestingSink sink = new SinkEventTestingSink();
+
+        parser.parse( text, sink );
+
+        Iterator it = sink.getEventList().iterator();
+
+        assertEquals( "section1", ( (SinkEventElement) it.next() ).getName() );
+        assertEquals( "sectionTitle1", ( (SinkEventElement) it.next() ).getName() );
+
+        SinkEventElement textEvt = (SinkEventElement) it.next();
+        assertEquals( "text", textEvt.getName() );
+        assertEquals( "&", textEvt.getArgs()[0] );
+
+        assertEquals( "sectionTitle1_", ( (SinkEventElement) it.next() ).getName() );
+        assertEquals( "paragraph", ( (SinkEventElement) it.next() ).getName() );
+
+        textEvt = (SinkEventElement) it.next();
+        assertEquals( "text", textEvt.getName() );
+        assertEquals( "&", textEvt.getArgs()[0] );
+
+        assertEquals( "paragraph_", ( (SinkEventElement) it.next() ).getName() );
+        assertEquals( "section1_", ( (SinkEventElement) it.next() ).getName() );
+        assertFalse( it.hasNext() );
+    }
 }

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkTest.java?rev=770807&r1=770806&r2=770807&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkTest.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkTest.java
Fri May  1 20:10:56 2009
@@ -20,11 +20,11 @@
  */
 
 import java.io.StringWriter;
+import java.io.Writer;
+
 import org.apache.maven.doxia.sink.AbstractSinkTest;
 import org.apache.maven.doxia.sink.Sink;
 
-import java.io.Writer;
-
 /**
  * @author Jason van Zyl
  * @version $Id$
@@ -274,4 +274,32 @@
         return text;
     }
 
+    /**
+     * Test entities is section titles and paragraphs.
+     */
+    public void testEntities()
+    {
+        XhtmlSink sink = null;
+        Writer writer =  new StringWriter();
+
+        try
+        {
+            sink = new XhtmlSink( writer );
+            sink.section( Sink.SECTION_LEVEL_1, null );
+            sink.sectionTitle( Sink.SECTION_LEVEL_1, null );
+            sink.text( "&", null );
+            sink.sectionTitle_( Sink.SECTION_LEVEL_1 );
+            sink.paragraph( null );
+            sink.text( "&", null );
+            sink.paragraph_();
+            sink.section_( Sink.SECTION_LEVEL_1 );
+        }
+        finally
+        {
+            sink.close();
+        }
+
+        assertEquals( "<div class=\"section\"><h2>&amp;</h2><p>&amp;</p></div>",
writer.toString() );
+    }
+
 }



Mime
View raw message