/* * 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 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( "Parent Relative Home Inherited" ); int index2 = content.indexOf( "Parent Relative Home Inherited with dot" ); int index3 = content.indexOf( "Parent Absolute Home Inherited" ); int index4 = content.indexOf( "Parent Absolute Home Inherited with index" ); 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( "Parent Relative Home Local" ); index2 = content.indexOf( "Parent Relative Home Local with dot" ); index3 = content.indexOf( "Parent Absolute Home Local" ); index4 = content.indexOf( "Parent Absolute Home Local with index" ); if ( index1 < 0 || index2 < 0 || index4 < 0 ) { System.err.println( "parent index.html has wrong local menu items!" ); result = false; } index1 = content.indexOf( "Child Not As Ref" ); index2 = content.indexOf( "Project Information" ); index3 = content.indexOf( "
Parent Project
" ); 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( "Parent Relative Home Inherited" ); index2 = content.indexOf( "Parent Relative Home Inherited with dot" ); index3 = content.indexOf( "Parent Absolute Home Inherited" ); index4 = content.indexOf( "Parent Absolute Home Inherited with index" ); 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( "Child Relative Home Local" ); index2 = content.indexOf( "Child Relative Home Local with dot" ); index3 = content.indexOf( "Child Absolute Home Local" ); index4 = content.indexOf( "Child Absolute Home Local with index" ); 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( "GrandChild Not As Ref" ); index2 = content.indexOf( "Parent Not As Ref" ); 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( "Parent Relative Home Inherited" ); index2 = content.indexOf( "Parent Relative Home Inherited with dot" ); index3 = content.indexOf( "Parent Absolute Home Inherited" ); index4 = content.indexOf( "Parent Absolute Home Inherited with index" ); 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( "Grand Child Relative Home Local" ); index2 = content.indexOf( "Grand Child Relative Home Local with dot" ); index3 = content.indexOf( "Grand Child Absolute Home Local" ); index4 = content.indexOf( "Grand Child Absolute Home Local with index" ); 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( "Child Not As Ref" ); 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;