maven-doxia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ltheu...@apache.org
Subject svn commit: r806537 - in /maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src: main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java test/java/org/apache/maven/doxia/module/xdoc/XdocParserTest.java
Date Fri, 21 Aug 2009 13:06:22 GMT
Author: ltheussl
Date: Fri Aug 21 13:06:21 2009
New Revision: 806537

URL: http://svn.apache.org/viewvc?rev=806537&view=rev
Log:
Fix title handling, text and end tag need to be ignored as well if a second title is read.
Add test.

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

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java?rev=806537&r1=806536&r2=806537&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java
Fri Aug 21 13:06:21 2009
@@ -125,14 +125,22 @@
         }
         else if ( parser.getName().equals( TITLE.toString() ) )
         {
-            if ( hasTitle && getLog().isWarnEnabled() )
+            if ( hasTitle )
             {
-                getLog().warn( "<title/> was already defined in <properties/>,
ignored <title/> in <head/>." );
+                getLog().warn( "<title> was already defined in <properties>,
ignored <title> in <head>." );
+
+                try
+                {
+                    parser.nextText(); // ignore next text event
+                }
+                catch ( IOException ex )
+                {
+                    throw new XmlPullParserException( "Failed to parse text", parser, ex
);
+                }
             }
             else
             {
                 sink.title( attribs );
-                this.hasTitle = true;
             }
         }
         else if ( parser.getName().equals( AUTHOR_TAG.toString() ) )
@@ -238,7 +246,11 @@
         }
         else if ( parser.getName().equals( TITLE.toString() ) )
         {
-            sink.title_();
+            if ( !hasTitle )
+            {
+                sink.title_();
+                this.hasTitle = true;
+            }
         }
         else if ( parser.getName().equals( AUTHOR_TAG.toString() ) )
         {

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=806537&r1=806536&r2=806537&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 Aug 21 13:06:21 2009
@@ -48,7 +48,7 @@
 {
     private XdocParser parser;
 
-    /** @see junit.framework.TestCase#setUp() */
+    /** {@inheritDoc} */
     protected void setUp()
         throws Exception
     {
@@ -190,12 +190,29 @@
         assertEquals( "body_", ( (SinkEventElement) it.next() ).getName() );
         assertFalse( it.hasNext() );
 
+        // DOXIA-359
         text = "<document>"
-                + "<properties><title>title</title>"
-                + "<author email=\"a@b.c\">John Doe</author></properties>"
-                + "<head><title>title</title></head><body></body></document>";
+                + "<properties><title>properties title</title></properties>"
+                + "<head><title>head title</title></head>"
+                + "<body></body></document>";
+
+        sink.reset();
         parser.parse( text, sink );
-        assertTrue( true );
+
+        it = sink.getEventList().iterator();
+
+        assertEquals( "head", ( (SinkEventElement) it.next() ).getName() );
+        assertEquals( "title", ( (SinkEventElement) it.next() ).getName() );
+
+        SinkEventElement title = (SinkEventElement) it.next();
+        assertEquals( "text", title.getName() );
+        assertEquals( "properties title", title.getArgs()[0] );
+
+        assertEquals( "title_", ( (SinkEventElement) it.next() ).getName() );
+        assertEquals( "head_", ( (SinkEventElement) it.next() ).getName() );
+        assertEquals( "body", ( (SinkEventElement) it.next() ).getName() );
+        assertEquals( "body_", ( (SinkEventElement) it.next() ).getName() );
+        assertFalse( it.hasNext() );
     }
 
     /** @throws Exception  */



Mime
View raw message