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

svn commit: r791015 - in /maven/plugins/trunk/maven-javadoc-plugin: ./ src/main/java/org/apache/maven/plugin/javadoc/ src/test/java/org/apache/maven/plugin/javadoc/ src/test/java/org/apache/maven/plugin/javadoc/stubs/ src/test/resources/unit/fix-test/ ...

Author: vsiveton
Date: Fri Jul  3 21:17:04 2009
New Revision: 791015

URL: http://svn.apache.org/viewvc?rev=791015&view=rev
Log:
o added outputDirectory field
o upgraded to qdox:1.9.1 (QDOX-155, QDOX-156)

Added:
    maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/FixJavadocMojoTest.java   (with props)
    maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/FixMavenProjectStub.java   (with props)
    maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/
    maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/pom.xml   (with props)
    maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/
    maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/
    maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/
    maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/
    maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/
    maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithJavadoc.java   (with props)
    maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithNoJavadoc.java   (with props)
    maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/InterfaceWithJavadoc.java   (with props)
    maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/InterfaceWithNoJavadoc.java   (with props)
Modified:
    maven/plugins/trunk/maven-javadoc-plugin/pom.xml
    maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractFixJavadocMojo.java
    maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/TestFixJavadocMojo.java

Modified: maven/plugins/trunk/maven-javadoc-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/pom.xml?rev=791015&r1=791014&r2=791015&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/pom.xml Fri Jul  3 21:17:04 2009
@@ -138,7 +138,7 @@
     <dependency>
       <groupId>com.thoughtworks.qdox</groupId>
       <artifactId>qdox</artifactId>
-      <version>1.9</version>
+      <version>1.9.1</version>
     </dependency>
     <dependency>
       <groupId>net.sf.clirr</groupId>
@@ -214,14 +214,28 @@
       <version>1.2</version>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.apache.maven.shared</groupId>
+      <artifactId>maven-invoker</artifactId>
+      <version>2.0.10</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.codehaus.modello</groupId>
+          <artifactId>modello-maven-plugin</artifactId>
+          <version>1.0.2</version>
+        </plugin>
+      </plugins>
+    </pluginManagement>
     <plugins>
       <plugin>
         <groupId>org.codehaus.modello</groupId>
         <artifactId>modello-maven-plugin</artifactId>
-        <version>1.0.1</version>
         <executions>
           <execution>
             <goals>
@@ -297,7 +311,7 @@
           <plugin>
             <groupId>org.apache.maven.plugins</groupId>
             <artifactId>maven-changes-plugin</artifactId>
-            <version>2.0</version>
+            <version>2.1</version>
             <configuration>
               <!-- For JIRA-report -->
               <columnNames>Type,Key,Summary,Assignee,Status,Resolution,Fix Version</columnNames>

Modified: maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractFixJavadocMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractFixJavadocMojo.java?rev=791015&r1=791014&r2=791015&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractFixJavadocMojo.java (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractFixJavadocMojo.java Fri Jul  3 21:17:04 2009
@@ -55,6 +55,7 @@
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
 import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
 import org.apache.maven.artifact.resolver.ArtifactResolver;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
@@ -341,6 +342,13 @@
     private String level;
 
     /**
+     * Output directory where Java classes will be rewrited.
+     *
+     * @parameter expression="${outputDirectory}" default-value="${project.build.sourceDirectory}"
+     */
+    private File outputDirectory;
+
+    /**
      * The Maven Project Object.
      *
      * @parameter expression="${project}"
@@ -416,11 +424,14 @@
         {
             JavaClass[] javaClasses = getQdoxClasses();
 
-            for ( int i = 0; i < javaClasses.length; i++ )
+            if ( javaClasses != null )
             {
-                JavaClass javaClass = javaClasses[i];
+                for ( int i = 0; i < javaClasses.length; i++ )
+                {
+                    JavaClass javaClass = javaClasses[i];
 
-                processFix( javaClass );
+                    processFix( javaClass );
+                }
             }
         }
         catch ( IOException e )
@@ -452,15 +463,6 @@
      */
     protected List getProjectSourceRoots( MavenProject p )
     {
-        if ( "pom".equals( p.getPackaging().toLowerCase() ) )
-        {
-            if ( getLog().isWarnEnabled() )
-            {
-                getLog().warn( "This project has 'pom' packaging, no Java sources will be available." );
-            }
-            return Collections.EMPTY_LIST;
-        }
-
         return p.getCompileSourceRoots();
     }
 
@@ -524,6 +526,14 @@
         return sb.toString();
     }
 
