maven-doxia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ltheu...@apache.org
Subject svn commit: r591285 - in /maven/doxia/doxia-sitetools/trunk/doxia-site-renderer: pom.xml src/test/java/org/apache/maven/doxia/siterenderer/DefaultSiteRendererTest.java src/test/site/fml/ src/test/site/fml/faq.fml
Date Fri, 02 Nov 2007 09:49:46 GMT
Author: ltheussl
Date: Fri Nov  2 02:49:45 2007
New Revision: 591285

URL: http://svn.apache.org/viewvc?rev=591285&view=rev
Log:
Add test for faq rendering

Added:
    maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/site/fml/
    maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/site/fml/faq.fml   (with
props)
Modified:
    maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/pom.xml
    maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/DefaultSiteRendererTest.java

Modified: maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/pom.xml
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/pom.xml?rev=591285&r1=591284&r2=591285&view=diff
==============================================================================
--- maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/pom.xml (original)
+++ maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/pom.xml Fri Nov  2 02:49:45 2007
@@ -113,6 +113,10 @@
       <artifactId>doxia-module-xhtml</artifactId>
     </dependency>
     <dependency>
+      <groupId>org.apache.maven.doxia</groupId>
+      <artifactId>doxia-module-fml</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-utils</artifactId>
     </dependency>

Modified: maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/DefaultSiteRendererTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/DefaultSiteRendererTest.java?rev=591285&r1=591284&r2=591285&view=diff
==============================================================================
--- maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/DefaultSiteRendererTest.java
(original)
+++ maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/DefaultSiteRendererTest.java
Fri Nov  2 02:49:45 2007
@@ -35,9 +35,14 @@
 import com.gargoylesoftware.htmlunit.html.HtmlParagraph;
 import com.gargoylesoftware.htmlunit.html.HtmlPreformattedText;
 import com.gargoylesoftware.htmlunit.html.HtmlScript;
+import com.gargoylesoftware.htmlunit.html.HtmlTable;
+import com.gargoylesoftware.htmlunit.html.HtmlTableDataCell;
+import com.gargoylesoftware.htmlunit.html.HtmlTableRow;
 import com.gargoylesoftware.htmlunit.html.HtmlUnorderedList;
+
 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 org.codehaus.plexus.util.IOUtil;
@@ -120,6 +125,7 @@
         verifyMacro();
         verifyEntitiesPage();
         verifyJavascriptPage();
