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/08 17:05:19 UTC

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

Author: vsiveton
Date: Wed Jul  8 15:05:18 2009
New Revision: 792176

URL: http://svn.apache.org/viewvc?rev=792176&view=rev
Log:
o improved inherited tag
o align javadoc with correct indentation
o refactoring test cases to use expected dir (better than string comparison)

Modified:
    maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractFixJavadocMojo.java
    maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/FixJavadocMojoTest.java
    maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithJavadoc.java
    maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithNoJavadoc.java
    maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/InterfaceWithJavadoc.java
    maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/InterfaceWithNoJavadoc.java

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=792176&r1=792175&r2=792176&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 Wed Jul  8 15:05:18 2009
@@ -45,7 +45,6 @@
 import java.util.Map;
 import java.util.Properties;
 import java.util.StringTokenizer;
-import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.apache.commons.lang.ClassUtils;
@@ -100,13 +99,29 @@
     private static final String EOL = System.getProperty( "line.separator" );
 
     /**
-     * Pattern to find if a Javadoc line contains Javadoc tag for instance
+     * Pattern <code>^\\s*\\*\\s*@\\w{1}.*$</code> to find if a Javadoc line contains Javadoc tag
+     * for instance:
      * <pre>
      * &#32;&#42; &#64;param X
      * </pre>
      */
-    private static final Pattern JAVADOC_TAG_LINE_PATTERN =
-        Pattern.compile( "\\s+\\*\\s+@\\w\\s*.*\\z", Pattern.DOTALL );
+    private static final String JAVADOC_TAG_LINE_PATTERN = "^\\s*\\*\\s*@\\w{1}.*$";
+
+    /**
+     * Pattern <code>^\\s*(\\/\\*\\*)?(\\s*(\\*)?)*(\\{)@inheritDoc\\s*(\\})(\\s*(\\*)?)*(\\*\\/)?$</code> to
+     * find if a Javadoc comment contains inherited tag for instance:
+     * <pre>
+     * &#47;&#42;&#42; {&#64;inheritDoc} &#42;&#47;
+     * </pre>
+     * or
+     * <pre>
+     * &#47;&#42;&#42;
+     * &#32;&#42; {&#64;inheritDoc}
+     * &#32;&#42;&#47;
+     * </pre>
+     */
+    private static final String INHERITED_TAG_PATTERN =
+        "^\\s*(\\/\\*\\*)?(\\s*(\\*)?)*(\\{)@inheritDoc\\s*(\\})(\\s*(\\*)?)*(\\*\\/)?$";
 
     /** Tag name for &#64;author **/
     private static final String AUTHOR_TAG = "author";
@@ -138,7 +153,7 @@
     /** Javadoc Separator i.e. <code> &#42; </code> **/
     private static final String SEPARATOR_JAVADOC = " * ";
 
-    /** Inherited Javadoc i.e. <code>&#47;&#42;&#42;{&#64;inheritDoc}&#42;&#47;</code> **/
+    /** Inherited Javadoc i.e. <code>&#47;&#42;&#42; {&#64;inheritDoc} &#42;&#47;</code> **/
     private static final String INHERITED_JAVADOC = START_JAVADOC + " " + INHERITED_TAG + " " + END_JAVADOC;
 
     /** <code>all</code> parameter used by {@link #fixTags} **/
@@ -1554,7 +1569,10 @@
                 }
 
                 String javadoc = getJavadocComment( originalContent, javaMethod );
-                if ( StringUtils.removeDuplicateWhitespace( javadoc.trim() ).equals( INHERITED_JAVADOC ) )
+
+                // case: /** {@inheritDoc} */ or no tags
+                if ( Pattern.matches( INHERITED_TAG_PATTERN, StringUtils.removeDuplicateWhitespace( javadoc ) )
+                    && ( javaMethod.getTags() == null || javaMethod.getTags().length == 0 ) )
                 {
                     sb.append( indent ).append( INHERITED_JAVADOC );
                     sb.append( EOL );
@@ -1562,7 +1580,6 @@
                     return;
                 }
 
