2014-04-18 08:35:59 -07:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @test
|
2014-05-08 08:23:44 -07:00
|
|
|
* @bug 8039410 8042601
|
2014-04-18 08:35:59 -07:00
|
|
|
* @summary test to determine if members are ordered correctly
|
|
|
|
* @author ksrini
|
|
|
|
* @library ../lib/
|
|
|
|
* @build JavadocTester
|
|
|
|
* @run main TestOrdering
|
|
|
|
*/
|
|
|
|
|
|
|
|
public class TestOrdering extends JavadocTester {
|
2014-05-09 15:37:12 -07:00
|
|
|
|
2014-04-18 08:35:59 -07:00
|
|
|
public static void main(String[] args) throws Exception {
|
|
|
|
TestOrdering tester = new TestOrdering();
|
2014-05-09 15:37:12 -07:00
|
|
|
tester.runTests();
|
|
|
|
}
|
2014-04-18 08:35:59 -07:00
|
|
|
|
2014-05-09 15:37:12 -07:00
|
|
|
@Test
|
|
|
|
void testUnnamedPackages() {
|
|
|
|
javadoc("-d", "out",
|
|
|
|
"-sourcepath", testSrc,
|
|
|
|
"-use",
|
|
|
|
testSrc("C.java"), testSrc("UsedInC.java"));
|
|
|
|
checkExit(Exit.OK);
|
|
|
|
checkExecutableMemberOrdering("class-use/UsedInC.html");
|
2014-04-18 08:35:59 -07:00
|
|
|
}
|
|
|
|
|
2014-05-09 15:37:12 -07:00
|
|
|
@Test
|
|
|
|
void testNamedPackages() {
|
|
|
|
javadoc("-d", "out-1",
|
|
|
|
"-sourcepath", testSrc,
|
|
|
|
"-use",
|
|
|
|
"pkg1");
|
|
|
|
checkExit(Exit.OK);
|
|
|
|
checkClassUseOrdering("pkg1/class-use/UsedClass.html");
|
|
|
|
checkIndexPathOrdering("index-all.html");
|
|
|
|
}
|
|
|
|
|
|
|
|
void checkExecutableMemberOrdering(String usePage) {
|
|
|
|
String contents = readFile(usePage);
|
2014-04-18 08:35:59 -07:00
|
|
|
// check constructors
|
2014-05-09 15:37:12 -07:00
|
|
|
checking("constructors");
|
|
|
|
int idx1 = contents.indexOf("C.html#C-UsedInC");
|
|
|
|
int idx2 = contents.indexOf("C.html#C-UsedInC-int");
|
|
|
|
int idx3 = contents.indexOf("C.html#C-UsedInC-java.lang.String");
|
2014-04-18 08:35:59 -07:00
|
|
|
if (idx1 == -1 || idx2 == -1 || idx3 == -1) {
|
2014-05-09 15:37:12 -07:00
|
|
|
failed("ctor strings not found");
|
|
|
|
} else if (idx1 > idx2 || idx2 > idx3 || idx1 > idx3) {
|
|
|
|
failed("ctor strings are out of order");
|
|
|
|
} else
|
|
|
|
passed("ctor strings are in order");
|
2014-04-18 08:35:59 -07:00
|
|
|
|
|
|
|
// check methods
|
2014-05-09 15:37:12 -07:00
|
|
|
checking("methods");
|
|
|
|
idx1 = contents.indexOf("C.html#ymethod-int");
|
|
|
|
idx2 = contents.indexOf("C.html#ymethod-java.lang.String");
|
2014-04-18 08:35:59 -07:00
|
|
|
if (idx1 == -1 || idx2 == -1) {
|
2014-05-09 15:37:12 -07:00
|
|
|
failed("#ymethod strings not found");
|
|
|
|
} else if (idx1 > idx2) {
|
|
|
|
failed("#ymethod strings are out of order");
|
|
|
|
} else
|
|
|
|
passed("Executable Member Ordering: OK");
|
2014-04-18 08:35:59 -07:00
|
|
|
}
|
|
|
|
|
2014-05-09 15:37:12 -07:00
|
|
|
void checkClassUseOrdering(String usePage) {
|
2014-04-18 08:35:59 -07:00
|
|
|
checkClassUseOrdering(usePage, "pkg1/C#ITERATION#.html#zfield");
|
|
|
|
checkClassUseOrdering(usePage, "pkg1/C#ITERATION#.html#fieldInC#ITERATION#");
|
|
|
|
checkClassUseOrdering(usePage, "pkg1/C#ITERATION#.html#zmethod-pkg1.UsedClass");
|
|
|
|
checkClassUseOrdering(usePage, "pkg1/C#ITERATION#.html#methodInC#ITERATION#");
|
|
|
|
}
|
|
|
|
|
2014-05-09 15:37:12 -07:00
|
|
|
void checkClassUseOrdering(String usePage, String searchString) {
|
|
|
|
String contents = readFile(usePage);
|
2014-04-18 08:35:59 -07:00
|
|
|
int lastidx = 0;
|
|
|
|
System.out.println("testing for " + searchString);
|
|
|
|
for (int i = 1; i < 5; i++) {
|
|
|
|
String s = searchString.replaceAll("#ITERATION#", Integer.toString(i));
|
2014-05-09 15:37:12 -07:00
|
|
|
checking(s);
|
|
|
|
int idx = contents.indexOf(s);
|
2014-04-18 08:35:59 -07:00
|
|
|
if (idx < lastidx) {
|
2014-05-09 15:37:12 -07:00
|
|
|
failed(s + ", member ordering error, last:" + lastidx + ", got:" + idx);
|
|
|
|
} else {
|
|
|
|
passed("\tlast: " + lastidx + " got:" + idx);
|
2014-04-18 08:35:59 -07:00
|
|
|
}
|
|
|
|
lastidx = idx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-09 15:37:12 -07:00
|
|
|
void checkIndexPathOrdering(String indexPage) {
|
|
|
|
checkOrder(indexPage,
|
2014-05-08 08:23:44 -07:00
|
|
|
"pkg1/UsedClass.html#add--",
|
|
|
|
"pkg1/ZZTop.html#add--",
|
|
|
|
"pkg1/UsedClass.html#add-double-",
|
|
|
|
"pkg1/UsedClass.html#add-java.lang.Double-",
|
|
|
|
"pkg1/ZZTop.html#add-double-",
|
|
|
|
"pkg1/ZZTop.html#add-java.lang.Double-",
|
|
|
|
"pkg1/UsedClass.html#add-double-byte-",
|
|
|
|
"pkg1/ZZTop.html#add-double-byte-",
|
|
|
|
"pkg1/UsedClass.html#add-double-double-",
|
|
|
|
"pkg1/UsedClass.html#add-double-java.lang.Double-",
|
|
|
|
"pkg1/ZZTop.html#add-double-double-",
|
|
|
|
"pkg1/ZZTop.html#add-double-java.lang.Double-",
|
|
|
|
"pkg1/UsedClass.html#add-float-",
|
|
|
|
"pkg1/ZZTop.html#add-float-",
|
|
|
|
"pkg1/UsedClass.html#add-float-int-",
|
|
|
|
"pkg1/ZZTop.html#add-float-int-",
|
|
|
|
"pkg1/UsedClass.html#add-int-",
|
|
|
|
"pkg1/ZZTop.html#add-int-",
|
|
|
|
"pkg1/UsedClass.html#add-int-float-",
|
|
|
|
"pkg1/ZZTop.html#add-int-float-",
|
|
|
|
"pkg1/UsedClass.html#add-java.lang.Integer-",
|
2014-05-09 15:37:12 -07:00
|
|
|
"pkg1/ZZTop.html#add-java.lang.Integer-");
|
2014-04-18 08:35:59 -07:00
|
|
|
}
|
|
|
|
}
|