maven-doxia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vsive...@apache.org
Subject svn commit: r500525 - in /maven/doxia/trunk/doxia-site-renderer/src/test: java/org/apache/maven/doxia/siterenderer/DefaultSiteRendererTest.java resources/default-site.vm site/xdoc/multipleblock.xml
Date Sat, 27 Jan 2007 13:05:25 GMT
Author: vsiveton
Date: Sat Jan 27 05:05:24 2007
New Revision: 500525

URL: http://svn.apache.org/viewvc?view=rev&rev=500525
Log:
DOXIA-93: xdoc renderer chokes on multiple block elements in a section

o Add another test case to prove that the issue has already be solved

Added:
    maven/doxia/trunk/doxia-site-renderer/src/test/site/xdoc/multipleblock.xml   (with props)
Modified:
    maven/doxia/trunk/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/DefaultSiteRendererTest.java
    maven/doxia/trunk/doxia-site-renderer/src/test/resources/default-site.vm

Modified: maven/doxia/trunk/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/DefaultSiteRendererTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/DefaultSiteRendererTest.java?view=diff&rev=500525&r1=500524&r2=500525
==============================================================================
--- maven/doxia/trunk/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/DefaultSiteRendererTest.java
(original)
+++ maven/doxia/trunk/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/DefaultSiteRendererTest.java
Sat Jan 27 05:05:24 2007
@@ -28,6 +28,7 @@
 import org.apache.maven.doxia.site.decoration.DecorationModel;
 import org.apache.maven.doxia.site.decoration.io.xpp3.DecorationXpp3Reader;
 import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.util.FileUtils;
 
 import com.gargoylesoftware.htmlunit.WebClient;
 import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
