1 /*
   2  * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 8039410 8042601 8042829 8049393 8050031 8155061 8155995 8167967 8169813 8182765 8196202
  27  * @summary test to determine if members are ordered correctly
  28  * @library ../../lib/
  29  * @modules jdk.javadoc/jdk.javadoc.internal.tool
  30  * @build javadoc.tester.*
  31  * @run main TestOrdering
  32  */
  33 
  34 import java.io.File;
  35 import java.io.IOException;
  36 import java.nio.file.Files;
  37 import java.util.ArrayList;
  38 import java.util.Arrays;
  39 import java.util.Collections;
  40 import java.util.List;
  41 
  42 import static java.nio.file.StandardOpenOption.*;
  43 
  44 import javadoc.tester.JavadocTester;
  45 
  46 public class TestOrdering extends JavadocTester {
  47 
  48     public static void main(String[] args) throws Exception {
  49         TestOrdering tester = new TestOrdering();
  50         tester.runTests();
  51     }
  52 
  53     @Test
  54     public void testUnnamedPackagesForClassUse() {
  55         new UnnamedPackageForClassUseTest().run();
  56     }
  57 
  58     @Test
  59     public void testNamedPackagesForClassUse() {
  60         new NamedPackagesForClassUseTest().run();
  61     }
  62 
  63     @Test
  64     public void testIndexOrdering() throws IOException {
  65         new IndexOrderingTest().run();
  66     }
  67 
  68     @Test
  69     public void testIndexTypeClustering() {
  70         new IndexTypeClusteringTest().run();
  71     }
  72 
  73     @Test
  74     public void testTypeElementMemberOrdering() {
  75         new TypeElementMemberOrderingTest().run();
  76     }
  77 
  78     class UnnamedPackageForClassUseTest {
  79 
  80         void run() {
  81             javadoc("-d", "out",
  82                     "-sourcepath", testSrc,
  83                     "-use",
  84                     testSrc("C.java"), testSrc("UsedInC.java"));
  85             checkExit(Exit.OK);
  86             checkExecutableMemberOrdering("class-use/UsedInC.html");
  87         }
  88 
  89         void checkExecutableMemberOrdering(String usePage) {
  90             String contents = readFile(usePage);
  91             // check constructors
  92             checking("constructors");
  93             int idx1 = contents.indexOf("C.html#%3Cinit%3E(UsedInC");
  94             int idx2 = contents.indexOf("C.html#%3Cinit%3E(UsedInC,int");
  95             int idx3 = contents.indexOf("C.html#%3Cinit%3E(UsedInC,java.lang.String");
  96             if (idx1 == -1 || idx2 == -1 || idx3 == -1) {
  97                 failed("ctor strings not found");
  98             } else if (idx1 > idx2 || idx2 > idx3 || idx1 > idx3) {
  99                 failed("ctor strings are out of order");
 100             } else {
 101                 passed("ctor strings are in order");
 102             }
 103 
 104             // check methods
 105             checking("methods");
 106             idx1 = contents.indexOf("C.html#ymethod(int");
 107             idx2 = contents.indexOf("C.html#ymethod(java.lang.String");
 108             if (idx1 == -1 || idx2 == -1) {
 109                 failed("#ymethod strings not found");
 110             } else if (idx1 > idx2) {
 111                 failed("#ymethod strings are out of order");
 112             } else {
 113                 passed("Executable Member Ordering: OK");
 114             }
 115         }
 116     }
 117 
 118     class NamedPackagesForClassUseTest {
 119 
 120         public void run() {
 121             javadoc("-d", "out-1",
 122                     "-sourcepath", testSrc,
 123                     "-use",
 124                     "pkg1");
 125             checkExit(Exit.OK);
 126 
 127             checkClassUseOrdering("pkg1/class-use/UsedClass.html");
 128 
 129             checkOrder("pkg1/class-use/UsedClass.html",
 130                     "../MethodOrder.html#m()",
 131                     "../MethodOrder.html#m(byte%5B%5D)",
 132                     "../MethodOrder.html#m(double)",
 133                     "../MethodOrder.html#m(double,double)",
 134                     "../MethodOrder.html#m(double,java.lang.Double)",
 135                     "../MethodOrder.html#m(int)",
 136                     "../MethodOrder.html#m(int,int)",
 137                     "../MethodOrder.html#m(int,java.lang.Integer)",
 138                     "../MethodOrder.html#m(long)",
 139                     "../MethodOrder.html#m(long,long)",
 140                     "../MethodOrder.html#m(long,java.lang.Long)",
 141                     "../MethodOrder.html#m(long,java.lang.Long...)",
 142                     "../MethodOrder.html#m(java.lang.Double)",
 143                     "../MethodOrder.html#m(java.lang.Double,double)",
 144                     "../MethodOrder.html#m(java.lang.Double,java.lang.Double)",
 145                     "../MethodOrder.html#m(java.lang.Integer)",
 146                     "../MethodOrder.html#m(java.lang.Integer,int)",
 147                     "../MethodOrder.html#m(java.lang.Integer,java.lang.Integer)",
 148                     "../MethodOrder.html#m(java.lang.Object%5B%5D)",
 149                     "../MethodOrder.html#m(java.util.ArrayList)",
 150                     "../MethodOrder.html#m(java.util.Collection)",
 151                     "../MethodOrder.html#m(java.util.List)");
 152 
 153             checkOrder("pkg1/class-use/UsedClass.html",
 154                     "../MethodOrder.html#tpm(pkg1.UsedClass)",
 155                     "../MethodOrder.html#tpm(pkg1.UsedClass,pkg1.UsedClass)",
 156                     "../MethodOrder.html#tpm(pkg1.UsedClass,pkg1.UsedClass%5B%5D)",
 157                     "../MethodOrder.html#tpm(pkg1.UsedClass,java.lang.String)");
 158 
 159             checkOrder("pkg1/class-use/UsedClass.html",
 160                     "../A.html#%3Cinit%3E(pkg1.UsedClass)",
 161                     "../B.A.html#%3Cinit%3E(pkg1.UsedClass)",
 162                     "../B.html#%3Cinit%3E(pkg1.UsedClass)",
 163                     "../A.C.html#%3Cinit%3E(pkg1.UsedClass,java.lang.Object%5B%5D)",
 164                     "../A.C.html#%3Cinit%3E(pkg1.UsedClass,java.util.Collection)",
 165                     "../A.C.html#%3Cinit%3E(pkg1.UsedClass,java.util.List)");
 166 
 167             checkOrder("pkg1/ImplementsOrdering.html",
 168                     "<dd><code>close</code>&nbsp;in interface&nbsp;<code>java.lang.AutoCloseable</code></dd>",
 169                     "<dd><code>close</code>&nbsp;in interface&nbsp;<code>java.nio.channels.Channel</code></dd>",
 170                     "<dd><code>close</code>&nbsp;in interface&nbsp;<code>java.io.Closeable</code></dd>");
 171 
 172             checkOrder("pkg1/OverrideOrdering.html",
 173                     "<dd><code>iterator</code>&nbsp;in interface&nbsp;<code>java.util.Collection&lt;",
 174                     "<dd><code>iterator</code>&nbsp;in interface&nbsp;<code>java.lang.Iterable&lt;");
 175         }
 176 
 177         void checkClassUseOrdering(String usePage) {
 178             checkClassUseOrdering(usePage, "C#ITERATION#.html#zfield");
 179             checkClassUseOrdering(usePage, "C#ITERATION#.html#fieldInC#ITERATION#");
 180             checkClassUseOrdering(usePage, "C#ITERATION#.html#zmethod(pkg1.UsedClass");
 181             checkClassUseOrdering(usePage, "C#ITERATION#.html#methodInC#ITERATION#");
 182         }
 183 
 184         void checkClassUseOrdering(String usePage, String searchString) {
 185             String contents = readFile(usePage);
 186             int lastidx = 0;
 187             System.out.println("testing for " + searchString);
 188             for (int i = 1; i < 5; i++) {
 189                 String s = searchString.replaceAll("#ITERATION#", Integer.toString(i));
 190                 checking(s);
 191                 int idx = contents.indexOf(s);
 192                 if (idx < lastidx) {
 193                     failed(s + ", member ordering error, last:" + lastidx + ", got:" + idx);
 194                 } else {
 195                     passed("\tlast: " + lastidx + " got:" + idx);
 196                 }
 197                 lastidx = idx;
 198             }
 199         }
 200     }
 201 
 202     enum ListOrder {
 203         NONE, REVERSE, SHUFFLE
 204     };
 205 
 206     class IndexOrderingTest {
 207 
 208 
 209         /*
 210          * By default we do not shuffle the input list, in order to keep the list deterministic,
 211          * and the test predictable. However, we can turn on the stress mode, by setting the following
 212          * property if required.
 213          */
 214         final ListOrder STRESS_MODE = Boolean.getBoolean("TestOrder.STRESS")
 215                 ? ListOrder.SHUFFLE
 216                 : ListOrder.REVERSE;
 217 
 218         /*
 219          * Controls the number of children packages, pkg0, pkg0.pkg, pkg0.pkg.pkg, .....
 220          * Note: having too long a depth (> 256 chars on Windows), will likely lead to
 221          * cause problems with automated build and test systems.
 222          */
 223         static final int MAX_SUBPACKAGES_DEPTH = 4;
 224 
 225         /*
 226          * Controls the number of sibling packages,  pkg0, pkg1, pkg2, .....
 227          */
 228         static final int MAX_PACKAGES = 4;
 229 
 230         String[] contents = {
 231             "public add ADDADD;",
 232             "public add AddAdd;",
 233             "public add addadd;",
 234             "public enum add {add, ADD, addd, ADDD};",
 235             "public enum ADD {ADD, add, addd, ADDD};",
 236             "public void   add(){}",
 237             "public void   add(double d){}",
 238             "public void   add(int i, float f){}",
 239             "public void   add(float f, int i){}",
 240             "public void   add(double d, byte b){}",
 241             "public Double add(Double d) {return (double) 22/7;}",
 242             "public double add(double d1, double d2) {return d1 + d2;}",
 243             "public double add(double d1, Double  d2) {return d1 + d2;}",
 244             "public Float  add(float f) {return (float) 22/7;}",
 245             "public void   add(int i){}",
 246             "public int    add(Integer i) {return 0;}"
 247         };
 248 
 249         String expectedEnumOrdering[] = {
 250             "Add.add.html\" title=\"enum in REPLACE_ME\"",
 251             "Add.ADD.html\" title=\"enum in REPLACE_ME\""
 252         };
 253 
 254         String expectedFieldOrdering[] = {
 255             "Add.html#addadd\"",
 256             "add0/add/add/add/Add.html#addadd\"",
 257             "add0/add/add/Add.html#addadd\"",
 258             "add0/add/Add.html#addadd\"",
 259             "add0/Add.html#addadd\"",
 260             "add1/add/add/add/Add.html#addadd\"",
 261             "add1/add/add/Add.html#addadd\"",
 262             "add1/add/Add.html#addadd\"",
 263             "add1/Add.html#addadd\"",
 264             "add2/add/add/add/Add.html#addadd\"",
 265             "add2/add/add/Add.html#addadd\"",
 266             "add2/add/Add.html#addadd\"",
 267             "add2/Add.html#addadd\"",
 268             "add3/add/add/add/Add.html#addadd\"",
 269             "add3/add/add/Add.html#addadd\"",
 270             "add3/add/Add.html#addadd\"",
 271             "add3/Add.html#addadd\"",
 272             "Add.html#AddAdd\"",
 273             "add0/add/add/add/Add.html#AddAdd\"",
 274             "add0/add/add/Add.html#AddAdd\"",
 275             "add0/add/Add.html#AddAdd\"",
 276             "add0/Add.html#AddAdd\"",
 277             "add1/add/add/add/Add.html#AddAdd\"",
 278             "add1/add/add/Add.html#AddAdd\"",
 279             "add1/add/Add.html#AddAdd\"",
 280             "add1/Add.html#AddAdd\"",
 281             "add2/add/add/add/Add.html#AddAdd\"",
 282             "add2/add/add/Add.html#AddAdd\"",
 283             "add2/add/Add.html#AddAdd\"",
 284             "add2/Add.html#AddAdd\"",
 285             "add3/add/add/add/Add.html#AddAdd\"",
 286             "add3/add/add/Add.html#AddAdd\"",
 287             "add3/add/Add.html#AddAdd\"",
 288             "add3/Add.html#AddAdd\"",
 289             "Add.html#ADDADD\"",
 290             "add0/add/add/add/Add.html#ADDADD\"",
 291             "add0/add/add/Add.html#ADDADD\"",
 292             "add0/add/Add.html#ADDADD\"",
 293             "add0/Add.html#ADDADD\"",
 294             "add1/add/add/add/Add.html#ADDADD\"",
 295             "add1/add/add/Add.html#ADDADD\"",
 296             "add1/add/Add.html#ADDADD\"",
 297             "add1/Add.html#ADDADD\"",
 298             "add2/add/add/add/Add.html#ADDADD\"",
 299             "add2/add/add/Add.html#ADDADD\"",
 300             "add2/add/Add.html#ADDADD\"",
 301             "add2/Add.html#ADDADD\"",
 302             "add3/add/add/add/Add.html#ADDADD\"",
 303             "add3/add/add/Add.html#ADDADD\"",
 304             "add3/add/Add.html#ADDADD\"",
 305             "add3/Add.html#ADDADD\""
 306         };
 307 
 308         String expectedMethodOrdering[] = {
 309             "Add.html#add()",
 310             "Add.html#add(double)",
 311             "Add.html#add(double,byte)",
 312             "Add.html#add(double,double)",
 313             "Add.html#add(double,java.lang.Double)",
 314             "Add.html#add(float)",
 315             "Add.html#add(float,int)",
 316             "Add.html#add(int)",
 317             "Add.html#add(int,float)",
 318             "Add.html#add(java.lang.Double)",
 319             "Add.html#add(java.lang.Integer)"
 320         };
 321 
 322         String expectedPackageOrdering[] = {
 323             "\"add0/package-summary.html\">add0</a> - package add0",
 324             "\"add0/add/package-summary.html\">add0.add</a> - package add0.add",
 325             "\"add0/add/add/package-summary.html\">add0.add.add</a> - package add0.add.add",
 326             "\"add0/add/add/add/package-summary.html\">add0.add.add.add</a> - package add0.add.add.add",
 327             "\"add1/package-summary.html\">add1</a> - package add1",
 328             "\"add1/add/package-summary.html\">add1.add</a> - package add1.add",
 329             "\"add1/add/add/package-summary.html\">add1.add.add</a> - package add1.add.add",
 330             "\"add1/add/add/add/package-summary.html\">add1.add.add.add</a> - package add1.add.add.add",
 331             "\"add2/package-summary.html\">add2</a> - package add2",
 332             "\"add2/add/package-summary.html\">add2.add</a> - package add2.add",
 333             "\"add2/add/add/package-summary.html\">add2.add.add</a> - package add2.add.add",
 334             "\"add2/add/add/add/package-summary.html\">add2.add.add.add</a> - package add2.add.add.add",
 335             "\"add3/package-summary.html\">add3</a> - package add3",
 336             "\"add3/add/package-summary.html\">add3.add</a> - package add3.add",
 337             "\"add3/add/add/package-summary.html\">add3.add.add</a> - package add3.add.add",
 338             "\"add3/add/add/add/package-summary.html\">add3.add.add.add</a> - package add3.add.add.add"
 339         };
 340 
 341         void run() throws IOException {
 342             final String clsname = "Add";
 343             List<String> cmdArgs = new ArrayList();
 344             cmdArgs.add("-d");
 345             cmdArgs.add("out-2");
 346             cmdArgs.add("-sourcepath");
 347             cmdArgs.add("src");
 348             cmdArgs.add("-package");
 349             System.out.println("STRESS_MODE: " + STRESS_MODE);
 350             emitFile(null, clsname, STRESS_MODE);
 351             for (int width = 0; width < MAX_PACKAGES; width++) {
 352                 String wpkgname = "add" + width;
 353                 String dpkgname = wpkgname;
 354                 emitFile(wpkgname, clsname, ListOrder.NONE); // list as-is
 355                 cmdArgs.add(wpkgname);
 356                 for (int depth = 1; depth < MAX_SUBPACKAGES_DEPTH; depth++) {
 357                     dpkgname = dpkgname + ".add";
 358                     emitFile(dpkgname, clsname, STRESS_MODE);
 359                     cmdArgs.add(dpkgname);
 360                 }
 361             }
 362             File srcDir = new File(new File("."), "src");
 363             cmdArgs.add(new File(srcDir, clsname + ".java").getPath());
 364             javadoc(cmdArgs.toArray(new String[cmdArgs.size()]));
 365             checkExit(Exit.OK);
 366             checkOrder("index-all.html", composeTestVectors());
 367             checkOrder("add0/add/package-tree.html",
 368                     "<a href=\"Add.add.html\" title=\"enum in add0.add\">",
 369                     "<a href=\"Add.ADD.html\" title=\"enum in add0.add\">");
 370             checkOrder("overview-tree.html",
 371                     "<a href=\"Add.add.html\" title=\"enum in &lt;Unnamed&gt;\">",
 372                     "<a href=\"add0/Add.add.html\" title=\"enum in add0\">",
 373                     "<a href=\"add0/add/Add.add.html\" title=\"enum in add0.add\">",
 374                     "<a href=\"add0/add/add/Add.add.html\" title=\"enum in add0.add.add\">",
 375                     "<a href=\"add0/add/add/add/Add.add.html\" title=\"enum in add0.add.add.add\">",
 376                     "<a href=\"add1/Add.add.html\" title=\"enum in add1\">",
 377                     "<a href=\"add1/add/Add.add.html\" title=\"enum in add1.add\">",
 378                     "<a href=\"add1/add/add/Add.add.html\" title=\"enum in add1.add.add\">",
 379                     "<a href=\"add1/add/add/add/Add.add.html\" title=\"enum in add1.add.add.add\">",
 380                     "<a href=\"add2/Add.add.html\" title=\"enum in add2\">",
 381                     "<a href=\"add2/add/Add.add.html\" title=\"enum in add2.add\">",
 382                     "<a href=\"add2/add/add/Add.add.html\" title=\"enum in add2.add.add\">",
 383                     "<a href=\"add2/add/add/add/Add.add.html\" title=\"enum in add2.add.add.add\">",
 384                     "<a href=\"add3/Add.add.html\" title=\"enum in add3\">",
 385                     "<a href=\"add3/add/Add.add.html\" title=\"enum in add3.add\">",
 386                     "<a href=\"add3/add/add/Add.add.html\" title=\"enum in add3.add.add\">",
 387                     "<a href=\"add3/add/add/add/Add.add.html\" title=\"enum in add3.add.add.add\">",
 388                     "<a href=\"Add.ADD.html\" title=\"enum in &lt;Unnamed&gt;\">",
 389                     "<a href=\"add0/Add.ADD.html\" title=\"enum in add0\">",
 390                     "<a href=\"add0/add/Add.ADD.html\" title=\"enum in add0.add\">",
 391                     "<a href=\"add0/add/add/Add.ADD.html\" title=\"enum in add0.add.add\">",
 392                     "<a href=\"add0/add/add/add/Add.ADD.html\" title=\"enum in add0.add.add.add\">",
 393                     "<a href=\"add1/Add.ADD.html\" title=\"enum in add1\">",
 394                     "<a href=\"add1/add/Add.ADD.html\" title=\"enum in add1.add\">",
 395                     "<a href=\"add1/add/add/Add.ADD.html\" title=\"enum in add1.add.add\">",
 396                     "<a href=\"add1/add/add/add/Add.ADD.html\" title=\"enum in add1.add.add.add\">",
 397                     "<a href=\"add2/Add.ADD.html\" title=\"enum in add2\">",
 398                     "<a href=\"add2/add/Add.ADD.html\" title=\"enum in add2.add\">",
 399                     "<a href=\"add2/add/add/Add.ADD.html\" title=\"enum in add2.add.add\">",
 400                     "<a href=\"add2/add/add/add/Add.ADD.html\" title=\"enum in add2.add.add.add\">",
 401                     "<a href=\"add3/Add.ADD.html\" title=\"enum in add3\">",
 402                     "<a href=\"add3/add/Add.ADD.html\" title=\"enum in add3.add\">",
 403                     "<a href=\"add3/add/add/Add.ADD.html\" title=\"enum in add3.add.add\">",
 404                     "<a href=\"add3/add/add/add/Add.ADD.html\" title=\"enum in add3.add.add.add\">");
 405         }
 406 
 407         void emitFile(String pkgname, String clsname, ListOrder order) throws IOException {
 408             File srcDir = new File("src");
 409             File outDir = pkgname == null
 410                     ? srcDir
 411                     : new File(srcDir, pkgname.replace(".", File.separator));
 412             File outFile = new File(outDir, clsname + ".java");
 413             outDir.mkdirs();
 414             List<String> scratch = new ArrayList<>(Arrays.asList(contents));
 415             switch (order) {
 416                 case SHUFFLE:
 417                     Collections.shuffle(scratch);
 418                     break;
 419                 case REVERSE:
 420                     Collections.reverse(scratch);
 421                     break;
 422                 default:
 423                 // leave list as-is
 424             }
 425             // insert the header
 426             scratch.add(0, "public class " + clsname + " {");
 427             if (pkgname != null) {
 428                 scratch.add(0, "package " + pkgname + ";");
 429             }
 430             // append the footer
 431             scratch.add("}");
 432             Files.write(outFile.toPath(), scratch, CREATE, TRUNCATE_EXISTING);
 433         }
 434 
 435         String[] composeTestVectors() {
 436             List<String> testList = new ArrayList<>();
 437 
 438             for (String x : expectedEnumOrdering) {
 439                 testList.add(x.replace("REPLACE_ME", "&lt;Unnamed&gt;"));
 440             }
 441             for (int i = 0; i < MAX_PACKAGES; i++) {
 442                 String wpkg = "add" + i;
 443                 for (String x : expectedEnumOrdering) {
 444                     testList.add(wpkg + "/" + x.replace("REPLACE_ME", wpkg));
 445                 }
 446                 String dpkg = wpkg;
 447                 for (int j = 1; j < MAX_SUBPACKAGES_DEPTH; j++) {
 448                     dpkg = dpkg + "/" + "add";
 449                     for (String x : expectedEnumOrdering) {
 450                         testList.add(dpkg + "/" + x.replace("REPLACE_ME", pathToPackage(dpkg)));
 451                     }
 452                 }
 453             }
 454 
 455             for (String x : expectedMethodOrdering) {
 456                 testList.add(x);
 457                 for (int i = 0; i < MAX_PACKAGES; i++) {
 458                     String wpkg = "add" + i;
 459                     testList.add(wpkg + "/" + x);
 460                     String dpkg = wpkg;
 461                     for (int j = 1; j < MAX_SUBPACKAGES_DEPTH; j++) {
 462                         dpkg = dpkg + "/" + "add";
 463                         testList.add(dpkg + "/" + x);
 464                     }
 465                 }
 466             }
 467             testList.addAll(Arrays.asList(expectedPackageOrdering));
 468             testList.addAll(Arrays.asList(expectedFieldOrdering));
 469 
 470             return testList.toArray(new String[testList.size()]);
 471         }
 472 
 473         String pathToPackage(String in) {
 474             return in.replace("/", ".");
 475         }
 476     }
 477 
 478     class IndexTypeClusteringTest {
 479 
 480         void run() {
 481             javadoc("-d", "out-3",
 482                     "-sourcepath", testSrc("src-2"),
 483                     "-use",
 484                     "a",
 485                     "b",
 486                     "e",
 487                     "something");
 488 
 489             checkExit(Exit.OK);
 490 
 491             checkOrder("index-all.html",
 492                     "something</a> - package something</dt>",
 493                     "something</span></a> - Class in",
 494                     "something</span></a> - Enum in",
 495                     "something</span></a> - Interface in",
 496                     "something</span></a> - Annotation Type in",
 497                     "something</a></span> - Variable in class",
 498                     "something()</a></span> - Constructor",
 499                     "something()</a></span> - Method in class a.<a href=\"a/A.html\"",
 500                     "something()</a></span> - Method in class a.<a href=\"a/something.html\"",
 501                     "something()</a></span> - Method in class something.<a href=\"something/J.html\"");
 502         }
 503     }
 504 
 505     class TypeElementMemberOrderingTest {
 506 
 507         void run() {
 508             javadoc("-d", "out-5",
 509                     "-javafx",
 510                     "--disable-javafx-strict-checks",
 511                     "-sourcepath", testSrc(new File(".").getPath()),
 512                     "pkg5"
 513             );
 514 
 515             checkExit(Exit.OK);
 516 
 517             checkOrder("pkg5/AnnoFieldTest.html",
 518                     "<h2>Field Details</h2>",
 519                     "<div class=\"memberSignature\"><span class=\"modifiers\">static final</span>&nbsp;"
 520                     + "<span class=\"returnType\">int</span>&nbsp;<span class=\"memberName\">one</span></div>",
 521                     "<div class=\"memberSignature\"><span class=\"modifiers\">static final</span>&nbsp;"
 522                     + "<span class=\"returnType\">int</span>&nbsp;<span class=\"memberName\">two</span></div>",
 523                     "<div class=\"memberSignature\"><span class=\"modifiers\">static final</span>&nbsp;"
 524                     + "<span class=\"returnType\">int</span>&nbsp;<span class=\"memberName\">three</span></div>",
 525                     "<div class=\"memberSignature\"><span class=\"modifiers\">static final</span>&nbsp;"
 526                     + "<span class=\"returnType\">int</span>&nbsp;<span class=\"memberName\">four</span></div>");
 527 
 528             checkOrder("pkg5/AnnoOptionalTest.html",
 529                     "<h2>Optional Element Summary</h2>",
 530                     "<a href=\"#four()\">four</a>",
 531                     "<a href=\"#one()\">one</a>",
 532                     "<a href=\"#three()\">three</a>",
 533                     "<a href=\"#two()\">two</a>",
 534                     "<h2>Element Details</h2>",
 535                     "<h3><a id=\"one()\">one</a></h3>",
 536                     "<h3><a id=\"two()\">two</a></h3>",
 537                     "<h3><a id=\"three()\">three</a></h3>",
 538                     "<h3><a id=\"four()\">four</a></h3>");
 539 
 540             checkOrder("pkg5/AnnoRequiredTest.html",
 541                     "<h2>Required Element Summary</h2>",
 542                     "<a href=\"#four()\">four</a>",
 543                     "<a href=\"#one()\">one</a>",
 544                     "<a href=\"#three()\">three</a>",
 545                     "<a href=\"#two()\">two</a>",
 546                     "<h2>Element Details</h2>",
 547                     "<h3><a id=\"one()\">one</a></h3>",
 548                     "<h3><a id=\"two()\">two</a></h3>",
 549                     "<h3><a id=\"three()\">three</a></h3>",
 550                     "<h3><a id=\"four()\">four</a></h3>");
 551 
 552             checkOrder("pkg5/CtorTest.html",
 553                     "<h2>Constructor Summary</h2>",
 554                     "<a href=\"#%3Cinit%3E(int)\"",
 555                     "<a href=\"#%3Cinit%3E(int,int)\"",
 556                     "<a href=\"#%3Cinit%3E(int,int,int)\"",
 557                     "<a href=\"#%3Cinit%3E(int,int,int,int)\"",
 558                     "<h2>Constructor Details</h2>",
 559                     "<a id=\"&lt;init&gt;(int,int,int,int)\">",
 560                     "<a id=\"&lt;init&gt;(int,int,int)\">",
 561                     "<a id=\"&lt;init&gt;(int,int)\">",
 562                     "<a id=\"&lt;init&gt;(int)\">");
 563 
 564             checkOrder("pkg5/EnumTest.html",
 565                     "<h2>Enum Constant Summary</h2>",
 566                     "<a href=\"#FOUR\">FOUR</a>",
 567                     "<a href=\"#ONE\">ONE</a>",
 568                     "<a href=\"#THREE\">THREE</a>",
 569                     "<a href=\"#TWO\">TWO</a>",
 570                     "<h2>Enum Constant Details</h2>",
 571                     "<h3><a id=\"ONE\">ONE</a></h3>",
 572                     "<h3><a id=\"TWO\">TWO</a></h3>",
 573                     "<h3><a id=\"THREE\">THREE</a></h3>",
 574                     "<h3><a id=\"FOUR\">FOUR</a></h3>");
 575 
 576             checkOrder("pkg5/FieldTest.html",
 577                     "<h2>Field Summary</h2>",
 578                     "<a href=\"#four\">four</a>",
 579                     "<a href=\"#one\">one</a>",
 580                     "<a href=\"#three\">three</a>",
 581                     "<a href=\"#two\">two</a>",
 582                     "<h2>Field Details</h2>",
 583                     "<h3><a id=\"one\">one</a></h3>",
 584                     "<h3><a id=\"two\">two</a></h3>",
 585                     "<h3><a id=\"three\">three</a></h3>",
 586                     "<h3><a id=\"four\">four</a></h3>");
 587 
 588             checkOrder("pkg5/IntfTest.html",
 589                     "<h2>Method Summary</h2>",
 590                     "<a href=\"#four()\">four</a>",
 591                     "<a href=\"#one()\">one</a>",
 592                     "<a href=\"#three()\">three</a>",
 593                     "<a href=\"#two()\">two</a>",
 594                     "<h2>Method Details</h2>",
 595                     "<h3><a id=\"one()\">one</a></h3>",
 596                     "<h3><a id=\"two()\">two</a></h3>",
 597                     "<h3><a id=\"three()\">three</a></h3>",
 598                     "<h3><a id=\"four()\">four</a></h3>");
 599 
 600             checkOrder("pkg5/MethodTest.html",
 601                     "<h2>Method Summary</h2>",
 602                     "<a href=\"#four()\">four</a>",
 603                     "<a href=\"#one()\">one</a>",
 604                     "<a href=\"#three()\">three</a>",
 605                     "<a href=\"#two()\">two</a>",
 606                     "<h2>Method Details</h2>",
 607                     "<h3><a id=\"one()\">one</a></h3>",
 608                     "<h3><a id=\"two()\">two</a></h3>",
 609                     "<h3><a id=\"three()\">three</a></h3>",
 610                     "<h3><a id=\"four()\">four</a></h3>");
 611 
 612             checkOrder("pkg5/PropertyTest.html",
 613                     "<h2>Property Summary</h2>",
 614                     "<a href=\"#fourProperty\">four</a>",
 615                     "<a href=\"#oneProperty\">one</a>",
 616                     "<a href=\"#threeProperty\">three</a>",
 617                     "<a href=\"#twoProperty\">two</a>",
 618                     "<h2>Property Details</h2>",
 619                     "<h3><a id=\"oneProperty()\">oneProperty</a></h3>",
 620                     "<h3><a id=\"twoProperty()\">twoProperty</a></h3>",
 621                     "<h3><a id=\"threeProperty()\">threeProperty</a></h3>",
 622                     "<h3><a id=\"fourProperty()\">fourProperty</a></h3>");
 623 
 624         }
 625     }
 626 }