svn commit: r1801772 [7/11] - in /maven/plugins/trunk/maven-javadoc-plugin: ./ src/main/java/org/apache/maven/plugin/ src/main/java/org/apache/maven/plugins/ src/main/java/org/apache/maven/plugins/javadoc/ src/main/java/org/apache/maven/plugins/javadoc...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

svn commit: r1801772 [7/11] - in /maven/plugins/trunk/maven-javadoc-plugin: ./ src/main/java/org/apache/maven/plugin/ src/main/java/org/apache/maven/plugins/ src/main/java/org/apache/maven/plugins/javadoc/ src/main/java/org/apache/maven/plugins/javadoc...

rfscholte
Added: maven/plugins/trunk/maven-javadoc-plugin/src/main/resources/org/apache/maven/plugins/javadoc/java-api-package-list-1.8
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/main/resources/org/apache/maven/plugins/javadoc/java-api-package-list-1.8?rev=1801772&view=auto
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/main/resources/org/apache/maven/plugins/javadoc/java-api-package-list-1.8 (added)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/main/resources/org/apache/maven/plugins/javadoc/java-api-package-list-1.8 Wed Jul 12 19:59:51 2017
@@ -0,0 +1,217 @@
+java.applet
+java.awt
+java.awt.color
+java.awt.datatransfer
+java.awt.dnd
+java.awt.event
+java.awt.font
+java.awt.geom
+java.awt.im
+java.awt.im.spi
+java.awt.image
+java.awt.image.renderable
+java.awt.print
+java.beans
+java.beans.beancontext
+java.io
+java.lang
+java.lang.annotation
+java.lang.instrument
+java.lang.invoke
+java.lang.management
+java.lang.ref
+java.lang.reflect
+java.math
+java.net
+java.nio
+java.nio.channels
+java.nio.channels.spi
+java.nio.charset
+java.nio.charset.spi
+java.nio.file
+java.nio.file.attribute
+java.nio.file.spi
+java.rmi
+java.rmi.activation
+java.rmi.dgc
+java.rmi.registry
+java.rmi.server
+java.security
+java.security.acl
+java.security.cert
+java.security.interfaces
+java.security.spec
+java.sql
+java.text
+java.text.spi
+java.time
+java.time.chrono
+java.time.format
+java.time.temporal
+java.time.zone
+java.util
+java.util.concurrent
+java.util.concurrent.atomic
+java.util.concurrent.locks
+java.util.function
+java.util.jar
+java.util.logging
+java.util.prefs
+java.util.regex
+java.util.spi
+java.util.stream
+java.util.zip
+javax.accessibility
+javax.activation
+javax.activity
+javax.annotation
+javax.annotation.processing
+javax.crypto
+javax.crypto.interfaces
+javax.crypto.spec
+javax.imageio
+javax.imageio.event
+javax.imageio.metadata
+javax.imageio.plugins.bmp
+javax.imageio.plugins.jpeg
+javax.imageio.spi
+javax.imageio.stream
+javax.jws
+javax.jws.soap
+javax.lang.model
+javax.lang.model.element
+javax.lang.model.type
+javax.lang.model.util
+javax.management
+javax.management.loading
+javax.management.modelmbean
+javax.management.monitor
+javax.management.openmbean
+javax.management.relation
+javax.management.remote
+javax.management.remote.rmi
+javax.management.timer
+javax.naming
+javax.naming.directory
+javax.naming.event
+javax.naming.ldap
+javax.naming.spi
+javax.net
+javax.net.ssl
+javax.print
+javax.print.attribute
+javax.print.attribute.standard
+javax.print.event
+javax.rmi
+javax.rmi.CORBA
+javax.rmi.ssl
+javax.script
+javax.security.auth
+javax.security.auth.callback
+javax.security.auth.kerberos
+javax.security.auth.login
+javax.security.auth.spi
+javax.security.auth.x500
+javax.security.cert
+javax.security.sasl
+javax.sound.midi
+javax.sound.midi.spi
+javax.sound.sampled
+javax.sound.sampled.spi
+javax.sql
+javax.sql.rowset
+javax.sql.rowset.serial
+javax.sql.rowset.spi
+javax.swing
+javax.swing.border
+javax.swing.colorchooser
+javax.swing.event
+javax.swing.filechooser
+javax.swing.plaf
+javax.swing.plaf.basic
+javax.swing.plaf.metal
+javax.swing.plaf.multi
+javax.swing.plaf.nimbus
+javax.swing.plaf.synth
+javax.swing.table
+javax.swing.text
+javax.swing.text.html
+javax.swing.text.html.parser
+javax.swing.text.rtf
+javax.swing.tree
+javax.swing.undo
+javax.tools
+javax.transaction
+javax.transaction.xa
+javax.xml
+javax.xml.bind
+javax.xml.bind.annotation
+javax.xml.bind.annotation.adapters
+javax.xml.bind.attachment
+javax.xml.bind.helpers
+javax.xml.bind.util
+javax.xml.crypto
+javax.xml.crypto.dom
+javax.xml.crypto.dsig
+javax.xml.crypto.dsig.dom
+javax.xml.crypto.dsig.keyinfo
+javax.xml.crypto.dsig.spec
+javax.xml.datatype
+javax.xml.namespace
+javax.xml.parsers
+javax.xml.soap
+javax.xml.stream
+javax.xml.stream.events
+javax.xml.stream.util
+javax.xml.transform
+javax.xml.transform.dom
+javax.xml.transform.sax
+javax.xml.transform.stax
+javax.xml.transform.stream
+javax.xml.validation
+javax.xml.ws
+javax.xml.ws.handler
+javax.xml.ws.handler.soap
+javax.xml.ws.http
+javax.xml.ws.soap
+javax.xml.ws.spi
+javax.xml.ws.spi.http
+javax.xml.ws.wsaddressing
+javax.xml.xpath
+org.ietf.jgss
+org.omg.CORBA
+org.omg.CORBA.DynAnyPackage
+org.omg.CORBA.ORBPackage
+org.omg.CORBA.TypeCodePackage
+org.omg.CORBA.portable
+org.omg.CORBA_2_3
+org.omg.CORBA_2_3.portable
+org.omg.CosNaming
+org.omg.CosNaming.NamingContextExtPackage
+org.omg.CosNaming.NamingContextPackage
+org.omg.Dynamic
+org.omg.DynamicAny
+org.omg.DynamicAny.DynAnyFactoryPackage
+org.omg.DynamicAny.DynAnyPackage
+org.omg.IOP
+org.omg.IOP.CodecFactoryPackage
+org.omg.IOP.CodecPackage
+org.omg.Messaging
+org.omg.PortableInterceptor
+org.omg.PortableInterceptor.ORBInitInfoPackage
+org.omg.PortableServer
+org.omg.PortableServer.CurrentPackage
+org.omg.PortableServer.POAManagerPackage
+org.omg.PortableServer.POAPackage
+org.omg.PortableServer.ServantLocatorPackage
+org.omg.PortableServer.portable
+org.omg.SendingContext
+org.omg.stub.java.rmi
+org.w3c.dom
+org.w3c.dom.bootstrap
+org.w3c.dom.events
+org.w3c.dom.ls
+org.w3c.dom.views
+org.xml.sax
+org.xml.sax.ext
+org.xml.sax.helpers

