Hi

This commit seems to have broken the unit tests for Maven Javadoc
Plugin. I can see the broken test on my machine and in Jenkins:

https://builds.apache.org/hudson/view/M-R/view/Maven/job/maven-plugins/167/

https://builds.apache.org/hudson/view/M-R/view/Maven/job/maven-plugins/176/org.apache.maven.plugins$maven-javadoc-plugin/testReport/junit/org.apache.maven.plugin.javadoc/JavadocReportTest/testProxy/

[email protected] skrev 2011-04-17 22:52:
> Author: hboutemy
> Date: Sun Apr 17 20:52:02 2011
> New Revision: 1094194
> 
> URL: http://svn.apache.org/viewvc?rev=1094194&view=rev
> Log:
> |MJAVADOC-317] limited javadoc links checks for automatic dependency urls
> 
> Modified:
>     maven/plugins/trunk/maven-javadoc-plugin/   (props changed)
>     
> maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java
>     
> maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/JavadocReportTest.java
>     
> maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/ProxyTestMavenProjectStub.java
>     
> maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/proxy-test/proxy-test-plugin-config.xml
> 
> Propchange: maven/plugins/trunk/maven-javadoc-plugin/
> ------------------------------------------------------------------------------
> --- svn:ignore (original)
> +++ svn:ignore Sun Apr 17 20:52:02 2011
> @@ -8,3 +8,5 @@ target
>  cobertura.ser
>  .settings
>  bin
> +
> +javadoc-options-javadoc-resources.xml
> 
> Modified: 
> maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java
> URL: 
> http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java?rev=1094194&r1=1094193&r2=1094194&view=diff
> ==============================================================================
> --- 
> maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java
>  (original)
> +++ 
> maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java
>  Sun Apr 17 20:52:02 2011
> @@ -3819,7 +3819,6 @@ public abstract class AbstractJavadocMoj
>       * @throws MavenReportException 
>       * @see #detectLinks
>       * @see #getDependenciesLinks()
> -     * @see JavadocUtil#fetchURL(Settings, URL)
>       * @see <a 
> href="http://download.oracle.com/javase/1.4.2/docs/tooldocs/windows/javadoc.html#package-list";>package-list
>  spec</a>
>       */
>      private void addLinkArguments( List<String> arguments )
> @@ -3839,10 +3838,7 @@ public abstract class AbstractJavadocMoj
>                  link = link.substring( 0, link.lastIndexOf( "/" ) );
>              }
>  
> -            if ( isValidJavadocLink( link ) )
> -            {
> -                addArgIfNotEmpty( arguments, "-link", 
> JavadocUtil.quotedPathArgument( link ), true );
> -            }
> +            addArgIfNotEmpty( arguments, "-link", 
> JavadocUtil.quotedPathArgument( link ), true );
>          }
>      }
>  
> @@ -5320,6 +5316,7 @@ public abstract class AbstractJavadocMoj
>       * @return the detected Javadoc links using the Maven conventions for 
> all dependencies defined in the current
>       * project or an empty list.
>       * @see #detectLinks
> +     * @see #isValidJavadocLink(String)
>       * @since 2.6
>       */
>      private List<String> getDependenciesLinks()
> @@ -5332,40 +5329,35 @@ public abstract class AbstractJavadocMoj
>          getLog().debug( "Trying to add links for dependencies..." );
>  
>          List<String> dependenciesLinks = new ArrayList<String>();
> -        for ( Iterator<Artifact> it = 
> project.getDependencyArtifacts().iterator(); it.hasNext(); )
> +
> +        final Set<Artifact> dependencies = project.getDependencyArtifacts();
> +        for ( Artifact artifact : dependencies )
>          {
> -            Artifact artifact = it.next();
> +            if ( artifact.getFile() == null || !artifact.getFile().exists() )
> +            {
> +                continue;
> +            }
>  
> -            if ( artifact != null && artifact.getFile() != null && 
> artifact.getFile().exists() )
> +            try
>              {
> -                try
> +                MavenProject artifactProject =
> +                    mavenProjectBuilder.buildFromRepository( artifact, 
> remoteRepositories, localRepository );
> +
> +                if ( StringUtils.isNotEmpty( artifactProject.getUrl() ) )
>                  {
> -                    MavenProject artifactProject =
> -                        mavenProjectBuilder.buildFromRepository( artifact, 
> remoteRepositories, localRepository );
> +                    String url = getJavadocLink( artifactProject );
>  
> -                    if ( StringUtils.isNotEmpty( artifactProject.getUrl() ) )
> +                    if ( isValidJavadocLink( url ) )
>                      {
> -                        String url = getJavadocLink( artifactProject );
> +                        getLog().debug( "Added Javadoc link: " + url + " for 
> " + artifactProject.getId() );
>  
> -                        if ( getLog().isDebugEnabled() )
> -                        {
> -                            getLog().debug(
> -                                            "Added Javadoc link: " + url + " 
> for the artifact: "
> -                                                + artifactProject.getId() );
> -                        }
>                          dependenciesLinks.add( url );
>                      }
>                  }
> -                catch ( ProjectBuildingException e )
> -                {
> -                    if ( getLog().isDebugEnabled() )
> -                    {
> -                        getLog().debug(
> -                                       "Error when building the artifact: " 
> + artifact.toString()
> -                                           + ". Ignored to add Javadoc 
> link." );
> -                    }
> -                    logError( "ProjectBuildingException: " + e.getMessage(), 
> e );
> -                }
> +            }
> +            catch ( ProjectBuildingException e )
> +            {
> +                logError( "ProjectBuildingException for " + 
> artifact.toString() + ": " + e.getMessage(), e );
>              }
>          }
>  
> @@ -5401,24 +5393,16 @@ public abstract class AbstractJavadocMoj
>              }
>              catch ( NumberFormatException e )
>              {
> -                if ( getLog().isDebugEnabled() )
> -                {
> -                    getLog().debug(
> -                                    "NumberFormatException for the source 
> parameter in the maven-compiler-plugin. "
> -                                        + "Ignored it", e );
> -                }
> +                getLog().debug( "NumberFormatException for the source 
> parameter in the maven-compiler-plugin. "
> +                                    + "Ignored it", e );
>              }
>          }
>          else
>          {
> -            if ( getLog().isDebugEnabled() )
> -            {
> -                getLog().debug(
> -                                "No maven-compiler-plugin defined in 
> ${build.plugins} or in "
> -                                    + "${project.build.pluginManagement} for 
> the " + project.getId()
> -                                    + ". Added Javadoc API link according 
> the javadoc executable version i.e.: "
> -                                    + fJavadocVersion );
> -            }
> +            getLog().debug( "No maven-compiler-plugin defined in 
> ${build.plugins} or in "
> +                                + "${project.build.pluginManagement} for the 
> " + project.getId()
> +                                + ". Added Javadoc API link according the 
> javadoc executable version i.e.: "
> +                                + fJavadocVersion );
>          }
>  
>          String javaApiLink = null;
> 
> Modified: 
> maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/JavadocReportTest.java
> URL: 
> http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/JavadocReportTest.java?rev=1094194&r1=1094193&r2=1094194&view=diff
> ==============================================================================
> --- 
> maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/JavadocReportTest.java
>  (original)
> +++ 
> maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/JavadocReportTest.java
>  Sun Apr 17 20:52:02 2011
> @@ -902,6 +902,10 @@ public class JavadocReportTest
>      public void testProxy()
>          throws Exception
>      {
> +        final boolean isMavenSiteOnline =
> +            JavadocUtilTest.isWebSiteOnline( null, 
> getContainer().getLogger(),
> +                                             
> "http://maven.apache.org/shared/maven-filtering/apidocs/package-list"; );
> +
>          Settings settings = new Settings();
>          Proxy proxy = new Proxy();
>  
> @@ -919,6 +923,7 @@ public class JavadocReportTest
>          JavadocReport mojo = (JavadocReport) lookupMojo( "javadoc", testPom 
> );
>          assertNotNull( mojo );
>          setVariableValueToObject( mojo, "settings", settings );
> +        setVariableValueToObject( mojo, "remoteRepositories", 
> mojo.project.getRemoteArtifactRepositories() );
>          mojo.execute();
>  
>          File commandLine = new File( getBasedir(), 
> "target/test/unit/proxy-test/target/site/apidocs/javadoc." + ( 
> SystemUtils.IS_OS_WINDOWS ? "bat" : "sh" ) );
> @@ -934,10 +939,10 @@ public class JavadocReportTest
>          File options = new File( getBasedir(), 
> "target/test/unit/proxy-test/target/site/apidocs/options" );
>          assertTrue( FileUtils.fileExists( options.getAbsolutePath() ) );
>          String optionsContent = readFile( options );
> -        // NO -link 
> http://download.oracle.com/javase/1.5.0/docs/api/docs/api/package-list
> -        if ( JavadocUtilTest.isWebSiteOnline( null, 
> getContainer().getLogger(), "http://download.oracle.com/"; ) )
> +        if ( isMavenSiteOnline )
>          {
> -            assertTrue( optionsContent.indexOf( "-link" ) == -1 );
> +            // NO -link 
> http://maven.apache.org/shared/maven-filtering/apidocs/package-list
> +            assertTrue( !optionsContent.contains( "-link 
> 'http://maven.apache.org/shared/maven-filtering/apidocs'" ) );
>          }
>  
>          // real proxy
> @@ -959,6 +964,7 @@ public class JavadocReportTest
>  
>              mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
>              setVariableValueToObject( mojo, "settings", settings );
> +            setVariableValueToObject( mojo, "remoteRepositories", 
> mojo.project.getRemoteArtifactRepositories() );
>              mojo.execute();
>              readed = readFile( commandLine );
>              assertTrue( readed.indexOf( "-J-Dhttp.proxySet=true" ) != -1 );
> @@ -966,10 +972,10 @@ public class JavadocReportTest
>              assertTrue( readed.indexOf( "-J-Dhttp.proxyPort=" + 
> proxyServer.getPort() ) != -1 );
>  
>              optionsContent = readFile( options );
> -            // -link 
> http://download.oracle.com/javase/1.5.0/docs/api/package-list
> -            if ( JavadocUtilTest.isWebSiteOnline( null, 
> getContainer().getLogger(), "http://download.oracle.com/"; ) )
> +            if ( isMavenSiteOnline )
>              {
> -                assertTrue( optionsContent.indexOf( "-link" ) != -1 );
> +                // -link 
> http://maven.apache.org/shared/maven-filtering/apidocs/package-list
> +                assertTrue( optionsContent.contains( "-link 
> 'http://maven.apache.org/shared/maven-filtering/apidocs'" ) );
>              }
>              assertTrue( true );
>          }
> @@ -1006,6 +1012,7 @@ public class JavadocReportTest
>  
>              mojo = (JavadocReport) lookupMojo( "javadoc", testPom );
>              setVariableValueToObject( mojo, "settings", settings );
> +            setVariableValueToObject( mojo, "remoteRepositories", 
> mojo.project.getRemoteArtifactRepositories() );
>              mojo.execute();
>              readed = readFile( commandLine );
>              assertTrue( readed.indexOf( "-J-Dhttp.proxySet=true" ) != -1 );
> @@ -1015,10 +1022,10 @@ public class JavadocReportTest
>              assertTrue( readed.indexOf( "-J-Dhttp.proxyPassword=\\\"bar\\\"" 
> ) != -1 );
>  
>              optionsContent = readFile( options );
> -            // -link 
> http://download.oracle.com/javase/1.5.0/docs/api/docs/api/package-list
> -            if ( JavadocUtilTest.isWebSiteOnline( null, 
> getContainer().getLogger(), "http://download.oracle.com"; ) )
> +            if ( isMavenSiteOnline )
>              {
> -                assertTrue( optionsContent.indexOf( "-link" ) != -1 );
> +                // -link 
> http://maven.apache.org/shared/maven-filtering/apidocs/package-list
> +                assertTrue( optionsContent.contains( "-link 
> 'http://maven.apache.org/shared/maven-filtering/apidocs'" ) );
>              }
>              assertTrue( true );
>          }
> 
> Modified: 
> maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/ProxyTestMavenProjectStub.java
> URL: 
> http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/ProxyTestMavenProjectStub.java?rev=1094194&r1=1094193&r2=1094194&view=diff
> ==============================================================================
> --- 
> maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/ProxyTestMavenProjectStub.java
>  (original)
> +++ 
> maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/stubs/ProxyTestMavenProjectStub.java
>  Sun Apr 17 20:52:02 2011
> @@ -19,19 +19,26 @@ package org.apache.maven.plugin.javadoc.
>   * under the License.
>   */
>  
> +import org.apache.maven.artifact.Artifact;
>  import org.apache.maven.model.Build;
> +import org.apache.maven.plugin.testing.stubs.ArtifactStub;
>  import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
>  
>  import java.io.File;
>  import java.util.ArrayList;
> +import java.util.HashSet;
>  import java.util.List;
> +import java.util.Set;
>  
>  /**
>   * @author <a href="mailto:[email protected]";>Vincent Siveton</a>
>   * @version $Id$
>   */
> -public class ProxyTestMavenProjectStub extends MavenProjectStub
> +public class ProxyTestMavenProjectStub
> +    extends MavenProjectStub
>  {
> +    private Set<Artifact> dependencyArtifacts = new HashSet<Artifact>();
> +
>      public ProxyTestMavenProjectStub()
>      {
>          readModel( new File( getBasedir(), "proxy-test-plugin-config.xml" ) 
> );
> @@ -52,6 +59,16 @@ public class ProxyTestMavenProjectStub e
>          List<String> compileSourceRoots = new ArrayList<String>();
>          compileSourceRoots.add( getBasedir() + "/src/main/java" );
>          setCompileSourceRoots( compileSourceRoots );
> +
> +        ArtifactStub artifact = new ArtifactStub();
> +        artifact.setGroupId( "org.apache.maven.shared" );
> +        artifact.setArtifactId( "maven-filtering" );
> +        artifact.setVersion( "1.0-beta-4" );
> +        artifact.setScope( Artifact.SCOPE_RUNTIME );
> +        artifact.setType( "jar" );
> +        artifact.setFile( getBasedir() );
> +
> +        dependencyArtifacts.add( artifact );
>      }
>  
>      /** {@inheritDoc} */
> @@ -59,4 +76,9 @@ public class ProxyTestMavenProjectStub e
>      {
>          return new File( super.getBasedir() + 
> "/src/test/resources/unit/proxy-test" );
>      }
> +
> +    public Set<Artifact> getDependencyArtifacts()
> +    {
> +        return dependencyArtifacts;
> +    }
>  }
> 
> Modified: 
> maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/proxy-test/proxy-test-plugin-config.xml
> URL: 
> http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/proxy-test/proxy-test-plugin-config.xml?rev=1094194&r1=1094193&r2=1094194&view=diff
> ==============================================================================
> --- 
> maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/proxy-test/proxy-test-plugin-config.xml
>  (original)
> +++ 
> maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/proxy-test/proxy-test-plugin-config.xml
>  Sun Apr 17 20:52:02 2011
> @@ -42,7 +42,8 @@ under the License.
>            <groups/>
>            <tags/>
>            <stylesheet>java</stylesheet>
> -          <detectJavaApiLink>true</detectJavaApiLink>
> +          <detectJavaApiLink>false</detectJavaApiLink>
> +          <detectLinks>true</detectLinks>
>            <quiet>true</quiet>
>            <debug>true</debug>
>            <failOnError>true</failOnError>
> 
> 
> 


-- 
Dennis Lundberg

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to