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 14:23:19 UTC

svn commit: r787217 - in /maven/plugins/trunk/maven-pdf-plugin/src/test: java/org/apache/maven/plugins/pdf/ java/org/apache/maven/plugins/pdf/stubs/ resources/unit/pdf/

Author: ltheussl
Date: Mon Jun 22 12:23:19 2009
New Revision: 787217

URL: http://svn.apache.org/viewvc?rev=787217&view=rev
Log:
Test for DocumentModelBuilder and DateBean

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

Added: maven/plugins/trunk/maven-pdf-plugin/src/test/java/org/apache/maven/plugins/pdf/DateBeanTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pdf-plugin/src/test/java/org/apache/maven/plugins/pdf/DateBeanTest.java?rev=787217&view=auto
==============================================================================
--- maven/plugins/trunk/maven-pdf-plugin/src/test/java/org/apache/maven/plugins/pdf/DateBeanTest.java (added)
+++ maven/plugins/trunk/maven-pdf-plugin/src/test/java/org/apache/maven/plugins/pdf/DateBeanTest.java Mon Jun 22 12:23:19 2009
@@ -0,0 +1,51 @@
+package org.apache.maven.plugins.pdf;
+
+/*
+ * 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.
+ */
+
+import java.util.Date;
+import junit.framework.TestCase;
+
+/**
+ *
+ * @author ltheussl
+ */
+public class DateBeanTest
+        extends TestCase
+{
+    /**
+     * Test DateBean.
+     */
+    public void testDateBean()
+    {
+        DateBean date = new DateBean();
+        date.setDate( new Date( 0L ) );
+
+        assertEquals( "1970-01-01", date.getDate() );
+        assertEquals( "1970-01-01T00:00:00Z", date.getDateTime() );
+        assertEquals( "01", date.getDay() );
+        assertEquals( "00", date.getHour() );
+        assertEquals( "000", date.getMillisecond() );
+        assertEquals( "00", date.getMinute() );
+        assertEquals( "01", date.getMonth() );
+        assertEquals( "00", date.getSecond() );
+        assertEquals( "00:00:00Z", date.getTime() );
+        assertEquals( "1970", date.getYear() );
+    }
+}

Propchange: maven/plugins/trunk/maven-pdf-plugin/src/test/java/org/apache/maven/plugins/pdf/DateBeanTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-pdf-plugin/src/test/java/org/apache/maven/plugins/pdf/DateBeanTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: 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=787217&view=auto
==============================================================================
--- maven/plugins/trunk/maven-pdf-plugin/src/test/java/org/apache/maven/plugins/pdf/DocumentModelBuilderTest.java (added)
+++ maven/plugins/trunk/maven-pdf-plugin/src/test/java/org/apache/maven/plugins/pdf/DocumentModelBuilderTest.java Mon Jun 22 12:23:19 2009
@@ -0,0 +1,80 @@
+package org.apache.maven.plugins.pdf;
+
+/*
+ * 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.
+ */
+
+import junit.framework.TestCase;
+
+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.plugins.pdf.stubs.ModelBuilderMavenProjectStub;
+
+/**
+ *
+ * @author ltheussl
+ * @version $Id$
+ */
+public class DocumentModelBuilderTest
+        extends TestCase
+{
+    /**
+     * Test of getDocumentModel method, of class DocumentModelBuilder.
+     */
+    public void testEmptyDocumentModel()
+    {
+        DocumentModel model = new DocumentModelBuilder( null ).getDocumentModel();
+
+        assertNotNull( model );
+        assertNull( model.getModelEncoding() );
+        assertNull( model.getOutputName() );
+        assertNotNull( model.getCover() );
+        assertNotNull( model.getMeta() );
+        assertNotNull( model.getToc() );
+    }
+
+    /**
+     * Test of getDocumentModel method, of class DocumentModelBuilder.
+     */
+    public void testGetDocumentModel()
+    {
+        DocumentModel model = new DocumentModelBuilder( new ModelBuilderMavenProjectStub() ).getDocumentModel();
+
+        assertEquals( "ISO-8859-1", model.getModelEncoding() );
+        assertEquals( "Test ArtifactId", model.getOutputName() );
+
+        DocumentCover cover = model.getCover();
+        assertEquals( "Test Version", cover.getCoverVersion() );
+        assertEquals( "Test Name", cover.getProjectName() );
+        assertEquals( "Test Name", cover.getCoverTitle() );
+        assertEquals( "v. Test Version", cover.getCoverSubTitle() );
+        assertEquals( 0, cover.getAuthors().size() );
+
+        DocumentMeta meta = model.getMeta();
+        assertEquals( "Test Description", meta.getDescription() );
+        assertEquals( 0, meta.getAuthors().size() );
+        assertEquals( "Test Name", meta.getSubject() );
+        assertEquals( "Test Name", meta.getTitle() );
+
+        DocumentTOC toc = model.getToc();
+        assertEquals( 0, toc.getItems().size() );
+    }
+}