Added: maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojoTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojoTest.java?rev=1801772&view=auto
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojoTest.java (added)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojoTest.java Wed Jul 12 19:59:51 2017
@@ -0,0 +1,210 @@
+package org.apache.maven.plugins.javadoc;
+
+/*
+ * 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 static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import org.apache.maven.plugins.javadoc.AbstractFixJavadocMojo;
+
+import junit.framework.TestCase;
+import junitx.util.PrivateAccessor;
+
+import com.thoughtworks.qdox.model.AbstractInheritableJavaEntity;
+import com.thoughtworks.qdox.model.DocletTag;
+import com.thoughtworks.qdox.model.IndentBuffer;
+import com.thoughtworks.qdox.model.JavaClass;
+
+public class AbstractFixJavadocMojoTest
+    extends TestCase
+{
+
+    public void testReplaceLinkTags_noLinkTag()
+        throws Throwable
+    {
+        String comment = "/** @see ConnectException */";
+        AbstractInheritableJavaEntity entity = spy( new PrivateAbstractInheritableJavaEntity() );
+        JavaClass clazz = mock( JavaClass.class );
+        when( entity.getParentClass() ).thenReturn( clazz );
+        when( clazz.resolveType( "ConnectException" ) ).thenReturn( "java.net.ConnectException" );
+        String newComment =
+            (String) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "replaceLinkTags", new Class[] {
+                String.class, AbstractInheritableJavaEntity.class }, new Object[] { comment, entity } );
+        assertEquals( "/** @see ConnectException */", newComment );
+    }
+
+    public void testReplaceLinkTags_oneLinkTag()
+        throws Throwable
+    {
+        String comment = "/** {@link ConnectException} */";
+        AbstractInheritableJavaEntity entity = spy( new PrivateAbstractInheritableJavaEntity() );
+        JavaClass clazz = mock( JavaClass.class );
+        when( entity.getParentClass() ).thenReturn( clazz );
+        when( clazz.resolveType( "ConnectException" ) ).thenReturn( "java.net.ConnectException" );
+        String newComment =
+            (String) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "replaceLinkTags", new Class[] {
+                String.class, AbstractInheritableJavaEntity.class }, new Object[] { comment, entity } );
+        assertEquals( "/** {@link java.net.ConnectException} */", newComment );
+    }
+
+    public void testReplaceLinkTags_missingEndBrace()
+        throws Throwable
+    {
+        String comment = "/** {@link ConnectException */";
+        AbstractInheritableJavaEntity entity = spy( new PrivateAbstractInheritableJavaEntity() );
+        JavaClass clazz = mock( JavaClass.class );
+        when( entity.getParentClass() ).thenReturn( clazz );
+        when( clazz.resolveType( "ConnectException" ) ).thenReturn( "java.net.ConnectException" );
+        String newComment =
+            (String) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "replaceLinkTags", new Class[] {
+                String.class, AbstractInheritableJavaEntity.class }, new Object[] { comment, entity } );
+
+        assertEquals( "/** {@link ConnectException */", newComment );
+    }
+
+    public void testReplaceLinkTags_spacesAfterLinkTag()
+        throws Throwable
+    {
+        String comment = "/** {@link     ConnectException} */";
+        AbstractInheritableJavaEntity entity = spy( new PrivateAbstractInheritableJavaEntity() );
+        JavaClass clazz = mock( JavaClass.class );
+        when( entity.getParentClass() ).thenReturn( clazz );
+        when( clazz.resolveType( "ConnectException" ) ).thenReturn( "java.net.ConnectException" );
+        String newComment =
+            (String) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "replaceLinkTags", new Class[] {
+                String.class, AbstractInheritableJavaEntity.class }, new Object[] { comment, entity } );
+
+        assertEquals( "/** {@link java.net.ConnectException} */", newComment );
+    }
+
+    public void testReplaceLinkTags_spacesAfterClassName()
+        throws Throwable
+    {
+        String comment = "/** {@link ConnectException       } */";
+        AbstractInheritableJavaEntity entity = spy( new PrivateAbstractInheritableJavaEntity() );
+        JavaClass clazz = mock( JavaClass.class );
+        when( entity.getParentClass() ).thenReturn( clazz );
+        when( clazz.resolveType( "ConnectException" ) ).thenReturn( "java.net.ConnectException" );
+        String newComment =
+            (String) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "replaceLinkTags", new Class[] {
+                String.class, AbstractInheritableJavaEntity.class }, new Object[] { comment, entity } );
+
+        assertEquals( "/** {@link java.net.ConnectException} */", newComment );
+    }
+
+    public void testReplaceLinkTags_spacesAfterMethod()
+        throws Throwable
+    {
+        String comment = "/** {@link ConnectException#getMessage()       } */";
+        AbstractInheritableJavaEntity entity = spy( new PrivateAbstractInheritableJavaEntity() );
+        JavaClass clazz = mock( JavaClass.class );
+        when( entity.getParentClass() ).thenReturn( clazz );
+        when( clazz.resolveType( "ConnectException" ) ).thenReturn( "java.net.ConnectException" );
+        String newComment =
+            (String) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "replaceLinkTags", new Class[] {
+                String.class, AbstractInheritableJavaEntity.class }, new Object[] { comment, entity } );
+
+        assertEquals( "/** {@link java.net.ConnectException#getMessage()} */", newComment );
+    }
+
+    public void testReplaceLinkTags_containingHash()
+        throws Throwable
+    {
+        String comment = "/** {@link ConnectException#getMessage()} */";
+        AbstractInheritableJavaEntity entity = spy( new PrivateAbstractInheritableJavaEntity() );
+        JavaClass clazz = mock( JavaClass.class );
+        when( entity.getParentClass() ).thenReturn( clazz );
+        when( clazz.resolveType( "ConnectException" ) ).thenReturn( "java.net.ConnectException" );
+        String newComment =
+            (String) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "replaceLinkTags", new Class[] {
+                String.class, AbstractInheritableJavaEntity.class }, new Object[] { comment, entity } );
+
+        assertEquals( "/** {@link java.net.ConnectException#getMessage()} */", newComment );
+    }
+
+    public void testReplaceLinkTags_followedByHash()
+        throws Throwable
+    {
+        String comment = "/** {@link ConnectException} ##important## */";
+        AbstractInheritableJavaEntity entity = spy( new PrivateAbstractInheritableJavaEntity() );
+        JavaClass clazz = mock( JavaClass.class );
+        when( entity.getParentClass() ).thenReturn( clazz );
+        when( clazz.resolveType( "ConnectException" ) ).thenReturn( "java.net.ConnectException" );
+        String newComment =
+            (String) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "replaceLinkTags", new Class[] {
+                String.class, AbstractInheritableJavaEntity.class }, new Object[] { comment, entity } );
+
+        assertEquals( "/** {@link java.net.ConnectException} ##important## */", newComment );
+    }
+
+    public void testReplaceLinkTags_twoLinks()
+        throws Throwable
+    {
+        String comment = "/** Use {@link ConnectException} instead of {@link Exception} */";
+        AbstractInheritableJavaEntity entity = spy( new PrivateAbstractInheritableJavaEntity() );
+        JavaClass clazz = mock( JavaClass.class );
+        when( entity.getParentClass() ).thenReturn( clazz );
+        when( clazz.resolveType( "ConnectException" ) ).thenReturn( "java.net.ConnectException" );
+        when( clazz.resolveType( "Exception" ) ).thenReturn( "java.lang.Exception" );
+        String newComment =
+            (String) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "replaceLinkTags", new Class[] {
+                String.class, AbstractInheritableJavaEntity.class }, new Object[] { comment, entity } );
+
+        assertEquals( "/** Use {@link java.net.ConnectException} instead of {@link java.lang.Exception} */", newComment );
+    }
+
+    public void testReplaceLinkTags_OnlyAnchor()
+        throws Throwable
+    {
+        String comment = "/** There's a {@link #getClass()} but no setClass() */";
+        AbstractInheritableJavaEntity entity = spy( new PrivateAbstractInheritableJavaEntity() );
+        JavaClass clazz = mock( JavaClass.class );
+        when( entity.getParentClass() ).thenReturn( clazz );
+        when( clazz.resolveType( "ConnectException" ) ).thenReturn( "java.net.ConnectException" );
+        when( clazz.resolveType( "Exception" ) ).thenReturn( "java.lang.Exception" );
+
+        String newComment =
+            (String) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "replaceLinkTags", new Class[] {
+                String.class, AbstractInheritableJavaEntity.class }, new Object[] { comment, entity } );
+
+        assertEquals( "/** There's a {@link #getClass()} but no setClass() */", newComment );
+    }
+
+    protected class PrivateAbstractInheritableJavaEntity
+        extends AbstractInheritableJavaEntity
+    {
+        public int compareTo( Object o )
+        {
+            return 0;
+        }
+
+        @Override
+        public DocletTag[] getTagsByName( String arg0, boolean arg1 )
+        {
+            return null;
+        }
+
+        @Override
+        protected void writeBody( IndentBuffer arg0 )
+        {
+        }
+    }
+}

