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-site-plugin.git
commit 9c099c439fdfd044e1f1352de764b00f07e5fdf0 Author: Sylwester Lachiewicz <[email protected]> AuthorDate: Wed Nov 25 19:50:59 2026 +0000 Modernize Groovy IT scripts See https://github.com/apache/maven-invoker-plugin/issues/811. --- src/it/projects/MSITE-159/verify.groovy | 46 +- src/it/projects/MSITE-265/verify.groovy | 101 +-- src/it/projects/MSITE-354/verify.groovy | 38 +- src/it/projects/MSITE-456/verify.groovy | 83 +-- src/it/projects/MSITE-458/verify.groovy | 49 +- src/it/projects/MSITE-548/verify.groovy | 55 +- src/it/projects/MSITE-566/verify.groovy | 74 +- src/it/projects/MSITE-609/verify.groovy | 88 +-- src/it/projects/MSITE-627/verify.groovy | 42 +- src/it/projects/MSITE-658/verify.groovy | 70 +- src/it/projects/MSITE-856/verify.groovy | 53 +- src/it/projects/inheritedMenus/verify.groovy | 272 +++---- src/it/projects/inheritedReports/verify.groovy | 46 +- .../report-changes-generation/verify.groovy | 43 +- .../projects/site-attach-descriptor/verify.groovy | 90 +-- src/it/projects/site-deploy/verify.groovy | 88 +-- src/it/projects/site-inheritance/verify.groovy | 828 +++++++-------------- src/it/projects/site-jar/verify.groovy | 77 +- src/it/projects/site-sd-lang/verify.groovy | 245 ++---- src/it/projects/site-skip/verify.groovy | 198 ++--- src/it/projects/template-skin/verify.groovy | 35 +- 21 files changed, 743 insertions(+), 1878 deletions(-) diff --git a/src/it/projects/MSITE-159/verify.groovy b/src/it/projects/MSITE-159/verify.groovy index bac0572c..8273435f 100644 --- a/src/it/projects/MSITE-159/verify.groovy +++ b/src/it/projects/MSITE-159/verify.groovy @@ -18,42 +18,14 @@ * under the License. */ -import java.io.*; +final File siteDirectory = new File( basedir, "target/site" ) +assert siteDirectory.exists() && siteDirectory.isDirectory() : "site is missing or not a directory." -import org.codehaus.plexus.util.*; +File index = new File( siteDirectory, "index.html" ) +assert index.exists() && !index.isDirectory() : "no index file or is a directory." -boolean result = true; - -try -{ - final File siteDirectory = new File( basedir, "target/site" ); - if ( !siteDirectory.exists() || !siteDirectory.isDirectory() ) - { - System.err.println( "site is missing or not a directory." ); - result = false; - } - - File index = new File( siteDirectory, "index.html" ); - if ( !index.exists() || index.isDirectory() ) - { - System.err.println( "no index file or is a directory." ); - result = false; - } - - String content = FileUtils.fileRead( index, "UTF-8" ); - int index1 = content.indexOf( "<a href=\"http://webhost.company.com/index.html\">Breadcrumb</a>" ); - int index2 = content.indexOf( "<a href=\"http://webhost.company.com/\">Link</a>" ); - int index3 = content.indexOf( "<a href=\"http://webhost.company.com/\">Menu</a>" ); - if ( index1 < 0 || index2 < 0 || index3 < 0 ) - { - System.err.println( "index.html has incorrect links!" ); - result = false; - } -} -catch ( IOException e ) -{ - e.printStackTrace(); - result = false; -} - -return result; +String content = index.getText('UTF-8') +int index1 = content.indexOf( "<a href=\"http://webhost.company.com/index.html\">Breadcrumb</a>" ) +int index2 = content.indexOf( "<a href=\"http://webhost.company.com/\">Link</a>" ) +int index3 = content.indexOf( "<a href=\"http://webhost.company.com/\">Menu</a>" ) +assert index1 >= 0 && index2 >= 0 && index3 >= 0 : "index.html has incorrect links!" diff --git a/src/it/projects/MSITE-265/verify.groovy b/src/it/projects/MSITE-265/verify.groovy index 400667d8..36d7f3c0 100644 --- a/src/it/projects/MSITE-265/verify.groovy +++ b/src/it/projects/MSITE-265/verify.groovy @@ -18,81 +18,26 @@ * under the License. */ -import java.io.*; -import org.codehaus.plexus.util.*; - -boolean result = true; - -try -{ - File target = new File( basedir, "target" ); - if ( !target.exists() || !target.isDirectory() ) - { - System.err.println( "target file is missing or not a directory." ); - return false; - } - - File siteDirectory = new File( target, "site" ); - if ( !siteDirectory.exists() || !siteDirectory.isDirectory() ) - { - System.err.println( "site file is missing or not a directory." ); - return false; - } - - File releaseDirectory = new File( siteDirectory, "releases" ); - if ( !releaseDirectory.exists() || !releaseDirectory.isDirectory() ) - { - System.err.println( "releaseDirectory file is missing or not a directory." ); - return false; - } - File release163 = new File( releaseDirectory, "release1.6.3.html" ); - if ( !release163.exists() || release163.isDirectory() ) - { - System.err.println( "release163 file is missing or a directory." ); - return false; - } - File release16 = new File( releaseDirectory, "release1.6.html" ); - if ( !release16.exists() || release16.isDirectory() ) - { - System.err.println( "release16 file is missing or a directory." ); - return false; - } - - File download = new File( siteDirectory, "download.html" ); - if ( !download.exists() || download.isDirectory() ) - { - System.err.println( "download.html file is missing or a directory." ); - return false; - } - String downloadContent = FileUtils.fileRead( download, "UTF-8" ); - int indexOf = downloadContent.indexOf( "Download Maven 3.0.5" ); - if ( indexOf < 0 ) - { - System.err.println( "download.html doesn't contain Download Maven 3.0.5" ); - return false; - } - if ( downloadContent.indexOf( "charset=\"UTF-8\"" ) < 0 ) - { - System.err.println( "download.html doesn't contain 'charset=\"UTF-8\"' directive" ); - return false; - } - if ( downloadContent.indexOf( "demo character: € (euro)" ) < 0 ) - { - System.err.println( "download.html doesn't contain euro symbol" ); - return false; - } - - File reports = new File( siteDirectory, "project-reports.html" ); - if ( !reports.exists() || reports.isDirectory() ) - { - System.err.println( "project-reports.html file is missing or a directory." ); - return false; - } -} -catch ( IOException e ) -{ - e.printStackTrace(); - result = false; -} - -return result; +File target = new File( basedir, "target" ) +assert target.exists() && target.isDirectory() : "target file is missing or not a directory." + +File siteDirectory = new File( target, "site" ) +assert siteDirectory.exists() && siteDirectory.isDirectory() : "site file is missing or not a directory." + +File releaseDirectory = new File( siteDirectory, "releases" ) +assert releaseDirectory.exists() && releaseDirectory.isDirectory() : "releaseDirectory file is missing or not a directory." +File release163 = new File( releaseDirectory, "release1.6.3.html" ) +assert release163.exists() && !release163.isDirectory() : "release163 file is missing or a directory." +File release16 = new File( releaseDirectory, "release1.6.html" ) +assert release16.exists() && !release16.isDirectory() : "release16 file is missing or a directory." + +File download = new File( siteDirectory, "download.html" ) +assert download.exists() && !download.isDirectory() : "download.html file is missing or a directory." +String downloadContent = download.getText('UTF-8') +int indexOf = downloadContent.indexOf( "Download Maven 3.0.5" ) +assert indexOf >= 0 : "download.html doesn't contain Download Maven 3.0.5" +assert downloadContent.indexOf( "charset=\"UTF-8\"" ) >= 0 : "download.html doesn't contain 'charset=\"UTF-8\"' directive" +assert downloadContent.indexOf( "demo character: € (euro)" ) >= 0 : "download.html doesn't contain euro symbol" + +File reports = new File( siteDirectory, "project-reports.html" ) +assert reports.exists() && !reports.isDirectory() : "project-reports.html file is missing or a directory." diff --git a/src/it/projects/MSITE-354/verify.groovy b/src/it/projects/MSITE-354/verify.groovy index ba63f6c2..917be147 100644 --- a/src/it/projects/MSITE-354/verify.groovy +++ b/src/it/projects/MSITE-354/verify.groovy @@ -18,37 +18,11 @@ * under the License. */ -import java.io.*; +File target = new File( basedir, "target" ) +assert target.exists() && target.isDirectory() : "target directory is missing or not a directory." -boolean result = true; +File site = new File( target, "site" ) +assert site.exists() && site.isDirectory() : "site directory is missing or not a directory." -try -{ - File target = new File( basedir, "target" ); - if ( !target.exists() || !target.isDirectory() ) - { - System.err.println( "target directory is missing or not a directory." ); - return false; - } - - File site = new File( target, "site" ); - if ( !site.exists() || !site.isDirectory() ) - { - System.err.println( "site directory is missing or not a directory." ); - return false; - } - - File projectInfo = new File( site, "project-info.html" ); - if ( projectInfo.exists() || projectInfo.isDirectory() ) - { - System.err.println( "project-info.html file is present although it shouldn't, or is a directory." ); - return false; - } -} -catch ( IOException e ) -{ - e.printStackTrace(); - result = false; -} - -return result; +File projectInfo = new File( site, "project-info.html" ) +assert !projectInfo.exists() && !projectInfo.isDirectory() : "project-info.html file is present although it shouldn't, or is a directory." diff --git a/src/it/projects/MSITE-456/verify.groovy b/src/it/projects/MSITE-456/verify.groovy index b63853a7..3d10f222 100644 --- a/src/it/projects/MSITE-456/verify.groovy +++ b/src/it/projects/MSITE-456/verify.groovy @@ -18,76 +18,31 @@ * under the License. */ -import java.io.*; -import org.codehaus.plexus.util.*; +File parentSiteDirectory = new File( basedir, "target/site" ) +assert parentSiteDirectory.exists() && parentSiteDirectory.isDirectory() : "parent site is missing or not a directory." -boolean result = true; +File parentIndex = new File( parentSiteDirectory, "index.html" ) +assert parentIndex.exists() && !parentIndex.isDirectory() : "no index file in parent or is a directory." -try -{ - File parentSiteDirectory = new File( basedir, "target/site" ); - if ( !parentSiteDirectory.exists() || !parentSiteDirectory.isDirectory() ) - { - System.err.println( "parent site is missing or not a directory." ); - result = false; - } +String content = parentIndex.getText('UTF-8') +int index1 = content.indexOf( "<a href=\"child/index.html\">MSITE-456 - child</a>" ) +int index2 = content.indexOf( "<a href=\"project-info.html\"><span class=\"icon-chevron-down\"></span>Project Information</a>" ) - File parentIndex = new File( parentSiteDirectory, "index.html" ); - if ( !parentIndex.exists() || parentIndex.isDirectory() ) - { - System.err.println( "no index file in parent or is a directory." ); - result = false; - } +assert index1 >= 0 && index2 >= 0 : "parent index.html has wrong navigation menu!" - String content = FileUtils.fileRead( parentIndex, "UTF-8" ); - int index1 = content.indexOf( "<a href=\"child/index.html\">MSITE-456 - child</a>" ); - int index2 = content.indexOf( "<a href=\"project-info.html\"><span class=\"icon-chevron-down\"></span>Project Information</a>" ); +// CHILD +File childDirectory = new File( basedir, "child" ) +assert childDirectory.exists() && childDirectory.isDirectory() : "child is missing or not a directory." - if ( index1 < 0 || index2 < 0 ) - { - System.err.println( "parent index.html has wrong navigation menu!" ); - result = false; - } +File childSiteDirectory = new File( childDirectory, "target/site" ) +assert childSiteDirectory.exists() && childSiteDirectory.isDirectory() : "child site is missing or not a directory." - // CHILD +File childIndex = new File( childSiteDirectory, "index.html" ) +assert childIndex.exists() && !childIndex.isDirectory() : "no index file in child or is a directory." +content = childIndex.getText('UTF-8') +index1 = content.indexOf( "<a href=\"../index.html\">MSITE-456 - parent</a>" ) +index2 = content.indexOf( "<a href=\"project-info.html\"><span class=\"icon-chevron-down\"></span>Project Information</a>" ) - File childDirectory = new File( basedir, "child" ); - if ( !childDirectory.exists() || !childDirectory.isDirectory() ) - { - System.err.println( "child is missing or not a directory." ); - result = false; - } - - File childSiteDirectory = new File( childDirectory, "target/site" ); - if ( !childSiteDirectory.exists() || !childSiteDirectory.isDirectory() ) - { - System.err.println( "child site is missing or not a directory." ); - result = false; - } - - File childIndex = new File( childSiteDirectory, "index.html" ); - if ( !childIndex.exists() || childIndex.isDirectory() ) - { - System.err.println( "no index file in child or is a directory." ); - result = false; - } - - content = FileUtils.fileRead( childIndex, "UTF-8" ); - index1 = content.indexOf( "<a href=\"../index.html\">MSITE-456 - parent</a>" ); - index2 = content.indexOf( "<a href=\"project-info.html\"><span class=\"icon-chevron-down\"></span>Project Information</a>" ); - - if ( index1 < 0 || index2 < 0 ) - { - System.err.println( "child index.html has wrong navigation menu!" ); - result = false; - } -} -catch ( IOException e ) -{ - e.printStackTrace(); - result = false; -} - -return result; +assert index1 >= 0 && index2 >= 0 : "child index.html has wrong navigation menu!" diff --git a/src/it/projects/MSITE-458/verify.groovy b/src/it/projects/MSITE-458/verify.groovy index a42a4a2b..22dd9d7b 100644 --- a/src/it/projects/MSITE-458/verify.groovy +++ b/src/it/projects/MSITE-458/verify.groovy @@ -18,47 +18,16 @@ * under the License. */ -import java.io.*; -import org.codehaus.plexus.util.*; +final File siteDirectory = new File( basedir, "target/site" ) +assert siteDirectory.exists() && siteDirectory.isDirectory() : "site is missing or not a directory." -boolean result = true; +File index = new File( siteDirectory, "index.html" ) +assert index.exists() && !index.isDirectory() : "no index.html!" -try -{ - final File siteDirectory = new File( basedir, "target/site" ); - if ( !siteDirectory.exists() || !siteDirectory.isDirectory() ) - { - System.err.println( "site is missing or not a directory." ); - result = false; - } +String content = index.getText('UTF-8') +int index1 = content.indexOf( "Should be first in Modules list" ) +int index2 = content.indexOf( "Should be second in Modules list" ) - File index = new File( siteDirectory, "index.html" ); - if ( !index.exists() || index.isDirectory() ) - { - System.err.println( "no index.html!" ); - result = false; - } +assert index1 >= 0 && index2 >= 0 : "index.html is missing module links!" - String content = FileUtils.fileRead( index, "UTF-8" ); - int index1 = content.indexOf( "Should be first in Modules list" ); - int index2 = content.indexOf( "Should be second in Modules list" ); - - if ( index1 < 0 || index2 < 0 ) - { - System.err.println( "index.html is missing module links!" ); - result = false; - } - - if ( index1 > index2 ) - { - System.err.println( "wrong order of module links!" ); - result = false; - } -} -catch ( IOException e ) -{ - e.printStackTrace(); - result = false; -} - -return result; +assert index1 <= index2 : "wrong order of module links!" diff --git a/src/it/projects/MSITE-548/verify.groovy b/src/it/projects/MSITE-548/verify.groovy index 13117ae1..feef1865 100644 --- a/src/it/projects/MSITE-548/verify.groovy +++ b/src/it/projects/MSITE-548/verify.groovy @@ -18,52 +18,17 @@ * under the License. */ -import java.io.*; -import org.codehaus.plexus.util.*; +File deployDirectory = new File( basedir, "deploy" ) +assert deployDirectory.exists() && deployDirectory.isDirectory() : "deploy directory is missing or not a directory:" + deployDirectory.getAbsolutePath() -boolean result = true; +File rootDirectory = new File( deployDirectory, "MSITE-548" ) +assert rootDirectory.exists() && rootDirectory.isDirectory() : "rootDirectory file is missing or not a directory." -try -{ - File deployDirectory = new File( basedir, "deploy" ); - if ( !deployDirectory.exists() || !deployDirectory.isDirectory() ) - { - System.err.println( "deploy directory is missing or not a directory:" + deployDirectory.getAbsolutePath() ); - return false; - } +File junkDirectory = new File( rootDirectory, "junk" ) +assert junkDirectory.exists() && junkDirectory.isDirectory() : "junkDirectory file is missing or not a directory." - File rootDirectory = new File( deployDirectory, "MSITE-548" ); - if ( !rootDirectory.exists() || !rootDirectory.isDirectory() ) - { - System.err.println( "rootDirectory file is missing or not a directory." ); - return false; - } +File module1Directory = new File( deployDirectory, "module1" ) +assert module1Directory.exists() && module1Directory.isDirectory() : "module1Directory file is missing or not a directory." - File junkDirectory = new File( rootDirectory, "junk" ); - if ( !junkDirectory.exists() || !junkDirectory.isDirectory() ) - { - System.err.println( "junkDirectory file is missing or not a directory." ); - return false; - } - - File module1Directory = new File( deployDirectory, "module1" ); - if ( !module1Directory.exists() || !module1Directory.isDirectory() ) - { - System.err.println( "module1Directory file is missing or not a directory." ); - return false; - } - - File module2Directory = new File( deployDirectory, "module-2" ); - if ( !module2Directory.exists() || !module2Directory.isDirectory() ) - { - System.err.println( "module2Directory file is missing or not a directory." ); - return false; - } -} -catch ( IOException e ) -{ - e.printStackTrace(); - result = false; -} - -return result; +File module2Directory = new File( deployDirectory, "module-2" ) +assert module2Directory.exists() && module2Directory.isDirectory() : "module2Directory file is missing or not a directory." diff --git a/src/it/projects/MSITE-566/verify.groovy b/src/it/projects/MSITE-566/verify.groovy index 1f328f0a..44fdcce0 100644 --- a/src/it/projects/MSITE-566/verify.groovy +++ b/src/it/projects/MSITE-566/verify.groovy @@ -18,65 +18,25 @@ * under the License. */ -import java.io.*; -import org.codehaus.plexus.util.*; +File target = new File( basedir, "target" ) +assert target.exists() && target.isDirectory() : "target file is missing or not a directory." -boolean result = true; +File siteDescriptor = new File( target, "test-1.0-SNAPSHOT-site.xml" ) +assert siteDescriptor.exists() && !siteDescriptor.isDirectory() : "siteDescriptor file is missing from target or is a directory." -try -{ - File target = new File( basedir, "target" ); - if ( !target.exists() || !target.isDirectory() ) - { - System.err.println( "target file is missing or not a directory." ); - result = false; - } +String content = siteDescriptor.getText('UTF-8') +int index1 = content.indexOf( 'name="${project.name}"' ) +int index2 = content.indexOf( '<menu name="${menu.title}">' ) +int index3 = content.indexOf( "<!-- a comment -->" ) +assert index1 >= 0 && index2 >= 0 && index3 >= 0 : "attached site descriptor has been modified!" - File siteDescriptor = new File( target, "test-1.0-SNAPSHOT-site.xml" ); - if ( !siteDescriptor.exists() || siteDescriptor.isDirectory() ) - { - System.err.println( "siteDescriptor file is missing from target or is a directory." ); - result = false; - } +File site = new File( target, "site" ) +assert site.exists() && site.isDirectory() : "site file is missing or not a directory." - String content = FileUtils.fileRead( siteDescriptor, "UTF-8" ); - int index1 = content.indexOf( 'name="${project.name}"' ); - int index2 = content.indexOf( '<menu name="${menu.title}">' ); - int index3 = content.indexOf( "<!-- a comment -->" ); - if ( index1 < 0 || index2 < 0 || index3 < 0 ) - { - System.err.println( "attached site descriptor has been modified!" ); - result = false; - } +File index = new File( site, "index.html" ) +assert index.exists() && !index.isDirectory() : "index.html is missing from target or is a directory." - - File site = new File( target, "site" ); - if ( !site.exists() || !site.isDirectory() ) - { - System.err.println( "site file is missing or not a directory." ); - result = false; - } - - File index = new File( site, "index.html" ); - if ( !index.exists() || index.isDirectory() ) - { - System.err.println( "index.html is missing from target or is a directory." ); - result = false; - } - - content = FileUtils.fileRead( index, "UTF-8" ); - index1 = content.indexOf( "MSITE-566 IT" ); - index2 = content.indexOf( "<li class=\"nav-header\">Documentation</li>" ); - if ( index1 < 0 || index2 < 0 ) - { - System.err.println( "generated site has unresolved properties!" ); - result = false; - } -} -catch ( IOException e ) -{ - e.printStackTrace(); - result = false; -} - -return result; +content = index.getText('UTF-8') +index1 = content.indexOf( "MSITE-566 IT" ) +index2 = content.indexOf( "<li class=\"nav-header\">Documentation</li>" ) +assert index1 >= 0 && index2 >= 0 : "generated site has unresolved properties!" diff --git a/src/it/projects/MSITE-609/verify.groovy b/src/it/projects/MSITE-609/verify.groovy index c143e5d7..8dda80dd 100644 --- a/src/it/projects/MSITE-609/verify.groovy +++ b/src/it/projects/MSITE-609/verify.groovy @@ -18,68 +18,26 @@ * under the License. */ -import java.io.*; -import groovy.xml.XmlSlurper; -import org.codehaus.plexus.util.*; - -boolean result = true; - -try -{ - File target = new File( basedir, "target" ); - if ( !target.exists() || !target.isDirectory() ) - { - System.err.println( "target file is missing or not a directory." ); - return false; - } - - File siteDirectory = new File( target, "site-deployed" ); - if ( !siteDirectory.exists() || !siteDirectory.isDirectory() ) - { - System.err.println( "site file is missing or not a directory." ); - return false; - } - - File releaseDirectory = new File( siteDirectory, "releases" ); - if ( !releaseDirectory.exists() || !releaseDirectory.isDirectory() ) - { - System.err.println( "releaseDirectory file is missing or not a directory." ); - return false; - } - File release163 = new File( releaseDirectory, "release1.6.3.html" ); - if ( !release163.exists() || release163.isDirectory() ) - { - System.err.println( "release163 file is missing or a directory." ); - return false; - } - File release16 = new File( releaseDirectory, "release1.6.html" ); - if ( !release16.exists() || release16.isDirectory() ) - { - System.err.println( "release16 file is missing or a directory." ); - return false; - } - - File download = new File( siteDirectory, "download.html" ); - if ( !download.exists() || download.isDirectory() ) - { - System.err.println( "download.html file is missing or a directory." ); - return false; - } - // the page interpolates ${currentVersion}, which the filtered POM sets from @mavenVersion@ - def pom = new XmlSlurper().parse( new File( basedir, "pom.xml" ) ) - String expected = "Download Maven " + pom.properties.currentVersion.text() - String downloadContent = FileUtils.fileRead( download, "UTF-8" ); - int indexOf = downloadContent.indexOf( expected ); - if ( indexOf < 0 ) - { - System.err.println( "download.html doesn't contain " + expected ); - return false; - } -} -catch ( IOException e ) -{ - e.printStackTrace(); - result = false; -} - -return result; +import groovy.xml.XmlSlurper + +File target = new File( basedir, "target" ) +assert target.exists() && target.isDirectory() : "target file is missing or not a directory." + +File siteDirectory = new File( target, "site-deployed" ) +assert siteDirectory.exists() && siteDirectory.isDirectory() : "site file is missing or not a directory." + +File releaseDirectory = new File( siteDirectory, "releases" ) +assert releaseDirectory.exists() && releaseDirectory.isDirectory() : "releaseDirectory file is missing or not a directory." +File release163 = new File( releaseDirectory, "release1.6.3.html" ) +assert release163.exists() && !release163.isDirectory() : "release163 file is missing or a directory." +File release16 = new File( releaseDirectory, "release1.6.html" ) +assert release16.exists() && !release16.isDirectory() : "release16 file is missing or a directory." + +File download = new File( siteDirectory, "download.html" ) +assert download.exists() && !download.isDirectory() : "download.html file is missing or a directory." +// the page interpolates ${currentVersion}, which the filtered POM sets from @mavenVersion@ +def pom = new XmlSlurper().parse( new File( basedir, "pom.xml" ) ) +String expected = "Download Maven " + pom.properties.currentVersion.text() +String downloadContent = download.getText('UTF-8') +int indexOf = downloadContent.indexOf( expected ) +assert indexOf >= 0 : "download.html doesn't contain " + expected diff --git a/src/it/projects/MSITE-627/verify.groovy b/src/it/projects/MSITE-627/verify.groovy index 0b4612f5..431a000f 100644 --- a/src/it/projects/MSITE-627/verify.groovy +++ b/src/it/projects/MSITE-627/verify.groovy @@ -18,40 +18,12 @@ * under the License. */ -import java.io.*; +final File siteDirectory = new File( basedir, "target/site" ) +assert siteDirectory.exists() && siteDirectory.isDirectory() : "site is missing or not a directory." -import org.codehaus.plexus.util.*; +File report = new File( siteDirectory, "MSITE-627.html" ) +assert report.exists() && !report.isDirectory() : "no report file or is a directory." -boolean result = true; - -try -{ - final File siteDirectory = new File( basedir, "target/site" ); - if ( !siteDirectory.exists() || !siteDirectory.isDirectory() ) - { - System.err.println( "site is missing or not a directory." ); - result = false; - } - - File report = new File( siteDirectory, "MSITE-627.html" ); - if ( !report.exists() || report.isDirectory() ) - { - System.err.println( "no report file or is a directory." ); - result = false; - } - - String content = FileUtils.fileRead( report, "UTF-8" ); - int index = content.indexOf( "Test passed" ); - if ( index < 0 ) - { - System.err.println( "MSITE-627.html has incorrect contents!" ); - result = false; - } -} -catch ( IOException e ) -{ - e.printStackTrace(); - result = false; -} - -return result; +String content = report.getText('UTF-8') +int index = content.indexOf( "Test passed" ) +assert index >= 0 : "MSITE-627.html has incorrect contents!" diff --git a/src/it/projects/MSITE-658/verify.groovy b/src/it/projects/MSITE-658/verify.groovy index 22f8542f..6f5b19bd 100644 --- a/src/it/projects/MSITE-658/verify.groovy +++ b/src/it/projects/MSITE-658/verify.groovy @@ -18,64 +18,24 @@ * under the License. */ -import java.io.*; +final File siteDirectory = new File( basedir, "target/site" ) +assert siteDirectory.isDirectory() : "site is missing or not a directory." -import org.codehaus.plexus.util.*; +File licenses = new File( siteDirectory, "licenses.html" ) +assert licenses.exists() && !licenses.isDirectory() : "no licenses file or is a directory." -boolean result = true; +String content = licenses.getText('UTF-8') +int index = content.indexOf( "<a href=\"index.html\">Home</a>" ) +assert index >= 0 : "licenses.html has incorrect links!" -try -{ - final File siteDirectory = new File( basedir, "target/site" ); - if ( !siteDirectory.isDirectory() ) - { - System.err.println( "site is missing or not a directory." ); - result = false; - } +// de - File licenses = new File( siteDirectory, "licenses.html" ); - if ( !licenses.exists() || licenses.isDirectory() ) - { - System.err.println( "no licenses file or is a directory." ); - result = false; - } +final File deDirectory = new File( siteDirectory, "de" ) +assert deDirectory.isDirectory() : "site is missing or not a directory." - String content = FileUtils.fileRead( licenses, "UTF-8" ); - int index = content.indexOf( "<a href=\"index.html\">Home</a>" ); - if ( index < 0 ) - { - System.err.println( "licenses.html has incorrect links!" ); - result = false; - } +licenses = new File( deDirectory, "licenses.html" ) +assert licenses.exists() && !licenses.isDirectory() : "no licenses file or is a directory." - // de - - final File deDirectory = new File( siteDirectory, "de" ); - if ( !deDirectory.isDirectory() ) - { - System.err.println( "site is missing or not a directory." ); - result = false; - } - - licenses = new File( deDirectory, "licenses.html" ); - if ( !licenses.exists() || licenses.isDirectory() ) - { - System.err.println( "no licenses file or is a directory." ); - result = false; - } - - content = FileUtils.fileRead( licenses, "UTF-8" ); - index = content.indexOf( "<a href=\"index.html\">Heim</a>" ); - if ( index < 0 ) - { - System.err.println( "licenses.html has incorrect links!" ); - result = false; - } -} -catch ( IOException e ) -{ - e.printStackTrace(); - result = false; -} - -return result; +content = licenses.getText('UTF-8') +index = content.indexOf( "<a href=\"index.html\">Heim</a>" ) +assert index >= 0 : "licenses.html has incorrect links!" diff --git a/src/it/projects/MSITE-856/verify.groovy b/src/it/projects/MSITE-856/verify.groovy index 4ee0e12d..de46d5b3 100644 --- a/src/it/projects/MSITE-856/verify.groovy +++ b/src/it/projects/MSITE-856/verify.groovy @@ -17,50 +17,17 @@ * under the License. */ -import java.io.*; -import org.codehaus.plexus.util.*; +final File siteDirectory = new File( basedir, "target/site" ) +assert siteDirectory.isDirectory() : "site is missing or not a directory." -try -{ - final File siteDirectory = new File( basedir, "target/site" ); - if ( !siteDirectory.isDirectory() ) - { - System.err.println( "site is missing or not a directory." ); - return false; - } +File sitemapHtmlFile = new File( siteDirectory, "sitemap.html" ) +assert sitemapHtmlFile.isFile() : "no sitemap.html!" - File sitemapHtmlFile = new File( siteDirectory, "sitemap.html" ); - if ( !sitemapHtmlFile.isFile() ) - { - System.err.println( "no sitemap.html!" ); - return false; - } +content = sitemapHtmlFile.getText('UTF-8') +assert content.contains( "<li>My first item</li>" ) : "\"<li>My first item</li>\" not found in sitemap.html!" - content = FileUtils.fileRead( sitemapHtmlFile, "UTF-8" ); - if ( !content.contains( "<li>My first item</li>" ) ) - { - System.err.println( "\"<li>My first item</li>\" not found in sitemap.html!" ); - return false; - } +File sitemapGermanHtmlFile = new File( siteDirectory, "de/sitemap.html" ) +assert sitemapGermanHtmlFile.isFile() : "no German sitemap.html!" - File sitemapGermanHtmlFile = new File( siteDirectory, "de/sitemap.html" ); - if ( !sitemapGermanHtmlFile.isFile() ) - { - System.err.println( "no German sitemap.html!" ); - return false; - } - - content = FileUtils.fileRead( sitemapGermanHtmlFile, "UTF-8" ); - if ( !content.contains( "<li>Mein erstes Element</li>" ) ) - { - System.err.println( "\"<li>Mein erstes Element</li>\" not found in German sitemap.html!" ); - return false; - } -} -catch ( IOException e ) -{ - e.printStackTrace(); - return false; -} - -return true; +content = sitemapGermanHtmlFile.getText('UTF-8') +assert content.contains( "<li>Mein erstes Element</li>" ) : "\"<li>Mein erstes Element</li>\" not found in German sitemap.html!" diff --git a/src/it/projects/inheritedMenus/verify.groovy b/src/it/projects/inheritedMenus/verify.groovy index dd321400..120b3ed5 100644 --- a/src/it/projects/inheritedMenus/verify.groovy +++ b/src/it/projects/inheritedMenus/verify.groovy @@ -18,185 +18,93 @@ * under the License. */ -import java.io.*; -import org.codehaus.plexus.util.*; - -boolean result = true; - -try -{ - File parentDirectory = new File( basedir, "parentNotAsRef" ); - if ( !parentDirectory.exists() || !parentDirectory.isDirectory() ) - { - System.err.println( "parent is missing or not a directory." ); - result = false; - } - - File parentSiteDirectory = new File( parentDirectory, "target/site" ); - if ( !parentSiteDirectory.exists() || !parentSiteDirectory.isDirectory() ) - { - System.err.println( "parent site is missing or not a directory." ); - result = false; - } - - File parentIndex = new File( parentSiteDirectory, "index.html" ); - if ( !parentIndex.exists() || parentIndex.isDirectory() ) - { - System.err.println( "no index file in parent or is a directory." ); - result = false; - } - - String content = FileUtils.fileRead( parentIndex, "UTF-8" ); - int index1 = content.indexOf( "<li class=\"active\"><a>Parent Relative Home Inherited</a></li>" ); - int index2 = content.indexOf( "<li class=\"active\"><a>Parent Relative Home Inherited with dot</a></li>" ); - int index3 = content.indexOf( "<li><a href=\"./\">Parent Absolute Home Inherited</a></li>" ); - int index4 = content.indexOf( "<li class=\"active\"><a>Parent Absolute Home Inherited with index</a></li>" ); - - if ( index1 < 0 || index2 < 0 || index3 < 0 || index4 < 0 ) - { - System.err.println( "parent index.html has wrong inherited menu items!" ); - result = false; - } - - index1 = content.indexOf( "<li class=\"active\"><a>Parent Relative Home Local</a></li>" ); - index2 = content.indexOf( "<li class=\"active\"><a>Parent Relative Home Local with dot</a></li>" ); - index3 = content.indexOf( "<li><a href=\"./\">Parent Absolute Home Local</a></li>" ); - index4 = content.indexOf( "<li class=\"active\"><a>Parent Absolute Home Local with index</a></li>" ); - - if ( index1 < 0 || index2 < 0 || index4 < 0 ) - { - System.err.println( "parent index.html has wrong local menu items!" ); - result = false; - } - - index1 = content.indexOf( "<li><a href=\"childNotAsRef/index.html\">Child Not As Ref</a></li>" ); - index2 = content.indexOf( "<li><a href=\"project-info.html\"><span class=\"icon-chevron-down\"></span>Project Information</a" ); - index3 = content.indexOf( "<li class=\"nav-header\">Parent Project</li>" ); - - if ( index1 < 0 || index2 < 0 || index3 >= 0 ) - { - System.err.println( "parent index.html has wrong reference menu items!" ); - result = false; - } - - - // CHILD - - - File childDirectory = new File( parentDirectory, "childNotAsRef" ); - if ( !childDirectory.exists() || !childDirectory.isDirectory() ) - { - System.err.println( "child is missing or not a directory." ); - result = false; - } - - File childSiteDirectory = new File( childDirectory, "target/site" ); - if ( !childSiteDirectory.exists() || !childSiteDirectory.isDirectory() ) - { - System.err.println( "child site is missing or not a directory." ); - result = false; - } - - File childIndex = new File( childSiteDirectory, "index.html" ); - if ( !childIndex.exists() || childIndex.isDirectory() ) - { - System.err.println( "no index file in child or is a directory." ); - result = false; - } - - content = FileUtils.fileRead( childIndex, "UTF-8" ); - index1 = content.indexOf( "<a href=\"../index.html\">Parent Relative Home Inherited</a>" ); - index2 = content.indexOf( "<a href=\"../index.html\">Parent Relative Home Inherited with dot</a>" ); - index3 = content.indexOf( "<a href=\"../\">Parent Absolute Home Inherited</a>" ); - index4 = content.indexOf( "<a href=\"../index.html\">Parent Absolute Home Inherited with index</a>" ); - - if ( index1 < 0 || index2 < 0 || index3 < 0 || index4 < 0 ) - { - System.err.println( "child index.html has wrong menu items in inherited menu!" ); - result = false; - } - - index1 = content.indexOf( "<li class=\"active\"><a>Child Relative Home Local</a></li>" ); - index2 = content.indexOf( "<li class=\"active\"><a>Child Relative Home Local with dot</a></li>" ); - index3 = content.indexOf( "<li><a href=\"./\">Child Absolute Home Local</a></li>" ); - index4 = content.indexOf( "<li class=\"active\"><a>Child Absolute Home Local with index</a></li>" ); - - if ( index1 < 0 || index2 < 0 || index3 < 0 || index4 < 0 ) - { - System.err.println( "child index.html has wrong menu items in local menu!" ); - result = false; - } - - index1 = content.indexOf( "<a href=\"grandChildNotAsRef/index.html\">GrandChild Not As Ref</a>" ); - index2 = content.indexOf( "<a href=\"../index.html\">Parent Not As Ref</a>" ); - - if ( index1 < 0 || index2 < 0 ) - { - System.err.println( "child index.html has wrong reference menu items!" ); - result = false; - } - - - // GRANDCHILD - - - File grandChildDirectory = new File( childDirectory, "grandChildNotAsRef" ); - if ( !grandChildDirectory.exists() || !grandChildDirectory.isDirectory() ) - { - System.err.println( "grandchild is missing or not a directory." ); - result = false; - } - - File grandChildSiteDirectory = new File( grandChildDirectory, "target/site" ); - if ( !grandChildSiteDirectory.exists() || !grandChildSiteDirectory.isDirectory() ) - { - System.err.println( "grandchild site is missing or not a directory." ); - result = false; - } - - File grandChildIndex = new File( grandChildSiteDirectory, "index.html" ); - if ( !grandChildIndex.exists() || grandChildIndex.isDirectory() ) - { - System.err.println( "no index file in grandchild or is a directory." ); - result = false; - } - - content = FileUtils.fileRead( grandChildIndex, "UTF-8" ); - index1 = content.indexOf( "a href=\"../../index.html\">Parent Relative Home Inherited</a>" ); - index2 = content.indexOf( "<a href=\"../../index.html\">Parent Relative Home Inherited with dot</a>" ); - index3 = content.indexOf( "<a href=\"../../\">Parent Absolute Home Inherited</a>" ); - index4 = content.indexOf( "<a href=\"../../index.html\">Parent Absolute Home Inherited with index</a>" ); - - if ( index1 < 0 || index2 < 0 || index3 < 0 || index4 < 0 ) - { - System.err.println( "grandchild index.html has wrong menu items in inherited menu!" ); - result = false; - } - - index1 = content.indexOf( "<li class=\"active\"><a>Grand Child Relative Home Local</a></li>" ); - index2 = content.indexOf( "<li class=\"active\"><a>Grand Child Relative Home Local with dot</a></li>" ); - index3 = content.indexOf( "<li><a href=\"./\">Grand Child Absolute Home Local</a></li>" ); - index4 = content.indexOf( "<li class=\"active\"><a>Grand Child Absolute Home Local with index</a></li>" ); - - if ( index1 < 0 || index2 < 0 || index3 < 0 || index4 < 0 ) - { - System.err.println( "grandchild index.html has wrong menu items in local menu!" ); - result = false; - } - - index1 = content.indexOf( "<a href=\"../index.html\">Child Not As Ref</a>" ); - - if ( index1 < 0 ) - { - System.err.println( "grandchild index.html has wrong reference menu items!" ); - result = false; - } - -} -catch ( IOException e ) -{ - e.printStackTrace(); - result = false; -} - -return result; +File parentDirectory = new File( basedir, "parentNotAsRef" ) +assert parentDirectory.exists() && parentDirectory.isDirectory() : "parent is missing or not a directory." + +File parentSiteDirectory = new File( parentDirectory, "target/site" ) +assert parentSiteDirectory.exists() && parentSiteDirectory.isDirectory() : "parent site is missing or not a directory." + +File parentIndex = new File( parentSiteDirectory, "index.html" ) +assert parentIndex.exists() && !parentIndex.isDirectory() : "no index file in parent or is a directory." + +String content = parentIndex.getText('UTF-8') +int index1 = content.indexOf( "<li class=\"active\"><a>Parent Relative Home Inherited</a></li>" ) +int index2 = content.indexOf( "<li class=\"active\"><a>Parent Relative Home Inherited with dot</a></li>" ) +int index3 = content.indexOf( "<li><a href=\"./\">Parent Absolute Home Inherited</a></li>" ) +int index4 = content.indexOf( "<li class=\"active\"><a>Parent Absolute Home Inherited with index</a></li>" ) + +assert index1 >= 0 && index2 >= 0 && index3 >= 0 && index4 >= 0 : "parent index.html has wrong inherited menu items!" + +index1 = content.indexOf( "<li class=\"active\"><a>Parent Relative Home Local</a></li>" ) +index2 = content.indexOf( "<li class=\"active\"><a>Parent Relative Home Local with dot</a></li>" ) +index3 = content.indexOf( "<li><a href=\"./\">Parent Absolute Home Local</a></li>" ) +index4 = content.indexOf( "<li class=\"active\"><a>Parent Absolute Home Local with index</a></li>" ) + +assert index1 >= 0 && index2 >= 0 && index4 >= 0 : "parent index.html has wrong local menu items!" + +index1 = content.indexOf( "<li><a href=\"childNotAsRef/index.html\">Child Not As Ref</a></li>" ) +index2 = content.indexOf( "<li><a href=\"project-info.html\"><span class=\"icon-chevron-down\"></span>Project Information</a" ) +index3 = content.indexOf( "<li class=\"nav-header\">Parent Project</li>" ) + +assert index1 >= 0 && index2 >= 0 && index3 < 0 : "parent index.html has wrong reference menu items!" + +// CHILD + +File childDirectory = new File( parentDirectory, "childNotAsRef" ) +assert childDirectory.exists() && childDirectory.isDirectory() : "child is missing or not a directory." + +File childSiteDirectory = new File( childDirectory, "target/site" ) +assert childSiteDirectory.exists() && childSiteDirectory.isDirectory() : "child site is missing or not a directory." + +File childIndex = new File( childSiteDirectory, "index.html" ) +assert childIndex.exists() && !childIndex.isDirectory() : "no index file in child or is a directory." + +content = childIndex.getText('UTF-8') +index1 = content.indexOf( "<a href=\"../index.html\">Parent Relative Home Inherited</a>" ) +index2 = content.indexOf( "<a href=\"../index.html\">Parent Relative Home Inherited with dot</a>" ) +index3 = content.indexOf( "<a href=\"../\">Parent Absolute Home Inherited</a>" ) +index4 = content.indexOf( "<a href=\"../index.html\">Parent Absolute Home Inherited with index</a>" ) + +assert index1 >= 0 && index2 >= 0 && index3 >= 0 && index4 >= 0 : "child index.html has wrong menu items in inherited menu!" + +index1 = content.indexOf( "<li class=\"active\"><a>Child Relative Home Local</a></li>" ) +index2 = content.indexOf( "<li class=\"active\"><a>Child Relative Home Local with dot</a></li>" ) +index3 = content.indexOf( "<li><a href=\"./\">Child Absolute Home Local</a></li>" ) +index4 = content.indexOf( "<li class=\"active\"><a>Child Absolute Home Local with index</a></li>" ) + +assert index1 >= 0 && index2 >= 0 && index3 >= 0 && index4 >= 0 : "child index.html has wrong menu items in local menu!" + +index1 = content.indexOf( "<a href=\"grandChildNotAsRef/index.html\">GrandChild Not As Ref</a>" ) +index2 = content.indexOf( "<a href=\"../index.html\">Parent Not As Ref</a>" ) + +assert index1 >= 0 && index2 >= 0 : "child index.html has wrong reference menu items!" + +// GRANDCHILD + +File grandChildDirectory = new File( childDirectory, "grandChildNotAsRef" ) +assert grandChildDirectory.exists() && grandChildDirectory.isDirectory() : "grandchild is missing or not a directory." + +File grandChildSiteDirectory = new File( grandChildDirectory, "target/site" ) +assert grandChildSiteDirectory.exists() && grandChildSiteDirectory.isDirectory() : "grandchild site is missing or not a directory." + +File grandChildIndex = new File( grandChildSiteDirectory, "index.html" ) +assert grandChildIndex.exists() && !grandChildIndex.isDirectory() : "no index file in grandchild or is a directory." + +content = grandChildIndex.getText('UTF-8') +index1 = content.indexOf( "a href=\"../../index.html\">Parent Relative Home Inherited</a>" ) +index2 = content.indexOf( "<a href=\"../../index.html\">Parent Relative Home Inherited with dot</a>" ) +index3 = content.indexOf( "<a href=\"../../\">Parent Absolute Home Inherited</a>" ) +index4 = content.indexOf( "<a href=\"../../index.html\">Parent Absolute Home Inherited with index</a>" ) + +assert index1 >= 0 && index2 >= 0 && index3 >= 0 && index4 >= 0 : "grandchild index.html has wrong menu items in inherited menu!" + +index1 = content.indexOf( "<li class=\"active\"><a>Grand Child Relative Home Local</a></li>" ) +index2 = content.indexOf( "<li class=\"active\"><a>Grand Child Relative Home Local with dot</a></li>" ) +index3 = content.indexOf( "<li><a href=\"./\">Grand Child Absolute Home Local</a></li>" ) +index4 = content.indexOf( "<li class=\"active\"><a>Grand Child Absolute Home Local with index</a></li>" ) + +assert index1 >= 0 && index2 >= 0 && index3 >= 0 && index4 >= 0 : "grandchild index.html has wrong menu items in local menu!" + +index1 = content.indexOf( "<a href=\"../index.html\">Child Not As Ref</a>" ) + +assert index1 >= 0 : "grandchild index.html has wrong reference menu items!" diff --git a/src/it/projects/inheritedReports/verify.groovy b/src/it/projects/inheritedReports/verify.groovy index 7cc6d948..a2023691 100644 --- a/src/it/projects/inheritedReports/verify.groovy +++ b/src/it/projects/inheritedReports/verify.groovy @@ -18,44 +18,16 @@ * under the License. */ -import java.io.*; -import org.codehaus.plexus.util.*; +File parentSiteDirectory = new File( basedir, "target/site" ) +File parentIndex = new File( parentSiteDirectory, "index.html" ) +assert parentIndex.exists() && !parentIndex.isDirectory() : "no index file in parent or is a directory." -boolean result = true; +// CHILD -try -{ - File parentSiteDirectory = new File( basedir, "target/site" ); - File parentIndex = new File( parentSiteDirectory, "index.html" ); - if ( !parentIndex.exists() || parentIndex.isDirectory() ) - { - System.err.println( "no index file in parent or is a directory." ); - result = false; - } +File childSiteDirectory = new File( basedir, "child/target/site" ) - // CHILD +File childIndex = new File( childSiteDirectory, "index.html" ) +assert childIndex.exists() : "no index file in child." - File childSiteDirectory = new File( basedir, "child/target/site" ); - - File childIndex = new File( childSiteDirectory, "index.html" ); - if ( !childIndex.exists() ) - { - System.err.println( "no index file in child." ); - result = false; - } - - File childSummary = new File( childSiteDirectory, "summary.html" ); - if ( !childSummary.exists() ) - { - System.err.println( "no summary file in child." ); - result = false; - } - -} -catch ( IOException e ) -{ - e.printStackTrace(); - result = false; -} - -return result; +File childSummary = new File( childSiteDirectory, "summary.html" ) +assert childSummary.exists() : "no summary file in child." diff --git a/src/it/projects/report-changes-generation/verify.groovy b/src/it/projects/report-changes-generation/verify.groovy index e2a56ac9..1a0a7b97 100644 --- a/src/it/projects/report-changes-generation/verify.groovy +++ b/src/it/projects/report-changes-generation/verify.groovy @@ -18,41 +18,14 @@ * under the License. */ -import java.io.*; -import java.util.*; -import java.util.jar.*; -import org.codehaus.plexus.util.*; +import java.util.jar.* -boolean result = true; +File report = new File( basedir, "target/site/changes.html" ) +assert report.exists() && !report.isDirectory() : "report file is missing or a directory." +String reportContent = report.getText('UTF-8') -try -{ - File report = new File( basedir, "target/site/changes.html" ); - if ( !report.exists() || report.isDirectory() ) - { - System.err.println( "report file is missing or a directory." ); - return false; - } - String reportContent = FileUtils.fileRead( report ); +int indexOf = reportContent.indexOf( "Changes" ) +assert indexOf >= 0 : "changes.html doesn't contains Changes Report title" - int indexOf = reportContent.indexOf( "Changes" ); - if ( indexOf < 0 ) - { - System.err.println( "changes.html doesn't contains Changes Report title" ); - return false; - } - - indexOf = reportContent.indexOf( "href=\"http://localhost/MCHANGES-88\"" ); - if ( indexOf < 0 ) - { - System.err.println( "changes.html doesn't contains jira issue link" ); - return false; - } -} -catch ( Throwable e ) -{ - e.printStackTrace(); - result = false; -} - -return result; +indexOf = reportContent.indexOf( "href=\"http://localhost/MCHANGES-88\"" ) +assert indexOf >= 0 : "changes.html doesn't contains jira issue link" diff --git a/src/it/projects/site-attach-descriptor/verify.groovy b/src/it/projects/site-attach-descriptor/verify.groovy index 7bc9d0c8..b0a655c9 100644 --- a/src/it/projects/site-attach-descriptor/verify.groovy +++ b/src/it/projects/site-attach-descriptor/verify.groovy @@ -18,75 +18,39 @@ * under the License. */ -import java.io.*; -import org.codehaus.plexus.util.*; +File target = new File( basedir, "target" ) +assert target.exists() && target.isDirectory() : "target file is missing or not a directory." -boolean result = true; - -try -{ - File target = new File( basedir, "target" ); - if ( !target.exists() || !target.isDirectory() ) - { - System.err.println( "target file is missing or not a directory." ); - return false; - } - - File siteDescriptor = new File( target, "site-attach-descriptor-1.0-SNAPSHOT-site.xml" ); - if ( !siteDescriptor.exists() || siteDescriptor.isDirectory() ) - { - System.err.println( "siteDescriptor file is missing from target or is a directory." ); - return false; - } - - File siteDescriptorSwedish = new File( target, "site-attach-descriptor-1.0-SNAPSHOT-site_sv.xml" ); - if ( !siteDescriptorSwedish.exists() || siteDescriptorSwedish.isDirectory() ) - { - System.err.println( "siteDescriptorSwedish file is missing from target or is a directory." ); - return false; - } +File siteDescriptor = new File( target, "site-attach-descriptor-1.0-SNAPSHOT-site.xml" ) +assert siteDescriptor.exists() && !siteDescriptor.isDirectory() : "siteDescriptor file is missing from target or is a directory." +File siteDescriptorSwedish = new File( target, "site-attach-descriptor-1.0-SNAPSHOT-site_sv.xml" ) +assert siteDescriptorSwedish.exists() && !siteDescriptorSwedish.isDirectory() : "siteDescriptorSwedish file is missing from target or is a directory." - File artifactsDirectory = new File( target, "snapshot-repo/org/apache/maven/plugins/site/its/site-attach-descriptor/1.0-SNAPSHOT" ); - boolean pomSiteDescriptor = false; - File[] files = artifactsDirectory.listFiles(); - for ( int i = 0; i < files.length; i++ ) - { - String name = files[i].getName(); - // site-attach-descriptor-1.0-20090823.204852-1-site.xml - if ( name.endsWith( "-site.xml" ) ) - { - pomSiteDescriptor = pomSiteDescriptor || name.startsWith( "site-attach-descriptor-1.0" ); - } - } - if ( !pomSiteDescriptor ) +File artifactsDirectory = new File( target, "snapshot-repo/org/apache/maven/plugins/site/its/site-attach-descriptor/1.0-SNAPSHOT" ) +boolean pomSiteDescriptor = false +File[] files = artifactsDirectory.listFiles() +for ( int i = 0; i < files.length; i++ ) +{ + String name = files[i].getName() + // site-attach-descriptor-1.0-20090823.204852-1-site.xml + if ( name.endsWith( "-site.xml" ) ) { - System.err.println( "site descriptor not deployed for pom packaging." ); - return false; + pomSiteDescriptor = pomSiteDescriptor || name.startsWith( "site-attach-descriptor-1.0" ) } +} +assert pomSiteDescriptor : "site descriptor not deployed for pom packaging." - artifactsDirectory = new File( target, "snapshot-repo/org/apache/maven/plugins/site/its/jar-site-attach-descriptor/1.0-SNAPSHOT" ); - boolean jarSiteDescriptor = false; - files = artifactsDirectory.listFiles(); - for ( int i = 0; i < files.length; i++ ) - { - String name = files[i].getName(); - // jar-site-attach-descriptor-1.0-20090823.204852-1-site.xml - if ( name.endsWith( "-site.xml" ) ) - { - jarSiteDescriptor = jarSiteDescriptor || name.startsWith( "jar-site-attach-descriptor-1.0" ); - } - } - if ( jarSiteDescriptor ) +artifactsDirectory = new File( target, "snapshot-repo/org/apache/maven/plugins/site/its/jar-site-attach-descriptor/1.0-SNAPSHOT" ) +boolean jarSiteDescriptor = false +files = artifactsDirectory.listFiles() +for ( int i = 0; i < files.length; i++ ) +{ + String name = files[i].getName() + // jar-site-attach-descriptor-1.0-20090823.204852-1-site.xml + if ( name.endsWith( "-site.xml" ) ) { - System.err.println( "site descriptor deployed for jar packaging." ); - return false; + jarSiteDescriptor = jarSiteDescriptor || name.startsWith( "jar-site-attach-descriptor-1.0" ) } } -catch ( IOException e ) -{ - e.printStackTrace(); - result = false; -} - -return result; \ No newline at end of file +assert !jarSiteDescriptor : "site descriptor deployed for jar packaging." \ No newline at end of file diff --git a/src/it/projects/site-deploy/verify.groovy b/src/it/projects/site-deploy/verify.groovy index c143e5d7..8dda80dd 100644 --- a/src/it/projects/site-deploy/verify.groovy +++ b/src/it/projects/site-deploy/verify.groovy @@ -18,68 +18,26 @@ * under the License. */ -import java.io.*; -import groovy.xml.XmlSlurper; -import org.codehaus.plexus.util.*; - -boolean result = true; - -try -{ - File target = new File( basedir, "target" ); - if ( !target.exists() || !target.isDirectory() ) - { - System.err.println( "target file is missing or not a directory." ); - return false; - } - - File siteDirectory = new File( target, "site-deployed" ); - if ( !siteDirectory.exists() || !siteDirectory.isDirectory() ) - { - System.err.println( "site file is missing or not a directory." ); - return false; - } - - File releaseDirectory = new File( siteDirectory, "releases" ); - if ( !releaseDirectory.exists() || !releaseDirectory.isDirectory() ) - { - System.err.println( "releaseDirectory file is missing or not a directory." ); - return false; - } - File release163 = new File( releaseDirectory, "release1.6.3.html" ); - if ( !release163.exists() || release163.isDirectory() ) - { - System.err.println( "release163 file is missing or a directory." ); - return false; - } - File release16 = new File( releaseDirectory, "release1.6.html" ); - if ( !release16.exists() || release16.isDirectory() ) - { - System.err.println( "release16 file is missing or a directory." ); - return false; - } - - File download = new File( siteDirectory, "download.html" ); - if ( !download.exists() || download.isDirectory() ) - { - System.err.println( "download.html file is missing or a directory." ); - return false; - } - // the page interpolates ${currentVersion}, which the filtered POM sets from @mavenVersion@ - def pom = new XmlSlurper().parse( new File( basedir, "pom.xml" ) ) - String expected = "Download Maven " + pom.properties.currentVersion.text() - String downloadContent = FileUtils.fileRead( download, "UTF-8" ); - int indexOf = downloadContent.indexOf( expected ); - if ( indexOf < 0 ) - { - System.err.println( "download.html doesn't contain " + expected ); - return false; - } -} -catch ( IOException e ) -{ - e.printStackTrace(); - result = false; -} - -return result; +import groovy.xml.XmlSlurper + +File target = new File( basedir, "target" ) +assert target.exists() && target.isDirectory() : "target file is missing or not a directory." + +File siteDirectory = new File( target, "site-deployed" ) +assert siteDirectory.exists() && siteDirectory.isDirectory() : "site file is missing or not a directory." + +File releaseDirectory = new File( siteDirectory, "releases" ) +assert releaseDirectory.exists() && releaseDirectory.isDirectory() : "releaseDirectory file is missing or not a directory." +File release163 = new File( releaseDirectory, "release1.6.3.html" ) +assert release163.exists() && !release163.isDirectory() : "release163 file is missing or a directory." +File release16 = new File( releaseDirectory, "release1.6.html" ) +assert release16.exists() && !release16.isDirectory() : "release16 file is missing or a directory." + +File download = new File( siteDirectory, "download.html" ) +assert download.exists() && !download.isDirectory() : "download.html file is missing or a directory." +// the page interpolates ${currentVersion}, which the filtered POM sets from @mavenVersion@ +def pom = new XmlSlurper().parse( new File( basedir, "pom.xml" ) ) +String expected = "Download Maven " + pom.properties.currentVersion.text() +String downloadContent = download.getText('UTF-8') +int indexOf = downloadContent.indexOf( expected ) +assert indexOf >= 0 : "download.html doesn't contain " + expected diff --git a/src/it/projects/site-inheritance/verify.groovy b/src/it/projects/site-inheritance/verify.groovy index 1d7ba07d..81727856 100644 --- a/src/it/projects/site-inheritance/verify.groovy +++ b/src/it/projects/site-inheritance/verify.groovy @@ -18,552 +18,282 @@ * under the License. */ -import java.io.*; -import org.codehaus.plexus.util.*; - -boolean result = true; - -try -{ - final File siteDirectory = new File( basedir, "webhost.company.com" ); - if ( !siteDirectory.exists() || !siteDirectory.isDirectory() ) - { - System.err.println( "site is missing or not a directory." ); - result = false; - } - - - // DEPLOY - - - final File deployDirectory = new File( siteDirectory, "deploy" ); - if ( !deployDirectory.exists() || !deployDirectory.isDirectory() ) - { - System.err.println( "deployDirectory is missing or not a directory." ); - result = false; - } - - // junk directory (aggregator) - File junkDirectory = new File( deployDirectory, "junk" ); - if ( !junkDirectory.exists() || !junkDirectory.isDirectory() ) - { - System.err.println( "deployed junkDirectory is missing or not a directory." ); - result = false; - } - - File index = new File( junkDirectory, "index.html" ); - if ( !index.exists() || index.isDirectory() ) - { - System.err.println( "no index file in deployed junk or is a directory." ); - result = false; - } - - String content = FileUtils.fileRead( index, "UTF-8" ); - int indexOf = content.indexOf( "<a href=\"../index.html\">Aggregator</a>" ); - if ( indexOf < 0 ) - { - System.err.println( "deployed junk index.html is missing module link!" ); - result = false; - } - - // deploy directory (main site) - index = new File( deployDirectory, "index.html" ); - if ( !index.exists() || index.isDirectory() ) - { - System.err.println( "no index file in deploy or is a directory." ); - result = false; - } - - content = FileUtils.fileRead( index, "UTF-8" ); - int index1 = content.indexOf( "<a href=\"www/website/deep/down/below/index.html\">Child and Module</a></li>" ); - int index2 = content.indexOf( "<a href=\"inheriting_child/index.html\">Inheriting Child</a>" ); - int index3 = content.indexOf( "<a href=\"www/website/module/index.html\">Module</a>" ); - int index4 = content.indexOf( "<a href=\"./\">Aggregator</a>" ); - if ( index1 < 0 || index2 < 0 || index3 < 0 || index4 < 0 ) - { - System.err.println( "deploy index.html is missing module link!" ); - result = false; - } - - // parent directory - File parentDirectory = new File( deployDirectory, "www/website" ); - if ( !parentDirectory.exists() || !parentDirectory.isDirectory() ) - { - System.err.println( "deployed parentDirectory is missing or not a directory." ); - result = false; - } - - index = new File( parentDirectory, "index.html" ); - if ( index.exists() || index.isDirectory() ) - { - System.err.println( "incorrect index file in deployed parent!" ); - result = false; - } - - // child_and_module - File deepDownBelow = new File( parentDirectory, "deep/down/below" ); - if ( !deepDownBelow.exists() || !deepDownBelow.isDirectory() ) - { - System.err.println( "deployed deepDownBelow is missing or not a directory." ); - result = false; - } - - index = new File( deepDownBelow, "index.html" ); - if ( !index.exists() || index.isDirectory() ) - { - System.err.println( "incorrect index file in deployed deepDownBelow!" ); - result = false; - } - - content = FileUtils.fileRead( index, "UTF-8" ); - index1 = content.indexOf( "<a href=\"../../../../../index.html\">breadcrumbs Parent</a>" ); - index2 = content.indexOf( "<a href=\"index.html\">breadcrumbs /Child</a>" ); - index3 = content.indexOf( "<a href=\"../../../../../index.html\">links ./Parent</a>" ); - index4 = content.indexOf( "<a href=\"../../../../../index.html\">Parent</a>" ); - if ( index1 < 0 || index2 < 0 || index3 < 0 || index4 < 0 ) - { - System.err.println( "deployed deepDownBelow index.html is missing links!" ); - result = false; - } - - // inheriting_child - File inheritingChild = new File( deployDirectory, "inheriting_child" ); - if ( !inheritingChild.exists() || !inheritingChild.isDirectory() ) - { - System.err.println( "deployed inheritingChild is missing or not a directory." ); - result = false; - } - - index = new File( inheritingChild, "index.html" ); - if ( !index.exists() || index.isDirectory() ) - { - System.err.println( "incorrect index file in deployed inheritingChild!" ); - result = false; - } - - content = FileUtils.fileRead( index, "UTF-8" ); - index1 = content.indexOf( "<a href=\"../index.html\">breadcrumbs /Parent</a>" ); - index2 = content.indexOf( "<a href=\"index.html\">breadcrumbs ./Child</a>" ); - index3 = content.indexOf( "<a href=\"../index.html\">links Parent</a>" ); - index4 = content.indexOf( "<a href=\"../index.html\">Parent</a>" ); - if ( index1 < 0 || index2 < 0 || index3 < 0 || index4 < 0 ) - { - System.err.println( "deployed inheritingChild index.html is missing links!" ); - result = false; - } - - // module - File moduleDirectory = new File( parentDirectory, "module" ); - if ( !moduleDirectory.exists() || !moduleDirectory.isDirectory() ) - { - System.err.println( "deployed moduleDirectory is missing or not a directory." ); - result = false; - } - - index = new File( moduleDirectory, "index.html" ); - if ( !index.exists() || index.isDirectory() ) - { - System.err.println( "incorrect index file in deployed moduleDirectory!" ); - result = false; - } - - content = FileUtils.fileRead( index, "UTF-8" ); - index1 = content.indexOf( "<a href=\"index.html\">breadcrumbs Module</a>" ); - index2 = content.indexOf( "<a>links ./Module</a>" ); - index3 = content.indexOf( "<a href=\"../sub_module/index.html\">Sub-Module</a>" ); - if ( index1 < 0 || index2 < 0 || index3 < 0 ) - { - System.err.println( "deployed moduleDirectory index.html has wrong links!" ); - result = false; - } - - - // sub_module - File subModuleDirectory = new File( parentDirectory, "sub_module" ); - if ( !subModuleDirectory.exists() || !subModuleDirectory.isDirectory() ) - { - System.err.println( "deployed subModuleDirectory is missing or not a directory." ); - result = false; - } - - index = new File( subModuleDirectory, "index.html" ); - if ( !index.exists() || index.isDirectory() ) - { - System.err.println( "incorrect index file in deployed subModuleDirectory!" ); - result = false; - } - - content = FileUtils.fileRead( index, "UTF-8" ); - index1 = content.indexOf( "<a href=\"../module/index.html\">breadcrumbs /Module</a>" ); - index2 = content.indexOf( "<a href=\"index.html\">breadcrumbs ./SubModule</a>" ); - index3 = content.indexOf( "<a href=\"../module/index.html\">links Module</a>" ); - index4 = content.indexOf( "<a href=\"../module/index.html\">Module</a>" ); - if ( index1 < 0 || index2 < 0 || index3 < 0 ) - { - System.err.println( "deployed subModuleDirectory index.html has wrong links!" ); - result = false; - } - - - // STAGE - - - final File stageDirectory = new File( siteDirectory, "stage" ); - if ( !stageDirectory.exists() || !stageDirectory.isDirectory() ) - { - System.err.println( "stage directory is missing or not a directory." ); - result = false; - } - - // the created directory structure in - // target/it/site-inheritance/webhost.company.com/stage/ - // should match the deploy structure in - // target/it/site-inheritance/webhost.company.com/deploy/ - - - // junk directory (aggregator) - junkDirectory = new File( stageDirectory, "junk" ); - if ( !junkDirectory.exists() || !junkDirectory.isDirectory() ) - { - System.err.println( "staged junkDirectory is missing or not a directory." ); - result = false; - } - - index = new File( junkDirectory, "index.html" ); - if ( !index.exists() || index.isDirectory() ) - { - System.err.println( "no index file in staged junk or is a directory." ); - result = false; - } - - content = FileUtils.fileRead( index, "UTF-8" ); - indexOf = content.indexOf( "<a href=\"../index.html\">Aggregator</a>" ); - if ( indexOf < 0 ) - { - System.err.println( "staged junk index.html is missing module link!" ); - result = false; - } - - // deploy directory (main site) - index = new File( stageDirectory, "index.html" ); - if ( !index.exists() || index.isDirectory() ) - { - System.err.println( "no index file in stage or is a directory." ); - result = false; - } - - content = FileUtils.fileRead( index, "UTF-8" ); - index1 = content.indexOf( "<a href=\"www/website/deep/down/below/index.html\">Child and Module</a>" ); - index2 = content.indexOf( "<a href=\"inheriting_child/index.html\">Inheriting Child</a>" ); - index3 = content.indexOf( "<a href=\"www/website/module/index.html\">Module</a>" ); - index4 = content.indexOf( "<a href=\"./\">Aggregator</a>" ); - if ( index1 < 0 || index2 < 0 || index3 < 0 || index4 < 0 ) - { - System.err.println( "staged index.html is missing module link!" ); - result = false; - } - - // parent directory - parentDirectory = new File( stageDirectory, "www/website" ); - if ( !parentDirectory.exists() || !parentDirectory.isDirectory() ) - { - System.err.println( "staged parentDirectory is missing or not a directory." ); - result = false; - } - - index = new File( parentDirectory, "index.html" ); - if ( index.exists() || index.isDirectory() ) - { - System.err.println( "incorrect staged index file in parent!" ); - result = false; - } - - // child_and_module - deepDownBelow = new File( parentDirectory, "deep/down/below" ); - if ( !deepDownBelow.exists() || !deepDownBelow.isDirectory() ) - { - System.err.println( "staged deepDownBelow is missing or not a directory." ); - result = false; - } - - index = new File( deepDownBelow, "index.html" ); - if ( !index.exists() || index.isDirectory() ) - { - System.err.println( "incorrect index file in staged deepDownBelow!" ); - result = false; - } - - content = FileUtils.fileRead( index, "UTF-8" ); - index1 = content.indexOf( "<a href=\"../../../../../index.html\">breadcrumbs Parent</a>" ); - index2 = content.indexOf( "<a href=\"index.html\">breadcrumbs /Child</a>" ); - index3 = content.indexOf( "<a href=\"../../../../../index.html\">links ./Parent</a>" ); - index4 = content.indexOf( "<a href=\"../../../../../index.html\">Parent</a>" ); - if ( index1 < 0 || index2 < 0 || index3 < 0 || index4 < 0 ) - { - System.err.println( "staged deepDownBelow index.html is missing links!" ); - result = false; - } - - // inheriting_child - inheritingChild = new File( stageDirectory, "inheriting_child" ); - if ( !inheritingChild.exists() || !inheritingChild.isDirectory() ) - { - System.err.println( "staged inheritingChild is missing or not a directory." ); - result = false; - } - - index = new File( inheritingChild, "index.html" ); - if ( !index.exists() || index.isDirectory() ) - { - System.err.println( "incorrect index file in staged inheritingChild!" ); - result = false; - } - - content = FileUtils.fileRead( index, "UTF-8" ); - index1 = content.indexOf( "<a href=\"../index.html\">breadcrumbs /Parent</a>" ); - index2 = content.indexOf( "<a href=\"index.html\">breadcrumbs ./Child</a>" ); - index3 = content.indexOf( "<a href=\"../index.html\">links Parent</a>" ); - index4 = content.indexOf( "<a href=\"../index.html\">Parent</a>" ); - if ( index1 < 0 || index2 < 0 || index3 < 0 || index4 < 0 ) - { - System.err.println( "staged inheritingChild index.html is missing links!" ); - result = false; - } - - // module - moduleDirectory = new File( parentDirectory, "module" ); - if ( !moduleDirectory.exists() || !moduleDirectory.isDirectory() ) - { - System.err.println( "staged moduleDirectory is missing or not a directory." ); - result = false; - } - - index = new File( moduleDirectory, "index.html" ); - if ( !index.exists() || index.isDirectory() ) - { - System.err.println( "incorrect index file in staged moduleDirectory!" ); - result = false; - } - - content = FileUtils.fileRead( index, "UTF-8" ); - index1 = content.indexOf( "<a href=\"index.html\">breadcrumbs Module</a>" ); - index2 = content.indexOf( "<a>links ./Module</a>" ); - index3 = content.indexOf( "<a href=\"../sub_module/index.html\">Sub-Module</a>" ); - if ( index1 < 0 || index2 < 0 || index3 < 0 ) - { - System.err.println( "staged moduleDirectory index.html has wrong links!" ); - result = false; - } - - - // sub_module - subModuleDirectory = new File( parentDirectory, "sub_module" ); - if ( !subModuleDirectory.exists() || !subModuleDirectory.isDirectory() ) - { - System.err.println( "staged subModuleDirectory is missing or not a directory." ); - result = false; - } - - index = new File( subModuleDirectory, "index.html" ); - if ( !index.exists() || index.isDirectory() ) - { - System.err.println( "incorrect index file in staged subModuleDirectory!" ); - result = false; - } - - content = FileUtils.fileRead( index, "UTF-8" ); - index1 = content.indexOf( "<a href=\"../module/index.html\">breadcrumbs /Module</a>" ); - index2 = content.indexOf( "<a href=\"index.html\">breadcrumbs ./SubModule</a>" ); - index3 = content.indexOf( "<a href=\"../module/index.html\">links Module</a>" ); - index4 = content.indexOf( "<a href=\"../module/index.html\">Module</a>" ); - if ( index1 < 0 || index2 < 0 || index3 < 0 ) - { - System.err.println( "staged subModuleDirectory index.html has wrong links!" ); - result = false; - } - - - // STAGE DEPLOY - - - final File stageDeployDirectory = new File( siteDirectory, "stage-deploy" ); - if ( !stageDeployDirectory.exists() || !stageDeployDirectory.isDirectory() ) - { - System.err.println( "stage-deploy directory is missing or not a directory." ); - result = false; - } - - // the created directory structure in - // target/it/site-inheritance/webhost.company.com/stage-deploy/ - // should match the deploy structure in - // target/it/site-inheritance/webhost.company.com/deploy/ - - // junk directory (aggregator) - junkDirectory = new File( stageDeployDirectory, "junk" ); - if ( !junkDirectory.exists() || !junkDirectory.isDirectory() ) - { - System.err.println( "stage-deployed junkDirectory is missing or not a directory." ); - result = false; - } - - index = new File( junkDirectory, "index.html" ); - if ( !index.exists() || index.isDirectory() ) - { - System.err.println( "no index file in stage-deployed junk or is a directory." ); - result = false; - } - - content = FileUtils.fileRead( index, "UTF-8" ); - indexOf = content.indexOf( "<a href=\"../index.html\">Aggregator</a>" ); - if ( indexOf < 0 ) - { - System.err.println( "stage-deployed junk index.html is missing module link!" ); - result = false; - } - - // deploy directory (main site) - index = new File( stageDeployDirectory, "index.html" ); - if ( !index.exists() || index.isDirectory() ) - { - System.err.println( "no index file in stage-deploy or is a directory." ); - result = false; - } - - content = FileUtils.fileRead( index, "UTF-8" ); - index1 = content.indexOf( "<a href=\"www/website/deep/down/below/index.html\">Child and Module</a>" ); - index2 = content.indexOf( "<a href=\"inheriting_child/index.html\">Inheriting Child</a>" ); - index3 = content.indexOf( "<a href=\"www/website/module/index.html\">Module</a>" ); - index4 = content.indexOf( "<a href=\"./\">Aggregator</a>" ); - if ( index1 < 0 || index2 < 0 || index3 < 0 || index4 < 0 ) - { - System.err.println( "stage-deployed index.html is missing module link!" ); - result = false; - } - - // parent directory - parentDirectory = new File( stageDeployDirectory, "www/website" ); - if ( !parentDirectory.exists() || !parentDirectory.isDirectory() ) - { - System.err.println( "stage-deployed parentDirectory is missing or not a directory." ); - result = false; - } - - index = new File( parentDirectory, "index.html" ); - if ( index.exists() || index.isDirectory() ) - { - System.err.println( "incorrect index file in stage-deployed parent!" ); - result = false; - } - - // child_and_module - deepDownBelow = new File( parentDirectory, "deep/down/below" ); - if ( !deepDownBelow.exists() || !deepDownBelow.isDirectory() ) - { - System.err.println( "stage-deployed deepDownBelow is missing or not a directory." ); - result = false; - } - - index = new File( deepDownBelow, "index.html" ); - if ( !index.exists() || index.isDirectory() ) - { - System.err.println( "incorrect index file in stage-deployed deepDownBelow!" ); - result = false; - } - - content = FileUtils.fileRead( index, "UTF-8" ); - index1 = content.indexOf( "<a href=\"../../../../../index.html\">breadcrumbs Parent</a>" ); - index2 = content.indexOf( "<a href=\"index.html\">breadcrumbs /Child</a>" ); - index3 = content.indexOf( "<a href=\"../../../../../index.html\">links ./Parent</a>" ); - index4 = content.indexOf( "<a href=\"../../../../../index.html\">Parent</a>" ); - if ( index1 < 0 || index2 < 0 || index3 < 0 || index4 < 0 ) - { - System.err.println( "stage-deployed deepDownBelow index.html is missing links!" ); - result = false; - } - - // inheriting_child - inheritingChild = new File( stageDeployDirectory, "inheriting_child" ); - if ( !inheritingChild.exists() || !inheritingChild.isDirectory() ) - { - System.err.println( "stage-deployed inheritingChild is missing or not a directory." ); - result = false; - } - - index = new File( inheritingChild, "index.html" ); - if ( !index.exists() || index.isDirectory() ) - { - System.err.println( "incorrect index file in stage-deployed inheritingChild!" ); - result = false; - } - - content = FileUtils.fileRead( index, "UTF-8" ); - index1 = content.indexOf( "<a href=\"../index.html\">breadcrumbs /Parent</a>" ); - index2 = content.indexOf( "<a href=\"index.html\">breadcrumbs ./Child</a>" ); - index3 = content.indexOf( "<a href=\"../index.html\">links Parent</a>" ); - index4 = content.indexOf( "<a href=\"../index.html\">Parent</a>" ); - if ( index1 < 0 || index2 < 0 || index3 < 0 || index4 < 0 ) - { - System.err.println( "stage-deployed inheritingChild index.html is missing links!" ); - result = false; - } - - // module - moduleDirectory = new File( parentDirectory, "module" ); - if ( !moduleDirectory.exists() || !moduleDirectory.isDirectory() ) - { - System.err.println( "stage-deployed moduleDirectory is missing or not a directory." ); - result = false; - } - - index = new File( moduleDirectory, "index.html" ); - if ( !index.exists() || index.isDirectory() ) - { - System.err.println( "incorrect index file in stage-deployed moduleDirectory!" ); - result = false; - } - - content = FileUtils.fileRead( index, "UTF-8" ); - index1 = content.indexOf( "<a href=\"index.html\">breadcrumbs Module</a>" ); - index2 = content.indexOf( "<a>links ./Module</a>" ); - index3 = content.indexOf( "<a href=\"../sub_module/index.html\">Sub-Module</a>" ); - if ( index1 < 0 || index2 < 0 || index3 < 0 ) - { - System.err.println( "stage-deployed moduleDirectory index.html has wrong links!" ); - result = false; - } - - - // sub_module - subModuleDirectory = new File( parentDirectory, "sub_module" ); - if ( !subModuleDirectory.exists() || !subModuleDirectory.isDirectory() ) - { - System.err.println( "stage-deployed subModuleDirectory is missing or not a directory." ); - result = false; - } - - index = new File( subModuleDirectory, "index.html" ); - if ( !index.exists() || index.isDirectory() ) - { - System.err.println( "incorrect index file in stage-deployed subModuleDirectory!" ); - result = false; - } - - content = FileUtils.fileRead( index, "UTF-8" ); - index1 = content.indexOf( "<a href=\"../module/index.html\">breadcrumbs /Module</a>" ); - index2 = content.indexOf( "<a href=\"index.html\">breadcrumbs ./SubModule</a>" ); - index3 = content.indexOf( "<a href=\"../module/index.html\">links Module</a>" ); - index4 = content.indexOf( "<a href=\"../module/index.html\">Module</a>" ); - if ( index1 < 0 || index2 < 0 || index3 < 0 ) - { - System.err.println( "stage-deployed subModuleDirectory index.html has wrong links!" ); - result = false; - } - -} -catch ( IOException e ) -{ - e.printStackTrace(); - result = false; -} - -return result; +final File siteDirectory = new File( basedir, "webhost.company.com" ) +assert siteDirectory.exists() && siteDirectory.isDirectory() : "site is missing or not a directory." + +// DEPLOY + +final File deployDirectory = new File( siteDirectory, "deploy" ) +assert deployDirectory.exists() && deployDirectory.isDirectory() : "deployDirectory is missing or not a directory." + +// junk directory (aggregator) +File junkDirectory = new File( deployDirectory, "junk" ) +assert junkDirectory.exists() && junkDirectory.isDirectory() : "deployed junkDirectory is missing or not a directory." + +File index = new File( junkDirectory, "index.html" ) +assert index.exists() && !index.isDirectory() : "no index file in deployed junk or is a directory." + +String content = index.getText('UTF-8') +int indexOf = content.indexOf( "<a href=\"../index.html\">Aggregator</a>" ) +assert indexOf >= 0 : "deployed junk index.html is missing module link!" + +// deploy directory (main site) +index = new File( deployDirectory, "index.html" ) +assert index.exists() && !index.isDirectory() : "no index file in deploy or is a directory." + +content = index.getText('UTF-8') +int index1 = content.indexOf( "<a href=\"www/website/deep/down/below/index.html\">Child and Module</a></li>" ) +int index2 = content.indexOf( "<a href=\"inheriting_child/index.html\">Inheriting Child</a>" ) +int index3 = content.indexOf( "<a href=\"www/website/module/index.html\">Module</a>" ) +int index4 = content.indexOf( "<a href=\"./\">Aggregator</a>" ) +assert index1 >= 0 && index2 >= 0 && index3 >= 0 && index4 >= 0 : "deploy index.html is missing module link!" + +// parent directory +File parentDirectory = new File( deployDirectory, "www/website" ) +assert parentDirectory.exists() && parentDirectory.isDirectory() : "deployed parentDirectory is missing or not a directory." + +index = new File( parentDirectory, "index.html" ) +assert !index.exists() && !index.isDirectory() : "incorrect index file in deployed parent!" + +// child_and_module +File deepDownBelow = new File( parentDirectory, "deep/down/below" ) +assert deepDownBelow.exists() && deepDownBelow.isDirectory() : "deployed deepDownBelow is missing or not a directory." + +index = new File( deepDownBelow, "index.html" ) +assert index.exists() && !index.isDirectory() : "incorrect index file in deployed deepDownBelow!" + +content = index.getText('UTF-8') +index1 = content.indexOf( "<a href=\"../../../../../index.html\">breadcrumbs Parent</a>" ) +index2 = content.indexOf( "<a href=\"index.html\">breadcrumbs /Child</a>" ) +index3 = content.indexOf( "<a href=\"../../../../../index.html\">links ./Parent</a>" ) +index4 = content.indexOf( "<a href=\"../../../../../index.html\">Parent</a>" ) +assert index1 >= 0 && index2 >= 0 && index3 >= 0 && index4 >= 0 : "deployed deepDownBelow index.html is missing links!" + +// inheriting_child +File inheritingChild = new File( deployDirectory, "inheriting_child" ) +assert inheritingChild.exists() && inheritingChild.isDirectory() : "deployed inheritingChild is missing or not a directory." + +index = new File( inheritingChild, "index.html" ) +assert index.exists() && !index.isDirectory() : "incorrect index file in deployed inheritingChild!" + +content = index.getText('UTF-8') +index1 = content.indexOf( "<a href=\"../index.html\">breadcrumbs /Parent</a>" ) +index2 = content.indexOf( "<a href=\"index.html\">breadcrumbs ./Child</a>" ) +index3 = content.indexOf( "<a href=\"../index.html\">links Parent</a>" ) +index4 = content.indexOf( "<a href=\"../index.html\">Parent</a>" ) +assert index1 >= 0 && index2 >= 0 && index3 >= 0 && index4 >= 0 : "deployed inheritingChild index.html is missing links!" + +// module +File moduleDirectory = new File( parentDirectory, "module" ) +assert moduleDirectory.exists() && moduleDirectory.isDirectory() : "deployed moduleDirectory is missing or not a directory." + +index = new File( moduleDirectory, "index.html" ) +assert index.exists() && !index.isDirectory() : "incorrect index file in deployed moduleDirectory!" + +content = index.getText('UTF-8') +index1 = content.indexOf( "<a href=\"index.html\">breadcrumbs Module</a>" ) +index2 = content.indexOf( "<a>links ./Module</a>" ) +index3 = content.indexOf( "<a href=\"../sub_module/index.html\">Sub-Module</a>" ) +assert index1 >= 0 && index2 >= 0 && index3 >= 0 : "deployed moduleDirectory index.html has wrong links!" + +// sub_module +File subModuleDirectory = new File( parentDirectory, "sub_module" ) +assert subModuleDirectory.exists() && subModuleDirectory.isDirectory() : "deployed subModuleDirectory is missing or not a directory." + +index = new File( subModuleDirectory, "index.html" ) +assert index.exists() && !index.isDirectory() : "incorrect index file in deployed subModuleDirectory!" + +content = index.getText('UTF-8') +index1 = content.indexOf( "<a href=\"../module/index.html\">breadcrumbs /Module</a>" ) +index2 = content.indexOf( "<a href=\"index.html\">breadcrumbs ./SubModule</a>" ) +index3 = content.indexOf( "<a href=\"../module/index.html\">links Module</a>" ) +index4 = content.indexOf( "<a href=\"../module/index.html\">Module</a>" ) +assert index1 >= 0 && index2 >= 0 && index3 >= 0 : "deployed subModuleDirectory index.html has wrong links!" + +// STAGE + +final File stageDirectory = new File( siteDirectory, "stage" ) +assert stageDirectory.exists() && stageDirectory.isDirectory() : "stage directory is missing or not a directory." + +// the created directory structure in +// target/it/site-inheritance/webhost.company.com/stage/ +// should match the deploy structure in +// target/it/site-inheritance/webhost.company.com/deploy/ + +// junk directory (aggregator) +junkDirectory = new File( stageDirectory, "junk" ) +assert junkDirectory.exists() && junkDirectory.isDirectory() : "staged junkDirectory is missing or not a directory." + +index = new File( junkDirectory, "index.html" ) +assert index.exists() && !index.isDirectory() : "no index file in staged junk or is a directory." + +content = index.getText('UTF-8') +indexOf = content.indexOf( "<a href=\"../index.html\">Aggregator</a>" ) +assert indexOf >= 0 : "staged junk index.html is missing module link!" + +// deploy directory (main site) +index = new File( stageDirectory, "index.html" ) +assert index.exists() && !index.isDirectory() : "no index file in stage or is a directory." + +content = index.getText('UTF-8') +index1 = content.indexOf( "<a href=\"www/website/deep/down/below/index.html\">Child and Module</a>" ) +index2 = content.indexOf( "<a href=\"inheriting_child/index.html\">Inheriting Child</a>" ) +index3 = content.indexOf( "<a href=\"www/website/module/index.html\">Module</a>" ) +index4 = content.indexOf( "<a href=\"./\">Aggregator</a>" ) +assert index1 >= 0 && index2 >= 0 && index3 >= 0 && index4 >= 0 : "staged index.html is missing module link!" + +// parent directory +parentDirectory = new File( stageDirectory, "www/website" ) +assert parentDirectory.exists() && parentDirectory.isDirectory() : "staged parentDirectory is missing or not a directory." + +index = new File( parentDirectory, "index.html" ) +assert !index.exists() && !index.isDirectory() : "incorrect staged index file in parent!" + +// child_and_module +deepDownBelow = new File( parentDirectory, "deep/down/below" ) +assert deepDownBelow.exists() && deepDownBelow.isDirectory() : "staged deepDownBelow is missing or not a directory." + +index = new File( deepDownBelow, "index.html" ) +assert index.exists() && !index.isDirectory() : "incorrect index file in staged deepDownBelow!" + +content = index.getText('UTF-8') +index1 = content.indexOf( "<a href=\"../../../../../index.html\">breadcrumbs Parent</a>" ) +index2 = content.indexOf( "<a href=\"index.html\">breadcrumbs /Child</a>" ) +index3 = content.indexOf( "<a href=\"../../../../../index.html\">links ./Parent</a>" ) +index4 = content.indexOf( "<a href=\"../../../../../index.html\">Parent</a>" ) +assert index1 >= 0 && index2 >= 0 && index3 >= 0 && index4 >= 0 : "staged deepDownBelow index.html is missing links!" + +// inheriting_child +inheritingChild = new File( stageDirectory, "inheriting_child" ) +assert inheritingChild.exists() && inheritingChild.isDirectory() : "staged inheritingChild is missing or not a directory." + +index = new File( inheritingChild, "index.html" ) +assert index.exists() && !index.isDirectory() : "incorrect index file in staged inheritingChild!" + +content = index.getText('UTF-8') +index1 = content.indexOf( "<a href=\"../index.html\">breadcrumbs /Parent</a>" ) +index2 = content.indexOf( "<a href=\"index.html\">breadcrumbs ./Child</a>" ) +index3 = content.indexOf( "<a href=\"../index.html\">links Parent</a>" ) +index4 = content.indexOf( "<a href=\"../index.html\">Parent</a>" ) +assert index1 >= 0 && index2 >= 0 && index3 >= 0 && index4 >= 0 : "staged inheritingChild index.html is missing links!" + +// module +moduleDirectory = new File( parentDirectory, "module" ) +assert moduleDirectory.exists() && moduleDirectory.isDirectory() : "staged moduleDirectory is missing or not a directory." + +index = new File( moduleDirectory, "index.html" ) +assert index.exists() && !index.isDirectory() : "incorrect index file in staged moduleDirectory!" + +content = index.getText('UTF-8') +index1 = content.indexOf( "<a href=\"index.html\">breadcrumbs Module</a>" ) +index2 = content.indexOf( "<a>links ./Module</a>" ) +index3 = content.indexOf( "<a href=\"../sub_module/index.html\">Sub-Module</a>" ) +assert index1 >= 0 && index2 >= 0 && index3 >= 0 : "staged moduleDirectory index.html has wrong links!" + +// sub_module +subModuleDirectory = new File( parentDirectory, "sub_module" ) +assert subModuleDirectory.exists() && subModuleDirectory.isDirectory() : "staged subModuleDirectory is missing or not a directory." + +index = new File( subModuleDirectory, "index.html" ) +assert index.exists() && !index.isDirectory() : "incorrect index file in staged subModuleDirectory!" + +content = index.getText('UTF-8') +index1 = content.indexOf( "<a href=\"../module/index.html\">breadcrumbs /Module</a>" ) +index2 = content.indexOf( "<a href=\"index.html\">breadcrumbs ./SubModule</a>" ) +index3 = content.indexOf( "<a href=\"../module/index.html\">links Module</a>" ) +index4 = content.indexOf( "<a href=\"../module/index.html\">Module</a>" ) +assert index1 >= 0 && index2 >= 0 && index3 >= 0 : "staged subModuleDirectory index.html has wrong links!" + +// STAGE DEPLOY + +final File stageDeployDirectory = new File( siteDirectory, "stage-deploy" ) +assert stageDeployDirectory.exists() && stageDeployDirectory.isDirectory() : "stage-deploy directory is missing or not a directory." + +// the created directory structure in +// target/it/site-inheritance/webhost.company.com/stage-deploy/ +// should match the deploy structure in +// target/it/site-inheritance/webhost.company.com/deploy/ + +// junk directory (aggregator) +junkDirectory = new File( stageDeployDirectory, "junk" ) +assert junkDirectory.exists() && junkDirectory.isDirectory() : "stage-deployed junkDirectory is missing or not a directory." + +index = new File( junkDirectory, "index.html" ) +assert index.exists() && !index.isDirectory() : "no index file in stage-deployed junk or is a directory." + +content = index.getText('UTF-8') +indexOf = content.indexOf( "<a href=\"../index.html\">Aggregator</a>" ) +assert indexOf >= 0 : "stage-deployed junk index.html is missing module link!" + +// deploy directory (main site) +index = new File( stageDeployDirectory, "index.html" ) +assert index.exists() && !index.isDirectory() : "no index file in stage-deploy or is a directory." + +content = index.getText('UTF-8') +index1 = content.indexOf( "<a href=\"www/website/deep/down/below/index.html\">Child and Module</a>" ) +index2 = content.indexOf( "<a href=\"inheriting_child/index.html\">Inheriting Child</a>" ) +index3 = content.indexOf( "<a href=\"www/website/module/index.html\">Module</a>" ) +index4 = content.indexOf( "<a href=\"./\">Aggregator</a>" ) +assert index1 >= 0 && index2 >= 0 && index3 >= 0 && index4 >= 0 : "stage-deployed index.html is missing module link!" + +// parent directory +parentDirectory = new File( stageDeployDirectory, "www/website" ) +assert parentDirectory.exists() && parentDirectory.isDirectory() : "stage-deployed parentDirectory is missing or not a directory." + +index = new File( parentDirectory, "index.html" ) +assert !index.exists() && !index.isDirectory() : "incorrect index file in stage-deployed parent!" + +// child_and_module +deepDownBelow = new File( parentDirectory, "deep/down/below" ) +assert deepDownBelow.exists() && deepDownBelow.isDirectory() : "stage-deployed deepDownBelow is missing or not a directory." + +index = new File( deepDownBelow, "index.html" ) +assert index.exists() && !index.isDirectory() : "incorrect index file in stage-deployed deepDownBelow!" + +content = index.getText('UTF-8') +index1 = content.indexOf( "<a href=\"../../../../../index.html\">breadcrumbs Parent</a>" ) +index2 = content.indexOf( "<a href=\"index.html\">breadcrumbs /Child</a>" ) +index3 = content.indexOf( "<a href=\"../../../../../index.html\">links ./Parent</a>" ) +index4 = content.indexOf( "<a href=\"../../../../../index.html\">Parent</a>" ) +assert index1 >= 0 && index2 >= 0 && index3 >= 0 && index4 >= 0 : "stage-deployed deepDownBelow index.html is missing links!" + +// inheriting_child +inheritingChild = new File( stageDeployDirectory, "inheriting_child" ) +assert inheritingChild.exists() && inheritingChild.isDirectory() : "stage-deployed inheritingChild is missing or not a directory." + +index = new File( inheritingChild, "index.html" ) +assert index.exists() && !index.isDirectory() : "incorrect index file in stage-deployed inheritingChild!" + +content = index.getText('UTF-8') +index1 = content.indexOf( "<a href=\"../index.html\">breadcrumbs /Parent</a>" ) +index2 = content.indexOf( "<a href=\"index.html\">breadcrumbs ./Child</a>" ) +index3 = content.indexOf( "<a href=\"../index.html\">links Parent</a>" ) +index4 = content.indexOf( "<a href=\"../index.html\">Parent</a>" ) +assert index1 >= 0 && index2 >= 0 && index3 >= 0 && index4 >= 0 : "stage-deployed inheritingChild index.html is missing links!" + +// module +moduleDirectory = new File( parentDirectory, "module" ) +assert moduleDirectory.exists() && moduleDirectory.isDirectory() : "stage-deployed moduleDirectory is missing or not a directory." + +index = new File( moduleDirectory, "index.html" ) +assert index.exists() && !index.isDirectory() : "incorrect index file in stage-deployed moduleDirectory!" + +content = index.getText('UTF-8') +index1 = content.indexOf( "<a href=\"index.html\">breadcrumbs Module</a>" ) +index2 = content.indexOf( "<a>links ./Module</a>" ) +index3 = content.indexOf( "<a href=\"../sub_module/index.html\">Sub-Module</a>" ) +assert index1 >= 0 && index2 >= 0 && index3 >= 0 : "stage-deployed moduleDirectory index.html has wrong links!" + +// sub_module +subModuleDirectory = new File( parentDirectory, "sub_module" ) +assert subModuleDirectory.exists() && subModuleDirectory.isDirectory() : "stage-deployed subModuleDirectory is missing or not a directory." + +index = new File( subModuleDirectory, "index.html" ) +assert index.exists() && !index.isDirectory() : "incorrect index file in stage-deployed subModuleDirectory!" + +content = index.getText('UTF-8') +index1 = content.indexOf( "<a href=\"../module/index.html\">breadcrumbs /Module</a>" ) +index2 = content.indexOf( "<a href=\"index.html\">breadcrumbs ./SubModule</a>" ) +index3 = content.indexOf( "<a href=\"../module/index.html\">links Module</a>" ) +index4 = content.indexOf( "<a href=\"../module/index.html\">Module</a>" ) +assert index1 >= 0 && index2 >= 0 && index3 >= 0 : "stage-deployed subModuleDirectory index.html has wrong links!" diff --git a/src/it/projects/site-jar/verify.groovy b/src/it/projects/site-jar/verify.groovy index 8a39c1f9..a07cd9f8 100644 --- a/src/it/projects/site-jar/verify.groovy +++ b/src/it/projects/site-jar/verify.groovy @@ -18,69 +18,38 @@ * under the License. */ -import java.io.*; -import java.util.*; -import java.util.jar.*; -import org.codehaus.plexus.util.*; +import java.util.jar.* -boolean result = true; +File target = new File( basedir, "target" ) +assert target.exists() && target.isDirectory() : "target file is missing or not a directory." -try -{ - File target = new File( basedir, "target" ); - if ( !target.exists() || !target.isDirectory() ) - { - System.err.println( "target file is missing or not a directory." ); - return false; - } - - File siteJar = new File( target, "site-jar-1.0-SNAPSHOT-site.jar" ); - if ( !siteJar.exists() || siteJar.isDirectory() ) - { - System.err.println( "siteJar file is missing or a directory." ); - return false; - } +File siteJar = new File( target, "site-jar-1.0-SNAPSHOT-site.jar" ) +assert siteJar.exists() && !siteJar.isDirectory() : "siteJar file is missing or a directory." - String[] fileNames = new String[] { "download.html", "index.html", "releases/release1.6.html" }; +String[] fileNames = new String[] { "download.html", "index.html", "releases/release1.6.html" } - Set contents = new HashSet(); +Set contents = new HashSet() - JarFile jar = new JarFile( siteJar ); - Enumeration jarEntries = jar.entries(); - long timestamp = -1; - while ( jarEntries.hasMoreElements() ) +JarFile jar = new JarFile( siteJar ) +Enumeration jarEntries = jar.entries() +long timestamp = -1 +while ( jarEntries.hasMoreElements() ) +{ + JarEntry entry = (JarEntry) jarEntries.nextElement() + if ( timestamp == -1 ) { - JarEntry entry = (JarEntry) jarEntries.nextElement(); - if ( timestamp == -1 ) - { - timestamp = entry.getTime(); // reproducible timestamp in jar file cause local timestamp depending on timezone - } - if ( entry.getTime() != timestamp ) - { - System.out.println( "wrong entry time for " + entry.getName() + ": " + entry.getTime() + " instead of " + timestamp ); - return false; - } - if ( !entry.isDirectory() ) - { - // Only compare files - contents.add( entry.getName() ); - } + timestamp = entry.getTime(); // reproducible timestamp in jar file cause local timestamp depending on timezone } - - for ( int i = 0; i < fileNames.length; i++ ) + assert entry.getTime() == timestamp : "wrong entry time for " + entry.getName() + ": " + entry.getTime() + " instead of " + timestamp + if ( !entry.isDirectory() ) { - String fileName = fileNames[i]; - if ( !contents.contains( fileName ) ) - { - System.err.println( "File[" + fileName + "] not found in jar archive" ); - return false; - } + // Only compare files + contents.add( entry.getName() ) } } -catch ( IOException e ) + +for ( int i = 0; i < fileNames.length; i++ ) { - e.printStackTrace(); - result = false; + String fileName = fileNames[i] + assert contents.contains( fileName ) : "File[" + fileName + "] not found in jar archive" } - -return result; diff --git a/src/it/projects/site-sd-lang/verify.groovy b/src/it/projects/site-sd-lang/verify.groovy index d735a966..db28c92e 100644 --- a/src/it/projects/site-sd-lang/verify.groovy +++ b/src/it/projects/site-sd-lang/verify.groovy @@ -18,180 +18,77 @@ * under the License. */ -import java.io.*; -import org.codehaus.plexus.util.*; +// TODO: also verify module links in generated files! -boolean result = true; +// SITE -// TODO: also verify module links in generated files! +File topLevelDirectory = new File( basedir, "target/site" ) +assert topLevelDirectory.exists() && topLevelDirectory.isDirectory() : "Site directory '" + topLevelDirectory + "' is missing or not a directory." + +File moduleDirectory = new File( basedir, "mymodule/target/site" ) +assert moduleDirectory.exists() && moduleDirectory.isDirectory() : "Site module directory '" + moduleDirectory + "' is missing or not a directory." + +File indexFile = new File( topLevelDirectory, "index.html" ) +assert indexFile.exists() && indexFile.isFile() : "Site index.html '" + indexFile + "' is missing or not a file." +String content = indexFile.getText('UTF-8') +assert content.contains( "the following locales are supported: [, en, fr, de, de_DE, de_AT, zh_TW]" ) : "index.html does not contain supported locales" + +File projectInfoFile = new File( topLevelDirectory, "project-info.html" ) +assert projectInfoFile.exists() && projectInfoFile.isFile() : "Site project-info.html '" + projectInfoFile + "' is missing or not a file." + +File frDirectory = new File( topLevelDirectory, "fr" ) +assert frDirectory.exists() && frDirectory.isDirectory() : "Site fr directory '" + frDirectory + "' is missing or not a directory." + +File frProjectInfoFile = new File( frDirectory, "project-info.html" ) +assert frProjectInfoFile.exists() && frProjectInfoFile.isFile() : "Site fr project-info.html '" + frProjectInfoFile + "' is missing or not a file." + +File frModuleDirectory = new File( moduleDirectory, "fr" ) +assert frModuleDirectory.exists() && frModuleDirectory.isDirectory() : "Site fr module directory '" + frModuleDirectory + "' is missing or not a directory." + +File moduleProjectInfoFile = new File( moduleDirectory, "project-info.html" ) +assert moduleProjectInfoFile.exists() && moduleProjectInfoFile.isFile() : "Site module project-info.html '" + moduleProjectInfoFile + "' is missing or not a file." + +File frModuleProjectInfoFile = new File( frModuleDirectory, "project-info.html" ) +assert frModuleProjectInfoFile.exists() && frModuleProjectInfoFile.isFile() : "Site fr module project-info.html '" + frModuleProjectInfoFile + "' is missing or not a file." + +// STAGING + +topLevelDirectory = new File( basedir, "target/staging" ) +assert topLevelDirectory.exists() && topLevelDirectory.isDirectory() : "Staging directory '" + topLevelDirectory + "' is missing or not a directory." + +moduleDirectory = new File( topLevelDirectory, "mymodule" ) +assert moduleDirectory.exists() && moduleDirectory.isDirectory() : "Staging module directory '" + moduleDirectory + "' is missing or not a directory." + +frDirectory = new File( topLevelDirectory, "fr" ) +assert frDirectory.exists() && frDirectory.isDirectory() : "Staging fr directory '" + frDirectory + "' is missing or not a directory." + +frModuleDirectory = new File( frDirectory, "mymodule" ) +assert frModuleDirectory.exists() && frModuleDirectory.isDirectory() : "Staging fr module directory '" + frModuleDirectory + "' is missing or not a directory." + +// DEPLOY + +topLevelDirectory = new File( basedir, "deploy" ) +assert topLevelDirectory.exists() && topLevelDirectory.isDirectory() : "Deploy directory '" + topLevelDirectory + "' is missing or not a directory." + +moduleDirectory = new File( topLevelDirectory, "mymodule" ) +assert moduleDirectory.exists() && moduleDirectory.isDirectory() : "Staging module directory '" + moduleDirectory + "' is missing or not a directory." + +frDirectory = new File( topLevelDirectory, "fr" ) +assert frDirectory.exists() && frDirectory.isDirectory() : "Staging fr directory '" + frDirectory + "' is missing or not a directory." + +frModuleDirectory = new File( frDirectory, "mymodule" ) +assert frModuleDirectory.exists() && frModuleDirectory.isDirectory() : "Staging fr module directory '" + frModuleDirectory + "' is missing or not a directory." + +// STAGE DEPLOY + +topLevelDirectory = new File( topLevelDirectory, "staging" ) +assert topLevelDirectory.exists() && topLevelDirectory.isDirectory() : "Stage deploy directory '" + topLevelDirectory + "' is missing or not a directory." + +moduleDirectory = new File( topLevelDirectory, "mymodule" ) +assert moduleDirectory.exists() && moduleDirectory.isDirectory() : "Staging module directory '" + moduleDirectory + "' is missing or not a directory." + +frDirectory = new File( topLevelDirectory, "fr" ) +assert frDirectory.exists() && frDirectory.isDirectory() : "Staging fr directory '" + frDirectory + "' is missing or not a directory." -try -{ - // SITE - - File topLevelDirectory = new File( basedir, "target/site" ); - if ( !topLevelDirectory.exists() || !topLevelDirectory.isDirectory() ) - { - System.err.println( "Site directory '" + topLevelDirectory + "' is missing or not a directory." ); - return false; - } - - File moduleDirectory = new File( basedir, "mymodule/target/site" ); - if ( !moduleDirectory.exists() || !moduleDirectory.isDirectory() ) - { - System.err.println( "Site module directory '" + moduleDirectory + "' is missing or not a directory." ); - return false; - } - - File indexFile = new File( topLevelDirectory, "index.html" ); - if ( !indexFile.exists() || !indexFile.isFile() ) - { - System.err.println( "Site index.html '" + indexFile + "' is missing or not a file." ); - return false; - } - String content = FileUtils.fileRead( indexFile, "UTF-8" ); - if ( !content.contains( "the following locales are supported: [, en, fr, de, de_DE, de_AT, zh_TW]" ) ) - { - System.err.println( "index.html does not contain supported locales" ); - return false; - } - - File projectInfoFile = new File( topLevelDirectory, "project-info.html" ); - if ( !projectInfoFile.exists() || !projectInfoFile.isFile() ) - { - System.err.println( "Site project-info.html '" + projectInfoFile + "' is missing or not a file." ); - return false; - } - - File frDirectory = new File( topLevelDirectory, "fr" ); - if ( !frDirectory.exists() || !frDirectory.isDirectory() ) - { - System.err.println( "Site fr directory '" + frDirectory + "' is missing or not a directory." ); - return false; - } - - File frProjectInfoFile = new File( frDirectory, "project-info.html" ); - if ( !frProjectInfoFile.exists() || !frProjectInfoFile.isFile() ) - { - System.err.println( "Site fr project-info.html '" + frProjectInfoFile + "' is missing or not a file." ); - return false; - } - - File frModuleDirectory = new File( moduleDirectory, "fr" ); - if ( !frModuleDirectory.exists() || !frModuleDirectory.isDirectory() ) - { - System.err.println( "Site fr module directory '" + frModuleDirectory + "' is missing or not a directory." ); - return false; - } - - File moduleProjectInfoFile = new File( moduleDirectory, "project-info.html" ); - if ( !moduleProjectInfoFile.exists() || !moduleProjectInfoFile.isFile() ) - { - System.err.println( "Site module project-info.html '" + moduleProjectInfoFile + "' is missing or not a file." ); - return false; - } - - File frModuleProjectInfoFile = new File( frModuleDirectory, "project-info.html" ); - if ( !frModuleProjectInfoFile.exists() || !frModuleProjectInfoFile.isFile() ) - { - System.err.println( "Site fr module project-info.html '" + frModuleProjectInfoFile + "' is missing or not a file." ); - return false; - } - - // STAGING - - topLevelDirectory = new File( basedir, "target/staging" ); - if ( !topLevelDirectory.exists() || !topLevelDirectory.isDirectory() ) - { - System.err.println( "Staging directory '" + topLevelDirectory + "' is missing or not a directory." ); - return false; - } - - moduleDirectory = new File( topLevelDirectory, "mymodule" ); - if ( !moduleDirectory.exists() || !moduleDirectory.isDirectory() ) - { - System.err.println( "Staging module directory '" + moduleDirectory + "' is missing or not a directory." ); - return false; - } - - frDirectory = new File( topLevelDirectory, "fr" ); - if ( !frDirectory.exists() || !frDirectory.isDirectory() ) - { - System.err.println( "Staging fr directory '" + frDirectory + "' is missing or not a directory." ); - return false; - } - - frModuleDirectory = new File( frDirectory, "mymodule" ); - if ( !frModuleDirectory.exists() || !frModuleDirectory.isDirectory() ) - { - System.err.println( "Staging fr module directory '" + frModuleDirectory + "' is missing or not a directory." ); - return false; - } - - // DEPLOY - - topLevelDirectory = new File( basedir, "deploy" ); - if ( !topLevelDirectory.exists() || !topLevelDirectory.isDirectory() ) - { - System.err.println( "Deploy directory '" + topLevelDirectory + "' is missing or not a directory." ); - return false; - } - - moduleDirectory = new File( topLevelDirectory, "mymodule" ); - if ( !moduleDirectory.exists() || !moduleDirectory.isDirectory() ) - { - System.err.println( "Staging module directory '" + moduleDirectory + "' is missing or not a directory." ); - return false; - } - - frDirectory = new File( topLevelDirectory, "fr" ); - if ( !frDirectory.exists() || !frDirectory.isDirectory() ) - { - System.err.println( "Staging fr directory '" + frDirectory + "' is missing or not a directory." ); - return false; - } - - frModuleDirectory = new File( frDirectory, "mymodule" ); - if ( !frModuleDirectory.exists() || !frModuleDirectory.isDirectory() ) - { - System.err.println( "Staging fr module directory '" + frModuleDirectory + "' is missing or not a directory." ); - return false; - } - - // STAGE DEPLOY - - topLevelDirectory = new File( topLevelDirectory, "staging" ); - if ( !topLevelDirectory.exists() || !topLevelDirectory.isDirectory() ) - { - System.err.println( "Stage deploy directory '" + topLevelDirectory + "' is missing or not a directory." ); - return false; - } - - moduleDirectory = new File( topLevelDirectory, "mymodule" ); - if ( !moduleDirectory.exists() || !moduleDirectory.isDirectory() ) - { - System.err.println( "Staging module directory '" + moduleDirectory + "' is missing or not a directory." ); - return false; - } - - frDirectory = new File( topLevelDirectory, "fr" ); - if ( !frDirectory.exists() || !frDirectory.isDirectory() ) - { - System.err.println( "Staging fr directory '" + frDirectory + "' is missing or not a directory." ); - return false; - } - - frModuleDirectory = new File( frDirectory, "mymodule" ); - if ( !frModuleDirectory.exists() || !frModuleDirectory.isDirectory() ) - { - System.err.println( "Staging fr module directory '" + frModuleDirectory + "' is missing or not a directory." ); - return false; - } -} -catch ( IOException e ) -{ - e.printStackTrace(); - result = false; -} - -return result; +frModuleDirectory = new File( frDirectory, "mymodule" ) +assert frModuleDirectory.exists() && frModuleDirectory.isDirectory() : "Staging fr module directory '" + frModuleDirectory + "' is missing or not a directory." diff --git a/src/it/projects/site-skip/verify.groovy b/src/it/projects/site-skip/verify.groovy index 3e412c76..7aa4d097 100644 --- a/src/it/projects/site-skip/verify.groovy +++ b/src/it/projects/site-skip/verify.groovy @@ -18,142 +18,62 @@ * under the License. */ -import java.io.*; -import org.codehaus.plexus.util.*; - -boolean result = true; - -try -{ - final File deployDirectory = new File( basedir, "deployed" ); - final File stageDirectory = new File( basedir, "target/staging" ); - final File stageDeployDirectory = new File( deployDirectory, "staging" ); - - // top - - File siteDir = new File( basedir, "target/site" ); - if ( !siteDir.exists() || !siteDir.isDirectory() ) - { - System.err.println( "top site is missing or not a directory." ); - result = false; - } - - File stageDir = new File( stageDirectory, "." ); - if ( !stageDir.exists() || !stageDir.isDirectory() ) - { - System.err.println( "top stage site is missing or not a directory." ); - result = false; - } - - File deployDir = new File( deployDirectory, "." ); - if ( !deployDir.exists() || !deployDir.isDirectory() ) - { - System.err.println( "top deploy site is missing or not a directory." ); - result = false; - } - - File stageDeployDir = new File( stageDeployDirectory, "." ); - if ( !stageDeployDir.exists() || !stageDeployDir.isDirectory() ) - { - System.err.println( "top stage-deploy site is missing or not a directory." ); - result = false; - } - - // site - - siteDir = new File( basedir, "site/target/site" ); - if ( !siteDir.exists() || !siteDir.isDirectory() ) - { - System.err.println( "site site is missing or not a directory." ); - result = false; - } - - stageDir = new File( stageDirectory, "site" ); - if ( !stageDir.exists() || !stageDir.isDirectory() ) - { - System.err.println( "site stage site is missing or not a directory." ); - result = false; - } - - deployDir = new File( deployDirectory, "site" ); - if ( !deployDir.exists() || !deployDir.isDirectory() ) - { - System.err.println( "site deploy site is missing or not a directory." ); - result = false; - } - - stageDeployDir = new File( stageDeployDirectory, "site" ); - if ( !stageDeployDir.exists() || !stageDeployDir.isDirectory() ) - { - System.err.println( "site stage-deploy site is missing or not a directory." ); - result = false; - } - - // skip-site - - siteDir = new File( basedir, "skip-site/target/site" ); - if ( siteDir.exists() ) - { - System.err.println( "skip-site site exists." ); - result = false; - } - - stageDir = new File( stageDirectory, "skip-site" ); - if ( stageDir.exists() ) - { - System.err.println( "skip-site stage site exists." ); - result = false; - } - - deployDir = new File( deployDirectory, "skip-site" ); - if ( deployDir.exists() ) - { - System.err.println( "skip-site deploy site exists." ); - result = false; - } - - stageDeployDir = new File( stageDeployDirectory, "skip-site" ); - if ( stageDeployDir.exists() ) - { - System.err.println( "skip-site stage-deploy site exists." ); - result = false; - } - - // skip-site-deploy - - siteDir = new File( basedir, "skip-site-deploy/target/site" ); - if ( !siteDir.exists() || !siteDir.isDirectory() ) - { - System.err.println( "skip-site-deploy site is missing or not a directory." ); - result = false; - } - - stageDir = new File( stageDirectory, "skip-site-deploy" ); - if ( !stageDir.exists() ) - { - System.err.println( "skip-site-deploy stage site should still exist." ); - result = false; - } - - deployDir = new File( deployDirectory, "skip-site-deploy" ); - if ( deployDir.exists() ) - { - System.err.println( "skip-site-deploy deploy site exists." ); - result = false; - } - - stageDeployDir = new File( stageDeployDirectory, "skip-site-deploy" ); - if ( stageDeployDir.exists() ) - { - System.err.println( "skip-site-deploy stage-deploy site exists." ); - result = false; - } - -} -catch( IOException e ) -{ - e.printStackTrace(); - result = false; -} - -return result; +final File deployDirectory = new File( basedir, "deployed" ) +final File stageDirectory = new File( basedir, "target/staging" ) +final File stageDeployDirectory = new File( deployDirectory, "staging" ) + +// top + +File siteDir = new File( basedir, "target/site" ) +assert siteDir.exists() && siteDir.isDirectory() : "top site is missing or not a directory." + +File stageDir = new File( stageDirectory, "." ) +assert stageDir.exists() && stageDir.isDirectory() : "top stage site is missing or not a directory." + +File deployDir = new File( deployDirectory, "." ) +assert deployDir.exists() && deployDir.isDirectory() : "top deploy site is missing or not a directory." + +File stageDeployDir = new File( stageDeployDirectory, "." ) +assert stageDeployDir.exists() && stageDeployDir.isDirectory() : "top stage-deploy site is missing or not a directory." + +// site + +siteDir = new File( basedir, "site/target/site" ) +assert siteDir.exists() && siteDir.isDirectory() : "site site is missing or not a directory." + +stageDir = new File( stageDirectory, "site" ) +assert stageDir.exists() && stageDir.isDirectory() : "site stage site is missing or not a directory." + +deployDir = new File( deployDirectory, "site" ) +assert deployDir.exists() && deployDir.isDirectory() : "site deploy site is missing or not a directory." + +stageDeployDir = new File( stageDeployDirectory, "site" ) +assert stageDeployDir.exists() && stageDeployDir.isDirectory() : "site stage-deploy site is missing or not a directory." + +// skip-site + +siteDir = new File( basedir, "skip-site/target/site" ) +assert !siteDir.exists() : "skip-site site exists." + +stageDir = new File( stageDirectory, "skip-site" ) +assert !stageDir.exists() : "skip-site stage site exists." + +deployDir = new File( deployDirectory, "skip-site" ) +assert !deployDir.exists() : "skip-site deploy site exists." + +stageDeployDir = new File( stageDeployDirectory, "skip-site" ) +assert !stageDeployDir.exists() : "skip-site stage-deploy site exists." + +// skip-site-deploy + +siteDir = new File( basedir, "skip-site-deploy/target/site" ) +assert siteDir.exists() && siteDir.isDirectory() : "skip-site-deploy site is missing or not a directory." + +stageDir = new File( stageDirectory, "skip-site-deploy" ) +assert stageDir.exists() : "skip-site-deploy stage site should still exist." + +deployDir = new File( deployDirectory, "skip-site-deploy" ) +assert !deployDir.exists() : "skip-site-deploy deploy site exists." + +stageDeployDir = new File( stageDeployDirectory, "skip-site-deploy" ) +assert !stageDeployDir.exists() : "skip-site-deploy stage-deploy site exists." diff --git a/src/it/projects/template-skin/verify.groovy b/src/it/projects/template-skin/verify.groovy index 70edecfc..3320c4b6 100644 --- a/src/it/projects/template-skin/verify.groovy +++ b/src/it/projects/template-skin/verify.groovy @@ -18,34 +18,11 @@ * under the License. */ -import java.io.*; -import org.codehaus.plexus.util.*; +File index = new File( basedir, "target/site/index.html" ) +assert index.exists() && !index.isDirectory() : "no index file or is a directory." -boolean result = true; +String content = index.getText('UTF-8') +int index1 = content.indexOf( "dummy=value" ) +int index2 = content.indexOf( "att1=val1" ); // MSITE-550 -try -{ - File index = new File( basedir, "target/site/index.html" ); - if ( !index.exists() || index.isDirectory() ) - { - System.err.println( "no index file or is a directory." ); - result = false; - } - - String content = FileUtils.fileRead( index, "UTF-8" ); - int index1 = content.indexOf( "dummy=value" ); - int index2 = content.indexOf( "att1=val1" ); // MSITE-550 - - if ( index1 < 0 || index2 < 0 ) - { - System.err.println( "index.html not resolved!" ); - result = false; - } -} -catch ( IOException e ) -{ - e.printStackTrace(); - result = false; -} - -return result; +assert index1 >= 0 && index2 >= 0 : "index.html not resolved!"
