You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2011/04/23 19:15:31 UTC
svn commit: r1096181 -
/maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/JavadocReportTest.java
Author: hboutemy
Date: Sat Apr 23 17:15:30 2011
New Revision: 1096181
URL: http://svn.apache.org/viewvc?rev=1096181&view=rev
Log:
code simplification
Modified:
maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/JavadocReportTest.java
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=1096181&r1=1096180&r2=1096181&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 Sat Apr 23 17:15:30 2011
@@ -34,7 +34,6 @@ import org.apache.maven.plugin.javadoc.P
import org.apache.maven.plugin.testing.AbstractMojoTestCase;
import org.apache.maven.settings.Proxy;
import org.apache.maven.settings.Settings;
-import org.apache.webdav.lib.properties.GetLastModifiedProperty;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.ReaderFactory;
@@ -338,8 +337,8 @@ public class JavadocReportTest
}
assertTrue( contentOptions != null );
- assertTrue( contentOptions.indexOf( "-link" ) != -1 );
- assertTrue( contentOptions.indexOf( "http://java.sun.com/j2se/" ) != -1 );
+ assertTrue( contentOptions.contains( "-link" ) );
+ assertTrue( contentOptions.contains( "http://java.sun.com/j2se/" ) );
}
/**
@@ -365,7 +364,7 @@ public class JavadocReportTest
File optionsFile = new File( mojo.getOutputDirectory(), "options" );
assertTrue( optionsFile.exists() );
String options = readFile( optionsFile );
- assertTrue( options.indexOf( "/target/local-repo/umlgraph/UMLGraph/2.1/UMLGraph-2.1.jar" ) != -1 );
+ assertTrue( options.contains( "/target/local-repo/umlgraph/UMLGraph/2.1/UMLGraph-2.1.jar" ) );
// ----------------------------------------------------------------------
// doclet-path: check if the file generated by UmlGraph exists and if
@@ -382,8 +381,8 @@ public class JavadocReportTest
optionsFile = new File( mojo.getOutputDirectory(), "options" );
assertTrue( optionsFile.exists() );
options = readFile( optionsFile );
- assertTrue( options.indexOf( "/target/local-repo/umlgraph/UMLGraph/2.1/UMLGraph-2.1.jar" ) != -1 );
- assertTrue( options.indexOf( "/target/local-repo/umlgraph/UMLGraph-bis/2.1/UMLGraph-bis-2.1.jar" ) != -1 );
+ assertTrue( options.contains( "/target/local-repo/umlgraph/UMLGraph/2.1/UMLGraph-2.1.jar" ) );
+ assertTrue( options.contains( "/target/local-repo/umlgraph/UMLGraph-bis/2.1/UMLGraph-bis-2.1.jar" ) );
}
/**
@@ -492,7 +491,7 @@ public class JavadocReportTest
File appFile = new File( apidocs, "taglet/test/App.html" );
assertTrue( appFile.exists() );
String appString = readFile( appFile );
- assertTrue( appString.indexOf( "<b>To Do:</b>" ) != -1 );
+ assertTrue( appString.contains( "<b>To Do:</b>" ) );
}
/**
@@ -586,13 +585,13 @@ public class JavadocReportTest
app = new File( apidocs, "resources/test/App.html" );
assertTrue( app.exists() );
content = readFile( app );
- assertTrue( content.indexOf( "<img src=\"doc-files/maven-feather.png\" alt=\"Maven\"/>" ) != -1 );
+ assertTrue( content.contains( "<img src=\"doc-files/maven-feather.png\" alt=\"Maven\"/>" ) );
assertFalse( new File( apidocs, "resources/test/doc-files/maven-feather.png" ).exists() );
app2 = new File( apidocs, "resources/test2/App2.html" );
assertTrue( app2.exists() );
content = readFile( app2 );
- assertTrue( content.indexOf( "<img src=\"doc-files/maven-feather.png\" alt=\"Maven\"/>" ) != -1 );
+ assertTrue( content.contains( "<img src=\"doc-files/maven-feather.png\" alt=\"Maven\"/>" ) );
assertTrue( new File( apidocs, "resources/test2/doc-files/maven-feather.png" ).exists() );
}
@@ -631,7 +630,7 @@ public class JavadocReportTest
File app = new File( apidocs, "resources/test/App.html" );
assertTrue( app.exists() );
readed = readFile( app );
- assertTrue( readed.indexOf( "<img src=\"doc-files/maven-feather.png\" alt=\"Maven\"/>" ) != -1 );
+ assertTrue( readed.contains( "<img src=\"doc-files/maven-feather.png\" alt=\"Maven\"/>" ) );
assertTrue( new File( apidocs, "resources/test/doc-files/maven-feather.png" ).exists() );
}
@@ -665,11 +664,11 @@ public class JavadocReportTest
File app = new File( getBasedir(), "target/test/unit/tag-test/target/site/apidocs/tag/test/App.html" );
assertTrue( FileUtils.fileExists( app.getAbsolutePath() ) );
String readed = readFile( app );
- assertTrue( readed.indexOf( "<B>To do something:</B>" ) != -1 );
- assertTrue( readed.indexOf( "<B>Generator Class:</B>" ) != -1 );
- assertTrue( readed.indexOf( "<B>Version:</B>" ) != -1 );
- assertTrue( readed.indexOf( "<DT><B>Version:</B></DT>" + LINE_SEPARATOR + " <DD>1.0</DD>" + LINE_SEPARATOR
- + "</DL>" ) != -1 );
+ assertTrue( readed.contains( "<B>To do something:</B>" ) );
+ assertTrue( readed.contains( "<B>Generator Class:</B>" ) );
+ assertTrue( readed.contains( "<B>Version:</B>" ) );
+ assertTrue( readed.contains( "<DT><B>Version:</B></DT>" + LINE_SEPARATOR + " <DD>1.0</DD>" + LINE_SEPARATOR
+ + "</DL>" ) );
}
/**
@@ -743,16 +742,16 @@ public class JavadocReportTest
File overviewSummary = new File( apidocs, "overview-summary.html" );
assertTrue( overviewSummary.exists() );
String content = readFile( overviewSummary );
- assertTrue( content.indexOf( "Top - Copyright © All rights reserved." ) != -1 );
- assertTrue( content.indexOf( "Header - Copyright © All rights reserved." ) != -1 );
- assertTrue( content.indexOf( "Footer - Copyright © All rights reserved." ) != -1 );
+ assertTrue( content.contains( "Top - Copyright © All rights reserved." ) );
+ assertTrue( content.contains( "Header - Copyright © All rights reserved." ) );
+ assertTrue( content.contains( "Footer - Copyright © All rights reserved." ) );
File packageSummary = new File( apidocs, "jdk6/test/package-summary.html" );
assertTrue( packageSummary.exists() );
content = readFile( packageSummary );
- assertTrue( content.indexOf( "Top - Copyright © All rights reserved." ) != -1 );
- assertTrue( content.indexOf( "Header - Copyright © All rights reserved." ) != -1 );
- assertTrue( content.indexOf( "Footer - Copyright © All rights reserved." ) != -1 );
+ assertTrue( content.contains( "Top - Copyright © All rights reserved." ) );
+ assertTrue( content.contains( "Header - Copyright © All rights reserved." ) );
+ assertTrue( content.contains( "Footer - Copyright © All rights reserved." ) );
}
/**
@@ -790,12 +789,12 @@ public class JavadocReportTest
File commandLine = new File( getBasedir(), "target/test/unit/proxy-test/target/site/apidocs/javadoc." + ( SystemUtils.IS_OS_WINDOWS ? "bat" : "sh" ) );
assertTrue( FileUtils.fileExists( commandLine.getAbsolutePath() ) );
String readed = readFile( commandLine );
- assertTrue( readed.indexOf( "-J-Dhttp.proxySet=true" ) != -1 );
- assertTrue( readed.indexOf( "-J-Dhttp.proxyHost=127.0.0.1" ) != -1 );
- assertTrue( readed.indexOf( "-J-Dhttp.proxyPort=80" ) != -1 );
- assertTrue( readed.indexOf( "-J-Dhttp.proxyUser=\\\"toto\\\"" ) != -1 );
- assertTrue( readed.indexOf( "-J-Dhttp.proxyPassword=\\\"toto\\\"" ) != -1 );
- assertTrue( readed.indexOf( "-J-Dhttp.nonProxyHosts=\\\"www.google.com|*.somewhere.com\\\"" ) != -1 );
+ assertTrue( readed.contains( "-J-Dhttp.proxySet=true" ) );
+ assertTrue( readed.contains( "-J-Dhttp.proxyHost=127.0.0.1" ) );
+ assertTrue( readed.contains( "-J-Dhttp.proxyPort=80" ) );
+ assertTrue( readed.contains( "-J-Dhttp.proxyUser=\\\"toto\\\"" ) );
+ assertTrue( readed.contains( "-J-Dhttp.proxyPassword=\\\"toto\\\"" ) );
+ assertTrue( readed.contains( "-J-Dhttp.nonProxyHosts=\\\"www.google.com|*.somewhere.com\\\"" ) );
File options = new File( getBasedir(), "target/test/unit/proxy-test/target/site/apidocs/options" );
assertTrue( FileUtils.fileExists( options.getAbsolutePath() ) );
@@ -803,7 +802,7 @@ public class JavadocReportTest
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'" ) );
+ assertFalse( optionsContent.contains( "-link 'http://maven.apache.org/shared/maven-filtering/apidocs'" ) );
}
// real proxy
@@ -828,9 +827,9 @@ public class JavadocReportTest
setVariableValueToObject( mojo, "remoteRepositories", mojo.project.getRemoteArtifactRepositories() );
mojo.execute();
readed = readFile( commandLine );
- assertTrue( readed.indexOf( "-J-Dhttp.proxySet=true" ) != -1 );
- assertTrue( readed.indexOf( "-J-Dhttp.proxyHost=" + proxyServer.getHostName() ) != -1 );
- assertTrue( readed.indexOf( "-J-Dhttp.proxyPort=" + proxyServer.getPort() ) != -1 );
+ assertTrue( readed.contains( "-J-Dhttp.proxySet=true" ) );
+ assertTrue( readed.contains( "-J-Dhttp.proxyHost=" + proxyServer.getHostName() ) );
+ assertTrue( readed.contains( "-J-Dhttp.proxyPort=" + proxyServer.getPort() ) );
optionsContent = readFile( options );
isMavenSiteOnline =
@@ -845,11 +844,6 @@ public class JavadocReportTest
{
getContainer().getLogger().warn( "unable to reach maven.apache.org: link detection test unavailable." );
}
- assertTrue( true );
- }
- catch ( Exception e )
- {
- assertTrue( false );
}
finally
{
@@ -883,11 +877,11 @@ public class JavadocReportTest
setVariableValueToObject( mojo, "remoteRepositories", mojo.project.getRemoteArtifactRepositories() );
mojo.execute();
readed = readFile( commandLine );
- assertTrue( readed.indexOf( "-J-Dhttp.proxySet=true" ) != -1 );
- assertTrue( readed.indexOf( "-J-Dhttp.proxyHost=" + proxyServer.getHostName() ) != -1 );
- assertTrue( readed.indexOf( "-J-Dhttp.proxyPort=" + proxyServer.getPort() ) != -1 );
- assertTrue( readed.indexOf( "-J-Dhttp.proxyUser=\\\"foo\\\"" ) != -1 );
- assertTrue( readed.indexOf( "-J-Dhttp.proxyPassword=\\\"bar\\\"" ) != -1 );
+ assertTrue( readed.contains( "-J-Dhttp.proxySet=true" ) );
+ assertTrue( readed.contains( "-J-Dhttp.proxyHost=" + proxyServer.getHostName() ) );
+ assertTrue( readed.contains( "-J-Dhttp.proxyPort=" + proxyServer.getPort() ) );
+ assertTrue( readed.contains( "-J-Dhttp.proxyUser=\\\"foo\\\"" ) );
+ assertTrue( readed.contains( "-J-Dhttp.proxyPassword=\\\"bar\\\"" ) );
optionsContent = readFile( options );
if ( isMavenSiteOnline )
@@ -895,11 +889,6 @@ public class JavadocReportTest
// -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 );
- }
- catch ( Exception e )
- {
- assertTrue( false );
}
finally
{
@@ -1147,34 +1136,34 @@ public class JavadocReportTest
mojo.execute();
String content = readFile( helpfile );
- assertTrue( content.indexOf( "<!-- Generated by javadoc" ) != -1 );
+ assertTrue( content.contains( "<!-- Generated by javadoc" ) );
String optionsContent = readFile( options );
- assertTrue( optionsContent.indexOf( "-helpfile" ) == -1 );
+ assertFalse( optionsContent.contains( "-helpfile" ) );
// helpfile defined in a javadoc plugin dependency
setVariableValueToObject( mojo, "helpfile", "com/mycompany/app/javadoc/helpfile/help-doc.html" );
mojo.execute();
content = readFile( helpfile );
- assertTrue( content.indexOf( "<!-- Help file from artefact -->" ) != -1 );
+ assertTrue( content.contains( "<!-- Help file from artefact -->" ) );
optionsContent = readFile( options );
- assertTrue( optionsContent.indexOf( "-helpfile" ) != -1 );
+ assertTrue( optionsContent.contains( "-helpfile" ) );
File help = new File( apidocs, "help-doc.html" );
- assertTrue( optionsContent.indexOf( "'" + help.getAbsolutePath().replaceAll( "\\\\", "/" ) + "'" ) != -1 );
+ assertTrue( optionsContent.contains( "'" + help.getAbsolutePath().replaceAll( "\\\\", "/" ) + "'" ) );
// helpfile defined as a project resource
setVariableValueToObject( mojo, "helpfile", "com/mycompany/app/javadoc/helpfile2/help-doc.html" );
mojo.execute();
content = readFile( helpfile );
- assertTrue( content.indexOf( "<!-- Help file from file -->" ) != -1 );
+ assertTrue( content.contains( "<!-- Help file from file -->" ) );
optionsContent = readFile( options );
- assertTrue( optionsContent.indexOf( "-helpfile" ) != -1 );
+ assertTrue( optionsContent.contains( "-helpfile" ) );
help = new File( unit, "helpfile-test/src/main/resources/com/mycompany/app/javadoc/helpfile2/help-doc.html" );
- assertTrue( optionsContent.indexOf( "'" + help.getAbsolutePath().replaceAll( "\\\\", "/" ) + "'" ) != -1 );
+ assertTrue( optionsContent.contains( "'" + help.getAbsolutePath().replaceAll( "\\\\", "/" ) + "'" ) );
// helpfile defined as file
help = new File( unit, "helpfile-test/src/main/resources/com/mycompany/app/javadoc/helpfile2/help-doc.html" );
@@ -1182,10 +1171,10 @@ public class JavadocReportTest
mojo.execute();
content = readFile( helpfile );
- assertTrue( content.indexOf( "<!-- Help file from file -->" ) != -1 );
+ assertTrue( content.contains( "<!-- Help file from file -->" ) );
optionsContent = readFile( options );
- assertTrue( optionsContent.indexOf( "-helpfile" ) != -1 );
- assertTrue( optionsContent.indexOf( "'" + help.getAbsolutePath().replaceAll( "\\\\", "/" ) + "'" ) != -1 );
+ assertTrue( optionsContent.contains( "-helpfile" ) );
+ assertTrue( optionsContent.contains( "'" + help.getAbsolutePath().replaceAll( "\\\\", "/" ) + "'" ) );
}
}