Added: maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojoTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojoTest.java?rev=1801772&view=auto
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojoTest.java (added)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojoTest.java Wed Jul 12 19:59:51 2017
@@ -0,0 +1,79 @@
+package org.apache.maven.plugins.javadoc;
+
+/*
+ * 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 static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.io.File;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.plugins.javadoc.AbstractJavadocMojo;
+
+import junit.framework.TestCase;
+
+public class AbstractJavadocMojoTest
+    extends TestCase
+{
+    AbstractJavadocMojo mojo;
+    
+    @Override
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+        mojo = new AbstractJavadocMojo()
+        {
+            @Override
+            public void doExecute()
+                throws MojoExecutionException, MojoFailureException
+            {
+            }
+        };
+    }
+    
+    public void testMJAVADOC432_DetectLinksMessages()
+    {
+        Log log = mock( Log.class );
+        when( log.isErrorEnabled() ).thenReturn( true );
+        mojo.setLog( log );
+        mojo.outputDirectory = new File( "target/test-classes" );
+
+        // first continues after warning, next exits with warning
+        assertFalse( mojo.isValidJavadocLink( new File( "pom.xml" ).getPath(), true ) );
+        assertFalse( mojo.isValidJavadocLink( "file://%%", true ) );
+        assertFalse( mojo.isValidJavadocLink( new File( "pom.xml" ).toURI().toString(), true ) );
+        verify( log, times( 4 ) ).warn( anyString() );
+        verify( log, never() ).error( anyString() );
+
+        // first continues after error, next exits with error
+        assertFalse( mojo.isValidJavadocLink( new File( "pom.xml" ).getPath(), false ) );
+        assertFalse( mojo.isValidJavadocLink( "file://%%", false ) );
+        assertFalse( mojo.isValidJavadocLink( new File( "pom.xml" ).toURI().toString(), false ) );
+        verify( log, times( 4 ) ).error( anyString() );
+        verify( log, times( 4 ) ).warn( anyString() ); // no extra warnings
+    }
+}

Added: maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugins/javadoc/AggregatorJavadocReportTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugins/javadoc/AggregatorJavadocReportTest.java?rev=1801772&view=auto
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugins/javadoc/AggregatorJavadocReportTest.java (added)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugins/javadoc/AggregatorJavadocReportTest.java Wed Jul 12 19:59:51 2017
@@ -0,0 +1,238 @@
+package org.apache.maven.plugins.javadoc;
+
+import java.io.BufferedReader;
+
+/*
+ * 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 java.io.IOException;
+import java.util.List;
+
+import org.apache.maven.model.Plugin;
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.apache.maven.plugins.javadoc.JavadocReport;
+import org.codehaus.plexus.util.FileUtils;
+
+public class AggregatorJavadocReportTest
+    extends AbstractMojoTestCase
+{
+    private static final char LINE_SEPARATOR = ' ';
+
+    /** flag to copy repo only one time */
+    private static boolean TEST_REPO_CREATED = false;
+
+    private File unit;
+
+    private File localRepo;
+
+    /** {@inheritDoc} */
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        unit = new File( getBasedir(), "src/test/resources/unit" );
+
+        localRepo = new File( getBasedir(), "target/local-repo/" );
+
+        createTestRepo();
+    }
+
+    private JavadocReport lookupMojo( File testPom )
+        throws Exception
+    {
+        JavadocReport mojo = (JavadocReport) lookupMojo( "aggregate", testPom );
+
+        PluginDescriptor pluginDescriptor = new PluginDescriptor();
+        pluginDescriptor.setPlugin( new Plugin() );
+
+        setVariableValueToObject( mojo, "plugin", pluginDescriptor );
+        return mojo;
+    }
+
+    /**
+     * Create test repository in target directory.
+     *
+     * @throws IOException if any
+     */
+    private void createTestRepo()
+        throws IOException
+    {
+        if ( TEST_REPO_CREATED )
+        {
+            return;
+        }
+
+        localRepo.mkdirs();
+
+        // ----------------------------------------------------------------------
+        // UMLGraph
+        // ----------------------------------------------------------------------
+
+        File sourceDir = new File( unit, "doclet-test/artifact-doclet" );
+        assertTrue( sourceDir.exists() );
+        FileUtils.copyDirectoryStructure( sourceDir, localRepo );
+
+        // ----------------------------------------------------------------------
+        // UMLGraph-bis
+        // ----------------------------------------------------------------------
+
+        sourceDir = new File( unit, "doclet-path-test/artifact-doclet" );
+        assertTrue( sourceDir.exists() );
+        FileUtils.copyDirectoryStructure( sourceDir, localRepo );
+
+        // ----------------------------------------------------------------------
+        // commons-attributes-compiler
+        // http://www.tullmann.org/pat/taglets/
+        // ----------------------------------------------------------------------
+
+        sourceDir = new File( unit, "taglet-test/artifact-taglet" );
+        assertTrue( sourceDir.exists() );
+        FileUtils.copyDirectoryStructure( sourceDir, localRepo );
+
+        // ----------------------------------------------------------------------
+        // stylesheetfile-test
+        // ----------------------------------------------------------------------
+
+        sourceDir = new File( unit, "stylesheetfile-test/artifact-stylesheetfile" );
+        assertTrue( sourceDir.exists() );
+        FileUtils.copyDirectoryStructure( sourceDir, localRepo );
+
+        // ----------------------------------------------------------------------
+        // helpfile-test
+        // ----------------------------------------------------------------------
+
+        sourceDir = new File( unit, "helpfile-test/artifact-helpfile" );
+        assertTrue( sourceDir.exists() );
+        FileUtils.copyDirectoryStructure( sourceDir, localRepo );
+
+        // Remove SCM files
+        List<String> files = FileUtils.getFileAndDirectoryNames( localRepo, FileUtils.getDefaultExcludesAsString(),
+                                                                 null, true, true, true, true );
+        for ( String filename : files )
+        {
+            File file = new File( filename );
+
+            if ( file.isDirectory() )
+            {
+                FileUtils.deleteDirectory( file );
+            }
+            else
+            {
+                file.delete();
+            }
+        }
+
+        TEST_REPO_CREATED = true;
+    }
+
+    /**
+     * Convenience method that reads the contents of the specified file object into a string with a <code>space</code>
+     * as line separator.
+     *
+     * @see #LINE_SEPARATOR
+     * @param file the file to be read
+     * @return a String object that contains the contents of the file
+     * @throws IOException if any
+     */
+    private static String readFile( File file )
+        throws IOException
+    {
+        String strTmp;
+        StringBuilder str = new StringBuilder( (int) file.length() );
+        BufferedReader in = new BufferedReader( new FileReader( file ) );
+
+        try
+        {
+            while ( ( strTmp = in.readLine() ) != null )
+            {
+                str.append( LINE_SEPARATOR );
+                str.append( strTmp );
+            }
+        }
+        finally
+        {
+            in.close();
+        }
+
+        return str.toString();
+    }
+
+    /**
+     * Method to test the aggregate parameter
+     *
+     * @throws Exception if any
+     */
+    public void testAggregate()
+        throws Exception
+    {
+        File testPom = new File( unit, "aggregate-test/aggregate-test-plugin-config.xml" );
+        JavadocReport mojo = (JavadocReport) lookupMojo( testPom );
+        mojo.execute();
+
+        File apidocs = new File( getBasedir(), "target/test/unit/aggregate-test/target/site/apidocs/" );
+
+        // check if project1 api files exist
+        assertTrue( new File( apidocs, "aggregate/test/project1/Project1App.html" ).exists() );
+        assertTrue( new File( apidocs, "aggregate/test/project1/Project1AppSample.html" ).exists() );
+        assertTrue( new File( apidocs, "aggregate/test/project1/Project1Sample.html" ).exists() );
+        assertTrue( new File( apidocs, "aggregate/test/project1/Project1Test.html" ).exists() );
+
+        // check if project2 api files exist
+        assertTrue( new File( apidocs, "aggregate/test/project2/Project2App.html" ).exists() );
+        assertTrue( new File( apidocs, "aggregate/test/project2/Project2AppSample.html" ).exists() );
+        assertTrue( new File( apidocs, "aggregate/test/project2/Project2Sample.html" ).exists() );
+        assertTrue( new File( apidocs, "aggregate/test/project2/Project2Test.html" ).exists() );
+    }
+
+    /**
+     * Test the javadoc resources in the aggregation case.
+     *
+     * @throws Exception if any
+     */
+    public void testAggregateJavadocResources()
+        throws Exception
+    {
+        File testPom = new File( unit, "aggregate-resources-test/aggregate-resources-test-plugin-config.xml" );
+        JavadocReport mojo = (JavadocReport) lookupMojo( testPom );
+        mojo.execute();
+
+        File apidocs = new File( getBasedir(), "target/test/unit/aggregate-resources-test/target/site/apidocs" );
+
+        // Test overview
+        File overviewSummary = new File( apidocs, "overview-summary.html" );
+        assertTrue( overviewSummary.exists() );
+        String overview = readFile( overviewSummary ).toLowerCase();
+        assertTrue( overview.contains( "<a href=\"resources/test/package-summary.html\">resources.test</a>" ) );
+        assertTrue( overview.contains( ">blabla</" ) );
+        assertTrue( overview.contains( "<a href=\"resources/test2/package-summary.html\">resources.test2</a>" ) );
+        assertTrue( overview.contains( "<a href=\"resources2/test/package-summary.html\">resources2.test</a>" ) );
+        assertTrue( overview.contains( "<a href=\"resources2/test2/package-summary.html\">resources2.test2</a>" ) );
+
+        // Test doc-files
+        File app = new File( apidocs, "resources/test/App.html" );
+        assertTrue( app.exists() );
+        overview = readFile( app );
+        assertTrue( overview.contains( "<img src=\"doc-files/maven-feather.png\" alt=\"Maven\">" ) );
+        assertTrue( new File( apidocs, "resources/test/doc-files/maven-feather.png" ).exists() );
+    }
+}

