test/com/sun/javadoc/testUseOption/TestUseOption.java

changeset 0
959103a6100f
child 2525
2eb010b6cb22
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/com/sun/javadoc/testUseOption/TestUseOption.java	Wed Apr 27 01:34:52 2016 +0800
     1.3 @@ -0,0 +1,139 @@
     1.4 +/*
     1.5 + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + */
    1.26 +
    1.27 +/*
    1.28 + * @test
    1.29 + * @bug 4496290 4985072 7006178 7068595 8016328
    1.30 + * @summary A simple test to determine if -use works.
    1.31 + * @author jamieh
    1.32 + * @library ../lib/
    1.33 + * @build JavadocTester
    1.34 + * @build TestUseOption
    1.35 + * @run main TestUseOption
    1.36 + */
    1.37 +
    1.38 +public class TestUseOption extends JavadocTester {
    1.39 +
    1.40 +    private static final String BUG_ID = "4496290-4985072-7006178-7068595";
    1.41 +
    1.42 +    //Input for string search tests.
    1.43 +    private static final String[] TEST2 = {
    1.44 +        "Field in C1.",
    1.45 +        "Field in C2.",
    1.46 +        "Field in C4.",
    1.47 +        "Field in C5.",
    1.48 +        "Field in C6.",
    1.49 +        "Field in C7.",
    1.50 +        "Field in C8.",
    1.51 +        "Method in C1.",
    1.52 +        "Method in C2.",
    1.53 +        "Method in C4.",
    1.54 +        "Method in C5.",
    1.55 +        "Method in C6.",
    1.56 +        "Method in C7.",
    1.57 +        "Method in C8.",
    1.58 +    };
    1.59 +
    1.60 +    private static final String[][] TEST3 = {
    1.61 +        {BUG_ID + "-3" + FS + "class-use" + FS + "UsedInC.html", "Uses of <a href=" +
    1.62 +                 "\"../UsedInC.html\" title=\"class in &lt;Unnamed&gt;\">" +
    1.63 +                 "UsedInC</a> in <a href=\"../package-summary.html\">&lt;Unnamed&gt;</a>"
    1.64 +        },
    1.65 +        {BUG_ID + "-3" + FS + "package-use.html", "<td class=\"colOne\">" +
    1.66 +                 "<a href=\"class-use/UsedInC.html#%3CUnnamed%3E\">UsedInC</a>&nbsp;</td>"
    1.67 +        }
    1.68 +    };
    1.69 +
    1.70 +    private static final String[][] TEST4 = {
    1.71 +        {BUG_ID + "-4" + FS + "pkg2" + FS + "class-use" + FS + "C3.html", "<a href=" +
    1.72 +                 "\"../../index.html?pkg2/class-use/C3.html\" target=\"_top\">" +
    1.73 +                 "Frames</a></li>"
    1.74 +        }
    1.75 +    };
    1.76 +
    1.77 +    private static final String[] ARGS = new String[] {
    1.78 +        "-d", BUG_ID, "-sourcepath", SRC_DIR, "-use", "pkg1", "pkg2"
    1.79 +    };
    1.80 +
    1.81 +    private static final String[] ARGS2 = new String[] {
    1.82 +        "-d", BUG_ID+"-2", "-sourcepath", SRC_DIR, "-use", "pkg1", "pkg2"
    1.83 +    };
    1.84 +
    1.85 +    private static final String[] ARGS3 = new String[] {
    1.86 +        "-d", BUG_ID + "-3", "-sourcepath", SRC_DIR, "-use", SRC_DIR + FS + "C.java", SRC_DIR + FS + "UsedInC.java"
    1.87 +    };
    1.88 +
    1.89 +    private static final String[] ARGS4 = new String[] {
    1.90 +        "-d", BUG_ID + "-4", "-sourcepath", SRC_DIR, "-use", "pkg1", "pkg2"
    1.91 +    };
    1.92 +
    1.93 +    /**
    1.94 +     * The entry point of the test.
    1.95 +     * @param args the array of command line arguments.
    1.96 +     */
    1.97 +    public static void main(String[] args) throws Exception {
    1.98 +        String[][] tests = new String[11][2];
    1.99 +        //Eight tests for class use.
   1.100 +        for (int i = 0; i < 8; i++) {
   1.101 +            tests[i][0] = BUG_ID + FS + "pkg1" + FS + "class-use" + FS + "C1.html";
   1.102 +            tests[i][1] = "Test " + (i + 1) + " passes";
   1.103 +        }
   1.104 +        //Three more tests for package use.
   1.105 +        for (int i = 8, j = 1; i < tests.length; i++, j++) {
   1.106 +            tests[i][0] = BUG_ID + FS + "pkg1" + FS + "package-use.html";
   1.107 +            tests[i][1] = "Test " + j + " passes";
   1.108 +        }
   1.109 +        TestUseOption tester = new TestUseOption();
   1.110 +        run(tester, ARGS, tests, NO_TEST);
   1.111 +        tester.printSummary();
   1.112 +        run(tester, ARGS2, NO_TEST, NO_TEST);
   1.113 +        String usePageContents = tester.readFileToString(BUG_ID +"-2" + FS + "pkg1" + FS + "class-use" + FS + "UsedClass.html");
   1.114 +        int prevIndex = -1;
   1.115 +        int currentIndex = -1;
   1.116 +        for (int i = 0; i < TEST2.length; i++) {
   1.117 +            currentIndex = usePageContents.indexOf(TEST2[i]);
   1.118 +            System.err.println(TEST2[i] + " at index " + currentIndex);
   1.119 +            if (currentIndex < prevIndex)
   1.120 +                throw new Exception(TEST2[i] + " is in the wrong order.");
   1.121 +            prevIndex = currentIndex;
   1.122 +        }
   1.123 +        tester.printSummary();
   1.124 +        run(tester, ARGS3, TEST3, NO_TEST);
   1.125 +        run(tester, ARGS4, TEST4, NO_TEST);
   1.126 +        tester.printSummary();
   1.127 +    }
   1.128 +
   1.129 +    /**
   1.130 +     * {@inheritDoc}
   1.131 +     */
   1.132 +    public String getBugId() {
   1.133 +        return BUG_ID;
   1.134 +    }
   1.135 +
   1.136 +    /**
   1.137 +     * {@inheritDoc}
   1.138 +     */
   1.139 +    public String getBugName() {
   1.140 +        return getClass().getName();
   1.141 +    }
   1.142 +}

mercurial