+        verifyFaqPage();
     }
 
     /**
@@ -659,7 +665,179 @@
         assertEquals( script.asText().trim(), "" );
         final List expectedAlerts = Collections.singletonList( "Hello!" );
         assertEquals( expectedAlerts, collectedAlerts );
-
     }
 
+    /**
+     * @throws Exception
+     */
+    public void verifyFaqPage()
+        throws Exception
+    {
+        File faqTest = getTestFile( "target/output/faq.html" );
+        assertNotNull( faqTest );
+        assertTrue( faqTest.exists() );
+
+        // HtmlUnit
+        WebClient webClient = new WebClient();
+        HtmlPage page = (HtmlPage) webClient.getPage( faqTest.toURL() );
+        assertNotNull( page );
+
+        HtmlElement element = page.getHtmlElementById( "contentBox" );
+        assertNotNull( element );
+        HtmlDivision division = (HtmlDivision) element;
+        assertNotNull( division );
+
+        Iterator elementIterator = division.getAllHtmlChildElements();
+
+        // ----------------------------------------------------------------------
+        //
+        // ----------------------------------------------------------------------
+
+        HtmlDivision div = (HtmlDivision) elementIterator.next();
+        assertEquals( div.getAttributeValue( "class" ), "section" );
+
+        HtmlHeader2 h2 = (HtmlHeader2) elementIterator.next();
+        assertEquals( h2.asText().trim(), "Oft Asked Questions" );
+
+        HtmlAnchor a = (HtmlAnchor) elementIterator.next();
+        assertEquals( a.getAttributeValue( "name" ), "Oft_Asked_Questions" );
+
+        HtmlParagraph p = (HtmlParagraph) elementIterator.next();
+        element = (HtmlElement) elementIterator.next();
+        assertEquals( element.getTagName(), "b" );
+        assertEquals( element.asText().trim(), "Contributing" );
+
+        HtmlOrderedList ol = (HtmlOrderedList) elementIterator.next();
+        assertEquals( ol.getFirstChild().asText().trim(), "One stupid question & a silly
answer?" );
+
+        HtmlListItem li = (HtmlListItem) elementIterator.next();
+        assertEquals( li.getFirstChild().asText().trim(), "One stupid question & a silly
answer?" );
+
+        a = (HtmlAnchor) elementIterator.next();
+        assertEquals( a.getAttributeValue( "href" ), "#stupid-question" );
+
+        element = (HtmlElement) elementIterator.next();
+        assertEquals( element.getTagName(), "b" );
+        assertEquals( element.asText().trim(), "stupid" );
+
+        p = (HtmlParagraph) elementIterator.next();
+        element = (HtmlElement) elementIterator.next();
+        assertEquals( element.getTagName(), "b" );
+        assertEquals( element.asText().trim(), "Using Maven" );
+
+        ol = (HtmlOrderedList) elementIterator.next();
+        assertEquals( ol.getFirstChild().asText().trim(), "How do I disable a report on my
site?" );
+
+        li = (HtmlListItem) elementIterator.next();
+        assertNotNull( li );
+        assertEquals( li.getFirstChild().asText().trim(), "How do I disable a report on my
site?" );
+
+        a = (HtmlAnchor) elementIterator.next();
+        assertEquals( a.getAttributeValue( "href" ), "#disable-reports" );
+
+        div = (HtmlDivision) elementIterator.next();
+        assertEquals( div.getAttributeValue( "class" ), "section" );
+
+        h2 = (HtmlHeader2) elementIterator.next();
+        assertEquals( h2.asText().trim(), "Contributing" );
+
+        a = (HtmlAnchor) elementIterator.next();
+        assertEquals( a.getAttributeValue( "name" ), "Contributing" );
+
+        HtmlDefinitionList dl = (HtmlDefinitionList) elementIterator.next();
+
+        HtmlDefinitionTerm dt = (HtmlDefinitionTerm) elementIterator.next();
+        assertEquals( dt.getFirstChild().asText().trim(), "One stupid question & a silly
answer?" );
+
+        a = (HtmlAnchor) elementIterator.next();
+        assertEquals( a.getAttributeValue( "name" ), "stupid-question" );
+
+        element = (HtmlElement) elementIterator.next();
+        assertEquals( element.getTagName(), "b" );
+        assertEquals( element.asText().trim(), "stupid" );
+
+        HtmlDefinitionDescription dd = (HtmlDefinitionDescription) elementIterator.next();
+
+        p = (HtmlParagraph) elementIterator.next();
+
+        a = (HtmlAnchor) elementIterator.next();
+        assertEquals( a.getAttributeValue( "href" ), "#Using_Maven" );
+        assertEquals( a.asText().trim(), "local link" );
+
+        a = (HtmlAnchor) elementIterator.next();
+        assertEquals( a.getAttributeValue( "href" ), "./cdc.html" );
+        assertEquals( a.asText().trim(), "source document" );
+
+        a = (HtmlAnchor) elementIterator.next();
+        assertEquals( a.getAttributeValue( "href" ), "http://maven.apache.org/" );
+        assertEquals( a.asText().trim(), "external link" );
+
+        element = (HtmlElement) elementIterator.next();
+        assertEquals( element.getTagName(), "i" );
+        assertEquals( element.asText().trim(), "italic" );
+
+        HtmlTable table = (HtmlTable) elementIterator.next();
+        assertEquals( table.getAttributeValue( "border" ), "0" );
+
+        element = (HtmlElement) elementIterator.next();
+        // this is a htmlunit bug
+        assertEquals( element.getTagName(), "tbody" );
+
+        HtmlTableRow tr = (HtmlTableRow) elementIterator.next();
+        HtmlTableDataCell td = (HtmlTableDataCell) elementIterator.next();
+        assertEquals( td.getAttributeValue( "align" ), "right" );
+
+        a = (HtmlAnchor) elementIterator.next();
+        assertEquals( a.getAttributeValue( "href" ), "#top" );
+        assertEquals( a.asText().trim(), "[top]" );
+
+
+        div = (HtmlDivision) elementIterator.next();
+        assertEquals( div.getAttributeValue( "class" ), "section" );
+
+        h2 = (HtmlHeader2) elementIterator.next();
+        assertEquals( h2.asText().trim(), "Using Maven" );
+
+        a = (HtmlAnchor) elementIterator.next();
+        assertEquals( a.getAttributeValue( "name" ), "Using_Maven" );
+
+        dl = (HtmlDefinitionList) elementIterator.next();
+
+        dt = (HtmlDefinitionTerm) elementIterator.next();
+        assertEquals( dt.getFirstChild().asText().trim(), "How do I disable a report on my
site?" );
+
+        a = (HtmlAnchor) elementIterator.next();
+        assertEquals( a.getAttributeValue( "name" ), "disable-reports" );
+
+        dd = (HtmlDefinitionDescription) elementIterator.next();
+
+        p = (HtmlParagraph) elementIterator.next();
+
+        element = (HtmlElement) elementIterator.next();
+        assertEquals( element.getTagName(), "code" );
+        assertEquals( element.asText().trim(), "<source></source>" );
+
+        div = (HtmlDivision) elementIterator.next();
+        assertEquals( div.getAttributeValue( "class" ), "source" );
+
+        HtmlPreformattedText pre = (HtmlPreformattedText) elementIterator.next();
+        assertEquals( pre.asText().trim(), "<source>1.5</source>" );
+
+        table = (HtmlTable) elementIterator.next();
+        assertEquals( table.getAttributeValue( "border" ), "0" );
+
+        element = (HtmlElement) elementIterator.next();
+        // this is a htmlunit bug
+        assertEquals( element.getTagName(), "tbody" );
+
+        tr = (HtmlTableRow) elementIterator.next();
+        td = (HtmlTableDataCell) elementIterator.next();
+        assertEquals( td.getAttributeValue( "align" ), "right" );
+
+        a = (HtmlAnchor) elementIterator.next();
+        assertEquals( a.getAttributeValue( "href" ), "#top" );
+        assertEquals( a.asText().trim(), "[top]" );
+
+        assertFalse( elementIterator.hasNext() );
+    }
 }

Added: maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/site/fml/faq.fml
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/site/fml/faq.fml?rev=591285&view=auto
==============================================================================
--- maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/site/fml/faq.fml (added)
+++ maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/site/fml/faq.fml Fri Nov
 2 02:49:45 2007
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+
+<faqs title="Oft Asked Questions">
+
+  <part id="contributing">
+    <!-- A comment -->
+    <title>Contributing</title>
+
+    <faq id="stupid-question">
+      <question>One <b>stupid</b> question &amp; a silly answer?</question>
+      <answer>
+        <p>
+          A paragraph with a <a href="#Using_Maven">local link</a>,
+          a link to another <a href="./cdc.html">source document</a>,
+          an <a href="http://maven.apache.org/">external link</a> and an <i>italic</i>
text.
+        </p>
+      </answer>
+    </faq>
+
+  </part>
+
+  <part id="using">
+    <title>Using Maven</title>
+
+    <faq id="disable-reports">
+      <question>How do I disable a report on my site?</question>
+      <answer>
+        <p>
+          Test nested <code>&lt;source&gt;&lt;/source&gt;</code>
tags (DOXIA-16):
+        </p>
+        <source><![CDATA[<source>1.5</source>]]></source>
+      </answer>
+    </faq>
+
+  </part>
+
+</faqs>
+

Propchange: maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/site/fml/faq.fml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/site/fml/faq.fml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"



Mime
View raw message