Added: maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugins/javadoc/FixJavadocMojoTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugins/javadoc/FixJavadocMojoTest.java?rev=1801772&view=auto
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugins/javadoc/FixJavadocMojoTest.java (added)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugins/javadoc/FixJavadocMojoTest.java Wed Jul 12 19:59:51 2017
@@ -0,0 +1,759 @@
+package org.apache.maven.plugins.javadoc;
+
+/*
+ * 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.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.List;
+
+import junitx.util.PrivateAccessor;
+
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+import org.apache.maven.plugins.javadoc.AbstractFixJavadocMojo;
+import org.apache.maven.plugins.javadoc.FixJavadocMojo;
+import org.apache.maven.plugins.javadoc.JavadocUtil;
+import org.apache.maven.plugins.javadoc.AbstractFixJavadocMojo.JavaEntityTags;
+import org.apache.maven.shared.invoker.MavenInvocationException;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.ReaderFactory;
+import org.codehaus.plexus.util.StringUtils;
+
+import com.thoughtworks.qdox.JavaDocBuilder;
+import com.thoughtworks.qdox.model.AbstractInheritableJavaEntity;
+import com.thoughtworks.qdox.model.AbstractJavaEntity;
+import com.thoughtworks.qdox.model.DocletTag;
+import com.thoughtworks.qdox.model.JavaClass;
+import com.thoughtworks.qdox.model.JavaMethod;
+
+/**
+ * @author <a href="mailto:[hidden email]">Vincent Siveton</a>
+ * @version $Id: FixJavadocMojoTest.java 1752069 2016-07-10 09:58:59Z rfscholte $
+ */
+public class FixJavadocMojoTest
+    extends AbstractMojoTestCase
+{
+    /** The vm line separator */
+    private static final String EOL = System.getProperty( "line.separator" );
+
+    /** flag to copy repo only one time */
+    private static boolean TEST_REPO_CREATED = false;
+
+    /** {@inheritDoc} */
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        createTestRepo();
+    }
+
+    /**
+     * Create test repository in target directory.
+     *
+     * @throws IOException if any
+     */
+    private void createTestRepo()
+        throws IOException
+    {
+        if ( TEST_REPO_CREATED )
+        {
+            return;
+        }
+
+        File localRepo = new File( getBasedir(), "target/local-repo/" );
+        localRepo.mkdirs();
+
+        // ----------------------------------------------------------------------
+        // fix-test-1.0.jar
+        // ----------------------------------------------------------------------
+
+        File sourceDir = new File( getBasedir(), "src/test/resources/unit/fix-test/repo/" );
+        assertTrue( sourceDir.exists() );
+        FileUtils.copyDirectoryStructure( sourceDir, localRepo );
+
+        // ----------------------------------------------------------------------
+        // fix-jdk5-test-1.0.jar
+        // ----------------------------------------------------------------------
+
+        sourceDir = new File( getBasedir(), "src/test/resources/unit/fix-jdk5-test/repo/" );
+        assertTrue( sourceDir.exists() );
+        FileUtils.copyDirectoryStructure( sourceDir, localRepo );
+
+        // ----------------------------------------------------------------------
+        // fix-jdk6-test-1.0.jar
+        // ----------------------------------------------------------------------
+
+        sourceDir = new File( getBasedir(), "src/test/resources/unit/fix-jdk6-test/repo/" );
+        assertTrue( sourceDir.exists() );
+        FileUtils.copyDirectoryStructure( sourceDir, localRepo );
+
+        // Remove SCM files
+        List<String> files =
+            FileUtils.getFileAndDirectoryNames( localRepo, FileUtils.getDefaultExcludesAsString(), null, true,
+                                                true, true, true );
+        for ( String filename : files )
+        {
+            File file = new File( filename );
+
+            if ( file.isDirectory() )
+            {
+                FileUtils.deleteDirectory( file );
+            }
+            else
+            {
+                file.delete();
+            }
+        }
+
+        TEST_REPO_CREATED = true;
+    }
+
+    /**
+     * @throws Exception if any
+     */
+    public void testFix()
+        throws Exception
+    {
+        File testPomBasedir = new File( getBasedir(), "target/test/unit/fix-test" );
+
+        executeMojoAndTest( testPomBasedir, new String[] { "ClassWithJavadoc.java", "ClassWithNoJavadoc.java",
+            "InterfaceWithJavadoc.java", "InterfaceWithNoJavadoc.java" } );
+    }
+
+    /**
+     * @throws Exception if any
+     */
+    public void testFixJdk5()
+        throws Exception
+    {
+        File testPomBasedir = new File( getBasedir(), "target/test/unit/fix-jdk5-test" );
+        executeMojoAndTest( testPomBasedir, new String[] { "ClassWithJavadoc.java", "ClassWithNoJavadoc.java",
+            "InterfaceWithJavadoc.java", "InterfaceWithNoJavadoc.java", "SubClassWithJavadoc.java" } );
+    }
+
+    /**
+     * @throws Exception if any
+     */
+    public void testFixJdk6()
+        throws Exception
+    {
+        File testPomBasedir = new File( getBasedir(), "target/test/unit/fix-jdk6-test" );
+        executeMojoAndTest( testPomBasedir, new String[] { "ClassWithJavadoc.java", "InterfaceWithJavadoc.java" } );
+    }
+
+    // ----------------------------------------------------------------------
+    // Test private static methods
+    // ----------------------------------------------------------------------
+
+    /**
+     * @throws Throwable if any
+     */
+    public void testAutodetectIndentation()
+        throws Throwable
+    {
+        String s = null;
+        assertEquals( "", PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "autodetectIndentation",
+                                                  new Class[] { String.class }, new Object[] { s } ) );
+
+        s = "no indentation";
+        assertEquals( "", PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "autodetectIndentation",
+                                                  new Class[] { String.class }, new Object[] { s } ) );
+
+        s = "no indentation with right spaces  ";
+        assertEquals( "", PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "autodetectIndentation",
+                                                  new Class[] { String.class }, new Object[] { s } ) );
+
+        s = "    indentation";
+        assertEquals( "    ", PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "autodetectIndentation",
+                                                      new Class[] { String.class }, new Object[] { s } ) );
+
+        s = "    indentation with right spaces  ";
+        assertEquals( "    ", PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "autodetectIndentation",
+                                                      new Class[] { String.class }, new Object[] { s } ) );
+
+        s = "\ttab indentation";
+        assertEquals( "\t", PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "autodetectIndentation",
+                                                    new Class[] { String.class }, new Object[] { s } ) );
+
+        s = "  \n  indentation with right spaces  ";
+        assertEquals( "  \n  ", PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "autodetectIndentation",
+                                                        new Class[] { String.class }, new Object[] { s } ) );
+    }
+
+    /**
+     * @throws Throwable if any
+     */
+    public void testTrimLeft()
+        throws Throwable
+    {
+        assertEquals( "", PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "trimLeft",
+                                                  new Class[] { String.class }, new Object[] { null } ) );
+        assertEquals( "", PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "trimLeft",
+                                                  new Class[] { String.class }, new Object[] { "  " } ) );
+        assertEquals( "", PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "trimLeft",
+                                                  new Class[] { String.class }, new Object[] { "  \t  " } ) );
+        assertEquals( "a", PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "trimLeft",
+                                                   new Class[] { String.class }, new Object[] { "a" } ) );
+        assertEquals( "a", PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "trimLeft",
+                                                   new Class[] { String.class }, new Object[] { "  a" } ) );
+        assertEquals( "a", PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "trimLeft",
+                                                   new Class[] { String.class }, new Object[] { "\ta" } ) );
+        assertEquals( "a  ", PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "trimLeft",
+                                                     new Class[] { String.class }, new Object[] { "  a  " } ) );
+        assertEquals( "a\t", PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "trimLeft",
+                                                     new Class[] { String.class }, new Object[] { "\ta\t" } ) );
+    }
+
+    /**
+     * @throws Throwable if any
+     */
+    public void testTrimRight()
+        throws Throwable
+    {
+        assertEquals( "", PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "trimRight",
+                                                  new Class[] { String.class }, new Object[] { null } ) );
+        assertEquals( "", PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "trimRight",
+                                                  new Class[] { String.class }, new Object[] { "  " } ) );
+        assertEquals( "", PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "trimRight",
+                                                  new Class[] { String.class }, new Object[] { "  \t  " } ) );
+        assertEquals( "a", PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "trimRight",
+                                                   new Class[] { String.class }, new Object[] { "a" } ) );
+        assertEquals( "a", PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "trimRight",
+                                                   new Class[] { String.class }, new Object[] { "a  " } ) );
+        assertEquals( "a", PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "trimRight",
+                                                   new Class[] { String.class }, new Object[] { "a\t" } ) );
+        assertEquals( "  a", PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "trimRight",
+                                                     new Class[] { String.class }, new Object[] { "  a  " } ) );
+        assertEquals( "\ta", PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "trimRight",
+                                                     new Class[] { String.class }, new Object[] { "\ta\t" } ) );
+    }
+
+    /**
+     * @throws Throwable if any
+     */
+    public void testHasInheritedTag()
+        throws Throwable
+    {
+        String content = "/** {@inheritDoc} */";
+        Boolean has =
+            (Boolean) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "hasInheritedTag",
+                                              new Class[] { String.class }, new Object[] { content } );
+        assertEquals( Boolean.TRUE, has );
+
+        content = "/**{@inheritDoc}*/";
+        has =
+            (Boolean) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "hasInheritedTag",
+                                              new Class[] { String.class }, new Object[] { content } );
+        assertEquals( Boolean.TRUE, has );
+
+        content = "/**{@inheritDoc  }  */";
+        has =
+            (Boolean) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "hasInheritedTag",
+                                              new Class[] { String.class }, new Object[] { content } );
+        assertEquals( Boolean.TRUE, has );
+
+        content = "/**  {@inheritDoc  }  */";
+        has =
+            (Boolean) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "hasInheritedTag",
+                                              new Class[] { String.class }, new Object[] { content } );
+        assertEquals( Boolean.TRUE, has );
+
+        content = "/** */";
+        has =
+            (Boolean) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "hasInheritedTag",
+                                              new Class[] { String.class }, new Object[] { content } );
+        assertEquals( Boolean.FALSE, has );
+
+        content = "/**{  @inheritDoc  }*/";
+        has =
+            (Boolean) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "hasInheritedTag",
+                                              new Class[] { String.class }, new Object[] { content } );
+        assertEquals( Boolean.FALSE, has );
+
+        content = "/**{@ inheritDoc}*/";
+        has =
+            (Boolean) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "hasInheritedTag",
+                                              new Class[] { String.class }, new Object[] { content } );
+        assertEquals( Boolean.FALSE, has );
+    }
+
+    /**
+     * @throws Throwable if any
+     */
+    public void testJavadocComment()
+        throws Throwable
+    {
+        String content = "/**" + EOL +
+                " * Dummy Class." + EOL +
+                " */" + EOL +
+                "public class DummyClass" + EOL +
+                "{" + EOL +
+                "    /**" + EOL +
+                "     *" + EOL +
+                "     * Dummy" + EOL +
+                "     *" + EOL +
+                "     *      Method." + EOL +
+                "     *" + EOL +
+                "     * @param args not" + EOL +
+                "     *" + EOL +
+                "     * null" + EOL +
+                "     * @param i non negative" + EOL +
+                "     * @param object could" + EOL +
+                "     * be" + EOL +
+                "     *      null" + EOL +
+                "     * @return a" + EOL +
+                "     * String" + EOL +
+                "     *" + EOL +
+                "     * @throws Exception if" + EOL +
+                "     * any" + EOL +
+                "     *" + EOL +
+                "     */" + EOL +
+                "    public static String dummyMethod( String[] args, int i, Object object )" + EOL +
+                "        throws Exception" + EOL +
+                "    {" + EOL +
+                "        return null;" + EOL +
+                "    }" + EOL +
+                "}";
+
+        JavaDocBuilder builder = new JavaDocBuilder();
+        builder.setEncoding( "UTF-8" );
+        builder.addSource( new StringReader( content ) );
+
+        JavaClass[] classes = builder.getClasses();
+        JavaClass clazz = classes[0];
+
+        JavaMethod javaMethod = clazz.getMethods()[0];
+
+        String javadoc =
+            (String) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "extractOriginalJavadoc", new Class[] {
+                String.class, AbstractJavaEntity.class }, new Object[] { content, javaMethod } );
+        assertEquals( "    /**" + EOL +
+                "     *" + EOL +
+                "     * Dummy" + EOL +
+                "     *" + EOL +
+                "     *      Method." + EOL +
+                "     *" + EOL +
+                "     * @param args not" + EOL +
+                "     *" + EOL +
+                "     * null" + EOL +
+                "     * @param i non negative" + EOL +
+                "     * @param object could" + EOL +
+                "     * be" + EOL +
+                "     *      null" + EOL +
+                "     * @return a" + EOL +
+                "     * String" + EOL +
+                "     *" + EOL +
+                "     * @throws Exception if" + EOL +
+                "     * any" + EOL +
+                "     *" + EOL +
+                "     */", javadoc );
+
+        String javadocContent =
+            (String) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "extractOriginalJavadocContent",
+                                             new Class[] { String.class, AbstractJavaEntity.class }, new Object[] {
+                                                 content, javaMethod } );
+        assertEquals( "     *" + EOL +
+                      "     * Dummy" + EOL +
+                      "     *" + EOL +
+                      "     *      Method." + EOL +
+                      "     *" + EOL +
+                      "     * @param args not" + EOL +
+                      "     *" + EOL +
+                      "     * null" + EOL +
+                      "     * @param i non negative" + EOL +
+                      "     * @param object could" + EOL +
+                      "     * be" + EOL +
+                      "     *      null" + EOL +
+                      "     * @return a" + EOL +
+                      "     * String" + EOL +
+                      "     *" + EOL +
+                      "     * @throws Exception if" + EOL +
+                      "     * any" + EOL +
+                      "     *", javadocContent );
+
+        String withoutEmptyJavadocLines =
+            (String) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "removeLastEmptyJavadocLines",
+                                             new Class[] { String.class }, new Object[] { javadocContent } );
+        assertTrue( withoutEmptyJavadocLines.endsWith( "any" ) );
+
+        String methodJavadoc =
+            (String) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "getJavadocComment", new Class[] {
+                String.class, AbstractJavaEntity.class }, new Object[] { content, javaMethod } );
+        assertEquals( "     *" + EOL +
+                "     * Dummy" + EOL +
+                "     *" + EOL +
+                "     *      Method." + EOL +
+                "     *", methodJavadoc );
+        withoutEmptyJavadocLines =
+            (String) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "removeLastEmptyJavadocLines",
+                                             new Class[] { String.class }, new Object[] { methodJavadoc } );
+        assertTrue( withoutEmptyJavadocLines.endsWith( "Method." ) );
+
+        assertEquals( 5, javaMethod.getTags().length );
+
+        AbstractFixJavadocMojo mojoInstance = new FixJavadocMojo();
+        setVariableValueToObject( mojoInstance, "fixTagsSplitted", new String[] { "all" } );
+
+        DocletTag tag = javaMethod.getTags()[0];
+        String tagJavadoc =
+            (String) PrivateAccessor.invoke( mojoInstance, "getJavadocComment", new Class[] {
+                String.class, AbstractInheritableJavaEntity.class, DocletTag.class }, new Object[] { content,
+                javaMethod, tag } );
+        assertEquals( "     * @param args not" + EOL +
+                "     *" + EOL +
+                "     * null", tagJavadoc );
+        withoutEmptyJavadocLines =
+            (String) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "removeLastEmptyJavadocLines",
+                                             new Class[] { String.class }, new Object[] { tagJavadoc } );
+        assertTrue( withoutEmptyJavadocLines.endsWith( "null" ) );
+
+        tag = javaMethod.getTags()[1];
+        tagJavadoc =
+            (String) PrivateAccessor.invoke( mojoInstance, "getJavadocComment", new Class[] {
+                String.class, AbstractInheritableJavaEntity.class, DocletTag.class }, new Object[] { content,
+                javaMethod, tag } );
+        assertEquals( "     * @param i non negative", tagJavadoc );
+        withoutEmptyJavadocLines =
+            (String) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "removeLastEmptyJavadocLines",
+                                             new Class[] { String.class }, new Object[] { tagJavadoc } );
+        assertTrue( withoutEmptyJavadocLines.endsWith( "negative" ) );
+
+        tag = javaMethod.getTags()[2];
+        tagJavadoc =
+            (String) PrivateAccessor.invoke( mojoInstance, "getJavadocComment", new Class[] {
+                String.class, AbstractInheritableJavaEntity.class, DocletTag.class }, new Object[] { content,
+                javaMethod, tag } );
+        assertEquals( "     * @param object could" + EOL +
+                "     * be" + EOL +
+                "     *      null", tagJavadoc );
+        withoutEmptyJavadocLines =
+            (String) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "removeLastEmptyJavadocLines",
+                                             new Class[] { String.class }, new Object[] { tagJavadoc } );
+        assertTrue( withoutEmptyJavadocLines.endsWith( "null" ) );
+
+        tag = javaMethod.getTags()[3];
+        tagJavadoc =
+            (String) PrivateAccessor.invoke( mojoInstance, "getJavadocComment", new Class[] {
+                String.class, AbstractInheritableJavaEntity.class, DocletTag.class }, new Object[] { content,
+                javaMethod, tag } );
+        assertEquals( "     * @return a" + EOL +
+                "     * String" + EOL +
+                "     *", tagJavadoc );
+        withoutEmptyJavadocLines =
+            (String) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "removeLastEmptyJavadocLines",
+                                             new Class[] { String.class }, new Object[] { tagJavadoc } );
+        assertTrue( withoutEmptyJavadocLines.endsWith( "String" ) );
+
+        tag = javaMethod.getTags()[4];
+        tagJavadoc =
+            (String) PrivateAccessor.invoke( mojoInstance, "getJavadocComment", new Class[] {
+                String.class, AbstractInheritableJavaEntity.class, DocletTag.class }, new Object[] { content,
+                javaMethod, tag } );
+        assertEquals( "     * @throws Exception if" + EOL +
+                "     * any" + EOL +
+                "     *", tagJavadoc );
+        withoutEmptyJavadocLines =
+            (String) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "removeLastEmptyJavadocLines",
+                                             new Class[] { String.class }, new Object[] { tagJavadoc } );
+        assertTrue( withoutEmptyJavadocLines.endsWith( "any" ) );
+    }
+
+    /**
+     * @throws Throwable if any
+     */
+    public void testJavadocCommentJdk5()
+        throws Throwable
+    {
+        String content = "/**" + EOL +
+                " * Dummy Class." + EOL +
+                " */" + EOL +
+                "public class DummyClass" + EOL +
+                "{" + EOL +
+                "    /**" + EOL +
+                "     * Dummy method." + EOL +
+                "     *" + EOL +
+                "     * @param <K>  The Key type for the method" + EOL +
+                "     * @param <V>  The Value type for the method" + EOL +
+                "     * @param name The name." + EOL +
+                "     * @return A map configured." + EOL +
+                "     */" + EOL +
+                "    public <K, V> java.util.Map<K, V> dummyMethod( String name )" + EOL +
+                "    {" + EOL +
+                "        return null;" + EOL +
+                "    }" + EOL +
+                "}";
+
+        JavaDocBuilder builder = new JavaDocBuilder();
+        builder.setEncoding( "UTF-8" );
+        builder.addSource( new StringReader( content ) );
+
+        JavaClass[] classes = builder.getClasses();
+        JavaClass clazz = classes[0];
+
+        JavaMethod javaMethod = clazz.getMethods()[0];
+
+        String methodJavadoc =
+            (String) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "getJavadocComment", new Class[] {
+                String.class, AbstractJavaEntity.class }, new Object[] { content, javaMethod } );
+        assertEquals( "     * Dummy method." + EOL +
+                "     *", methodJavadoc );
+
+        assertEquals( 4, javaMethod.getTags().length );
+
+        AbstractFixJavadocMojo mojoInstance = new FixJavadocMojo();
+        setVariableValueToObject( mojoInstance, "fixTagsSplitted", new String[] { "all" } );
+
+        DocletTag tag = javaMethod.getTags()[0];
+        String tagJavadoc =
+            (String) PrivateAccessor.invoke( mojoInstance, "getJavadocComment", new Class[] {
+                String.class, AbstractInheritableJavaEntity.class, DocletTag.class }, new Object[] { content,
+                javaMethod, tag } );
+        assertEquals( "     * @param <K>  The Key type for the method", tagJavadoc );
+
+        tag = javaMethod.getTags()[1];
+        tagJavadoc =
+            (String) PrivateAccessor.invoke( mojoInstance, "getJavadocComment", new Class[] {
+                String.class, AbstractInheritableJavaEntity.class, DocletTag.class }, new Object[] { content,
+                javaMethod, tag } );
+        assertEquals( "     * @param <V>  The Value type for the method", tagJavadoc );
+
+        tag = javaMethod.getTags()[2];
+        tagJavadoc =
+            (String) PrivateAccessor.invoke( mojoInstance, "getJavadocComment", new Class[] {
+                String.class, AbstractInheritableJavaEntity.class, DocletTag.class }, new Object[] { content,
+                javaMethod, tag } );
+        assertEquals( "     * @param name The name.", tagJavadoc );
+
+        tag = javaMethod.getTags()[3];
+        tagJavadoc =
+            (String) PrivateAccessor.invoke( mojoInstance, "getJavadocComment", new Class[] {
+                String.class, AbstractInheritableJavaEntity.class, DocletTag.class }, new Object[] { content,
+                javaMethod, tag } );
+        assertEquals( "     * @return A map configured.", tagJavadoc );
+    }
+    
+    public void testInitParameters()
+        throws Throwable
+    {
+        AbstractFixJavadocMojo mojoInstance = new FixJavadocMojo();
+        setVariableValueToObject( mojoInstance, "fixTags", "author, version, since, param, return, throws, link" );
+        setVariableValueToObject(mojoInstance, "defaultSince", "1.0");
+        setVariableValueToObject(mojoInstance, "level", "protected");
+        
+        PrivateAccessor.invoke( mojoInstance, "init", new Class[] { }, new String[] { } );
+        
+        String[] fixTags = (String[]) getVariableValueFromObject(mojoInstance, "fixTagsSplitted");
+        
+        assertEquals("author", fixTags[0]);
+        assertEquals("version", fixTags[1]);
+        assertEquals("since", fixTags[2]);
+        assertEquals("param", fixTags[3]);
+        assertEquals("return", fixTags[4]);
+        assertEquals("throws", fixTags[5]);
+        assertEquals("link", fixTags[6]);
+        assertEquals(7, fixTags.length);
+        
+        setVariableValueToObject( mojoInstance, "fixTags", "return, fake_value" );
+        PrivateAccessor.invoke( mojoInstance, "init", new Class[] { }, new String[] { } );
+        fixTags = (String[]) getVariableValueFromObject(mojoInstance, "fixTagsSplitted");
+        
+        assertEquals("return", fixTags[0]);
+        assertEquals(1, fixTags.length);
+    }
+    
+    public void testRemoveUnknownExceptions() throws Exception
+    {
+        AbstractFixJavadocMojo mojoInstance = new FixJavadocMojo();
+        setVariableValueToObject( mojoInstance, "fixTagsSplitted", new String[] { "all" } );
+        setVariableValueToObject( mojoInstance, "project", new MavenProjectStub() );
+
+        String source = "package a.b.c;" + EOL
+                        + "public class Clazz {" + EOL
+                        + " /**" + EOL
+                        + " * @throws java.lang.RuntimeException" + EOL
+                        + " * @throws NumberFormatException" + EOL
+                        + " * @throws java.lang.Exception" + EOL // not thrown and no RTE -> remove
+                        + " * @throws com.foo.FatalException" + EOL // not on classpath (?!) -> see removeUnknownThrows
+                        + " */" + EOL
+                        + " public void method() {}" + EOL                        
+                        + "}";
+
+        JavaDocBuilder builder = new JavaDocBuilder();
+        JavaMethod javaMethod = builder.addSource( new StringReader( source ) ).getClasses()[0].getMethods()[0];
+        
+        JavaEntityTags javaEntityTags = mojoInstance.parseJavadocTags( source, javaMethod, "", true );
+        
+        StringBuilder sb = new StringBuilder();
+        mojoInstance.writeThrowsTag( sb, javaMethod, javaEntityTags, new String[] { "java.lang.RuntimeException" } );
+        assertEquals( " * @throws java.lang.RuntimeException", sb.toString() );
+
+        sb = new StringBuilder();
+        mojoInstance.writeThrowsTag( sb, javaMethod, javaEntityTags, new String[] { "NumberFormatException" } );
+        assertEquals( " * @throws java.lang.NumberFormatException", sb.toString() );
+
+        sb = new StringBuilder();
+        mojoInstance.writeThrowsTag( sb, javaMethod, javaEntityTags, new String[] { "java.lang.Exception" } );
+        assertEquals( "", sb.toString() );
+        
+        setVariableValueToObject( mojoInstance, "removeUnknownThrows", true );
+        sb = new StringBuilder();
+        mojoInstance.writeThrowsTag( sb, javaMethod, javaEntityTags, new String[] { "com.foo.FatalException" } );
+        assertEquals( "", sb.toString() );
+
+        setVariableValueToObject( mojoInstance, "removeUnknownThrows", false );
+        sb = new StringBuilder();
+        mojoInstance.writeThrowsTag( sb, javaMethod, javaEntityTags, new String[] { "com.foo.FatalException" } );
+        assertEquals( " * @throws com.foo.FatalException if any.", sb.toString() );
+    }
+
+    // ----------------------------------------------------------------------
+    // private methods
+    // ----------------------------------------------------------------------
+
+    /**
+     * @param testPomBasedir the basedir for the test project
+     * @param clazzToCompare an array of the classes name to compare
+     * @throws Exception if any
+     */
+    private void executeMojoAndTest( File testPomBasedir, String[] clazzToCompare )
+        throws Exception
+    {
+        prepareTestProjects( testPomBasedir.getName() );
+
+        File testPom = new File( testPomBasedir, "pom.xml" );
+        assertTrue( testPom.getAbsolutePath() + " should exist", testPom.exists() );
+
+        FixJavadocMojo mojo = (FixJavadocMojo) lookupMojo( "fix", testPom );
+        assertNotNull( mojo );
+
+        // compile the test project
+        invokeCompileGoal( testPom, mojo.getLog() );
+        assertTrue( new File( testPomBasedir, "target/classes" ).exists() );
+
+        mojo.execute();
+
+        File expectedDir = new File( testPomBasedir, "expected/src/main/java/fix/test" );
+        assertTrue( expectedDir.exists() );
+
+        File generatedDir = new File( testPomBasedir, "target/generated/fix/test" );
+        assertTrue( generatedDir.exists() );
+
+        for (String className : clazzToCompare) {
+            assertEquals(new File(expectedDir, className), new File(generatedDir, className));
+        }
+    }
+
+    /**
+     * Invoke the compilation on the given pom file.
+     *
+     * @param testPom not null
+     * @param log not null
+     * @throws MavenInvocationException if any
+     */
+    private void invokeCompileGoal( File testPom, Log log )
+        throws MavenInvocationException
+    {
+        List<String> goals = new ArrayList<String>();
+        goals.add( "clean" );
+        goals.add( "compile" );
+        File invokerDir = new File( getBasedir(), "target/invoker" );
+        invokerDir.mkdirs();
+        File invokerLogFile = FileUtils.createTempFile( "FixJavadocMojoTest", ".txt", invokerDir );
+        JavadocUtil.invokeMaven( log, new File( getBasedir(), "target/local-repo" ), testPom, goals, null,
+                                 invokerLogFile );
+    }
+
+    // ----------------------------------------------------------------------
+    // static methods
+    // ----------------------------------------------------------------------
+
+    /**
+     * Asserts that files are equal. If they are not an AssertionFailedError is thrown.
+     *
+     * @throws IOException if any
+     */
+    private static void assertEquals( File expected, File actual )
+        throws IOException
+    {
+        assertTrue( " Expected file DNE: " + expected, expected.exists() );
+        String expectedContent = StringUtils.unifyLineSeparators( readFile( expected ) );
+
+        assertTrue( " Actual file DNE: " + actual, actual.exists() );
+        String actualContent = StringUtils.unifyLineSeparators( readFile( actual ) );
+
+        assertEquals( "Expected file: " + expected.getAbsolutePath() + ", actual file: "
+            + actual.getAbsolutePath(), expectedContent, actualContent );
+    }
+
+    /**
+     * @param testProjectDirName not null
+     * @throws IOException if any
+     */
+    private static void prepareTestProjects( String testProjectDirName )
+        throws IOException
+    {
+        File testPomBasedir = new File( getBasedir(), "target/test/unit/" + testProjectDirName );
+
+        // Using unit test dir
+        FileUtils
+                 .copyDirectoryStructure(
+                                          new File( getBasedir(), "src/test/resources/unit/" + testProjectDirName ),
+                                          testPomBasedir );
+        List<String> scmFiles = FileUtils.getDirectoryNames( testPomBasedir, "**/.svn", null, true );
+        for ( String filename : scmFiles )
+        {
+            File dir = new File( filename );
+
+            if ( dir.isDirectory() )
+            {
+                FileUtils.deleteDirectory( dir );
+            }
+        }
+    }
+
+    /**
+     * @param file not null
+     * @return the content of the given file
+     * @throws IOException if any
+     */
+    private static String readFile( File file )
+        throws IOException
+    {
+        Reader fileReader = null;
+        try
+        {
+            fileReader = ReaderFactory.newReader( file, "UTF-8" );
+            final String content = IOUtil.toString( fileReader );
+            fileReader.close();
+            fileReader = null;
+            return content;
+        }
+        finally
+        {
+            IOUtil.close( fileReader );
+        }
+    }
+}

