langtools/test/jdk/javadoc/doclet/testOrdering/TestOrdering.java
changeset 37752 4243173b58db
parent 36526 3b41f1c69604
child 40511 1b3c502e0bdc
equal deleted inserted replaced
37751:77e7bb904a13 37752:4243173b58db
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
    24 /*
    24 /*
    25  * @test
    25  * @test
    26  * @bug 8039410 8042601 8042829 8049393 8050031
    26  * @bug 8039410 8042601 8042829 8049393 8050031 8155061
    27  * @summary test to determine if members are ordered correctly
    27  * @summary test to determine if members are ordered correctly
    28  * @author ksrini
    28  * @author ksrini
    29  * @library ../lib/
    29  * @library ../lib/
    30  * @modules jdk.javadoc/jdk.javadoc.internal.tool
    30  * @modules jdk.javadoc/jdk.javadoc.internal.tool
    31  * @build JavadocTester
    31  * @build JavadocTester
    70         checkOrder("pkg1/class-use/UsedClass.html", expectedClassUseMethodOrdering);
    70         checkOrder("pkg1/class-use/UsedClass.html", expectedClassUseMethodOrdering);
    71         checkOrder("pkg1/class-use/UsedClass.html", expectedClassUseWithTypeParams);
    71         checkOrder("pkg1/class-use/UsedClass.html", expectedClassUseWithTypeParams);
    72         checkOrder("pkg1/class-use/UsedClass.html", expectedInnerClassContructors);
    72         checkOrder("pkg1/class-use/UsedClass.html", expectedInnerClassContructors);
    73         checkOrder("pkg1/ImplementsOrdering.html", expectedImplementsOrdering);
    73         checkOrder("pkg1/ImplementsOrdering.html", expectedImplementsOrdering);
    74         checkOrder("pkg1/OverrideOrdering.html", expectedOverrideOrdering);
    74         checkOrder("pkg1/OverrideOrdering.html", expectedOverrideOrdering);
       
    75         checkOrder("allclasses-noframe.html", expectedAllClasses);
       
    76         checkOrder("allclasses-frame.html", expectedAllClasses);
    75     }
    77     }
    76 
    78 
    77     enum ListOrder { NONE, REVERSE, SHUFFLE };
    79     enum ListOrder { NONE, REVERSE, SHUFFLE };
    78     /*
    80     /*
    79      * By default we do not shuffle the input list, in order to keep the list deterministic,
    81      * By default we do not shuffle the input list, in order to keep the list deterministic,
   177         "something()</a></span> - Method in class a.<a href=\"a/something.html\"",
   179         "something()</a></span> - Method in class a.<a href=\"a/something.html\"",
   178         "something()</a></span> - Method in class something.<a href=\"something/J.html\""
   180         "something()</a></span> - Method in class something.<a href=\"something/J.html\""
   179     };
   181     };
   180     String[] composeTestVectors() {
   182     String[] composeTestVectors() {
   181         List<String> testList = new ArrayList<>();
   183         List<String> testList = new ArrayList<>();
       
   184 
       
   185         testList.addAll(Arrays.asList(expectedPackageOrdering));
       
   186 
       
   187         for (String x : expectedMethodOrdering) {
       
   188             testList.add(x);
       
   189             for (int i = 0; i < MAX_PACKAGES; i++) {
       
   190                 String wpkg = "add" + i;
       
   191                 testList.add(wpkg + "/" + x);
       
   192                 String dpkg = wpkg;
       
   193                 for (int j = 1; j < MAX_SUBPACKAGES_DEPTH; j++) {
       
   194                     dpkg = dpkg + "/" + "add";
       
   195                     testList.add(dpkg + "/" + x);
       
   196                 }
       
   197             }
       
   198         }
       
   199 
   182         for (String x : expectedEnumOrdering) {
   200         for (String x : expectedEnumOrdering) {
   183             testList.add(x.replace("REPLACE_ME", "&lt;Unnamed&gt;"));
   201             testList.add(x.replace("REPLACE_ME", "&lt;Unnamed&gt;"));
   184             for (int i = 0; i < MAX_PACKAGES; i++) {
   202             for (int i = 0; i < MAX_PACKAGES; i++) {
   185                 String wpkg = "add" + i;
   203                 String wpkg = "add" + i;
   186                 testList.add(wpkg + "/" + x.replace("REPLACE_ME", wpkg));
   204                 testList.add(wpkg + "/" + x.replace("REPLACE_ME", wpkg));
   192             }
   210             }
   193         }
   211         }
   194 
   212 
   195         testList.addAll(Arrays.asList(expectedFieldOrdering));
   213         testList.addAll(Arrays.asList(expectedFieldOrdering));
   196 
   214 
   197         for (String x : expectedMethodOrdering) {
       
   198             testList.add(x);
       
   199             for (int i = 0; i < MAX_PACKAGES; i++) {
       
   200                 String wpkg = "add" + i;
       
   201                 testList.add(wpkg + "/" + x);
       
   202                 String dpkg = wpkg;
       
   203                 for (int j = 1; j < MAX_SUBPACKAGES_DEPTH; j++) {
       
   204                     dpkg = dpkg + "/" + "add";
       
   205                     testList.add(dpkg + "/" + x);
       
   206                 }
       
   207             }
       
   208         }
       
   209         return testList.toArray(new String[testList.size()]);
   215         return testList.toArray(new String[testList.size()]);
   210     }
   216     }
       
   217 
   211     void checkExecutableMemberOrdering(String usePage) {
   218     void checkExecutableMemberOrdering(String usePage) {
   212         String contents = readFile(usePage);
   219         String contents = readFile(usePage);
   213         // check constructors
   220         // check constructors
   214         checking("constructors");
   221         checking("constructors");
   215         int idx1 = contents.indexOf("C.html#C-UsedInC");
   222         int idx1 = contents.indexOf("C.html#C-UsedInC");
   307 
   314 
   308     String pathToPackage(String in) {
   315     String pathToPackage(String in) {
   309         return in.replace("/", ".");
   316         return in.replace("/", ".");
   310     }
   317     }
   311 
   318 
       
   319     final String expectedAllClasses[] = {
       
   320         "pkg1/A.html\" title=\"class in pkg1",
       
   321         "pkg1/A.C.html\" title=\"class in pkg1",
       
   322         "pkg1/B.html\" title=\"class in pkg1",
       
   323         "pkg1/B.A.html\" title=\"class in pkg1",
       
   324         "pkg1/C1.html\" title=\"class in pkg1",
       
   325         "pkg1/C2.html\" title=\"class in pkg1",
       
   326         "pkg1/C3.html\" title=\"class in pkg1",
       
   327         "pkg1/C4.html\" title=\"class in pkg1",
       
   328         "pkg1/ImplementsOrdering.html\" title=\"interface in pkg1",
       
   329         "pkg1/MethodOrder.html\" title=\"class in pkg1",
       
   330         "pkg1/OverrideOrdering.html\" title=\"class in pkg1",
       
   331         "pkg1/UsedClass.html\" title=\"class in pkg1"
       
   332 
       
   333     };
       
   334 
   312     final String expectedInnerClassContructors[] = {
   335     final String expectedInnerClassContructors[] = {
   313         "../../pkg1/A.html#A-pkg1.UsedClass-",
   336         "../../pkg1/A.html#A-pkg1.UsedClass-",
   314         "../../pkg1/B.A.html#A-pkg1.UsedClass-",
   337         "../../pkg1/B.A.html#A-pkg1.UsedClass-",
   315         "../../pkg1/B.html#B-pkg1.UsedClass-",
   338         "../../pkg1/B.html#B-pkg1.UsedClass-",
   316         "../../pkg1/A.C.html#C-pkg1.UsedClass-java.lang.Object:A-",
   339         "../../pkg1/A.C.html#C-pkg1.UsedClass-java.lang.Object:A-",
   340         "../../pkg1/MethodOrder.html#m-java.lang.Object:A-",
   363         "../../pkg1/MethodOrder.html#m-java.lang.Object:A-",
   341         "../../pkg1/MethodOrder.html#m-java.util.ArrayList-",
   364         "../../pkg1/MethodOrder.html#m-java.util.ArrayList-",
   342         "../../pkg1/MethodOrder.html#m-java.util.Collection-",
   365         "../../pkg1/MethodOrder.html#m-java.util.Collection-",
   343         "../../pkg1/MethodOrder.html#m-java.util.List-"
   366         "../../pkg1/MethodOrder.html#m-java.util.List-"
   344     };
   367     };
       
   368 
   345     final String expectedClassUseWithTypeParams[] = {
   369     final String expectedClassUseWithTypeParams[] = {
   346         "../../pkg1/MethodOrder.html#tpm-pkg1.UsedClass-",
   370         "../../pkg1/MethodOrder.html#tpm-pkg1.UsedClass-",
   347         "../../pkg1/MethodOrder.html#tpm-pkg1.UsedClass-pkg1.UsedClass-",
   371         "../../pkg1/MethodOrder.html#tpm-pkg1.UsedClass-pkg1.UsedClass-",
   348         "../../pkg1/MethodOrder.html#tpm-pkg1.UsedClass-pkg1.UsedClass:A-",
   372         "../../pkg1/MethodOrder.html#tpm-pkg1.UsedClass-pkg1.UsedClass:A-",
   349         "../../pkg1/MethodOrder.html#tpm-pkg1.UsedClass-java.lang.String-"
   373         "../../pkg1/MethodOrder.html#tpm-pkg1.UsedClass-java.lang.String-"
   350     };
   374     };
       
   375 
       
   376     final String expectedPackageOrdering[] = {
       
   377         "\"add0/package-summary.html\">add0</a> - package add0",
       
   378         "\"add0/add/package-summary.html\">add0.add</a> - package add0.add",
       
   379         "\"add0/add/add/package-summary.html\">add0.add.add</a> - package add0.add.add",
       
   380         "\"add0/add/add/add/package-summary.html\">add0.add.add.add</a> - package add0.add.add.add",
       
   381         "\"add1/package-summary.html\">add1</a> - package add1",
       
   382         "\"add1/add/package-summary.html\">add1.add</a> - package add1.add",
       
   383         "\"add1/add/add/package-summary.html\">add1.add.add</a> - package add1.add.add",
       
   384         "\"add1/add/add/add/package-summary.html\">add1.add.add.add</a> - package add1.add.add.add",
       
   385         "\"add2/package-summary.html\">add2</a> - package add2",
       
   386         "\"add2/add/package-summary.html\">add2.add</a> - package add2.add",
       
   387         "\"add2/add/add/package-summary.html\">add2.add.add</a> - package add2.add.add",
       
   388         "\"add2/add/add/add/package-summary.html\">add2.add.add.add</a> - package add2.add.add.add",
       
   389         "\"add3/package-summary.html\">add3</a> - package add3",
       
   390         "\"add3/add/package-summary.html\">add3.add</a> - package add3.add",
       
   391         "\"add3/add/add/package-summary.html\">add3.add.add</a> - package add3.add.add",
       
   392         "\"add3/add/add/add/package-summary.html\">add3.add.add.add</a> - package add3.add.add.add"
       
   393     };
       
   394 
   351     final String expectedMethodOrdering[] = {
   395     final String expectedMethodOrdering[] = {
   352         "Add.html#add--",
   396         "Add.html#add--",
   353         "Add.html#add-double-",
   397         "Add.html#add-double-",
   354         "Add.html#add-double-byte-",
   398         "Add.html#add-double-byte-",
   355         "Add.html#add-double-double-",
   399         "Add.html#add-double-double-",
   359         "Add.html#add-int-",
   403         "Add.html#add-int-",
   360         "Add.html#add-int-float-",
   404         "Add.html#add-int-float-",
   361         "Add.html#add-java.lang.Double-",
   405         "Add.html#add-java.lang.Double-",
   362         "Add.html#add-java.lang.Integer-"
   406         "Add.html#add-java.lang.Integer-"
   363     };
   407     };
       
   408 
   364     final String expectedEnumOrdering[] = {
   409     final String expectedEnumOrdering[] = {
   365         "Add.add.html\" title=\"enum in REPLACE_ME\"",
   410         "Add.add.html\" title=\"enum in REPLACE_ME\"",
   366         "Add.ADD.html\" title=\"enum in REPLACE_ME\""
   411         "Add.ADD.html\" title=\"enum in REPLACE_ME\""
   367     };
   412     };
       
   413 
   368     final String expectedFieldOrdering[] = {
   414     final String expectedFieldOrdering[] = {
   369         "Add.html#addadd\"",
   415         "Add.html#addadd\"",
   370         "add0/add/add/add/Add.html#addadd\"",
   416         "add0/add/add/add/Add.html#addadd\"",
   371         "add0/add/add/Add.html#addadd\"",
   417         "add0/add/add/Add.html#addadd\"",
   372         "add0/add/Add.html#addadd\"",
   418         "add0/add/Add.html#addadd\"",
   416         "add3/add/add/add/Add.html#ADDADD\"",
   462         "add3/add/add/add/Add.html#ADDADD\"",
   417         "add3/add/add/Add.html#ADDADD\"",
   463         "add3/add/add/Add.html#ADDADD\"",
   418         "add3/add/Add.html#ADDADD\"",
   464         "add3/add/Add.html#ADDADD\"",
   419         "add3/Add.html#ADDADD\""
   465         "add3/Add.html#ADDADD\""
   420     };
   466     };
       
   467 
   421     final String expectedPackageTreeOrdering[] = {
   468     final String expectedPackageTreeOrdering[] = {
   422         "<a href=\"../../add0/add/Add.add.html\" title=\"enum in add0.add\">",
   469         "<a href=\"../../add0/add/Add.add.html\" title=\"enum in add0.add\">",
   423         "<a href=\"../../add0/add/Add.ADD.html\" title=\"enum in add0.add\">"
   470         "<a href=\"../../add0/add/Add.ADD.html\" title=\"enum in add0.add\">"
   424     };
   471     };
       
   472 
   425     final String expectedOverviewOrdering[] = {
   473     final String expectedOverviewOrdering[] = {
   426         "<a href=\"Add.add.html\" title=\"enum in &lt;Unnamed&gt;\">",
   474         "<a href=\"Add.add.html\" title=\"enum in &lt;Unnamed&gt;\">",
   427         "<a href=\"add0/Add.add.html\" title=\"enum in add0\">",
   475         "<a href=\"add0/Add.add.html\" title=\"enum in add0\">",
   428         "<a href=\"add0/add/Add.add.html\" title=\"enum in add0.add\">",
   476         "<a href=\"add0/add/Add.add.html\" title=\"enum in add0.add\">",
   429         "<a href=\"add0/add/add/Add.add.html\" title=\"enum in add0.add.add\">",
   477         "<a href=\"add0/add/add/Add.add.html\" title=\"enum in add0.add.add\">",
   456         "<a href=\"add3/Add.ADD.html\" title=\"enum in add3\">",
   504         "<a href=\"add3/Add.ADD.html\" title=\"enum in add3\">",
   457         "<a href=\"add3/add/Add.ADD.html\" title=\"enum in add3.add\">",
   505         "<a href=\"add3/add/Add.ADD.html\" title=\"enum in add3.add\">",
   458         "<a href=\"add3/add/add/Add.ADD.html\" title=\"enum in add3.add.add\">",
   506         "<a href=\"add3/add/add/Add.ADD.html\" title=\"enum in add3.add.add\">",
   459         "<a href=\"add3/add/add/add/Add.ADD.html\" title=\"enum in add3.add.add.add\">",
   507         "<a href=\"add3/add/add/add/Add.ADD.html\" title=\"enum in add3.add.add.add\">",
   460     };
   508     };
       
   509 
   461     final static String expectedOverviewFrameOrdering[] = {
   510     final static String expectedOverviewFrameOrdering[] = {
   462         "<a href=\"package-frame.html\" target=\"packageFrame\">&lt;unnamed package&gt;</a>",
   511         "<a href=\"package-frame.html\" target=\"packageFrame\">&lt;unnamed package&gt;</a>",
   463         "<a href=\"add0/package-frame.html\" target=\"packageFrame\">add0</a>",
   512         "<a href=\"add0/package-frame.html\" target=\"packageFrame\">add0</a>",
   464         "<a href=\"add0/add/package-frame.html\" target=\"packageFrame\">add0.add</a>",
   513         "<a href=\"add0/add/package-frame.html\" target=\"packageFrame\">add0.add</a>",
   465         "<a href=\"add0/add/add/package-frame.html\" target=\"packageFrame\">add0.add.add</a>",
   514         "<a href=\"add0/add/add/package-frame.html\" target=\"packageFrame\">add0.add.add</a>",
   475         "<a href=\"add3/package-frame.html\" target=\"packageFrame\">add3</a>",
   524         "<a href=\"add3/package-frame.html\" target=\"packageFrame\">add3</a>",
   476         "<a href=\"add3/add/package-frame.html\" target=\"packageFrame\">add3.add</a>",
   525         "<a href=\"add3/add/package-frame.html\" target=\"packageFrame\">add3.add</a>",
   477         "<a href=\"add3/add/add/package-frame.html\" target=\"packageFrame\">add3.add.add</a>",
   526         "<a href=\"add3/add/add/package-frame.html\" target=\"packageFrame\">add3.add.add</a>",
   478         "<a href=\"add3/add/add/add/package-frame.html\" target=\"packageFrame\">add3.add.add.add</a></li>"
   527         "<a href=\"add3/add/add/add/package-frame.html\" target=\"packageFrame\">add3.add.add.add</a></li>"
   479     };
   528     };
       
   529 
   480     final static String expectedImplementsOrdering[] = {
   530     final static String expectedImplementsOrdering[] = {
   481         "<dd><code>close</code>&nbsp;in interface&nbsp;<code>java.lang.AutoCloseable</code></dd>",
   531         "<dd><code>close</code>&nbsp;in interface&nbsp;<code>java.lang.AutoCloseable</code></dd>",
   482         "<dd><code>close</code>&nbsp;in interface&nbsp;<code>java.nio.channels.Channel</code></dd>",
   532         "<dd><code>close</code>&nbsp;in interface&nbsp;<code>java.nio.channels.Channel</code></dd>",
   483         "<dd><code>close</code>&nbsp;in interface&nbsp;<code>java.io.Closeable</code></dd>"
   533         "<dd><code>close</code>&nbsp;in interface&nbsp;<code>java.io.Closeable</code></dd>"
   484     };
   534     };
       
   535 
   485     final static String expectedOverrideOrdering[] = {
   536     final static String expectedOverrideOrdering[] = {
   486         "<dd><code>iterator</code>&nbsp;in interface&nbsp;<code>java.util.Collection&lt;",
   537         "<dd><code>iterator</code>&nbsp;in interface&nbsp;<code>java.util.Collection&lt;",
   487         "<dd><code>iterator</code>&nbsp;in interface&nbsp;<code>java.lang.Iterable&lt;"
   538         "<dd><code>iterator</code>&nbsp;in interface&nbsp;<code>java.lang.Iterable&lt;"
   488     };
   539     };
   489 }
   540 }