@@ -52,6 +53,8 @@
 public class DefaultSiteRendererTest
     extends PlexusTestCase
 {
+    private static final String OUTPUT = "target/output";
+
     private Renderer renderer;
 
     /**
@@ -62,6 +65,9 @@
     {
         super.setUp();
         renderer = (Renderer) lookup( Renderer.ROLE );
+
+        // Safety
+        FileUtils.deleteDirectory( getTestFile( OUTPUT ) );
     }
 
     /**
@@ -74,6 +80,9 @@
         super.tearDown();
     }
 
+    /**
+     * @throws Exception
+     */
     public void testRender()
         throws Exception
     {
@@ -93,15 +102,19 @@
         context.setDecoration( decoration );
         context.addSiteDirectory( getTestFile( "src/test/site" ) );
 
-        renderer.render( renderer.locateDocumentFiles( context ).values(), context, getTestFile(
"target/output" ) );
+        renderer.render( renderer.locateDocumentFiles( context ).values(), context, getTestFile(
OUTPUT ) );
 
         // ----------------------------------------------------------------------
         // Verify specific pages
         // ----------------------------------------------------------------------
         verifyCdcPage();
         verifyNestedItemsPage();
+        verifyMultipleBlock();
     }
 
+    /**
+     * @throws Exception
+     */
     public void verifyCdcPage()
         throws Exception
     {
@@ -110,6 +123,9 @@
         assertTrue( nestedItems.exists() );
     }
 
+    /**
+     * @throws Exception
+     */
     public void verifyNestedItemsPage()
         throws Exception
     {
@@ -129,6 +145,10 @@
 
         Iterator elementIterator = division.getAllHtmlChildElements();
 
+        // ----------------------------------------------------------------------
+        // Verify link
+        // ----------------------------------------------------------------------
+
         HtmlAnchor a = (HtmlAnchor) elementIterator.next();
         assertNotNull( a );
         assertEquals( a.getAttributeValue( "name" ), "list_section" );
@@ -139,14 +159,14 @@
 
         HtmlHeader2 h2 = (HtmlHeader2) elementIterator.next();
         assertNotNull( h2 );
-        assertEquals( h2.asText(), "List Section");
+        assertEquals( h2.asText(), "List Section" );
 
         // ----------------------------------------------------------------------
         // Unordered lists
         // ----------------------------------------------------------------------
         HtmlHeader4 h4 = (HtmlHeader4) elementIterator.next();
         assertNotNull( h4 );
-        assertEquals( h4.asText(), "Unordered lists");
+        assertEquals( h4.asText(), "Unordered lists" );
 
         HtmlParagraph p = (HtmlParagraph) elementIterator.next();
         assertNotNull( p );
@@ -168,7 +188,6 @@
         assertNotNull( li );
         // No paragraph renderer
         assertEquals( li.getFirstChild().asText(), "Item 11." );
-        System.out.println(li.getFirstChild().asText() );
         li = (HtmlListItem) elementIterator.next();
         assertNotNull( li );
         // No paragraph renderer
@@ -230,7 +249,7 @@
         // ----------------------------------------------------------------------
         h4 = (HtmlHeader4) elementIterator.next();
         assertNotNull( h4 );
-        assertEquals( h4.asText(), "Ordered lists");
+        assertEquals( h4.asText(), "Ordered lists" );
 
         p = (HtmlParagraph) elementIterator.next();
         assertNotNull( p );
@@ -311,7 +330,7 @@
         // ----------------------------------------------------------------------
         h4 = (HtmlHeader4) elementIterator.next();
         assertNotNull( h4 );
-        assertEquals( h4.asText(), "Definition lists");
+        assertEquals( h4.asText(), "Definition lists" );
 
         p = (HtmlParagraph) elementIterator.next();
         assertNotNull( p );
@@ -363,6 +382,107 @@
         p = (HtmlParagraph) elementIterator.next();
         assertNotNull( p );
         assertEquals( p.asText(), "Paragraph 6 below list." );
+
+        assertFalse( elementIterator.hasNext() );
+    }
+
+    /**
+     * @throws Exception
+     */
+    public void verifyMultipleBlock()
+        throws Exception
+    {
+        File multipleblock = getTestFile( "target/output/multipleblock.html" );
+        assertNotNull( multipleblock );
+        assertTrue( multipleblock.exists() );
+
+        // HtmlUnit
+        WebClient webClient = new WebClient();
+        HtmlPage page = (HtmlPage) webClient.getPage( multipleblock.toURL() );
+        assertNotNull( page );
+
+        HtmlElement element = page.getHtmlElementById( "contentBox" );
+        assertNotNull( element );
+        HtmlDivision division = (HtmlDivision) element;
+        assertNotNull( division );
+
+        Iterator elementIterator = division.getAllHtmlChildElements();
+
+        // ----------------------------------------------------------------------
+        // Verify link
+        // ----------------------------------------------------------------------
+
+        HtmlAnchor a = (HtmlAnchor) elementIterator.next();
+        assertNotNull( a );
+        assertEquals( a.getAttributeValue( "name" ), "section_name" );
+
+        HtmlDivision div = (HtmlDivision) elementIterator.next();
+        assertNotNull( div );
+        assertEquals( div.getAttributeValue( "class" ), "section" );
+
+        HtmlHeader2 h2 = (HtmlHeader2) elementIterator.next();
+        assertNotNull( h2 );
+        assertEquals( h2.asText(), "section name" );
+
+        // ----------------------------------------------------------------------
+        // Paragraph
+        // ----------------------------------------------------------------------
+
+        HtmlParagraph p = (HtmlParagraph) elementIterator.next();
+        assertNotNull( p );
+        assertEquals( p.asText(), "text" );
+
+        // ----------------------------------------------------------------------
+        // Unordered list
+        // ----------------------------------------------------------------------
+
+        HtmlUnorderedList ul = (HtmlUnorderedList) elementIterator.next();
+        assertNotNull( ul );
+        assertEquals( ul.getFirstChild().asText(), "" );
+
+        HtmlListItem li = (HtmlListItem) elementIterator.next();
+        assertNotNull( li );
+        assertEquals( li.getFirstChild().asText(), "list1" );
+
+        // ----------------------------------------------------------------------
+        // Paragraph
+        // ----------------------------------------------------------------------
+
+        p = (HtmlParagraph) elementIterator.next();
+        assertNotNull( p );
+        assertEquals( p.asText(), "text2" );
+
+        // ----------------------------------------------------------------------
+        // Unordered list
+        // ----------------------------------------------------------------------
+
+        ul = (HtmlUnorderedList) elementIterator.next();
+        assertNotNull( ul );
+        assertEquals( ul.getFirstChild().asText(), "" );
+
+        li = (HtmlListItem) elementIterator.next();
+        assertNotNull( li );
+        assertEquals( li.getFirstChild().asText(), "list1" );
+
+        // ----------------------------------------------------------------------
+        // Paragraph
+        // ----------------------------------------------------------------------
+
+        p = (HtmlParagraph) elementIterator.next();
+        assertNotNull( p );
+        assertEquals( p.asText(), "text3" );
+
+        // ----------------------------------------------------------------------
+        // Unordered list
+        // ----------------------------------------------------------------------
+
+        ul = (HtmlUnorderedList) elementIterator.next();
+        assertNotNull( ul );
+        assertEquals( ul.getFirstChild().asText(), "" );
+
+        li = (HtmlListItem) elementIterator.next();
+        assertNotNull( li );
+        assertEquals( li.getFirstChild().asText(), "list1" );
 
         assertFalse( elementIterator.hasNext() );
     }

Modified: maven/doxia/trunk/doxia-site-renderer/src/test/resources/default-site.vm
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-site-renderer/src/test/resources/default-site.vm?view=diff&rev=500525&r1=500524&r2=500525
==============================================================================
--- maven/doxia/trunk/doxia-site-renderer/src/test/resources/default-site.vm (original)
+++ maven/doxia/trunk/doxia-site-renderer/src/test/resources/default-site.vm Sat Jan 27 05:05:24
2007
@@ -1,5 +1,13 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
+#macro ( link $href $name )
+  #if ( ( $href.toLowerCase().startsWith("http") || $href.toLowerCase().startsWith("https")
) )
+    <a href="$href" class="externalLink">$name</a>
+  #else
+    <a href="$href">$name</a>
+  #end
+#end
+
 #macro ( banner $banner $id )
   #if ( $banner )
     #if( $banner.href )