Added: maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugins/javadoc/JavadocJarTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugins/javadoc/JavadocJarTest.java?rev=1801772&view=auto
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugins/javadoc/JavadocJarTest.java (added)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugins/javadoc/JavadocJarTest.java Wed Jul 12 19:59:51 2017
@@ -0,0 +1,196 @@
+package org.apache.maven.plugins.javadoc;
+
+/*
+ * 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.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+import org.apache.maven.model.Plugin;
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.apache.maven.plugins.javadoc.AbstractJavadocMojo;
+import org.apache.maven.plugins.javadoc.JavadocJar;
+import org.apache.maven.plugins.javadoc.JavadocVersion;
+import org.codehaus.plexus.util.FileUtils;
+
+/**
+ * @author <a href="mailto:[hidden email]">Maria Odea Ching</a>
+ */
+public class JavadocJarTest
+    extends AbstractMojoTestCase
+{
+    
+    private JavadocJar lookupMojo( File testPom )
+                    throws Exception
+    {
+        JavadocJar mojo = (JavadocJar) lookupMojo( "jar", testPom );
+        
+        PluginDescriptor pluginDescriptor = new PluginDescriptor();
+        pluginDescriptor.setPlugin( new Plugin() );
+        
+        setVariableValueToObject( mojo, "plugin", pluginDescriptor );
+        return mojo;
+    }
+
+
+    /**
+     * Test when default configuration is provided
+     *
+     * @throws Exception if any
+     */
+    public void testDefaultConfig()
+        throws Exception
+    {
+        File testPom =
+            new File( getBasedir(), "src/test/resources/unit/javadocjar-default/javadocjar-default-plugin-config.xml" );
+        JavadocJar mojo = lookupMojo( testPom );
+        mojo.execute();
+
+        //check if the javadoc jar file was generated
+        File generatedFile =
+            new File( getBasedir(), "target/test/unit/javadocjar-default/target/javadocjar-default-javadoc.jar" );
+        assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
+
+        //validate contents of jar file
+        ZipFile jar = new ZipFile( generatedFile );
+        Set<String> set = new HashSet<String>();
+        for( Enumeration<? extends ZipEntry> entries = jar.entries(); entries.hasMoreElements(); )
+        {
+            ZipEntry entry = entries.nextElement();
+            set.add( entry.getName() );
+        }
+
+        assertTrue( set.contains( "stylesheet.css" ) );
+        JavadocVersion javadocVersion = (JavadocVersion) getVariableValueFromObject( mojo, "javadocRuntimeVersion" );
+        if ( javadocVersion.compareTo( JavadocVersion.parse( "1.7" ) ) < 0 )
+        {
+            assertTrue( set.contains( "resources/inherit.gif" ) );
+        }
+        else if ( javadocVersion.compareTo( JavadocVersion.parse( "1.8" ) ) < 0 )
+        {
+            assertTrue( set.contains( "resources/background.gif" ) /* JDK7 */);
+        }
+        else
+        {
+            // JDK8 has no resources anymore
+            assertFalse( set.contains( "resources" ) );
+        }
+
+        assertTrue( set.contains( "javadocjar/def/package-use.html" ) );
+        assertTrue( set.contains( "javadocjar/def/package-tree.html" ) );
+        assertTrue( set.contains( "javadocjar/def/package-summary.html" ) );
+        assertTrue( set.contains( "javadocjar/def/package-frame.html" ) );
+        assertTrue( set.contains( "javadocjar/def/class-use/AppSample.html" ) );
+        assertTrue( set.contains( "index.html" ) );
+        assertTrue( set.contains( "javadocjar/def/App.html" ) );
+        assertTrue( set.contains( "javadocjar/def/AppSample.html" ) );
+        assertTrue( set.contains( "javadocjar/def/class-use/App.html" ) );
+
+        assertFalse( set.contains( AbstractJavadocMojo.ARGFILE_FILE_NAME ) );
+        assertFalse( set.contains( AbstractJavadocMojo.FILES_FILE_NAME ) );
+        assertFalse( set.contains( AbstractJavadocMojo.OPTIONS_FILE_NAME ) );
+        assertFalse( set.contains( AbstractJavadocMojo.PACKAGES_FILE_NAME ) );
+
+        //check if the javadoc files were created
+        generatedFile =
+            new File( getBasedir(), "target/test/unit/javadocjar-default/target/site/apidocs/javadocjar/def/App.html" );
+        assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
+
+        generatedFile = new File( getBasedir(),
+                                  "target/test/unit/javadocjar-default/target/site/apidocs/javadocjar/def/AppSample.html" );
+        assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
+    }
+
+    /**
+     * Test when the specified destDir parameter has an invalid value
+     *
+     * @throws Exception if any
+     */
+    public void testInvalidDestdir()
+        throws Exception
+    {
+        File testPom = new File( getBasedir(),
+                                 "src/test/resources/unit/javadocjar-invalid-destdir/javadocjar-invalid-destdir-plugin-config.xml" );
+        JavadocJar mojo = lookupMojo( testPom );
+        mojo.execute();
+
+        //check if the javadoc jar file was generated
+        File generatedFile = new File( getBasedir(),
+                                       "target/test/unit/javadocjar-invalid-destdir/target/javadocjar-invalid-destdir-javadoc.jar" );
+        assertTrue( !FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
+    }
+
+    public void testContinueIfFailOnErrorIsFalse() throws Exception
+    {
+        File testPom =
+                new File( getBasedir(), "src/test/resources/unit/javadocjar-failonerror/javadocjar-failonerror-plugin-config.xml" );
+        JavadocJar mojo = lookupMojo( testPom );
+        mojo.execute();
+
+        //check if the javadoc jar file was generated
+        File generatedFile =
+                new File( getBasedir(), "target/test/unit/javadocjar-failonerror/target/javadocjar-failonerror-javadoc.jar" );
+        assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
+    }
+
+    public void testIncludeMavenDescriptorWhenExplicitlyConfigured() throws Exception
+    {
+        File testPom =
+                new File( getBasedir(), "src/test/resources/unit/javadocjar-archive-config/javadocjar-archive-config.xml" );
+        JavadocJar mojo = lookupMojo( testPom );
+        mojo.execute();
+
+        //check if the javadoc jar file was generated
+        File generatedFile =
+                new File( getBasedir(), "target/test/unit/javadocjar-archive-config/target/javadocjar-archive-config-javadoc.jar" );
+        assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
+
+        //validate contents of jar file
+        ZipFile jar = new ZipFile( generatedFile );
+        Set<String> set = new HashSet<String>();
+        for (Enumeration<? extends ZipEntry> entries = jar.entries(); entries.hasMoreElements(); )
+        {
+            ZipEntry entry = entries.nextElement();
+            set.add( entry.getName() );
+        }
+        jar.close();
+
+        List<String> expected = new ArrayList();
+        expected.add( "META-INF/" );
+        expected.add( "META-INF/maven/" );
+        expected.add( "META-INF/maven/org.apache.maven.plugins.maven-javadoc-plugin.unit/" );
+        expected.add( "META-INF/maven/org.apache.maven.plugins.maven-javadoc-plugin.unit/javadocjar-archive-config/" );
+        expected.add( "META-INF/maven/org.apache.maven.plugins.maven-javadoc-plugin.unit/javadocjar-archive-config/pom.xml" );
+        expected.add( "META-INF/maven/org.apache.maven.plugins.maven-javadoc-plugin.unit/javadocjar-archive-config/pom.properties" );
+
+        for (int i = 0; i < expected.size(); i++)
+        {
+            String entry = expected.get( i );
+            assertTrue( "Expected jar to contain " + entry, set.contains( entry ) );
+        }
+    }
+}


Loading...