Propchange: maven/plugins/trunk/maven-pdf-plugin/src/test/java/org/apache/maven/plugins/pdf/DocumentModelBuilderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-pdf-plugin/src/test/java/org/apache/maven/plugins/pdf/DocumentModelBuilderTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/plugins/trunk/maven-pdf-plugin/src/test/java/org/apache/maven/plugins/pdf/stubs/ModelBuilderMavenProjectStub.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pdf-plugin/src/test/java/org/apache/maven/plugins/pdf/stubs/ModelBuilderMavenProjectStub.java?rev=787217&view=auto
==============================================================================
--- maven/plugins/trunk/maven-pdf-plugin/src/test/java/org/apache/maven/plugins/pdf/stubs/ModelBuilderMavenProjectStub.java (added)
+++ maven/plugins/trunk/maven-pdf-plugin/src/test/java/org/apache/maven/plugins/pdf/stubs/ModelBuilderMavenProjectStub.java Mon Jun 22 12:23:19 2009
@@ -0,0 +1,66 @@
+package org.apache.maven.plugins.pdf.stubs;
+
+/*
+ * 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.
+ */
+
+import java.io.File;
+import java.io.FileReader;
+
+import org.apache.maven.model.Model;
+import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+
+/**
+ * @author ltheussl
+ * @version $Id$
+ */
+public class ModelBuilderMavenProjectStub
+    extends MavenProjectStub
+{
+    /**
+     * Stub to test the DocumentModelBuilder.
+     */
+    public ModelBuilderMavenProjectStub()
+    {
+        try
+        {
+            Model model = new MavenXpp3Reader().read(
+                    new FileReader( new File( getBasedir() + "/pom_model_builder.xml" ) ) );
+            setModel( model );
+
+            setGroupId( model.getGroupId() );
+            setArtifactId( model.getArtifactId() );
+            setVersion( model.getVersion() );
+            setName( model.getName() );
+            setDescription( model.getDescription() );
+        }
+        catch ( Exception e )
+        {
+            throw new RuntimeException( e );
+        }
+    }
+
+    /** {@inheritDoc}
+     * @return the test base dir: "/target/test-classes/unit/pdf/".
+     */
+    public File getBasedir()
+    {
+        return new File( super.getBasedir() + "/target/test-classes/unit/pdf/" );
+    }
+}

Propchange: maven/plugins/trunk/maven-pdf-plugin/src/test/java/org/apache/maven/plugins/pdf/stubs/ModelBuilderMavenProjectStub.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-pdf-plugin/src/test/java/org/apache/maven/plugins/pdf/stubs/ModelBuilderMavenProjectStub.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: 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=787217&view=auto
==============================================================================
--- maven/plugins/trunk/maven-pdf-plugin/src/test/resources/unit/pdf/pom_model_builder.xml (added)
+++ maven/plugins/trunk/maven-pdf-plugin/src/test/resources/unit/pdf/pom_model_builder.xml Mon Jun 22 12:23:19 2009
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!--
+  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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>Test GroupId</groupId>
+  <artifactId>Test ArtifactId</artifactId>
+  <version>Test Version</version>
+  <name>Test Name</name>
+  <description>Test Description</description>
+
+</project>

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

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