langtools/test/com/sun/javadoc/DocRootSlash/DocRootSlash.java
author katleman
Tue, 21 Jan 2014 18:17:23 -0800
changeset 22365 895bfde469d4
parent 15357 61fec7e4133f
child 23971 f5ff1f5a8dee
permissions -rw-r--r--
Added tag jdk9-b01 for changeset ae2d94255f32
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
15357
61fec7e4133f 8006241: Test DocRootSlash.java fails
jjg
parents: 5520
diff changeset
     2
 * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
06bc494ca11e Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    21
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
/*
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
 * @test
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
 * @bug 4524350 4662945 4633447
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
 * @summary stddoclet: {@docRoot} inserts an extra trailing "/"
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
 * @author dkramer
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
 * @run main DocRootSlash
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
import com.sun.javadoc.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
import java.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
import java.io.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
import java.nio.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
import java.util.regex.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 * Runs javadoc and runs regression tests on the resulting HTML.
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 * It reads each file, complete with newlines, into a string to easily
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 * find strings that contain newlines.
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
public class DocRootSlash
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
{
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
    private static final String BUGID = "4524350, 4662945, or 4633447";
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
    private static final String BUGNAME = "DocRootSlash";
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
    private static final String FS = System.getProperty("file.separator");
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
    private static final String PS = System.getProperty("path.separator");
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
    private static final String TMPDIR_STRING1 = "." + FS + "docs1" + FS;
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
    // Test number.  Needed because runResultsOnHTMLFile is run twice, and subtestNum
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
    // should increment across test runs.
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
    public static int subtestNum = 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
    public static int numOfSubtestsPassed = 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
    // Entry point
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
    public static void main(String[] args) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
        // Directory that contains source files that javadoc runs on
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
        String srcdir = System.getProperty("test.src", ".");
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
        runJavadoc(new String[] {"-d", TMPDIR_STRING1,
15357
61fec7e4133f 8006241: Test DocRootSlash.java fails
jjg
parents: 5520
diff changeset
    63
                                 "-Xdoclint:none",
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
                                 "-overview", (srcdir + FS + "overview.html"),
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
                                 "-header", "<A HREF=\"{@docroot}/package-list\">{&#064;docroot}</A> <A HREF=\"{@docRoot}/help-doc\">{&#064;docRoot}</A>",
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
                                 "-sourcepath", srcdir,
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
                                 "p1", "p2"});
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
        runTestsOnHTMLFiles(filenameArray);
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
        printSummary();
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
    /** Run javadoc */
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
    public static void runJavadoc(String[] javadocArgs) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
        if (com.sun.tools.javadoc.Main.execute(javadocArgs) != 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
            throw new Error("Javadoc failed to execute");
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
    /**  The array of filenames to test */
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
    private static final String[] filenameArray = {
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
        TMPDIR_STRING1 + "p1" + FS + "C1.html" ,
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
        TMPDIR_STRING1 + "p1" + FS + "package-summary.html",
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
        TMPDIR_STRING1 + "overview-summary.html"
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
    };
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
    public static void runTestsOnHTMLFiles(String[] filenameArray) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
        String fileString;
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
        // Bugs 4524350 4662945
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
        for (int i = 0; i < filenameArray.length; i++ ) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
            // Read contents of file (whose filename is in filenames) into a string
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
            fileString = readFileToString(filenameArray[i]);
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
            System.out.println("\nSub-tests for file: " + filenameArray[i]
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
                                + " --------------");
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
            // Loop over all tests in a single file
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
            for ( int j = 0; j < 11; j++ ) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
                subtestNum += 1;
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
                // Compare actual to expected string for a single subtest
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
                compareActualToExpected(fileString);
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
        // Bug 4633447: Special test for overview-frame.html
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
        // Find two strings in file "overview-frame.html"
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
        String filename = TMPDIR_STRING1 + "overview-frame.html";
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
        fileString = readFileToString(filename);
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
        // Find first string <A HREF="./package-list"> in overview-frame.html
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
        subtestNum += 1;
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
        String stringToFind = "<A HREF=\"./package-list\">";
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
        String result;
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
        if ( fileString.indexOf(stringToFind) == -1 ) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
            result = "FAILED";
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
            result = "succeeded";
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
            numOfSubtestsPassed += 1;
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
        System.out.println("\nSub-test " + (subtestNum)
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
            + " for bug " + BUGID + " (" + BUGNAME + ") " + result + "\n"
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
            + "when searching for:\n"
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
            + stringToFind + "\n"
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
            + "in file " + filename);
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
        // Find second string <A HREF="./help-doc"> in overview-frame.html
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
        subtestNum += 1;
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
        stringToFind = "<A HREF=\"./help-doc\">";
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
        if ( fileString.indexOf(stringToFind) == -1 ) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
            result = "FAILED";
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
            result = "succeeded";
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
            numOfSubtestsPassed += 1;
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
        System.out.println("\nSub-test " + (subtestNum)
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
            + " for bug " + BUGID + " (" + BUGNAME + ") " + result + "\n"
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
            + "when searching for:\n"
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
            + stringToFind + "\n"
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
            + "in file " + filename);
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
    public static void printSummary() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
        System.out.println("");
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
        if ( numOfSubtestsPassed == subtestNum ) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
            System.out.println("\nAll " + numOfSubtestsPassed + " subtests passed");
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
            throw new Error("\n" + (subtestNum - numOfSubtestsPassed) + " of " + (subtestNum)
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
                            + " subtests failed for bug " + BUGID + " (" + BUGNAME + ")\n");
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
    // Read the contents of the file into a String
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
    public static String readFileToString(String filename) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
        try {
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
            File file = new File(filename);
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
            if ( !file.exists() ) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
                System.out.println("\nFILE DOES NOT EXIST: " + filename);
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
            BufferedReader in = new BufferedReader(new FileReader(file));
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
            // Create an array of characters the size of the file
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
            char[] allChars = new char[(int)file.length()];
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
            // Read the characters into the allChars array
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
            in.read(allChars, 0, (int)file.length());
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
            in.close();
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
            // Convert to a string
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
            String allCharsString = new String(allChars);
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
            return allCharsString;
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
        } catch (FileNotFoundException e) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
            System.err.println(e);
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
            return "";
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
        } catch (IOException e) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
            System.err.println(e);
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
            return "";
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
     * Regular expression pattern matching code adapted from Eric's
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
     * /java/pubs/dev/linkfix/src/LinkFix.java
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
     * Prefix Pattern:
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
     * flag   (?i)            (case insensitive, so "a href" == "A HREF" and all combinations)
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
     * group1 (
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
     *          <a or <A
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
     *          \\s+          (one or more whitespace characters)
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
     *          href or HREF
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
     *          \"            (double quote)
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
     *        )
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
     * group2 ([^\"]*)        (link reference -- characters that don't include a quote)
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
     * group3 (\".*?>)        (" target="frameName">)
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
     * group4 (.*?)           (label - zero or more characters)
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
     * group5 (</a>)          (end tag)
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
    static String prefix = "(?i)(<a\\s+href=";    // <a href=     (start group1)
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
    static String ref1   = "\")([^\"]*)(\".*?>)"; // doublequotes (end group1, group2, group3)
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
    static String ref2   = ")(\\S+?)([^<>]*>)";   // no quotes    (end group1, group2, group3)
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
    static String label  = "(.*?)";               // text label   (group4)
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
    static String end    = "(</a>)";              // </a>         (group5)
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
     * Compares the actual string to the expected string in the specified string
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
     * str   String to search through
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
    static void compareActualToExpected(String str) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
        // Pattern must be compiled each run because subtestNum is incremented
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
        Pattern actualLinkPattern1 =
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
            Pattern.compile("Sub-test " + subtestNum + " Actual: " + prefix + ref1, Pattern.DOTALL);
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
        Pattern expectLinkPattern1 =
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
            Pattern.compile("Sub-test " + subtestNum + " Expect: " + prefix + ref1, Pattern.DOTALL);
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
        // Pattern linkPattern2 = Pattern.compile(prefix + ref2 + label + end, Pattern.DOTALL);
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
        CharBuffer charBuffer = CharBuffer.wrap(str);
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
        Matcher actualLinkMatcher1 = actualLinkPattern1.matcher(charBuffer);
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
        Matcher expectLinkMatcher1 = expectLinkPattern1.matcher(charBuffer);
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
        String result;
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
        if ( expectLinkMatcher1.find() && actualLinkMatcher1.find() ) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
            String expectRef = expectLinkMatcher1.group(2);
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
            String actualRef = actualLinkMatcher1.group(2);
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
            if ( actualRef.equals(expectRef) ) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
                result = "succeeded";
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
                numOfSubtestsPassed += 1;
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
                // System.out.println("pattern:   " + actualLinkPattern1.pattern());
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
                // System.out.println("actualRef: " + actualRef);
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
                // System.out.println("group0:    " + actualLinkMatcher1.group());
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
                // System.out.println("group1:    " + actualLinkMatcher1.group(1));
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
                // System.out.println("group2:    " + actualLinkMatcher1.group(2));
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
                // System.out.println("group3:    " + actualLinkMatcher1.group(3));
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
                // System.exit(0);
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
            } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
                result = "FAILED";
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
            System.out.println("\nSub-test " + (subtestNum)
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
                + " for bug " + BUGID + " (" + BUGNAME + ") " + result + "\n"
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
                + "Actual: \"" + actualRef + "\"" + "\n"
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
                + "Expect: \"" + expectRef + "\"");
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
            System.out.println("Didn't find <A HREF> that fits the pattern: "
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
                  + expectLinkPattern1.pattern() );
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
}