ok, I can reproduce the failure now: it works perfectly with Maven 3 but fails with Maven 2.2 It sounds strange, since such a UT shouldn't be affected by Maven version, but it is. I'm lookgin into it and I'll share my findings
Regards, Hervé Le vendredi 22 avril 2011, Dennis Lundberg a écrit : > Hervé BOUTEMY skrev 2011-04-22 20:03: > > Hi, > > > > I'm trying to fix it since then, but my problem is that I can't reproduce > > the failure. > > > > If you can reproduce it, perhaps I can understand the cause. I suppose it > > has to do with proxy: do you use a proxy? How do you configure it? > > No, I don't use a proxy. If I understand the test correctly it sets up > its proxy during the test. It does this three times. > > The first run sets up a proxy on http://127.0.0.1/ with authentication, > calling it a "dummy proxy". This part of the succeeds and the final > assert is this one: > > if ( isMavenSiteOnline ) > { > // NO -link > http://maven.apache.org/shared/maven-filtering/apidocs/package-list > assertTrue( !optionsContent.contains( "-link > 'http://maven.apache.org/shared/maven-filtering/apidocs'" ) ); > } > > > The second run sets up a proxy using ProxyServer and > AuthAsyncProxyServlet on localhost without authentication using some > default values of the previous classes, calling it a "real proxy". This > part fails at this assert: > > if ( isMavenSiteOnline ) > { > // -link > http://maven.apache.org/shared/maven-filtering/apidocs/package-list > assertTrue( optionsContent.contains( "-link > 'http://maven.apache.org/shared/maven-filtering/apidocs'" ) ); > } > > The third run is like the second but it uses authentication and it has > the same assert as the second one. > > > Note how the asserts differ between the first and second run. I don't > know what they are supposed to check, but to me it would seem logical > that all the three proxy variants would produce the same results. Hence > they should have the same asserts. > > I'll do some more testing locally to see what I can dig up. > > > Regards, > > > > Hervé > > > > Le jeudi 21 avril 2011, Dennis Lundberg a écrit : > >> 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/1 > >> 67/ > >> > >> https://builds.apache.org/hudson/view/M-R/view/Maven/job/maven-plugins/1 > >> 76/ > >> org.apache.maven.plugins$maven-javadoc-plugin/testReport/junit/org.apac > >> he.m aven.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/m > >>> av en/plugin/javadoc/AbstractJavadocMojo.java > >>> maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/m > >>> a ven/plugin/javadoc/JavadocReportTest.java > >>> maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/m > >>> a ven/plugin/javadoc/stubs/ProxyTestMavenProjectStub.java > >>> maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/pr > >>> o xy-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/s > >>> r > >>> c/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java?r > >>> ev= 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/windo > >>> w s/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/s > >>> r > >>> c/test/java/org/apache/maven/plugin/javadoc/JavadocReportTest.java?rev > >>> =10 94194&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/s > >>> r > >>> c/test/java/org/apache/maven/plugin/javadoc/stubs/ProxyTestMavenProjec > >>> tSt ub.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/mave > >>> n/ 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- > >>> t est/proxy-test-plugin-config.xml URL: > >>> http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/s > >>> r > >>> c/test/resources/unit/proxy-test/proxy-test-plugin-config.xml?rev=1094 > >>> 194 &r1=1094193&r2=1094194&view=diff > >>> ======================================================================= > >>> = ====== --- > >>> maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/proxy- > >>> t est/proxy-test-plugin-config.xml (original) +++ > >>> maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/proxy- > >>> t est/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> > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [email protected] > > For additional commands, e-mail: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
