/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.*; import java.util.*; import java.util.regex.*; import org.codehaus.plexus.util.*; try { File siteDir = new File( basedir, "target/site" ); if ( !siteDir.isDirectory() ) { System.out.println( "Site directory not existent: " + siteDir ); return false; } String[] reports = { "index", // index "project-summary", // summary "license", // license "team-list", // project-team "source-repository", // scm "issue-tracking", // issue-tracking "mail-lists", // mailing-list "dependency-info", // dependency-info "dependency-management", // dependency-management "dependencies", // dependencies "integration", // cim "plugin-management", // plugin-management "plugins", // plugins "distribution-management" // distribution-management }; String info = FileUtils.fileRead( new File( siteDir, "project-info.html"), "UTF-8" ); int index1 = 10; int index2 = 10; String previousReportLink; for ( String report : reports ) { File reportFile = new File( siteDir, report + ".html" ); if ( !reportFile.isFile() ) { System.out.println( "Report file not existent: " + reportFile ); return false; } String link = " " + link + ", but found " + i1 + " < " + index1 ); System.out.println( " previous report link: " + info.substring( index1 - 10, index1 + 70 ) ); System.out.println( " actual report link: " + info.substring( i1 - 10, i1 + 70 ) ); //return false; // test known to fail: MPIR-182 } if ( i2 < index2 ) { System.out.println( "Wrong order for second report link: expected " + previousReportLink + " -> " + link + ", but found " + i2 + " < " + index2 ); System.out.println( " previous report link: " + info.substring( index2 - 10, index2 + 70 ) ); System.out.println( " actual report link: " + info.substring( i2 - 10, i2 + 70 ) ); //return false; // test known to fail: MPIR-182 } index1 = i1; index2 = i2; previousReportLink = link; } File maillist = new File( siteDir, "mail-lists.html"); String content = FileUtils.fileRead( maillist, "UTF-8" ); if ( !content.contains( "mail list intro text foo" ) ) { System.err.println( "mail-lists.html doesn't contain mail list intro text foo" ); return false; } File dependencies = new File( siteDir, "dependencies.html"); content = FileUtils.fileRead( dependencies, "UTF-8" ); if ( !content.contains( "doxia-core-1.2.jar" ) ) { System.err.println( "dependencies.html doesn't contain doxia-core-1.2.jar" ); return false; } if ( !content.contains( "central" ) ) { if ( content.contains( "mirror-testhttp://mirrors.ibiblio.org/pub/mirrors/maven2/" ) ) { System.err.println( "MPIR-244: 'Dependency Repository Locations' in dependencies.html doesn't refer to central repository but mirror-test which is its corresponding mirror." ); } else { System.err.println( "[ERROR] 'Dependency Repository Locations' in dependencies.html doesn't refer to central repository nor mirror-test." ); } return false; } File dependencyMgmt = new File( siteDir, "dependency-management.html"); content = FileUtils.fileRead( dependencyMgmt, "UTF-8" ); if ( !content.contains( "http://maven.apache.org/doxia/doxia/doxia-sink-api/" ) ) { System.err.println( "dependency-management doesn't contain doxia-sink-api url http://maven.apache.org/doxia/doxia/doxia-sink-api/" ); return false; } } catch( Throwable t ) { t.printStackTrace(); return false; } return true;