+    /**
+     * @return the source dir for the given project
+     */
+    protected File getProjectSourceDirectory()
+    {
+        return new File( project.getBuild().getSourceDirectory() );
+    }
+
     // ----------------------------------------------------------------------
     // private methods
     // ----------------------------------------------------------------------
@@ -609,6 +619,11 @@
             return true;
         }
 
+        if ( outputDirectory != null && !outputDirectory.getAbsolutePath().equals( getProjectSourceDirectory().getAbsolutePath() ) )
+        {
+            return true;
+        }
+
         if ( !settings.isInteractiveMode() )
         {
             if ( getLog().isErrorEnabled() )
@@ -698,7 +713,27 @@
 
             wrapper.execute();
         }
-        catch ( Exception e )
+        catch ( MojoExecutionException e )
+        {
+            if ( e.getCause().getClass().isAssignableFrom( ArtifactNotFoundException.class ) )
+            {
+                getLog().warn( "Clirr is ignored because no previous artifact has been deployed." );
+            }
+            else
+            {
+                if ( getLog().isDebugEnabled() )
+                {
+                    getLog().error( "Error when executing Clirr: " + e.getMessage(), e );
+                }
+                else
+                {
+                    getLog().error( "Error when executing Clirr: " + e.getMessage() );
+                }
+                getLog().error( "Clirr is ignored due to the error above." );
+            }
+            return;
+        }
+        catch ( MojoFailureException e )
         {
             if ( getLog().isDebugEnabled() )
             {
@@ -711,6 +746,11 @@
             getLog().error( "Clirr is ignored due to the error above." );
             return;
         }
+        catch ( Exception e )
+        {
+            getLog().error( "Error when executing Clirr: " + e.getMessage() );
+            return;
+        }
 
         clirrNewClasses = wrapper.getNewClasses();
         clirrNewMethods = wrapper.getNewMethods();
@@ -829,6 +869,15 @@
     private JavaClass[] getQdoxClasses()
         throws FileNotFoundException, IOException, MojoExecutionException
     {
+        if ( "pom".equals( project.getPackaging().toLowerCase() ) )
+        {
+            if ( getLog().isWarnEnabled() )
+            {
+                getLog().warn( "This project has 'pom' packaging, no Java sources will be available." );
+            }
+            return null;
+        }
+
         List javaFiles = new LinkedList();
         for ( Iterator i = getProjectSourceRoots( project ).iterator(); i.hasNext(); )
         {
@@ -897,7 +946,7 @@
             getLog().debug( "Reading '" + javaClass.getFullyQualifiedName() + "' class." );
         }
 
-        final File javaFile = javaClass.getSource().getFile();
+        File javaFile = new File( javaClass.getSource().getURL().getFile() );
         // the original java content in memory
         final String originalContent = readFile( javaFile, encoding );
 
@@ -983,6 +1032,15 @@
         {
             getLog().debug( "Saving " + javaClass.getFullyQualifiedName() );
         }
+
+        if ( outputDirectory != null && !outputDirectory.getAbsolutePath().equals( getProjectSourceDirectory().getAbsolutePath() ) )
+        {
+            String path =
+                StringUtils.replace( javaFile.getAbsolutePath().replaceAll( "\\\\", "/" ),
+                                     project.getBuild().getSourceDirectory().replaceAll( "\\\\", "/" ), "" );
+            javaFile = new File( outputDirectory, path );
+            javaFile.getParentFile().mkdirs();
+        }
         writeFile( javaFile, encoding, stringWriter.toString() );
     }
 
@@ -1239,14 +1297,12 @@
                 || qualifiedName.equals( Character.TYPE.toString() ) )
             {
                 sb.append( "=" );
-                // QDOX-155 for char
                 sb.append( field.getInitializationExpression().trim() );
             }
 
             if ( qualifiedName.equals( String.class.getName() ) )
             {
                 StringBuffer value = new StringBuffer();
-                // QDOX-156 and QDOX-157
                 String[] lines = getLines( field.getInitializationExpression() );
                 for ( int i = 0; i < lines.length; i++ )
                 {

Modified: maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/TestFixJavadocMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/TestFixJavadocMojo.java?rev=791015&r1=791014&r2=791015&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/TestFixJavadocMojo.java (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/TestFixJavadocMojo.java Fri Jul  3 21:17:04 2009
@@ -59,15 +59,6 @@
     /** {@inheritDoc} */
     protected List getProjectSourceRoots( MavenProject p )
     {
-        if ( "pom".equals( p.getPackaging().toLowerCase() ) )
-        {
-            if ( getLog().isWarnEnabled() )
-            {
-                getLog().warn( "This project has 'pom' packaging, no test Java sources will be available." );
-            }
-            return Collections.EMPTY_LIST;
-        }
-
         return p.getTestCompileSourceRoots();
     }
 

Added: maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/FixJavadocMojoTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/FixJavadocMojoTest.java?rev=791015&view=auto
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/FixJavadocMojoTest.java (added)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/FixJavadocMojoTest.java Fri Jul  3 21:17:04 2009
@@ -0,0 +1,325 @@
+package org.apache.maven.plugin.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.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.apache.maven.shared.invoker.DefaultInvocationRequest;
+import org.apache.maven.shared.invoker.DefaultInvoker;
+import org.apache.maven.shared.invoker.InvocationOutputHandler;
+import org.apache.maven.shared.invoker.InvocationRequest;
+import org.apache.maven.shared.invoker.InvocationResult;
+import org.apache.maven.shared.invoker.Invoker;
+import org.apache.maven.shared.invoker.MavenInvocationException;
+import org.apache.maven.shared.invoker.PrintStreamHandler;
+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 org.codehaus.plexus.util.cli.CommandLineUtils;
+
+/**
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id$
+ */
+public class FixJavadocMojoTest
+    extends AbstractMojoTestCase
+{
+    /** The vm line separator */
+    private static final String EOL = System.getProperty( "line.separator" );
+
+    /** The M2_HOME env variable */
+    private static final File M2_HOME;
+
+    static
+    {
+        String mavenHome = System.getProperty( "maven.home" );
+
+        if ( mavenHome == null )
+        {
+            try
+            {
+                mavenHome = CommandLineUtils.getSystemEnvVars().getProperty( "M2_HOME" );
+            }
+            catch ( IOException e )
+            {
+                // nop
+            }
+        }
+
+        if ( mavenHome == null )
+        {
+            fail( "Cannot find Maven application "
+                + "directory. Either specify \'maven.home\' system property, or M2_HOME environment variable." );
+        }
+
+        M2_HOME = new File( mavenHome );
+    }
+
+    private File testPomBasedir;
+
+    /** {@inheritDoc} */
+    protected void setUp()
+        throws Exception
+    {
+        // required for mojo lookups to work
+        super.setUp();
+
+        testPomBasedir = new File( getBasedir(), "target/test/unit/fix-test/" );
+
+        // Using unit test dir
+        if ( !testPomBasedir.exists() )
+        {
+            FileUtils.copyDirectoryStructure( new File( getBasedir(), "src/test/resources/unit/fix-test/" ),
+                                              testPomBasedir );
+        }
+    }
+
+    /** {@inheritDoc} */
+    protected void tearDown()
+        throws Exception
+    {
+        super.tearDown();
+    }
+
+    /**
+     * @throws Exception if any
+     */
+    public void testFix()
+        throws Exception
+    {
+        File testPom = new File( testPomBasedir, "pom.xml" );
+        assertTrue( testPom.getAbsolutePath() + " should exist", testPom.exists() );
+
+        // compile the test project
+        if ( !new File( testPom.getParentFile(), "target" ).exists() )
+        {
+            invokeCompileGoal( testPom );
+            assertTrue( new File( testPomBasedir, "target/classes" ).exists() );
+        }
+
+        FixJavadocMojo mojo = (FixJavadocMojo) lookupMojo( "fix", testPom );
+        assertNotNull( mojo );
+        mojo.execute();
+
+        File packageDir = new File( testPomBasedir, "target/generated/fix/test" );
+        assertTrue( packageDir.exists() );
+
+        File clazzFile = new File( packageDir, "ClassWithJavadoc.java" );
+        assertTrue( clazzFile.exists() );
+        String content = readFile( clazzFile );
+        assertTrue( content.indexOf( "" +EOL+
+                "/**" +EOL+
+                " * Some Javadoc." +EOL+
+                " *" +EOL+
+                " * @author Administrator" +EOL+
+                " * @version $Id$" +EOL+
+                " * @since 1.0" +EOL+
+                " */" +EOL+
+                "public class ClassWithJavadoc" ) != -1 );
+        assertTrue( content.indexOf( "" +EOL+
+                "    /** Constant <code>MY_STRING_CONSTANT=\"value\"</code> */" +EOL+
+                "    public static final String MY_STRING_CONSTANT = \"value\";" ) != -1 );
+        assertTrue( content.indexOf( "" +EOL+
+                "    /** Constant <code>MY_INT_CONSTANT=1</code> */" +EOL+
+                "    public static final int MY_INT_CONSTANT = 1;" ) != -1 );
+        assertTrue( content.indexOf( "" +EOL+
+                "    /** Constant <code>EOL=\"System.getProperty( line.separator )\"</code> */" +EOL+
+                "    public static final String EOL = System.getProperty( \"line.separator\" );" ) != -1 );
+        assertTrue( content.indexOf( "" +EOL+
+                "    private static final String MY_PRIVATE_CONSTANT = \"\";" ) != -1 );
+        assertTrue( content.indexOf( "" +EOL+
+                "    /**" +EOL+
+                "     * <p>main</p>" +EOL+
+                "     *" +EOL+
+                "     * @param args an array of {@link java.lang.String} objects." +EOL+
+                "     */" +EOL+
+                "    public static void main( String[] args )" ) != -1 );
+        assertTrue( content.indexOf( "" +EOL+
+                "    /**" +EOL+
+                "     * <p>methodWithMissingParameters</p>" +EOL+
+                "     *" +EOL+
+                "     * @param str a {@link java.lang.String} object." +EOL+
+                "     * @param b a boolean." +EOL+
+                "     * @param i a int." +EOL+
+                "     * @return a {@link java.lang.String} object." +EOL+
+                "     */" +EOL+
+                "    public String methodWithMissingParameters( String str, boolean b, int i )" ) != -1 );
+        assertTrue( content.indexOf( "" +EOL+
+                "    /**" +EOL+
+                "     * <p>methodWithWrongJavadocParameters</p>" +EOL+
+                "     *" +EOL+
+                "     * @param aString a {@link java.lang.String} object." +EOL+
+                "     */" +EOL+
+                "    public void methodWithWrongJavadocParameters( String aString )" ) != -1 );
+
+        clazzFile = new File( packageDir, "ClassWithNoJavadoc.java" );
+        assertTrue( clazzFile.exists() );
+        content = readFile( clazzFile );
+        // QDOX-155
+        assertTrue( content.indexOf( "" +EOL+
+                "    /** Constant <code>SEPARATOR=','</code> */" +EOL+
+                "    public static final char SEPARATOR = ',';" ) != -1 );
+        // QDOX-156
+        assertTrue( content.indexOf( "" +EOL+
+                "    // TODO: blabla" +EOL+
+                "    /** Constant <code>TEST1=\"test1\"</code> */" +EOL+
+                "    public static final String TEST1 = \"test1\";" ) != -1 );
+        assertTrue( content.indexOf( "" +EOL+
+                "/**" +EOL+
+                " * <p>ClassWithNoJavadoc class.</p>" +EOL+
+                " *" +EOL+
+                " * @author Administrator" +EOL+
+                " * @version $Id$" +EOL+
+                " * @since 1.0" +EOL+
+                " */" +EOL+
+                "public class ClassWithNoJavadoc" ) != -1 );
+        assertTrue( content.indexOf( "" +EOL+
+                "    /**" +EOL+
+                "     * <p>main</p>" +EOL+
+                "     *" +EOL+
+                "     * @param args an array of {@link java.lang.String} objects." +EOL+
+                "     */" +EOL+
+                "    public static void main( String[] args )" ) != -1 );
+        assertTrue( content.indexOf( "" +EOL+
+                "    private void sampleMethod( String str )" ) != -1 );
+
+        clazzFile = new File( packageDir, "InterfaceWithJavadoc.java" );
+        assertTrue( clazzFile.exists() );
+        content = readFile( clazzFile );
+        assertTrue( content.indexOf( "" +EOL+
+                "/**" +EOL+
+                " * Some Javadoc." +EOL+
+                " *" +EOL+
+                " * @author Administrator" +EOL+
+                " * @version $Id$" +EOL+
+                " * @since 1.0" +EOL+
+                " */" +EOL+
+                "public interface InterfaceWithJavadoc" ) != -1 );
+        assertTrue( content.indexOf( "" +EOL+
+                "    /** comment */" +EOL+
+                "    String MY_STRING_CONSTANT = \"value\";" ) != -1 );
+        assertTrue( content.indexOf( "" +EOL+
+                "    /**" +EOL+
+                "     * My method" +EOL+
+                "     *" +EOL+
+                "     * @param aString a {@link java.lang.String} object." +EOL+
+                "     */" +EOL+
+                "    public void method( String aString );" ) != -1 );
+
+        clazzFile = new File( packageDir, "InterfaceWithNoJavadoc.java" );
+        assertTrue( clazzFile.exists() );
+        content = readFile( clazzFile );
+        assertTrue( content.indexOf( "" +EOL+
+                "/**" +EOL+
+                " * <p>InterfaceWithNoJavadoc interface.</p>" +EOL+
+                " *" +EOL+
+                " * @author Administrator" +EOL+
+                " * @version $Id$" +EOL+
+                " * @since 1.0" +EOL+
+                " */" +EOL+
+                "public interface InterfaceWithNoJavadoc" ) != -1 );
+        assertTrue( content.indexOf( "" +EOL+
+                "    /** Constant <code>MY_STRING_CONSTANT=\"value\"</code> */" +EOL+
+                "    String MY_STRING_CONSTANT = \"value\";" ) != -1 );
+        assertTrue( content.indexOf( "" +EOL+
+                "    /**" +EOL+
+                "     * <p>method</p>" +EOL+
+                "     *" +EOL+
+                "     * @param aString a {@link java.lang.String} object." +EOL+
+                "     */" +EOL+
+                "    public void method( String aString );" ) != -1 );
+    }
+
+    /**
+     * Invoke the compilation on the given pom file.
+     *
+     * @param testPom
+     */
+    private void invokeCompileGoal( File testPom )
+    {
+        Invoker invoker = new DefaultInvoker();
+        invoker.setMavenHome( M2_HOME );
+
+        InvocationRequest request = new DefaultInvocationRequest();
+        request.setBaseDirectory( testPom.getParentFile() );
+        request.setPomFile( testPom );
+
+        ByteArrayOutputStream outLog = new ByteArrayOutputStream();
+        InvocationOutputHandler outputHandler = new PrintStreamHandler( new PrintStream( outLog ), false );
+        request.setOutputHandler( outputHandler );
+        request.setDebug( true );
+
+        List goals = new ArrayList();
+        goals.add( "clean" );
+        goals.add( "compile" );
+
+        request.setGoals( goals );
+
+        try
+        {
+            InvocationResult result = invoker.execute( request );
+            assertEquals( 0, result.getExitCode() );
+        }
+        catch ( MavenInvocationException e )
+        {
+            getContainer().getLogger().error( "Error when invoking Maven: " + e.getMessage(), e );
+            if ( getContainer().getLogger().isDebugEnabled() )
+            {
+                StringBuffer msg = new StringBuffer();
+                msg.append( "Ouput from invoker:" ).append( "\n" );
+                msg.append( StringUtils.repeat( "-", 78 ) ).append( "\n" );
+                msg.append( outLog ).append( "\n" );
+                msg.append( StringUtils.repeat( "-", 78 ) ).append( "\n" );
+
+                getContainer().getLogger().debug( msg.toString() );
+            }
+
+            fail( "Error when invoking Maven: " + e.getMessage() );
+        }
+    }
+
+    /**
+     * @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" );
+            return IOUtil.toString( fileReader );
+        }
+        finally
+        {
+            IOUtil.close( fileReader );
+        }
+    }
+}

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

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

Added: maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/FixMavenProjectStub.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/FixMavenProjectStub.java?rev=791015&view=auto
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/FixMavenProjectStub.java (added)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/FixMavenProjectStub.java Fri Jul  3 21:17:04 2009
@@ -0,0 +1,94 @@
+package org.apache.maven.plugin.javadoc.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 org.apache.maven.model.Build;
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+
+/**
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id$
+ */
+public class FixMavenProjectStub
+    extends MavenProjectStub
+{
+    public FixMavenProjectStub()
+    {
+        readModel( new File( getBasedir(), "pom.xml" ) );
+
+        addCompileSourceRoot( getBasedir().getAbsolutePath() + "/target/classes" );
+        addCompileSourceRoot( getBasedir().getAbsolutePath() + "/src/main/java" );
+
+        Build build = new Build();
+        build.setDirectory( getBasedir().getAbsolutePath() + "/target" );
+        build.setSourceDirectory( getBasedir().getAbsolutePath() + "/src/main/java" );
+        build.setOutputDirectory( getBasedir().getAbsolutePath() + "/target/classes" );
+        build.setTestSourceDirectory( getBasedir().getAbsolutePath() + "/src/test/java" );
+        build.setTestOutputDirectory( getBasedir().getAbsolutePath() + "/target/test-classes" );
+        setBuild( build );
+    }
+
+    /** {@inheritDoc} */
+    public String getArtifactId()
+    {
+        return getModel().getArtifactId();
+    }
+
+    /** {@inheritDoc} */
+    public String getGroupId()
+    {
+        String groupId = getModel().getGroupId();
+
+        if ( ( groupId == null ) && ( getModel().getParent() != null ) )
+        {
+            groupId = getModel().getParent().getGroupId();
+        }
+
+        return groupId;
+    }
+
+    /** {@inheritDoc} */
+    public String getVersion()
+    {
+        String version = getModel().getVersion();
+
+        if ( ( version == null ) && ( getModel().getParent() != null ) )
+        {
+            version = getModel().getParent().getVersion();
+        }
+
+        return version;
+    }
+
+    /** {@inheritDoc} */
+    public String getPackaging()
+    {
+        return getModel().getPackaging();
+    }
+
+    /** {@inheritDoc} */
+    public File getBasedir()
+    {
+        // Using unit test dir
+        return new File( super.getBasedir() + "/target/test/unit/fix-test/" );
+    }
+}

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

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

Added: maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/pom.xml?rev=791015&view=auto
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/pom.xml (added)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/pom.xml Fri Jul  3 21:17:04 2009
@@ -0,0 +1,61 @@
+<?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 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/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>test</groupId>
+  <artifactId>testProject</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <name>Javadoc Test Project</name>
+  <packaging>jar</packaging>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>2.0.2</version>
+        <configuration>
+          <source>1.4</source>
+          <target>1.4</target>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-javadoc-plugin</artifactId>
+        <configuration>
+          <project implementation="org.apache.maven.plugin.javadoc.stubs.FixMavenProjectStub"/>
+          <localRepository>${localRepository}</localRepository>
+          <outputDirectory>${basedir}/target/test/unit/fix-test/target/generated</outputDirectory>
+          <defaultSince>1.0-SNAPSHOT</defaultSince>
+          <encoding>UTF-8</encoding>
+          <fixTags>all</fixTags>
+          <fixClassComment>true</fixClassComment>
+          <fixFieldComment>true</fixFieldComment>
+          <fixMethodComment>true</fixMethodComment>
+          <force>true</force>
+          <ignoreClirr>true</ignoreClirr>
+          <includes>**/*.java</includes>
+          <level>protected</level>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Propchange: maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithJavadoc.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithJavadoc.java?rev=791015&view=auto
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithJavadoc.java (added)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithJavadoc.java Fri Jul  3 21:17:04 2009
@@ -0,0 +1,54 @@
+package fix.test;
+
+/*
+ * 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.
+ */
+
+/**
+ * Some Javadoc.
+ */
+public class ClassWithJavadoc
+{
+    public static final String MY_STRING_CONSTANT = "value";
+
+    public static final int MY_INT_CONSTANT = 1;
+
+    public static final String EOL = System.getProperty( "line.separator" );
+
+    private static final String MY_PRIVATE_CONSTANT = "";
+
+    public static void main( String[] args )
+    {
+        System.out.println( "Sample Application." );
+    }
+
+    /**
+     * @param str
+     */
+    public String methodWithMissingParameters( String str, boolean b, int i )
+    {
+        return null;
+    }
+
+    /**
+     * @param str
+     */
+    public void methodWithWrongJavadocParameters( String aString )
+    {
+    }
+}

Propchange: maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithJavadoc.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithJavadoc.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithNoJavadoc.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithNoJavadoc.java?rev=791015&view=auto
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithNoJavadoc.java (added)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithNoJavadoc.java Fri Jul  3 21:17:04 2009
@@ -0,0 +1,40 @@
+package fix.test;
+
+/*
+ * 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.
+ */
+
+public class ClassWithNoJavadoc
+{
+    // QDOX-155
+    public static final char SEPARATOR = ',';
+
+    // QDOX-156
+    // TODO: blabla
+    public static final String TEST1 = "test1";
+
+    public static void main( String[] args )
+    {
+        System.out.println( "Sample Application." );
+    }
+
+    private void sampleMethod( String str )
+    {
+        System.out.println( str );
+    }
+}

Propchange: maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithNoJavadoc.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithNoJavadoc.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/InterfaceWithJavadoc.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/InterfaceWithJavadoc.java?rev=791015&view=auto
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/InterfaceWithJavadoc.java (added)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/InterfaceWithJavadoc.java Fri Jul  3 21:17:04 2009
@@ -0,0 +1,34 @@
+package fix.test;
+
+/*
+ * 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.
+ */
+
+/**
+ * Some Javadoc.
+ */
+public interface InterfaceWithJavadoc
+{
+    /** comment */
+    String MY_STRING_CONSTANT = "value";
+
+    /**
+     * My method
+     */
+    public void method( String aString );
+}

Propchange: maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/InterfaceWithJavadoc.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/InterfaceWithJavadoc.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/InterfaceWithNoJavadoc.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/InterfaceWithNoJavadoc.java?rev=791015&view=auto
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/InterfaceWithNoJavadoc.java (added)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/InterfaceWithNoJavadoc.java Fri Jul  3 21:17:04 2009
@@ -0,0 +1,27 @@
+package fix.test;
+
+/*
+ * 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.
+ */
+
+public interface InterfaceWithNoJavadoc
+{
+    String MY_STRING_CONSTANT = "value";
+
+    public void method( String aString );
+}

Propchange: maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/InterfaceWithNoJavadoc.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/InterfaceWithNoJavadoc.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision