553N/A * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 553N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 553N/A * or visit www.oracle.com if you need additional information or have any 0N/A * @bug 4524350 4662945 4633447 0N/A * @summary stddoclet: {@docRoot} inserts an extra trailing "/" 0N/A * @run main DocRootSlash 0N/A * Runs javadoc and runs regression tests on the resulting HTML. 0N/A * It reads each file, complete with newlines, into a string to easily 0N/A * find strings that contain newlines. 0N/A // Test number. Needed because runResultsOnHTMLFile is run twice, and subtestNum 0N/A // should increment across test runs. 0N/A // Directory that contains source files that javadoc runs on 0N/A "-header",
"<A HREF=\"{@docroot}/package-list\">{@docroot}</A> <A HREF=\"{@docRoot}/help-doc\">{@docRoot}</A>",
0N/A throw new Error(
"Javadoc failed to execute");
0N/A /** The array of filenames to test */ 0N/A // Bugs 4524350 4662945 0N/A // Read contents of file (whose filename is in filenames) into a string 0N/A +
" --------------");
0N/A // Loop over all tests in a single file 0N/A for (
int j =
0; j <
11; j++ ) {
0N/A // Compare actual to expected string for a single subtest 0N/A +
"when searching for:\n" 0N/A +
"when searching for:\n" 0N/A // Read the contents of the file into a String 0N/A // Create an array of characters the size of the file 0N/A // Read the characters into the allChars array 0N/A // Convert to a string 0N/A * Regular expression pattern matching code adapted from Eric's 0N/A * flag (?i) (case insensitive, so "a href" == "A HREF" and all combinations) 0N/A * \\s+ (one or more whitespace characters) 0N/A * group2 ([^\"]*) (link reference -- characters that don't include a quote) 0N/A * group3 (\".*?>) (" target="frameName">) 0N/A * group4 (.*?) (label - zero or more characters) 0N/A * group5 (</a>) (end tag) 0N/A static String ref1 =
"\")([^\"]*)(\".*?>)";
// doublequotes (end group1, group2, group3) 0N/A static String ref2 =
")(\\S+?)([^<>]*>)";
// no quotes (end group1, group2, group3) 0N/A * Compares the actual string to the expected string in the specified string 0N/A * str String to search through 0N/A // Pattern must be compiled each run because subtestNum is incremented 0N/A // Pattern linkPattern2 = Pattern.compile(prefix + ref2 + label + end, Pattern.DOTALL); 0N/A // System.out.println("pattern: " + actualLinkPattern1.pattern()); 0N/A // System.out.println("actualRef: " + actualRef); 0N/A // System.out.println("group0: " + actualLinkMatcher1.group()); 0N/A // System.out.println("group1: " + actualLinkMatcher1.group(1)); 0N/A // System.out.println("group2: " + actualLinkMatcher1.group(2)); 0N/A // System.out.println("group3: " + actualLinkMatcher1.group(3));