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

changeset 1
9a66ca7c79fa
child 554
9d9f26857129
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/com/sun/javadoc/testUseOption/TestUseOption.java	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,111 @@
     1.4 +/*
     1.5 + * Copyright 2002-2004 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    1.24 + * have any questions.
    1.25 + */
    1.26 +
    1.27 +/*
    1.28 + * @test
    1.29 + * @bug 4496290 4985072
    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";
    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[] ARGS = new String[] {
    1.61 +        "-d", BUG_ID, "-sourcepath", SRC_DIR, "-use", "pkg1", "pkg2"
    1.62 +    };
    1.63 +
    1.64 +    private static final String[] ARGS2 = new String[] {
    1.65 +        "-d", BUG_ID+"-2", "-sourcepath", SRC_DIR, "-use", "pkg1", "pkg2"
    1.66 +    };
    1.67 +
    1.68 +    /**
    1.69 +     * The entry point of the test.
    1.70 +     * @param args the array of command line arguments.
    1.71 +     */
    1.72 +    public static void main(String[] args) throws Exception {
    1.73 +        String[][] tests = new String[11][2];
    1.74 +        //Eight tests for class use.
    1.75 +        for (int i = 0; i < 8; i++) {
    1.76 +            tests[i][0] = BUG_ID + FS + "pkg1" + FS + "class-use" + FS + "C1.html";
    1.77 +            tests[i][1] = "Test " + (i + 1) + " passes";
    1.78 +        }
    1.79 +        //Three more tests for package use.
    1.80 +        for (int i = 8, j = 1; i < tests.length; i++, j++) {
    1.81 +            tests[i][0] = BUG_ID + FS + "pkg1" + FS + "package-use.html";
    1.82 +            tests[i][1] = "Test " + j + " passes";
    1.83 +        }
    1.84 +        TestUseOption tester = new TestUseOption();
    1.85 +        run(tester, ARGS, tests, NO_TEST);
    1.86 +        tester.printSummary();
    1.87 +        run(tester, ARGS2, NO_TEST, NO_TEST);
    1.88 +        String usePageContents = tester.readFileToString(BUG_ID +"-2" + FS + "pkg1" + FS + "class-use" + FS + "UsedClass.html");
    1.89 +        int prevIndex = -1;
    1.90 +        int currentIndex = -1;
    1.91 +        for (int i = 0; i < TEST2.length; i++) {
    1.92 +            currentIndex = usePageContents.indexOf(TEST2[i]);
    1.93 +            System.err.println(TEST2[i] + " at index " + currentIndex);
    1.94 +            if (currentIndex < prevIndex)
    1.95 +                throw new Exception(TEST2[i] + " is in the wrong order.");
    1.96 +            prevIndex = currentIndex;
    1.97 +        }
    1.98 +        tester.printSummary();
    1.99 +    }
   1.100 +
   1.101 +    /**
   1.102 +     * {@inheritDoc}
   1.103 +     */
   1.104 +    public String getBugId() {
   1.105 +        return BUG_ID;
   1.106 +    }
   1.107 +
   1.108 +    /**
   1.109 +     * {@inheritDoc}
   1.110 +     */
   1.111 +    public String getBugName() {
   1.112 +        return getClass().getName();
   1.113 +    }
   1.114 +}

mercurial