You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by lt...@apache.org on 2009/06/22 23:11:36 UTC

svn commit: r787400 - in /maven/plugins/trunk/maven-pdf-plugin/src/test: java/org/apache/maven/plugins/pdf/DocumentModelBuilderTest.java resources/unit/pdf/pom_model_builder.xml resources/unit/pdf/src/site/model_builder_site.xml

Author: ltheussl
Date: Mon Jun 22 21:11:36 2009
New Revision: 787400

URL: http://svn.apache.org/viewvc?rev=787400&view=rev
Log:
Test DocumentModelBuilder with site descriptor

Added:
    maven/plugins/trunk/maven-pdf-plugin/src/test/resources/unit/pdf/src/site/model_builder_site.xml   (with props)
Modified:
    maven/plugins/trunk/maven-pdf-plugin/src/test/java/org/apache/maven/plugins/pdf/DocumentModelBuilderTest.java
    maven/plugins/trunk/maven-pdf-plugin/src/test/resources/unit/pdf/pom_model_builder.xml

Modified: maven/plugins/trunk/maven-pdf-plugin/src/test/java/org/apache/maven/plugins/pdf/DocumentModelBuilderTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pdf-plugin/src/test/java/org/apache/maven/plugins/pdf/DocumentModelBuilderTest.java?rev=787400&r1=787399&r2=787400&view=diff
==============================================================================
--- maven/plugins/trunk/maven-pdf-plugin/src/test/java/org/apache/maven/plugins/pdf/DocumentModelBuilderTest.java (original)
+++ maven/plugins/trunk/maven-pdf-plugin/src/test/java/org/apache/maven/plugins/pdf/DocumentModelBuilderTest.java Mon Jun 22 21:11:36 2009
@@ -19,22 +19,31 @@
  * under the License.
  */
 
-import junit.framework.TestCase;
+import java.io.File;
+import java.io.IOException;
+import java.io.Reader;
 
 import org.apache.maven.doxia.document.DocumentCover;
 import org.apache.maven.doxia.document.DocumentMeta;
 import org.apache.maven.doxia.document.DocumentModel;
-
 import org.apache.maven.doxia.document.DocumentTOC;
+import org.apache.maven.doxia.document.DocumentTOCItem;
+import org.apache.maven.doxia.site.decoration.DecorationModel;
+import org.apache.maven.doxia.site.decoration.io.xpp3.DecorationXpp3Reader;
 import org.apache.maven.plugins.pdf.stubs.ModelBuilderMavenProjectStub;
 
+import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.ReaderFactory;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
 /**
  *
  * @author ltheussl
  * @version $Id$
  */
 public class DocumentModelBuilderTest
-        extends TestCase
+        extends PlexusTestCase
 {
     /**
      * Test of getDocumentModel method, of class DocumentModelBuilder.
@@ -77,4 +86,45 @@
         DocumentTOC toc = model.getToc();
         assertEquals( 0, toc.getItems().size() );
     }
+
+    /**
+     * Test of getDocumentModel method, of class DocumentModelBuilder.
+     * @throws Exception if something happens.
+     */
+    public void testGetDocumentModelWithSiteDescriptor()
+            throws Exception
+    {
+        System.out.println( "basedir: " + getBasedir() );
+        File descriptorFile = new File( testBaseDir() + "src/site/", "model_builder_site.xml" );
+        DecorationModel dModel = getDecorationModelFromFile( descriptorFile );
+        DocumentModel model =
+                new DocumentModelBuilder( new ModelBuilderMavenProjectStub(), dModel ).getDocumentModel();
+
+        DocumentTOC toc = model.getToc();
+        assertEquals( 1, toc.getItems().size() );
+        assertEquals( "Intro", ( (DocumentTOCItem) toc.getItems().get( 0 ) ).getName() );
+
+    }
+
+    private DecorationModel getDecorationModelFromFile( File descriptorFile )
+            throws IOException, XmlPullParserException
+    {
+        Reader reader = null;
+
+        try
+        {
+            reader = ReaderFactory.newXmlReader( descriptorFile );
+
+            return new DecorationXpp3Reader().read( reader );
+        }
+        finally
+        {
+            IOUtil.close( reader );
+        }
+    }
+
+    private String testBaseDir()
+    {
+        return getBasedir() + "/src/test/resources/unit/pdf/";
+    }
 }

Modified: maven/plugins/trunk/maven-pdf-plugin/src/test/resources/unit/pdf/pom_model_builder.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pdf-plugin/src/test/resources/unit/pdf/pom_model_builder.xml?rev=787400&r1=787399&r2=787400&view=diff
==============================================================================
--- maven/plugins/trunk/maven-pdf-plugin/src/test/resources/unit/pdf/pom_model_builder.xml (original)
+++ maven/plugins/trunk/maven-pdf-plugin/src/test/resources/unit/pdf/pom_model_builder.xml Mon Jun 22 21:11:36 2009
@@ -28,4 +28,22 @@
   <name>Test Name</name>
   <description>Test Description</description>
 
+  <developers>
+    <developer>
+      <id>devid</id>
+      <name>dev name</name>
+      <email>dev@email</email>
+      <organization>dev broetchengeber</organization>
+      <roles>
+        <role>dev main role</role>
+        <role>dev second role</role>
+      </roles>
+      <timezone>-15</timezone>
+    </developer>
+    <developer>
+      <id>devid2</id>
+      <name>dev name 2</name>
+    </developer>
+  </developers>
+
 </project>

Added: maven/plugins/trunk/maven-pdf-plugin/src/test/resources/unit/pdf/src/site/model_builder_site.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pdf-plugin/src/test/resources/unit/pdf/src/site/model_builder_site.xml?rev=787400&view=auto
==============================================================================
--- maven/plugins/trunk/maven-pdf-plugin/src/test/resources/unit/pdf/src/site/model_builder_site.xml (added)
+++ maven/plugins/trunk/maven-pdf-plugin/src/test/resources/unit/pdf/src/site/model_builder_site.xml Mon Jun 22 21:11:36 2009
@@ -0,0 +1,29 @@
+<?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.
+-->
+
+<project name="Teste mich!">
+
+  <body>
+    <menu name="Inhaltsverzeichnis">
+      <item name="Intro" href="index.html"/>
+    </menu>
+  </body>
+</project>

Propchange: maven/plugins/trunk/maven-pdf-plugin/src/test/resources/unit/pdf/src/site/model_builder_site.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-pdf-plugin/src/test/resources/unit/pdf/src/site/model_builder_site.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"