-                javadoc = removeLastEmptyJavadocLines( javadoc );
                 if ( javadoc.indexOf( START_JAVADOC ) != -1 )
                 {
                     javadoc = javadoc.substring( javadoc.indexOf( START_JAVADOC ) + START_JAVADOC.length() );
@@ -1571,53 +1588,50 @@
                 {
                     javadoc = javadoc.substring( 0, javadoc.indexOf( END_JAVADOC ) );
                 }
-                if ( StringUtils.removeDuplicateWhitespace( javadoc.trim() ).equals( "* " + INHERITED_TAG )
-                    && ( javaMethod.getTags() == null || javaMethod.getTags().length == 0 ) )
+
+                sb.append( indent ).append( START_JAVADOC );
+                sb.append( EOL );
+                if ( javadoc.indexOf( INHERITED_TAG ) == -1 )
                 {
-                    sb.append( indent ).append( START_JAVADOC ).append( INHERITED_TAG ).append( END_JAVADOC );
+                    sb.append( indent ).append( SEPARATOR_JAVADOC ).append( INHERITED_TAG );
                     sb.append( EOL );
+                    appendSeparator( sb, indent );
                 }
-                else
-                {
-                    sb.append( indent ).append( START_JAVADOC );
-                    sb.append( EOL );
-                    if ( javadoc.indexOf( INHERITED_TAG ) == -1 )
-                    {
-                        sb.append( indent ).append( SEPARATOR_JAVADOC ).append( INHERITED_TAG );
-                        sb.append( EOL );
-                        appendSeparator( sb, indent );
-                    }
-                    String leftTrimmed = trimLeft( javadoc );
-                    if ( leftTrimmed.startsWith( "* " ) )
-                    {
-                        sb.append( indent ).append( " " ).append( leftTrimmed );
-                    }
-                    else
-                    {
-                        sb.append( indent ).append( SEPARATOR_JAVADOC ).append( leftTrimmed );
-                    }
-                    sb.append( EOL );
-                    if ( javaMethod.getTags() != null )
-                    {
-                        for ( int i = 0; i < javaMethod.getTags().length; i++ )
+                javadoc = removeLastEmptyJavadocLines( javadoc );
+                javadoc = alignIndentationJavadocLines( javadoc, indent );
+                sb.append( javadoc );
+                sb.append( EOL );
+                if ( javaMethod.getTags() != null )
+                {
+                    for ( int i = 0; i < javaMethod.getTags().length; i++ )
+                    {
+                        DocletTag docletTag = javaMethod.getTags()[i];
+
+                        // Voluntary ignore these tags
+                        if ( docletTag.getName().equals( PARAM_TAG )
+                            || docletTag.getName().equals( RETURN_TAG )
+                            || docletTag.getName().equals( THROWS_TAG ) )
                         {
-                            DocletTag docletTag = javaMethod.getTags()[i];
-
-                            // Voluntary ignore these tags
-                            if ( docletTag.getName().equals( PARAM_TAG )
-                                || docletTag.getName().equals( RETURN_TAG )
-                                || docletTag.getName().equals( THROWS_TAG ) )
-                            {
-                                continue;
-                            }
-
-                            String s = getJavadocComment( originalContent, entity, docletTag );
-                            sb.append( trimRight( s ) );
-                            sb.append( EOL );
+                            continue;
                         }
+
+                        String s = getJavadocComment( originalContent, entity, docletTag );
+                        s = removeLastEmptyJavadocLines( s );
+                        s = alignIndentationJavadocLines( s, indent );
+                        sb.append( s );
+                        sb.append( EOL );
                     }
-                    sb.append( indent ).append( " " ).append( END_JAVADOC );
+                }
+                sb.append( indent ).append( " " ).append( END_JAVADOC );
+                sb.append( EOL );
+
+                if ( Pattern.matches( INHERITED_TAG_PATTERN, StringUtils.removeDuplicateWhitespace( sb.toString().trim() ) ) )
+                {
+                    sb = new StringBuffer();
+                    sb.append( indent ).append( INHERITED_JAVADOC );
                     sb.append( EOL );
+                    stringWriter.write( sb.toString() );
+                    return;
                 }
 
                 stringWriter.write( sb.toString() );
@@ -1667,6 +1681,7 @@
     {
         String comment = getJavadocComment( originalContent, entity );
         comment = removeLastEmptyJavadocLines( comment );
+        comment = alignIndentationJavadocLines( comment, indent );
 
         if ( comment.indexOf( START_JAVADOC ) != -1 )
         {
@@ -1724,7 +1739,7 @@
         appendSeparator( sb, indent );
 
         // parse tags
-        JavaEntityTags javaEntityTags = parseJavadocTags( originalContent, entity, isJavaMethod );
+        JavaEntityTags javaEntityTags = parseJavadocTags( originalContent, entity, indent, isJavaMethod );
 
         // update and write tags
         updateJavadocTags( sb, entity, isJavaMethod, javaEntityTags );
@@ -1738,12 +1753,14 @@
      *
      * @param originalContent not null
      * @param entity not null
+     * @param indent not null
      * @param isJavaMethod
      * @return an instance of {@link JavaEntityTags}
      * @throws IOException if any
      */
     private JavaEntityTags parseJavadocTags( final String originalContent,
-                                             final AbstractInheritableJavaEntity entity, final boolean isJavaMethod )
+                                             final AbstractInheritableJavaEntity entity, final String indent,
+                                             final boolean isJavaMethod )
         throws IOException
     {
         JavaEntityTags javaEntityTags = new JavaEntityTags( entity, isJavaMethod );
@@ -1753,6 +1770,7 @@
 
             String originalJavadocTag = getJavadocComment( originalContent, entity, docletTag );
             originalJavadocTag = removeLastEmptyJavadocLines( originalJavadocTag );
+            originalJavadocTag = alignIndentationJavadocLines( originalJavadocTag, indent );
 
             javaEntityTags.getNamesTags().add( docletTag.getName() );
 
@@ -2858,6 +2876,27 @@
     }
 
     /**
+     * @param javaFile not null
+     * @param encoding not null
+     * @param content not null
+     * @throws IOException if any
+     */
+    private static void writeFile( File javaFile, String encoding, String content )
+        throws IOException
+    {
+        Writer writer = null;
+        try
+        {
+            writer = WriterFactory.newWriter( javaFile, encoding );
+            writer.write( content );
+        }
+        finally
+        {
+            IOUtil.close( writer );
+        }
+    }
+
+    /**
      * @return the maven home defined in the "maven.home" system property or defined in M2_HOME system env variables
      * or null if never setted.
      */
@@ -2880,27 +2919,6 @@
     }
 
     /**
-     * @param javaFile not null
-     * @param encoding not null
-     * @param content not null
-     * @throws IOException if any
-     */
-    private static void writeFile( File javaFile, String encoding, String content )
-        throws IOException
-    {
-        Writer writer = null;
-        try
-        {
-            writer = WriterFactory.newWriter( javaFile, encoding );
-            writer.write( content );
-        }
-        finally
-        {
-            IOUtil.close( writer );
-        }
-    }
-
-    /**
      * Default comment for class.
      *
      * @param javaClass not null
@@ -3000,6 +3018,15 @@
         }
 
         String originalJavadoc = extractOriginalJavadoc( javaClassContent, entity );
+        if ( originalJavadoc.indexOf( START_JAVADOC ) != -1 )
+        {
+            originalJavadoc =
+                trimLeft( originalJavadoc.substring( originalJavadoc.indexOf( START_JAVADOC ) + START_JAVADOC.length() ) );
+        }
+        if ( originalJavadoc.indexOf( END_JAVADOC ) != -1 )
+        {
+            originalJavadoc = trimRight( originalJavadoc.substring( 0, originalJavadoc.indexOf( END_JAVADOC ) ) );
+        }
         String[] originalJavadocLines = getLines( originalJavadoc );
 
         if ( originalJavadocLines.length == 1 )
@@ -3010,22 +3037,6 @@
         List originalJavadocLinesAsList = new LinkedList();
         originalJavadocLinesAsList.addAll( Arrays.asList( originalJavadocLines ) );
 
-        Collections.reverse( originalJavadocLinesAsList );
-
-        for ( Iterator it = originalJavadocLinesAsList.iterator(); it.hasNext(); )
-        {
-            String line = (String) it.next();
-
-            if ( line.endsWith( END_JAVADOC ) )
-            {
-                break;
-            }
-
-            it.remove();
-        }
-
-        Collections.reverse( originalJavadocLinesAsList );
-
         boolean toremove = false;
         for ( Iterator it = originalJavadocLinesAsList.iterator(); it.hasNext(); )
         {
@@ -3037,28 +3048,7 @@
                 continue;
             }
 
-            if ( line.trim().equals( START_JAVADOC ) )
-            {
-                it.remove();
-                continue;
-            }
-            if ( line.trim().equals( END_JAVADOC ) )
-            {
-                it.remove();
-                break;
-            }
-
-            if ( line.indexOf( START_JAVADOC ) != -1 )
-            {
-                line = line.substring( line.indexOf( START_JAVADOC ) + START_JAVADOC.length() );
-            }
-            if ( line.indexOf( END_JAVADOC ) != -1 )
-            {
-                line = line.substring( 0, line.indexOf( END_JAVADOC ) );
-            }
-
-            Matcher matcher = JAVADOC_TAG_LINE_PATTERN.matcher( line );
-            if ( matcher.find() )
+            if ( Pattern.matches( JAVADOC_TAG_LINE_PATTERN, line ) )
             {
                 it.remove();
                 toremove = true;
@@ -3119,7 +3109,7 @@
         {
             String originalJavadocLine = originalJavadocLines[i];
 
-            if ( JAVADOC_TAG_LINE_PATTERN.matcher( originalJavadocLine ).find() )
+            if ( Pattern.matches( JAVADOC_TAG_LINE_PATTERN, originalJavadocLine ) )
             {
                 if ( start != 0 )
                 {
@@ -3137,13 +3127,16 @@
 
         for ( int i = start; i < end; i++ )
         {
-            String originalJavadocLine = originalJavadocLines[i];
+            String originalJavadocLine = trimRight( originalJavadocLines[i] );
 
             sb.append( originalJavadocLine );
-            sb.append( EOL );
+            if ( i < end - 1 )
+            {
+                sb.append( EOL );
+            }
         }
 
-        return trimRight( sb.toString() );
+        return sb.toString();
     }
 
     /**
@@ -3184,6 +3177,7 @@
      * @param content not null
      * @return the content without javadoc separator (ie <code> * </code>)
      * @throws IOException if any
+     * @see #getJavadocComment(String, AbstractInheritableJavaEntity, DocletTag)
      */
     private static String removeLastEmptyJavadocLines( String content )
         throws IOException
@@ -3224,6 +3218,30 @@
     }
 
     /**
+     * @param content not null
+     * @return the javadoc comment with the given indentation
+     * @throws IOException if any
+     * @see #getJavadocComment(String, AbstractInheritableJavaEntity, DocletTag)
+     */
+    private static String alignIndentationJavadocLines( String content, String indent )
+        throws IOException
+    {
+        String[] lines = getLines( content );
+
+        StringBuffer sb = new StringBuffer();
+        for ( int i = 0; i < lines.length; i++ )
+        {
+            sb.append( indent ).append( " " ).append( lines[i].trim() );
+            if ( i < lines.length - 1 )
+            {
+                sb.append( EOL );
+            }
+        }
+
+        return sb.toString();
+    }
+
+    /**
      * @param line not null
      * @return the indentation for the given line.
      */

Modified: 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=792176&r1=792175&r2=792176&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/FixJavadocMojoTest.java (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/FixJavadocMojoTest.java Wed Jul  8 15:05:18 2009
@@ -40,6 +40,7 @@
 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;
 
 /**
@@ -49,9 +50,6 @@
 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;
 
@@ -101,173 +99,41 @@
         assertNotNull( mojo );
         mojo.execute();
 
-        File packageDir = new File( testPomBasedir, "target/generated/fix/test" );
-        assertTrue( packageDir.exists() );
+        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() );
+
+        String className = "ClassWithJavadoc.java";
+        assertEquals( new File( expectedDir, className ), new File( generatedDir, className ) );
+
+        className = "ClassWithNoJavadoc.java";
+        assertEquals( new File( expectedDir, className ), new File( generatedDir, className ) );
+
+        className = "InterfaceWithJavadoc.java";
+        assertEquals( new File( expectedDir, className ), new File( generatedDir, className ) );
+
+        className = "InterfaceWithNoJavadoc.java";
+        assertEquals( new File( expectedDir, className ), new File( generatedDir, className ) );
+    }
+
+    /**
+     * 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.exists() );
+        String expectedContent = StringUtils.unifyLineSeparators( readFile( expected ) );
+
+        assertTrue( actual.exists() );
+        String actualContent = StringUtils.unifyLineSeparators( readFile( actual ) );
 
-        File clazzFile = new File( packageDir, "ClassWithJavadoc.java" );
-        assertTrue( clazzFile.exists() );
-        String content = readFile( clazzFile );
-        assertTrue( content.indexOf( "" + EOL +
-                "/**" + EOL +
-                " * Some Javadoc." + EOL +
-                " *" + EOL +
-                " * @author " + System.getProperty( "user.name" ) + EOL+
-                " * @version \u0024Id: \u0024" + 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>Constructor for ClassWithJavadoc.</p>" + EOL +
-                "     */" + EOL +
-                "    public ClassWithJavadoc()" ) != -1 );
-        assertTrue( content.indexOf( "" + EOL +
-                "    /**" + EOL +
-                "     * The main method" + EOL +
-                "     *" + EOL +
-                "     * @param args      an array of strings that contains the arguments" + 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>methodWithMissingParameters2</p>" + EOL +
-                "     *" + EOL +
-                "     * @param str a {@link java.lang.String} object." + EOL +
-                "     * @throws java.lang.UnsupportedOperationException if any" + EOL +
-                "     * @param b a boolean." + EOL +
-                "     * @param i a int." + EOL +
-                "     * @return a {@link java.lang.String} object." + EOL +
-                "     */" + EOL +
-                "    public String methodWithMissingParameters2( 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 );
-        assertTrue( content.indexOf( "" + EOL +
-                "    /**" + EOL +
-                "     * <p>methodWithMultiLinesJavadoc</p>" + EOL +
-                "     *" + EOL +
-                "     * @param aString" + EOL +
-                "     *      a string" + EOL +
-                "     * @param anotherString" + EOL +
-                "     *      with" + EOL +
-                "     *      multi" + EOL +
-                "     *      line" + EOL +
-                "     *      comments" + EOL +
-                "     * @return a" + EOL +
-                "     *      String" + EOL +
-                "     * @throws java.lang.UnsupportedOperationException" + EOL +
-                "     *      if any" + EOL +
-                "     */" + EOL +
-                "    public String methodWithMultiLinesJavadoc( String aString, String anotherString )" ) != -1 );
-        assertTrue( content.indexOf( "" + EOL +
-                "    /**" + EOL +
-                "     * methodWithMultiLinesJavadoc2" + EOL +
-                "     *" + EOL +
-                "     * @return a {@link java.lang.String} object." + EOL +
-                "     */" + EOL +
-                "    protected String methodWithMultiLinesJavadoc2()" ) != -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 " + System.getProperty( "user.name" ) + EOL+
-                " * @version \u0024Id: \u0024" + 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 " + System.getProperty( "user.name" ) + EOL+
-                " * @version \u0024Id: \u0024" + 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 " + System.getProperty( "user.name" ) + EOL+
-                " * @version \u0024Id: \u0024" + 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 );
+        assertEquals( "Expected file: " + expected.getAbsolutePath() + ", actual file: "
+            + actual.getAbsolutePath(), expectedContent, actualContent );
     }
 
     /**

Modified: 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=792176&r1=792175&r2=792176&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithJavadoc.java (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithJavadoc.java Wed Jul  8 15:05:18 2009
@@ -20,21 +20,16 @@
  */
 
 /**
- * Some Javadoc.
+ * To add default class tags.
  */
 public class ClassWithJavadoc
+    implements InterfaceWithJavadoc
 {
-    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 = "";
-
+    /**
+     * Constructor comment.
+     */
     public ClassWithJavadoc()
     {
-        // nop
     }
 
     /**
@@ -42,15 +37,14 @@
      *
      * @param args      an array of strings that contains the arguments
      */
-    public static void main( String[] args )
+    public void spacesInJavadocTags( String[] args )
     {
-        System.out.println( "Sample Application." );
     }
 
     /**
      * @param str
      */
-    public String methodWithMissingParameters( String str, boolean b, int i )
+    public String missingJavadocTags( String str, boolean b, int i )
     {
         return null;
     }
@@ -59,7 +53,7 @@
      * @param str
      * @throws UnsupportedOperationException if any
      */
-    public String methodWithMissingParameters2( String str, boolean b, int i )
+    public String missingJavadocTags2( String str, boolean b, int i )
         throws UnsupportedOperationException
     {
         return null;
@@ -68,7 +62,7 @@
     /**
      * @param str
      */
-    public void methodWithWrongJavadocParameters( String aString )
+    public void wrongJavadocTag( String aString )
     {
     }
 
@@ -85,18 +79,103 @@
      * @throws UnsupportedOperationException
      *      if any
      */
-    public String methodWithMultiLinesJavadoc( String aString, String anotherString )
+    public String multiLinesJavadocTags( String aString, String anotherString )
         throws UnsupportedOperationException
     {
         return null;
     }
 
+        /**
+         * To take care of the Javadoc indentation.
+         *
+         * @param aString a
+         *      String
+         *
+         * @return dummy
+         *      value
+         */
+    public String wrongJavadocIndentation( String aString )
+    {
+        return null;
+    }
+
+    // one single comment
+    /**
+     * To take care of single comments.
+     */
+    // other single comment
+    public String singleComments( String aString )
+    {
+        return null;
+    }
+
+    // ----------------------------------------------------------------------
+    // Inheritance
+    // ----------------------------------------------------------------------
+
+    /** {@inheritDoc} */
+    public void method1( String aString )
+    {
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * specific comment
+     */
+    public void method2( String aString )
+    {
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * @param aString not
+     *      used
+     */
+    public String method3( String aString )
+    {
+        return null;
+    }
+
+    /**
+     * @param aString not
+     *      used
+     */
+    public String method4( String aString )
+    {
+        return null;
+    }
+
+    /**
+     * Specific comment
+     *
+     * @param aString not
+     *      used
+     */
+    public String method5( String aString )
+    {
+        return null;
+    }
+
+    // ----------------------------------------------------------------------
+    // Inner classes
+    // ----------------------------------------------------------------------
+
     /**
-     * methodWithMultiLinesJavadoc2
-     * @return
+     * No javadoc for inner class.
      */
-    protected String methodWithMultiLinesJavadoc2()
+    public class InnerClass
     {
-      return null;
+        /**
+         * constructor
+         */
+        public InnerClass()
+        {
+        }
+
+        public void nothing()
+        {
+        }
     }
 }

Modified: 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=792176&r1=792175&r2=792176&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithNoJavadoc.java (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/ClassWithNoJavadoc.java Wed Jul  8 15:05:18 2009
@@ -19,22 +19,55 @@
  * under the License.
  */
 
+import java.util.Map;
+
 public class ClassWithNoJavadoc
 {
+    public static final String MY_STRING_CONSTANT = "value";
+
+    public static final String MY_STRING_CONSTANT2 = "default" + " value";
+
+    public static final int MY_INT_CONSTANT = 1;
+
+    public static final String EOL = System.getProperty( "line.separator" );
+
+    // take care of identifier
+    private static final String MY_PRIVATE_STRING_CONSTANT = "";
+
     // QDOX-155
     public static final char SEPARATOR = ',';
 
     // QDOX-156
-    // TODO: blabla
     public static final String TEST1 = "test1";
 
-    public static void main( String[] args )
+    public ClassWithNoJavadoc()
+    {
+    }
+
+    // take care of primitive
+    public void missingJavadocTagsForPrimitives( int i, byte b, float f, char c, short s, long l, double d, boolean bb )
+    {
+    }
+
+    // take care of object
+    public void missingJavadocTagsForObjects( String s, Map m )
     {
-        System.out.println( "Sample Application." );
     }
 
-    private void sampleMethod( String str )
+    // no Javadoc needed
+    private void privateMethod( String str )
     {
-        System.out.println( str );
+    }
+
+    //No javadoc for inner class.
+    public class InnerClass
+    {
+        public InnerClass()
+        {
+        }
+
+        public void nothing()
+        {
+        }
     }
 }

Modified: 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=792176&r1=792175&r2=792176&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/InterfaceWithJavadoc.java (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/InterfaceWithJavadoc.java Wed Jul  8 15:05:18 2009
@@ -20,15 +20,40 @@
  */
 
 /**
- * Some Javadoc.
+ * To add default interface tags.
  */
 public interface InterfaceWithJavadoc
 {
-    /** comment */
+    /** default comment */
     String MY_STRING_CONSTANT = "value";
 
     /**
-     * My method
+     * To add default method tags.
      */
-    public void method( String aString );
+    public void method1( String aString );
+
+    /**
+     * To take care of identifier.
+     */
+    void method2( String aString );
+
+    // one single comment
+    /**
+     * To take care of single comments.
+     *
+     * @param aString a string
+     * @return null
+     */
+    // other single comment
+    public String method3( String aString );
+
+    /**
+     * Nothing.
+     */
+    public String method4( String aString );
+
+    /**
+     * Nothing.
+     */
+    public String method5( String aString );
 }

Modified: 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=792176&r1=792175&r2=792176&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/InterfaceWithNoJavadoc.java (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-test/src/main/java/fix/test/InterfaceWithNoJavadoc.java Wed Jul  8 15:05:18 2009
@@ -23,5 +23,8 @@
 {
     String MY_STRING_CONSTANT = "value";
 
-    public void method( String aString );
+    public void missingJavadoc( String aString );
+
+    // take care of identifier
+    void missingJavadoc2( String aString );
 }