This is an automated email from the ASF dual-hosted git repository. slachiewicz pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-javadoc-plugin.git
commit d3fffcaf34e7d0bf8e297aa3a6042884dda79c31 Author: Sylwester Lachiewicz <[email protected]> AuthorDate: Wed Nov 25 21:43:42 2026 +0000 Modernize Groovy IT scripts See https://github.com/apache/maven-invoker-plugin/issues/811. --- src/it/projects/MJAVADOC-110/verify.groovy | 36 +----- src/it/projects/MJAVADOC-126/verify.groovy | 32 +---- src/it/projects/MJAVADOC-172/verify.groovy | 45 ++----- src/it/projects/MJAVADOC-180/verify.groovy | 44 ++----- src/it/projects/MJAVADOC-194/verify.groovy | 68 +++------- src/it/projects/MJAVADOC-259/verify.groovy | 68 +++------- src/it/projects/MJAVADOC-369/verify.groovy | 16 +-- src/it/projects/MJAVADOC-407/verify.groovy | 9 +- src/it/projects/MJAVADOC-414/verify.groovy | 22 +--- src/it/projects/MJAVADOC-437/verify.groovy | 38 +----- src/it/projects/MJAVADOC-444/verify.groovy | 16 +-- src/it/projects/MJAVADOC-497/verify.groovy | 42 ++----- src/it/projects/dependencySource-1/verify.groovy | 26 +--- src/it/projects/dependencySource-2/verify.groovy | 26 +--- src/it/projects/dependencySource-3/verify.groovy | 26 +--- src/it/projects/dependencySource-4/verify.groovy | 26 +--- src/it/projects/detectLinks/verify.groovy | 151 +++++------------------ 17 files changed, 131 insertions(+), 560 deletions(-) diff --git a/src/it/projects/MJAVADOC-110/verify.groovy b/src/it/projects/MJAVADOC-110/verify.groovy index 547fb2bb..b4bd978a 100644 --- a/src/it/projects/MJAVADOC-110/verify.groovy +++ b/src/it/projects/MJAVADOC-110/verify.groovy @@ -20,35 +20,11 @@ import java.io.*; -boolean result = true; +File target = new File( basedir, "target" ); +assert target.exists() && target.isDirectory() : "target file is missing or a directory." -try -{ - File target = new File( basedir, "target" ); - if ( !target.exists() || !target.isDirectory() ) - { - System.err.println( "target file is missing or a directory." ); - return false; - } +File apidocs = new File( target, "reports/apidocs" ); +assert apidocs.exists() && apidocs.isDirectory() : "target/reports/apidocs file is missing or a directory." - File apidocs = new File( target, "reports/apidocs" ); - if ( !apidocs.exists() || !apidocs.isDirectory() ) - { - System.err.println( "target/reports/apidocs file is missing or a directory." ); - return false; - } - - File htmlFile = new File( apidocs, "Test.html" ); - if ( !htmlFile.isFile() ) - { - System.err.println( "target/reports/apidocs/Test.html file is missing or a a file." ); - return false; - } -} -catch( IOException e ) -{ - e.printStackTrace(); - result = false; -} - -return result; +File htmlFile = new File( apidocs, "Test.html" ); +assert htmlFile.isFile() : "target/reports/apidocs/Test.html file is missing or a a file." diff --git a/src/it/projects/MJAVADOC-126/verify.groovy b/src/it/projects/MJAVADOC-126/verify.groovy index da4e155b..ecf6e293 100644 --- a/src/it/projects/MJAVADOC-126/verify.groovy +++ b/src/it/projects/MJAVADOC-126/verify.groovy @@ -21,38 +21,16 @@ import java.io.*; File target = new File( basedir, "test/target" ); -if ( !target.isDirectory() ) -{ - System.err.println( "target is missing or not a directory." ); - return false; -} +assert target.isDirectory() : "target is missing or not a directory." File apidocs = new File( basedir, "test/target/reports/apidocs" ); -if ( !apidocs.isDirectory() ) -{ - System.err.println( apidocs.getAbsolutePath() + " is missing or not a directory." ); - return false; -} +assert apidocs.isDirectory() : apidocs.getAbsolutePath() + " is missing or not a directory." File file1 = new File( apidocs, "file1.txt" ); -if ( !file1.isFile() ) -{ - System.err.println( file1.getAbsolutePath() + " is missing or a directory." ); - return false; -} +assert file1.isFile() : file1.getAbsolutePath() + " is missing or a directory." File file2 = new File( apidocs, "file2.txt" ); -if ( !file2.isFile() ) -{ - System.err.println( file2.getAbsolutePath() + " is missing or a directory." ); - return false; -} +assert file2.isFile() : file2.getAbsolutePath() + " is missing or a directory." File metainf = new File( apidocs, "META-INF" ); -if ( metainf.isDirectory() ) -{ - System.err.println( metainf.getAbsolutePath() + " exists." ); - return false; -} - -return true; +assert !metainf.isDirectory() : metainf.getAbsolutePath() + " exists." diff --git a/src/it/projects/MJAVADOC-172/verify.groovy b/src/it/projects/MJAVADOC-172/verify.groovy index 7d82745d..54fe5046 100644 --- a/src/it/projects/MJAVADOC-172/verify.groovy +++ b/src/it/projects/MJAVADOC-172/verify.groovy @@ -19,45 +19,16 @@ */ import java.io.*; -import org.codehaus.plexus.util.*; -boolean result = true; +File target = new File( basedir, "target" ); +assert target.exists() && target.isDirectory() : "target file is missing or a directory." -try -{ - File target = new File( basedir, "target" ); - if ( !target.exists() || !target.isDirectory() ) - { - System.err.println( "target file is missing or a directory." ); - return false; - } +File apidocs = new File( basedir, "target/reports/apidocs" ); +assert apidocs.exists() && apidocs.isDirectory() : "target/reports/apidocs file is missing or a directory." - File apidocs = new File( basedir, "target/reports/apidocs" ); - if ( !apidocs.exists() || !apidocs.isDirectory() ) - { - System.err.println( "target/reports/apidocs file is missing or a directory." ); - return false; - } +File options = new File( apidocs, "options" ); +assert options.exists() && options.isFile() : "target/reports/apidocs/options file is missing or not a file." - File options = new File( apidocs, "options" ); - if ( !options.exists() || !options.isFile() ) - { - System.err.println( "target/reports/apidocs/options file is missing or not a file." ); - return false; - } +String str = options.getText( 'UTF-8' ); - String str = FileUtils.fileRead( options ); - - if ( !str.contains( "junit-4.13.1.jar" ) ) - { - System.err.println( "Javadoc doesn't used correct artifacts." ); - return false; - } -} -catch( IOException e ) -{ - e.printStackTrace(); - result = false; -} - -return result; +assert str.contains( "junit-4.13.1.jar" ) : "Javadoc doesn't used correct artifacts." diff --git a/src/it/projects/MJAVADOC-180/verify.groovy b/src/it/projects/MJAVADOC-180/verify.groovy index 325e21be..00bffe0f 100644 --- a/src/it/projects/MJAVADOC-180/verify.groovy +++ b/src/it/projects/MJAVADOC-180/verify.groovy @@ -20,42 +20,14 @@ import java.io.*; -boolean result = true; +File target = new File( basedir, "target" ); +assert target.exists() && target.isDirectory() : "target file is missing or a directory." -try -{ - File target = new File( basedir, "target" ); - if ( !target.exists() || !target.isDirectory() ) - { - System.err.println( "target file is missing or a directory." ); - return false; - } +File testapidocs = new File( basedir, "target/reports/testapidocs" ); +assert testapidocs.exists() && testapidocs.isDirectory() : "target/reports/testapidocs file is missing or a directory." - File testapidocs = new File( basedir, "target/reports/testapidocs" ); - if ( !testapidocs.exists() || !testapidocs.isDirectory() ) - { - System.err.println( "target/reports/testapidocs file is missing or a directory." ); - return false; - } +File options = new File( testapidocs, "options" ); +assert options.exists() && options.isFile() : "target/reports/testapidocs/options file is missing or not a file." - File options = new File( testapidocs, "options" ); - if ( !options.exists() || !options.isFile() ) - { - System.err.println( "target/reports/testapidocs/options file is missing or not a file." ); - return false; - } - - File index = new File( testapidocs, "index.html" ); - if ( !index.exists() || !index.isFile() ) - { - System.err.println( "target/reports/testapidocs/index.html file is missing or not a file." ); - return false; - } -} -catch( IOException e ) -{ - e.printStackTrace(); - result = false; -} - -return result; +File index = new File( testapidocs, "index.html" ); +assert index.exists() && index.isFile() : "target/reports/testapidocs/index.html file is missing or not a file." diff --git a/src/it/projects/MJAVADOC-194/verify.groovy b/src/it/projects/MJAVADOC-194/verify.groovy index 655e1cfc..bc2487fc 100644 --- a/src/it/projects/MJAVADOC-194/verify.groovy +++ b/src/it/projects/MJAVADOC-194/verify.groovy @@ -20,63 +20,23 @@ import java.io.*; -boolean result = true; +File target = new File( basedir, "target" ); +assert target.exists() && target.isDirectory() : "target file is missing or a directory." -try -{ - File target = new File( basedir, "target" ); - if ( !target.exists() || !target.isDirectory() ) - { - System.err.println( "target file is missing or a directory." ); - return false; - } +File apidocs = new File( basedir, "target/reports/apidocs" ); +assert apidocs.exists() && apidocs.isDirectory() : "target/reports/apidocs file is missing or a directory." - File apidocs = new File( basedir, "target/reports/apidocs" ); - if ( !apidocs.exists() || !apidocs.isDirectory() ) - { - System.err.println( "target/reports/apidocs file is missing or a directory." ); - return false; - } +File index = new File( apidocs, "index.html" ); +assert index.exists() && index.isFile() : "target/reports/apidocs/index.html file is missing or not a file." - File index = new File( apidocs, "index.html" ); - if ( !index.exists() || !index.isFile() ) - { - System.err.println( "target/reports/apidocs/index.html file is missing or not a file." ); - return false; - } +File test1 = new File( apidocs, "test/Test1.html" ); +assert test1.exists() && test1.isFile() : "target/reports/apidocs/test/Test1.html file is missing or not a file." - File test1 = new File( apidocs, "test/Test1.html" ); - if ( !test1.exists() || !test1.isFile() ) - { - System.err.println( "target/reports/apidocs/test/Test1.html file is missing or not a file." ); - return false; - } +File test2 = new File( apidocs, "test/Test2.html" ); +assert test2.exists() && test2.isFile() : "target/reports/apidocs/test/Test2.html file is missing or not a file." - File test2 = new File( apidocs, "test/Test2.html" ); - if ( !test2.exists() || !test2.isFile() ) - { - System.err.println( "target/reports/apidocs/test/Test2.html file is missing or not a file." ); - return false; - } +File generatedTest1 = new File( apidocs, "test/GeneratedTest1.html" ); +assert generatedTest1.exists() && generatedTest1.isFile() : "target/reports/apidocs/test/GeneratedTest1.html file is missing or not a file." - File generatedTest1 = new File( apidocs, "test/GeneratedTest1.html" ); - if ( !generatedTest1.exists() || !generatedTest1.isFile() ) - { - System.err.println( "target/reports/apidocs/test/GeneratedTest1.html file is missing or not a file." ); - return false; - } - - File generatedTest2 = new File( apidocs, "test/GeneratedTest2.html" ); - if ( !generatedTest2.exists() || !generatedTest2.isFile() ) - { - System.err.println( "target/reports/apidocs/test/GeneratedTest2.html file is missing or not a file." ); - return false; - } -} -catch( IOException e ) -{ - e.printStackTrace(); - result = false; -} - -return result; +File generatedTest2 = new File( apidocs, "test/GeneratedTest2.html" ); +assert generatedTest2.exists() && generatedTest2.isFile() : "target/reports/apidocs/test/GeneratedTest2.html file is missing or not a file." diff --git a/src/it/projects/MJAVADOC-259/verify.groovy b/src/it/projects/MJAVADOC-259/verify.groovy index 8c104772..e5a4191b 100644 --- a/src/it/projects/MJAVADOC-259/verify.groovy +++ b/src/it/projects/MJAVADOC-259/verify.groovy @@ -20,55 +20,19 @@ import java.io.*; -boolean result = true; - -try -{ - // Generated files checks - File apidocs = new File( basedir, "target/site/apidocs" ); - if ( !apidocs.isDirectory() ) - { - System.err.println( apidocs.getAbsolutePath() + " dir is missing or a directory." ); - return false; - } - - File resourcesDir = new File( apidocs, "resources" ); - if ( !resourcesDir.isDirectory() ) - { - System.err.println( resourcesDir.getAbsolutePath() + " dir is missing or a directory." ); - return false; - } - - File inheritSrc = new File( basedir, "src/main/javadoc/resources/inherit.gif" ); - File inheritTarget = new File( resourcesDir, "inherit.gif" ); - if ( !inheritTarget.isFile() ) - { - System.err.println( inheritTarget.getAbsolutePath() + " file is missing or a file." ); - return false; - } - if ( inheritSrc.length() != inheritTarget.length() ) - { - System.err.println( "inherit.gif seems not copied." ); - return false; - } - - File docFiles = new File( apidocs, "com/mycompany/myapp/doc-files" ); - if ( !docFiles.isDirectory() ) - { - System.err.println( docFiles.getAbsolutePath() + " dir is missing or a directory." ); - return false; - } - resourcesDir = new File( apidocs, "com/mycompany/myapp/resources" ); - if ( resourcesDir.isDirectory() ) - { - System.err.println( resourcesDir.getAbsolutePath() + " dir exists." ); - return false; - } -} -catch( RuntimeException e ) -{ - e.printStackTrace(); - return false; -} - -return result; +// Generated files checks +File apidocs = new File( basedir, "target/site/apidocs" ); +assert apidocs.isDirectory() : apidocs.getAbsolutePath() + " dir is missing or a directory." + +File resourcesDir = new File( apidocs, "resources" ); +assert resourcesDir.isDirectory() : resourcesDir.getAbsolutePath() + " dir is missing or a directory." + +File inheritSrc = new File( basedir, "src/main/javadoc/resources/inherit.gif" ); +File inheritTarget = new File( resourcesDir, "inherit.gif" ); +assert inheritTarget.isFile() : inheritTarget.getAbsolutePath() + " file is missing or a file." +assert inheritSrc.length() == inheritTarget.length() : "inherit.gif seems not copied." + +File docFiles = new File( apidocs, "com/mycompany/myapp/doc-files" ); +assert docFiles.isDirectory() : docFiles.getAbsolutePath() + " dir is missing or a directory." +resourcesDir = new File( apidocs, "com/mycompany/myapp/resources" ); +assert !resourcesDir.isDirectory() : resourcesDir.getAbsolutePath() + " dir exists." diff --git a/src/it/projects/MJAVADOC-369/verify.groovy b/src/it/projects/MJAVADOC-369/verify.groovy index 105617a5..162838ae 100644 --- a/src/it/projects/MJAVADOC-369/verify.groovy +++ b/src/it/projects/MJAVADOC-369/verify.groovy @@ -19,22 +19,12 @@ */ import java.io.*; -import org.codehaus.plexus.util.*; File indexFile = new File( basedir, "target/site/apidocs/index.html" ); -if ( !indexFile.exists() ) -{ - System.err.println( indexFile.getAbsolutePath() + " is missing." ); - return false; -} +assert indexFile.exists() : indexFile.getAbsolutePath() + " is missing." File buildLog = new File( basedir, "build.log" ); -String content = IOUtil.toString( new FileInputStream( buildLog ) ); +String content = buildLog.getText( 'UTF-8' ); String needle = ">>> maven-javadoc-plugin"; -if ( content.contains( needle ) ) -{ - System.err.println( "build.log contains '" + needle + "'" ); - return false; -} -return true; \ No newline at end of file +assert !content.contains( needle ) : "build.log contains '" + needle + "'" \ No newline at end of file diff --git a/src/it/projects/MJAVADOC-407/verify.groovy b/src/it/projects/MJAVADOC-407/verify.groovy index 46a7d3da..b60fa86d 100644 --- a/src/it/projects/MJAVADOC-407/verify.groovy +++ b/src/it/projects/MJAVADOC-407/verify.groovy @@ -19,14 +19,7 @@ */ import java.io.*; -import org.codehaus.plexus.util.*; File javadocFile = new File( basedir, "target/reports/apidocs/foo/Bar.html" ); -if ( !javadocFile.exists() ) -{ - System.err.println( javadocFile.getAbsolutePath() + " is missing." ); - return false; -} - -return true; \ No newline at end of file +assert javadocFile.exists() : javadocFile.getAbsolutePath() + " is missing." \ No newline at end of file diff --git a/src/it/projects/MJAVADOC-414/verify.groovy b/src/it/projects/MJAVADOC-414/verify.groovy index cf9faed6..71fb2da5 100644 --- a/src/it/projects/MJAVADOC-414/verify.groovy +++ b/src/it/projects/MJAVADOC-414/verify.groovy @@ -19,29 +19,15 @@ */ import java.io.*; -import org.codehaus.plexus.util.*; File indexFile = new File( basedir, "target/reports/testapidocs/mjavadoc414/test/AppTest.html" ); -if ( !indexFile.exists() ) -{ - System.err.println( indexFile.getAbsolutePath() + " is missing." ); - return false; -} +assert indexFile.exists() : indexFile.getAbsolutePath() + " is missing." File buildLog = new File( basedir, "build.log" ); -String content = IOUtil.toString( new FileInputStream( buildLog ) ); +String content = buildLog.getText( 'UTF-8' ); String importError = "error: cannot find symbol"; -if ( content.contains( importError ) ) -{ - System.err.println( "build.log contains '" + importError + "'" ); - return false; -} +assert !content.contains( importError ) : "build.log contains '" + importError + "'" String referenceWarning = "Tag @link: reference not found: mjavadoc414.App"; -if ( content.contains( referenceWarning ) ) -{ - System.err.println( "build.log contains '" + referenceWarning + "'" ); - return false; -} -return true; +assert !content.contains( referenceWarning ) : "build.log contains '" + referenceWarning + "'" diff --git a/src/it/projects/MJAVADOC-437/verify.groovy b/src/it/projects/MJAVADOC-437/verify.groovy index 1e7e4fd3..f00b4aea 100644 --- a/src/it/projects/MJAVADOC-437/verify.groovy +++ b/src/it/projects/MJAVADOC-437/verify.groovy @@ -31,39 +31,7 @@ import java.io.*; // If the package prefix is missing, we know that maven-javadoc-plugin // failed to resolve the classpath dependencies. -boolean result = true; +File javadoc = new File( basedir, "target/reports/apidocs/com/example/bar/Bar.html" ); +assert javadoc.exists() : javadoc + " is missing" -try -{ - File javadoc = new File( basedir, "target/reports/apidocs/com/example/bar/Bar.html" ); - if ( !javadoc.exists() ) - { - System.err.println( javadoc + " is missing" ); - return false; - } - - FileReader fr = new FileReader( javadoc ); - BufferedReader br = new BufferedReader( fr ); - String line; - while ( ( line = br.readLine() ) != null ) - { - if ( line.contains( "org.apache.commons.io" ) ) - { - result = true; - break; - } - } - br.close(); - if ( !result ) - { - System.err.println( "package name org.apache.commons.io not found" ); - } - return result; -} -catch ( Exception e ) -{ - e.printStackTrace(); - return false; -} - -return result; +assert javadoc.readLines( 'UTF-8' ).any { it.contains( "org.apache.commons.io" ) } : "package name org.apache.commons.io not found" diff --git a/src/it/projects/MJAVADOC-444/verify.groovy b/src/it/projects/MJAVADOC-444/verify.groovy index 828d834b..3ddc3df4 100644 --- a/src/it/projects/MJAVADOC-444/verify.groovy +++ b/src/it/projects/MJAVADOC-444/verify.groovy @@ -19,22 +19,12 @@ */ import java.io.*; -import org.codehaus.plexus.util.*; File indexFile = new File( basedir, "target/site/apidocs/index.html" ); -if ( !indexFile.exists() ) -{ - System.err.println( indexFile.getAbsolutePath() + " is missing." ); - return false; -} +assert indexFile.exists() : indexFile.getAbsolutePath() + " is missing." File buildLog = new File( basedir, "build.log" ); -String content = IOUtil.toString( new FileInputStream( buildLog ) ); +String content = buildLog.getText( 'UTF-8' ); String needle = ">>> maven-javadoc-plugin"; -if ( content.contains( needle ) ) -{ - System.err.println( "build.log contains '" + needle + "'" ); - return false; -} -return true; +assert !content.contains( needle ) : "build.log contains '" + needle + "'" diff --git a/src/it/projects/MJAVADOC-497/verify.groovy b/src/it/projects/MJAVADOC-497/verify.groovy index 8aa8285f..e92aa676 100644 --- a/src/it/projects/MJAVADOC-497/verify.groovy +++ b/src/it/projects/MJAVADOC-497/verify.groovy @@ -19,40 +19,18 @@ import java.io.*; -try -{ - File list; - - String javaVersion = System.getProperty( "java.specification.version" ); - if ( javaVersion.startsWith( "1." ) || javaVersion.equals( "9" ) ) - { - list = new File( basedir, "target/reports/apidocs/package-list" ); - } - else - { - list = new File( basedir, "target/reports/apidocs/element-list" ); - } - - if ( !list.exists() ) - { - System.err.println( packageList + " is missing" ); - return false; - } +File list; - FileReader fr = new FileReader( list ); - BufferedReader br = new BufferedReader( fr ); - String line = br.readLine(); - if ( !"com.example.foo".equals( line ) || br.readLine() != null ) - { - System.err.println( "package com.example.foo is not the only entry in the package-list" ); - return false; - } - br.close(); +String javaVersion = System.getProperty( "java.specification.version" ); +if ( javaVersion.startsWith( "1." ) || javaVersion.equals( "9" ) ) +{ + list = new File( basedir, "target/reports/apidocs/package-list" ); } -catch ( Exception e ) +else { - e.printStackTrace(); - return false; + list = new File( basedir, "target/reports/apidocs/element-list" ); } -return true; \ No newline at end of file +assert list.exists() : list + " is missing" + +assert list.readLines( 'UTF-8' ) == ["com.example.foo"] : "package com.example.foo is not the only entry in the package-list" \ No newline at end of file diff --git a/src/it/projects/dependencySource-1/verify.groovy b/src/it/projects/dependencySource-1/verify.groovy index c276427a..5cbb64f7 100644 --- a/src/it/projects/dependencySource-1/verify.groovy +++ b/src/it/projects/dependencySource-1/verify.groovy @@ -24,28 +24,10 @@ File apidocs = new File( distroTarget, "apidocs" ); File testApidocs = new File( distroTarget, "testapidocs" ); File f; -if ( !( f = new File( apidocs, "org/apache/maven/plugins/mjavadoc/it/moda/App.html" ) ).exists() ) -{ - System.out.println( f + " does not exist!" ); - return false; -} +assert ( f = new File( apidocs, "org/apache/maven/plugins/mjavadoc/it/moda/App.html" ) ).exists() : f + " does not exist!" -if ( !( f = new File( apidocs, "org/apache/maven/plugins/mjavadoc/it/modb/App.html" ) ).exists() ) -{ - System.out.println( f + " does not exist!" ); - return false; -} +assert ( f = new File( apidocs, "org/apache/maven/plugins/mjavadoc/it/modb/App.html" ) ).exists() : f + " does not exist!" -if ( !( f = new File( testApidocs, "org/apache/maven/plugins/mjavadoc/it/moda/AppTest.html" ) ).exists() ) -{ - System.out.println( f + " does not exist!" ); - return false; -} +assert ( f = new File( testApidocs, "org/apache/maven/plugins/mjavadoc/it/moda/AppTest.html" ) ).exists() : f + " does not exist!" -if ( !( f = new File( testApidocs, "org/apache/maven/plugins/mjavadoc/it/modb/AppTest.html" ) ).exists() ) -{ - System.out.println( f + " does not exist!" ); - return false; -} - -return true; +assert ( f = new File( testApidocs, "org/apache/maven/plugins/mjavadoc/it/modb/AppTest.html" ) ).exists() : f + " does not exist!" diff --git a/src/it/projects/dependencySource-2/verify.groovy b/src/it/projects/dependencySource-2/verify.groovy index b5d55473..2cfaeaf6 100644 --- a/src/it/projects/dependencySource-2/verify.groovy +++ b/src/it/projects/dependencySource-2/verify.groovy @@ -24,28 +24,10 @@ File apidocs = new File( distroTarget, "apidocs" ); File testApidocs = new File( distroTarget, "testapidocs" ); File f; -if ( !( f = new File( apidocs, "org/apache/maven/plugins/mjavadoc/it/moda/App.html" ) ).exists() ) -{ - System.out.println( f + " does not exist!" ); - return false; -} +assert ( f = new File( apidocs, "org/apache/maven/plugins/mjavadoc/it/moda/App.html" ) ).exists() : f + " does not exist!" -if ( !( f = new File( apidocs, "org/apache/maven/plugins/mjavadoc/it/modb/App.html" ) ).exists() ) -{ - System.out.println( f + " does not exist!" ); - return false; -} +assert ( f = new File( apidocs, "org/apache/maven/plugins/mjavadoc/it/modb/App.html" ) ).exists() : f + " does not exist!" -if ( !( f = new File( testApidocs, "org/apache/maven/plugins/mjavadoc/it/moda/AppTest.html" ) ).exists() ) -{ - System.out.println( f + " does not exist!" ); - return false; -} +assert ( f = new File( testApidocs, "org/apache/maven/plugins/mjavadoc/it/moda/AppTest.html" ) ).exists() : f + " does not exist!" -if ( !( f = new File( testApidocs, "org/apache/maven/plugins/mjavadoc/it/modb/AppTest.html" ) ).exists() ) -{ - System.out.println( f + " does not exist!" ); - return false; -} - -return true; +assert ( f = new File( testApidocs, "org/apache/maven/plugins/mjavadoc/it/modb/AppTest.html" ) ).exists() : f + " does not exist!" diff --git a/src/it/projects/dependencySource-3/verify.groovy b/src/it/projects/dependencySource-3/verify.groovy index 3320b79b..34b2d109 100644 --- a/src/it/projects/dependencySource-3/verify.groovy +++ b/src/it/projects/dependencySource-3/verify.groovy @@ -24,28 +24,10 @@ File apidocs = new File( distroTarget, "apidocs" ); File testApidocs = new File( distroTarget, "testapidocs" ); File f; -if ( !( f = new File( apidocs, "org/apache/maven/plugins/mjavadoc/it/moda/App.html" ) ).exists() ) -{ - System.out.println( f + " does not exist!" ); - return false; -} +assert ( f = new File( apidocs, "org/apache/maven/plugins/mjavadoc/it/moda/App.html" ) ).exists() : f + " does not exist!" -if ( !( f = new File( apidocs, "org/apache/maven/plugins/mjavadoc/it/modb/App.html" ) ).exists() ) -{ - System.out.println( f + " does not exist!" ); - return false; -} +assert ( f = new File( apidocs, "org/apache/maven/plugins/mjavadoc/it/modb/App.html" ) ).exists() : f + " does not exist!" -if ( !( f = new File( testApidocs, "org/apache/maven/plugins/mjavadoc/it/moda/AppTest.html" ) ).exists() ) -{ - System.out.println( f + " does not exist!" ); - return false; -} +assert ( f = new File( testApidocs, "org/apache/maven/plugins/mjavadoc/it/moda/AppTest.html" ) ).exists() : f + " does not exist!" -if ( !( f = new File( testApidocs, "org/apache/maven/plugins/mjavadoc/it/modb/AppTest.html" ) ).exists() ) -{ - System.out.println( f + " does not exist!" ); - return false; -} - -return true; +assert ( f = new File( testApidocs, "org/apache/maven/plugins/mjavadoc/it/modb/AppTest.html" ) ).exists() : f + " does not exist!" diff --git a/src/it/projects/dependencySource-4/verify.groovy b/src/it/projects/dependencySource-4/verify.groovy index 11a216d2..140940b8 100644 --- a/src/it/projects/dependencySource-4/verify.groovy +++ b/src/it/projects/dependencySource-4/verify.groovy @@ -24,28 +24,10 @@ File apidocs = new File( distroTarget, "apidocs" ); File testApidocs = new File( distroTarget, "testapidocs" ); File f; -if ( !( f = new File( apidocs, "org/apache/maven/plugins/mjavadoc/it/moda/App.html" ) ).exists() ) -{ - System.out.println( f + " does not exist!" ); - return false; -} +assert ( f = new File( apidocs, "org/apache/maven/plugins/mjavadoc/it/moda/App.html" ) ).exists() : f + " does not exist!" -if ( !( f = new File( apidocs, "org/apache/maven/plugins/mjavadoc/it/modb/App.html" ) ).exists() ) -{ - System.out.println( f + " does not exist!" ); - return false; -} +assert ( f = new File( apidocs, "org/apache/maven/plugins/mjavadoc/it/modb/App.html" ) ).exists() : f + " does not exist!" -if ( !( f = new File( testApidocs, "org/apache/maven/plugins/mjavadoc/it/moda/AppTest.html" ) ).exists() ) -{ - System.out.println( f + " does not exist!" ); - return false; -} +assert ( f = new File( testApidocs, "org/apache/maven/plugins/mjavadoc/it/moda/AppTest.html" ) ).exists() : f + " does not exist!" -if ( !( f = new File( testApidocs, "org/apache/maven/plugins/mjavadoc/it/modb/AppTest.html" ) ).exists() ) -{ - System.out.println( f + " does not exist!" ); - return false; -} - -return true; +assert ( f = new File( testApidocs, "org/apache/maven/plugins/mjavadoc/it/modb/AppTest.html" ) ).exists() : f + " does not exist!" diff --git a/src/it/projects/detectLinks/verify.groovy b/src/it/projects/detectLinks/verify.groovy index 58802196..56cf399a 100644 --- a/src/it/projects/detectLinks/verify.groovy +++ b/src/it/projects/detectLinks/verify.groovy @@ -19,121 +19,38 @@ */ import java.io.*; -import org.codehaus.plexus.util.*; -boolean result = true; - -try -{ - // Generated files checks - File apidocs1 = new File( basedir, "module1/target/reports/apidocs" ); - if ( !apidocs1.exists() || !apidocs1.isDirectory() ) - { - System.err.println( apidocs1.getAbsolutePath() + " dir is missing or a directory." ); - return false; - } - File apidocs2 = new File( basedir, "module2/target/reports/apidocs" ); - if ( !apidocs2.exists() || !apidocs2.isDirectory() ) - { - System.err.println( apidocs2.getAbsolutePath() + " dir is missing or a directory." ); - return false; - } - - File options1 = new File( apidocs1, "options" ); - if ( !options1.exists() || !options1.isFile() ) - { - System.err.println( options1.getAbsolutePath() + " file is missing or not a file." ); - return false; - } - File options2 = new File( apidocs2, "options" ); - if ( !options2.exists() || !options2.isFile() ) - { - System.err.println( options2.getAbsolutePath() + " file is missing or not a file." ); - return false; - } - - // Read files - String contentOptions1 = FileUtils.fileRead( options1 ); - String contentOptions2 = FileUtils.fileRead( options2 ); - String log = FileUtils.fileRead( new File( basedir, "build.log" ) ); - - // Generated files content checks - if ( contentOptions1.contains( "module2" ) ) - { // module1 does not depend on module2, then it should not link - System.err.println( "module1 -linkoffline module2 added: " + options1 ); - return false; - } - int link1 = contentOptions1.indexOf( "-link" ); - if ( link1 == -1 ) - { - System.err.println( "-link not added: " + options1 ); - return false; - } - if ( !contentOptions1.substring( link1 ).contains( "commons.apache.org" ) ) - { - System.err.println( "link for commons-lang not added: " + options1 ); - if ( !log.contains( "Error fetching link: http://commons.apache.org/lang/apidocs" ) ) - { - return false; - } - } - if ( !contentOptions1.substring( link1 ).contains( "junit.org" ) ) - { - System.err.println( "link for junit not added: " + options1 ); - if ( !log.contains( "Error fetching link: http://junit.org/apidocs" ) ) - { - return false; - } - } - if ( contentOptions1.contains( "http://maven.apache.org/maven2/maven-script/maven-script-marmalade/apidocs" ) ) - { - System.err.println( "link for maven-script-marmalade added: " + options1 ); - return false; - } - - int linkoffline2 = contentOptions2.indexOf( "module1" ); - if ( linkoffline2 < 0 ) - { // module2 depends on module1, then it should link - System.err.println( "module2 -linkoffline module1 not added: " + options2 ); - return false; - } - if ( !contentOptions2.substring( linkoffline2 ).contains( apidocs1.getCanonicalPath().replaceAll( "\\\\", "/" ) ) ) - { - System.err.println( apidocs1.getCanonicalPath().replaceAll( "\\\\", "/" ) + " not added: " + options2 ); - return false; - } - int link2 = contentOptions2.indexOf( "-link" ); - if ( link2 == -1 ) - { - System.err.println( "-link not added: " + options2 ); - return false; - } - if ( !contentOptions2.substring( link2 ).contains( "commons.apache.org" ) ) - { - System.err.println( "link for commons-lang not added: " + options2 ); - if ( !log.contains( "Error fetching link: http://commons.apache.org/lang/apidocs" ) ) - { - return false; - } - } - if ( !contentOptions2.substring( link2 ).contains( "junit.org" ) ) - { - System.err.println( "link for junit not added: " + options2 ); - if ( !log.contains( "Error fetching link: http://junit.org/apidocs" ) ) - { - return false; - } - } - if ( contentOptions2.contains( "http://maven.apache.org/maven2/maven-script/maven-script-marmalade/apidocs" ) ) - { - System.err.println( "link for maven-script-marmalade added: " + options2 ); - return false; - } -} -catch( RuntimeException e ) -{ - e.printStackTrace(); - return false; -} - -return result; +// Generated files checks +File apidocs1 = new File( basedir, "module1/target/reports/apidocs" ); +assert apidocs1.exists() && apidocs1.isDirectory() : apidocs1.getAbsolutePath() + " dir is missing or a directory." +File apidocs2 = new File( basedir, "module2/target/reports/apidocs" ); +assert apidocs2.exists() && apidocs2.isDirectory() : apidocs2.getAbsolutePath() + " dir is missing or a directory." + +File options1 = new File( apidocs1, "options" ); +assert options1.exists() && options1.isFile() : options1.getAbsolutePath() + " file is missing or not a file." +File options2 = new File( apidocs2, "options" ); +assert options2.exists() && options2.isFile() : options2.getAbsolutePath() + " file is missing or not a file." + +// Read files +String contentOptions1 = options1.getText( 'UTF-8' ); +String contentOptions2 = options2.getText( 'UTF-8' ); +String log = new File( basedir, "build.log" ).getText( 'UTF-8' ); + +// Generated files content checks +// module1 does not depend on module2, then it should not link +assert !contentOptions1.contains( "module2" ) : "module1 -linkoffline module2 added: " + options1 +int link1 = contentOptions1.indexOf( "-link" ); +assert link1 != -1 : "-link not added: " + options1 +assert contentOptions1.substring( link1 ).contains( "commons.apache.org" ) || log.contains( "Error fetching link: http://commons.apache.org/lang/apidocs" ) : "link for commons-lang not added: " + options1 +assert contentOptions1.substring( link1 ).contains( "junit.org" ) || log.contains( "Error fetching link: http://junit.org/apidocs" ) : "link for junit not added: " + options1 +assert !contentOptions1.contains( "http://maven.apache.org/maven2/maven-script/maven-script-marmalade/apidocs" ) : "link for maven-script-marmalade added: " + options1 + +int linkoffline2 = contentOptions2.indexOf( "module1" ); +// module2 depends on module1, then it should link +assert linkoffline2 >= 0 : "module2 -linkoffline module1 not added: " + options2 +assert contentOptions2.substring( linkoffline2 ).contains( apidocs1.getCanonicalPath().replaceAll( "\\\\", "/" ) ) : apidocs1.getCanonicalPath().replaceAll( "\\\\", "/" ) + " not added: " + options2 +int link2 = contentOptions2.indexOf( "-link" ); +assert link2 != -1 : "-link not added: " + options2 +assert contentOptions2.substring( link2 ).contains( "commons.apache.org" ) || log.contains( "Error fetching link: http://commons.apache.org/lang/apidocs" ) : "link for commons-lang not added: " + options2 +assert contentOptions2.substring( link2 ).contains( "junit.org" ) || log.contains( "Error fetching link: http://junit.org/apidocs" ) : "link for junit not added: " + options2 +assert !contentOptions2.contains( "http://maven.apache.org/maven2/maven-script/maven-script-marmalade/apidocs" ) : "link for maven-script-marmalade added: " + options2