@@ -38,7 +46,7 @@
     #set ( $counter = $counter + 1 )
     #set ( $currentItemHref = $PathTool.calculateLink( $item.href, $relativePath ) )
     #set ( $currentItemHref = $currentItemHref.replaceAll( "\\", "/" ) )
-    <a href="$currentItemHref">$item.name</a>
+    #link( $currentItemHref $item.name )
     #if ( $links.size() > $counter )
       |
     #end
@@ -55,7 +63,7 @@
     #if ( $currentItemHref == $alignedFileName || $currentItemHref == "" )
       $item.name
     #else
-      <a href="$currentItemHref">$item.name</a>
+      #link( $currentItemHref $item.name )
     #end
     #if ( $breadcrumbs.size() > $counter )
       &gt;
@@ -102,7 +110,7 @@
     #if ( $item.img )
       #if ( ! ( $item.img.toLowerCase().startsWith("http") || $item.img.toLowerCase().startsWith("https")
) )
         #set ( $src = $PathTool.calculateLink( $item.img, $relativePath ) )
-        #set ( $src = $item.img.replaceAll( "\\", "/" ) )
+        #set ( $src = $src.replaceAll( "\\", "/" ) )
         <img src="$src"/>
       #else
         <img src="$item.img" align="absbottom" style="border-width: 0"/>
@@ -111,7 +119,7 @@
     #if ( $alignedFileName == $currentItemHref )
       <strong>$item.name</strong>
     #else
-      <a href="$currentItemHref">$item.name</a>
+      #link( $currentItemHref $item.name )
     #end
   #if ( $item && $item.items && $item.items.size() > 0 )
     #if ( $collapse == "expanded" )
@@ -130,11 +138,13 @@
     #if ( $menu.name )
     <h5>$menu.name</h5>
     #end
+    #if ( $menu.items && $menu.items.size() > 0 )
     <ul>
       #foreach( $item in $menu.items )
         #menuItem( $item )
       #end
     </ul>
+    #end
   #end
 #end
 
@@ -180,10 +190,17 @@
   #end
 
   #set ( $breadcrumbs = $decoration.body.breadcrumbs )
+  #set ( $links = $decoration.body.links )
+
+  #if ( $datePosition.equalsIgnoreCase( "right" ) && $links && $links.size()
> 0 )
+    #set ( $prefix = "&nbsp;|" )
+  #else
+    #set ( $prefix = "" )
+  #end
 
   #if ( $datePosition.equalsIgnoreCase( $position ) )
     #if ( ( $datePosition.equalsIgnoreCase( "right" ) ) || ( $datePosition.equalsIgnoreCase(
