langtools/test/com/sun/javadoc/testOrdering/TestOrdering.java
author jjg
Fri, 09 May 2014 15:37:12 -0700
changeset 24399 af1a0220d0fa
parent 24394 74279778c307
child 25004 b33effe4f252
permissions -rw-r--r--
8038730: Clean up the way JavadocTester is invoked, and checks for errors. Reviewed-by: ksrini, sogoel, bpatel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24220
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
     1
/*
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
     4
 *
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
     7
 * published by the Free Software Foundation.
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
     8
 *
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    13
 * accompanied this code).
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    14
 *
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    18
 *
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    21
 * questions.
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    22
 */
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    23
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    24
/*
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    25
 * @test
24394
74279778c307 8042601: Javadoc sort fails
ksrini
parents: 24220
diff changeset
    26
 * @bug 8039410 8042601
24220
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    27
 * @summary test to determine if members are ordered correctly
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    28
 * @author ksrini
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    29
 * @library ../lib/
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    30
 * @build JavadocTester
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    31
 * @run main TestOrdering
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    32
 */
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    33
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    34
public class TestOrdering extends JavadocTester {
24220
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    35
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    36
    public static void main(String[] args) throws Exception {
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    37
        TestOrdering tester = new TestOrdering();
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    38
        tester.runTests();
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    39
    }
24220
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    40
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    41
    @Test
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    42
    void testUnnamedPackages() {
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    43
        javadoc("-d", "out",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    44
                "-sourcepath", testSrc,
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    45
                "-use",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    46
                testSrc("C.java"), testSrc("UsedInC.java"));
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    47
        checkExit(Exit.OK);
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    48
        checkExecutableMemberOrdering("class-use/UsedInC.html");
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    49
    }
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    50
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    51
    @Test
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    52
    void testNamedPackages() {
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    53
        javadoc("-d", "out-1",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    54
                "-sourcepath", testSrc,
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    55
                "-use",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    56
                "pkg1");
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    57
        checkExit(Exit.OK);
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    58
        checkClassUseOrdering("pkg1/class-use/UsedClass.html");
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    59
        checkIndexPathOrdering("index-all.html");
24220
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    60
    }
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    61
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    62
    void checkExecutableMemberOrdering(String usePage) {
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    63
        String contents = readFile(usePage);
24220
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    64
        // check constructors
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    65
        checking("constructors");
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    66
        int idx1 = contents.indexOf("C.html#C-UsedInC");
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    67
        int idx2 = contents.indexOf("C.html#C-UsedInC-int");
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    68
        int idx3 = contents.indexOf("C.html#C-UsedInC-java.lang.String");
24220
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    69
        if (idx1 == -1 || idx2 == -1 || idx3 == -1) {
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    70
            failed("ctor strings not found");
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    71
        } else if (idx1 > idx2 || idx2 > idx3 || idx1 > idx3) {
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    72
            failed("ctor strings are out of order");
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    73
        } else
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    74
            passed("ctor strings are in order");
24220
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    75
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    76
        // check methods
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    77
        checking("methods");
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    78
        idx1 = contents.indexOf("C.html#ymethod-int");
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    79
        idx2 = contents.indexOf("C.html#ymethod-java.lang.String");
24220
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    80
        if (idx1 == -1 || idx2 == -1) {
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    81
            failed("#ymethod strings not found");
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    82
        } else if (idx1 > idx2) {
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    83
            failed("#ymethod strings are out of order");
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    84
        } else
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    85
            passed("Executable Member Ordering: OK");
24220
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    86
    }
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    87
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    88
    void checkClassUseOrdering(String usePage) {
24220
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    89
        checkClassUseOrdering(usePage, "pkg1/C#ITERATION#.html#zfield");
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    90
        checkClassUseOrdering(usePage, "pkg1/C#ITERATION#.html#fieldInC#ITERATION#");
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    91
        checkClassUseOrdering(usePage, "pkg1/C#ITERATION#.html#zmethod-pkg1.UsedClass");
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    92
        checkClassUseOrdering(usePage, "pkg1/C#ITERATION#.html#methodInC#ITERATION#");
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    93
    }
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    94
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    95
    void checkClassUseOrdering(String usePage, String searchString) {
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
    96
        String contents = readFile(usePage);
24220
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    97
        int lastidx = 0;
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    98
        System.out.println("testing for " + searchString);
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
    99
        for (int i = 1; i < 5; i++) {
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
   100
            String s = searchString.replaceAll("#ITERATION#", Integer.toString(i));
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
   101
            checking(s);
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
   102
            int idx = contents.indexOf(s);
24220
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
   103
            if (idx < lastidx) {
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
   104
                failed(s + ", member ordering error, last:" + lastidx + ", got:" + idx);
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
   105
            } else {
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
   106
                passed("\tlast: " + lastidx + " got:" + idx);
24220
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
   107
            }
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
   108
            lastidx = idx;
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
   109
        }
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
   110
    }
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
   111
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
   112
    void checkIndexPathOrdering(String indexPage) {
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
   113
        checkOrder(indexPage,
24394
74279778c307 8042601: Javadoc sort fails
ksrini
parents: 24220
diff changeset
   114
            "pkg1/UsedClass.html#add--",
74279778c307 8042601: Javadoc sort fails
ksrini
parents: 24220
diff changeset
   115
            "pkg1/ZZTop.html#add--",
74279778c307 8042601: Javadoc sort fails
ksrini
parents: 24220
diff changeset
   116
            "pkg1/UsedClass.html#add-double-",
74279778c307 8042601: Javadoc sort fails
ksrini
parents: 24220
diff changeset
   117
            "pkg1/UsedClass.html#add-java.lang.Double-",
74279778c307 8042601: Javadoc sort fails
ksrini
parents: 24220
diff changeset
   118
            "pkg1/ZZTop.html#add-double-",
74279778c307 8042601: Javadoc sort fails
ksrini
parents: 24220
diff changeset
   119
            "pkg1/ZZTop.html#add-java.lang.Double-",
74279778c307 8042601: Javadoc sort fails
ksrini
parents: 24220
diff changeset
   120
            "pkg1/UsedClass.html#add-double-byte-",
74279778c307 8042601: Javadoc sort fails
ksrini
parents: 24220
diff changeset
   121
            "pkg1/ZZTop.html#add-double-byte-",
74279778c307 8042601: Javadoc sort fails
ksrini
parents: 24220
diff changeset
   122
            "pkg1/UsedClass.html#add-double-double-",
74279778c307 8042601: Javadoc sort fails
ksrini
parents: 24220
diff changeset
   123
            "pkg1/UsedClass.html#add-double-java.lang.Double-",
74279778c307 8042601: Javadoc sort fails
ksrini
parents: 24220
diff changeset
   124
            "pkg1/ZZTop.html#add-double-double-",
74279778c307 8042601: Javadoc sort fails
ksrini
parents: 24220
diff changeset
   125
            "pkg1/ZZTop.html#add-double-java.lang.Double-",
74279778c307 8042601: Javadoc sort fails
ksrini
parents: 24220
diff changeset
   126
            "pkg1/UsedClass.html#add-float-",
74279778c307 8042601: Javadoc sort fails
ksrini
parents: 24220
diff changeset
   127
            "pkg1/ZZTop.html#add-float-",
74279778c307 8042601: Javadoc sort fails
ksrini
parents: 24220
diff changeset
   128
            "pkg1/UsedClass.html#add-float-int-",
74279778c307 8042601: Javadoc sort fails
ksrini
parents: 24220
diff changeset
   129
            "pkg1/ZZTop.html#add-float-int-",
74279778c307 8042601: Javadoc sort fails
ksrini
parents: 24220
diff changeset
   130
            "pkg1/UsedClass.html#add-int-",
74279778c307 8042601: Javadoc sort fails
ksrini
parents: 24220
diff changeset
   131
            "pkg1/ZZTop.html#add-int-",
74279778c307 8042601: Javadoc sort fails
ksrini
parents: 24220
diff changeset
   132
            "pkg1/UsedClass.html#add-int-float-",
74279778c307 8042601: Javadoc sort fails
ksrini
parents: 24220
diff changeset
   133
            "pkg1/ZZTop.html#add-int-float-",
74279778c307 8042601: Javadoc sort fails
ksrini
parents: 24220
diff changeset
   134
            "pkg1/UsedClass.html#add-java.lang.Integer-",
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24394
diff changeset
   135
            "pkg1/ZZTop.html#add-java.lang.Integer-");
24220
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
   136
    }
eb213562268d 8039410: [javadoc] fix class-use items to be deterministic and index ordering
ksrini
parents:
diff changeset
   137
}