"bottom" ) ) )
-      &nbsp;| $i18n.getString( "site-renderer", $locale, "template.lastpublished" ):
$dateToday
+      $prefix $i18n.getString( "site-renderer", $locale, "template.lastpublished" ): $dateToday
       #if ( $versionPosition.equalsIgnoreCase( $position ) )
         &nbsp;| $i18n.getString( "site-renderer", $locale, "template.version" ): ${project.version}
       #end
@@ -207,7 +224,7 @@
     #end
   #elseif ( $versionPosition.equalsIgnoreCase( $position ) )
     #if ( ( $versionPosition.equalsIgnoreCase( "right" ) ) || ( $versionPosition.equalsIgnoreCase(
"bottom" ) ) )
-      &nbsp;| $i18n.getString( "site-renderer", $locale, "template.version" ): ${project.version}
+      $prefix $i18n.getString( "site-renderer", $locale, "template.version" ): ${project.version}
     #elseif ( ( $versionPosition.equalsIgnoreCase( "navigation-bottom" ) ) || ( $versionPosition.equalsIgnoreCase(
"navigation-top" ) ) )
       <div id="lastPublished">
         $i18n.getString( "site-renderer", $locale, "template.version" ): ${project.version}
@@ -252,19 +269,19 @@
                 #set ( $img = "images/logos/maven-feather.png" )
             #end
 
-            <a href="$href" title="$name" id="poweredBy">
+            <a href="$href" title="$name" class="poweredBy">
               #set ( $img = $PathTool.calculateLink( $img, $relativePath ) )
               #set ( $img = $img.replaceAll( "\\", "/" ) )
               <img alt="$name" src="$img" />
             </a>
         #end
         #if( $poweredBy.isEmpty() )
-          <a href="http://maven.apache.org/" title="$i18n.getString( "site-renderer",
$locale, "template.builtby" ) Maven" id="poweredBy">
+          <a href="http://maven.apache.org/" title="$i18n.getString( "site-renderer",
$locale, "template.builtby" ) Maven" class="poweredBy">
             <img alt="$i18n.getString( "site-renderer", $locale, "template.builtby" )
Maven" src="$relativePath/images/logos/maven-feather.png"></img>
           </a>
         #end
     #else
-        <a href="http://maven.apache.org/" title="$i18n.getString( "site-renderer", $locale,
"template.builtby" ) Maven" id="poweredBy">
+        <a href="http://maven.apache.org/" title="$i18n.getString( "site-renderer", $locale,
"template.builtby" ) Maven" class="poweredBy">
           <img alt="$i18n.getString( "site-renderer", $locale, "template.builtby" ) Maven"
src="$relativePath/images/logos/maven-feather.png"></img>
         </a>
     #end

Added: maven/doxia/trunk/doxia-site-renderer/src/test/site/xdoc/multipleblock.xml
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-site-renderer/src/test/site/xdoc/multipleblock.xml?view=auto&rev=500525
==============================================================================
--- maven/doxia/trunk/doxia-site-renderer/src/test/site/xdoc/multipleblock.xml (added)
+++ maven/doxia/trunk/doxia-site-renderer/src/test/site/xdoc/multipleblock.xml Sat Jan 27
05:05:24 2007
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+
+<document>
+  <properties>
+    <title>Test DOXIA-93</title>
+    <author email="vsiveton@apache.org">Vincent Siveton</author>
+  </properties>
+  <body>
+    <section name="section name">
+      <p>text</p>
+      <ul>
+        <li>list1</li>
+      </ul>
+      <p>text2</p>
+      <ul>
+        <li>list1</li>
+      </ul>
+      <p>text3</p>
+      <ul>
+        <li><p>list1</p></li>
+      </ul>
+    </section>
+  </body>
+</document>

Propchange: maven/doxia/trunk/doxia-site-renderer/src/test/site/xdoc/multipleblock.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/doxia/trunk/doxia-site-renderer/src/test/site/xdoc/multipleblock.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"



Mime
View raw message