--- a/langtools/test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java Fri May 09 23:31:05 2014 +0200
+++ b/langtools/test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java Fri May 09 15:37:12 2014 -0700
@@ -37,237 +37,185 @@
* Make sure when no modifier appear in the class signature, the
* signature is displayed correctly without extra space at the beginning.
* @author jamieh
- * @library ../lib/
- * @build JavadocTester TestPrivateClasses
+ * @library ../lib
+ * @build JavadocTester
* @run main TestPrivateClasses
*/
public class TestPrivateClasses extends JavadocTester {
- //Javadoc arguments.
- private static final String[] ARGS1 = new String[] {
- "-d", OUTPUT_DIR + "-1", "-sourcepath", SRC_DIR, "pkg", "pkg2"
- };
- private static final String[] ARGS2 = new String[] {
- "-d", OUTPUT_DIR + "-2", "-sourcepath", SRC_DIR, "-private",
- "pkg", "pkg2"
- };
+ public static void main(String... args) throws Exception {
+ TestPrivateClasses tester = new TestPrivateClasses();
+ tester.runTests();
+ }
- // Test output when -private flag is not used.
- private static final String[][] TEST1 = {
- // Field inheritence from non-public superclass.
- { "pkg/PublicChild.html",
- "<a href=\"../pkg/PublicChild.html#fieldInheritedFromParent\">" +
- "fieldInheritedFromParent</a>"
- },
-
- // Method inheritence from non-public superclass.
- { "pkg/PublicChild.html",
- "<a href=\"../pkg/PublicChild.html#methodInheritedFromParent-int-\">" +
- "methodInheritedFromParent</a>"
- },
+ @Test
+ void testDefault() {
+ javadoc("-d", "out-default",
+ "-sourcepath", testSrc,
+ "pkg", "pkg2");
+ checkExit(Exit.OK);
- // Field inheritence from non-public superinterface.
- { "pkg/PublicInterface.html",
- "<a href=\"../pkg/PublicInterface.html#fieldInheritedFromInterface\">" +
- "fieldInheritedFromInterface</a>"
- },
-
- // Method inheritence from non-public superinterface.
- { "pkg/PublicInterface.html",
- "<a href=\"../pkg/PublicInterface.html#methodInterface-int-\">" +
- "methodInterface</a>"
- },
-
- // private class does not show up in tree
- { "pkg/PublicChild.html",
- "<ul class=\"inheritance\">\n" +
- "<li>java.lang.Object</li>\n" +
- "<li>\n" +
- "<ul class=\"inheritance\">\n" +
- "<li>pkg.PublicChild</li>\n" +
- "</ul>\n" +
- "</li>\n" +
- "</ul>"
- },
-
- // Method is documented as though it is declared in the inheriting method.
- { "pkg/PublicChild.html",
- "<pre>public void methodInheritedFromParent(int p1)"
- },
+ checkOutput("pkg/PublicChild.html", true,
+ // Field inheritence from non-public superclass.
+ "<a href=\"../pkg/PublicChild.html#fieldInheritedFromParent\">"
+ + "fieldInheritedFromParent</a>",
+ // Method inheritance from non-public superclass.
+ "<a href=\"../pkg/PublicChild.html#methodInheritedFromParent-int-\">"
+ + "methodInheritedFromParent</a>",
+ // private class does not show up in tree
+ "<ul class=\"inheritance\">\n"
+ + "<li>java.lang.Object</li>\n"
+ + "<li>\n"
+ + "<ul class=\"inheritance\">\n"
+ + "<li>pkg.PublicChild</li>\n"
+ + "</ul>\n"
+ + "</li>\n"
+ + "</ul>",
+ // Method is documented as though it is declared in the inheriting method.
+ "<pre>public void methodInheritedFromParent(int p1)",
+ "<dl>\n"
+ + "<dt>All Implemented Interfaces:</dt>\n"
+ + "<dd><a href=\"../pkg/PublicInterface.html\" title=\"interface in pkg\">"
+ + "PublicInterface</a></dd>\n"
+ + "</dl>");
- //Make sure implemented interfaces from private superclass are inherited
- { "pkg/PublicInterface.html",
- "<dl>\n" +
- "<dt>All Known Implementing Classes:</dt>\n" +
- "<dd><a href=\"../pkg/PublicChild.html\" title=\"class in pkg\">" +
- "PublicChild</a></dd>\n" +
- "</dl>"},
-
- { "pkg/PublicChild.html",
- "<dl>\n" +
- "<dt>All Implemented Interfaces:</dt>\n" +
- "<dd><a href=\"../pkg/PublicInterface.html\" title=\"interface in pkg\">" +
- "PublicInterface</a></dd>\n" +
- "</dl>"},
+ checkOutput("pkg/PublicChild.html", false,
+ // Should not document that a method overrides method from private class.
+ "<span class=\"overrideSpecifyLabel\">Overrides:</span>",
+ // Should not document that a method specified by private interface.
+ "<span class=\"overrideSpecifyLabel\">Specified by:</span>",
+ // Should not mention that any documentation was copied.
+ "Description copied from",
+ // Don't extend private classes or interfaces
+ "PrivateParent",
+ "PrivateInterface");
- //Generic interface method test.
- { "pkg2/C.html",
- "This comment should get copied to the implementing class"},
- };
- private static final String[][] NEGATED_TEST1 = {
- // Should not document that a method overrides method from private class.
- { "pkg/PublicChild.html",
- "<span class=\"overrideSpecifyLabel\">Overrides:</span>"},
- // Should not document that a method specified by private interface.
- { "pkg/PublicChild.html",
- "<span class=\"overrideSpecifyLabel\">Specified by:</span>"},
- { "pkg/PublicInterface.html",
- "<span class=\"overrideSpecifyLabel\">Specified by:</span>"},
- // Should not mention that any documentation was copied.
- { "pkg/PublicChild.html",
- "Description copied from"},
- { "pkg/PublicInterface.html",
- "Description copied from"},
- // Don't extend private classes or interfaces
- { "pkg/PublicChild.html",
- "PrivateParent"},
- { "pkg/PublicInterface.html",
- "PrivateInterface"},
- { "pkg/PublicChild.html",
- "PrivateInterface"},
- { "pkg/PublicInterface.html",
- "All Superinterfaces"},
- // Make inherited constant are documented correctly.
- { "constant-values.html",
- "PrivateInterface"},
+ checkOutput("pkg/PublicInterface.html", true,
+ // Field inheritance from non-public superinterface.
+ "<a href=\"../pkg/PublicInterface.html#fieldInheritedFromInterface\">"
+ + "fieldInheritedFromInterface</a>",
+ // Method inheritance from non-public superinterface.
+ "<a href=\"../pkg/PublicInterface.html#methodInterface-int-\">"
+ + "methodInterface</a>",
+ //Make sure implemented interfaces from private superclass are inherited
+ "<dl>\n"
+ + "<dt>All Known Implementing Classes:</dt>\n"
+ + "<dd><a href=\"../pkg/PublicChild.html\" title=\"class in pkg\">"
+ + "PublicChild</a></dd>\n"
+ + "</dl>");
- //Do not inherit private interface method with generic parameters.
- //This method has been implemented.
- { "pkg2/C.html",
- "<span class=\"memberNameLink\"><a href=\"../pkg2/I.html#hello-T-\">hello</a></span>"},
- };
+ checkOutput("pkg/PublicInterface.html", false,
+ "<span class=\"overrideSpecifyLabel\">Specified by:</span>",
+ "Description copied from",
+ "PrivateInterface",
+ "All Superinterfaces");
+
+ checkOutput("pkg2/C.html", true,
+ //Generic interface method test.
+ "This comment should get copied to the implementing class");
+
+ checkOutput("pkg2/C.html", false,
+ //Do not inherit private interface method with generic parameters.
+ //This method has been implemented.
+ "<span class=\"memberNameLink\"><a href=\"../pkg2/I.html#hello-T-\">hello</a></span>");
+
+ checkOutput("constant-values.html", false,
+ // Make inherited constant are documented correctly.
+ "PrivateInterface");
+ }
- // Test output when -private flag is used.
- private static final String[][] TEST2 = {
- // Field inheritence from non-public superclass.
- { "pkg/PublicChild.html",
- "Fields inherited from class pkg." +
- "<a href=\"../pkg/PrivateParent.html\" title=\"class in pkg\">" +
- "PrivateParent</a>"
- },
- { "pkg/PublicChild.html",
- "<a href=\"../pkg/PrivateParent.html#fieldInheritedFromParent\">" +
- "fieldInheritedFromParent</a>"
- },
- // Field inheritence from non-public superinterface.
- { "pkg/PublicInterface.html",
- "Fields inherited from interface pkg." +
- "<a href=\"../pkg/PrivateInterface.html\" title=\"interface in pkg\">" +
- "PrivateInterface</a>"
- },
- { "pkg/PublicInterface.html",
- "<a href=\"../pkg/PrivateInterface.html#fieldInheritedFromInterface\">" +
- "fieldInheritedFromInterface</a>"
- },
- // Method inheritence from non-public superclass.
- { "pkg/PublicChild.html",
- "Methods inherited from class pkg." +
- "<a href=\"../pkg/PrivateParent.html\" title=\"class in pkg\">" +
- "PrivateParent</a>"
- },
- { "pkg/PublicChild.html",
- "<a href=\"../pkg/PrivateParent.html#methodInheritedFromParent-int-\">" +
- "methodInheritedFromParent</a>"
- },
- // Should document that a method overrides method from private class.
- { "pkg/PublicChild.html",
- "<dt><span class=\"overrideSpecifyLabel\">Overrides:</span></dt>\n" +
- "<dd><code><a href=\"../pkg/PrivateParent.html#methodOverridenFromParent-char:A-int-T-V-java.util.List-\">" +
- "methodOverridenFromParent</a></code> in class <code>" +
- "<a href=\"../pkg/PrivateParent.html\" title=\"class in pkg\">" +
- "PrivateParent</a></code></dd>"},
- // Should document that a method is specified by private interface.
- { "pkg/PublicChild.html",
- "<dt><span class=\"overrideSpecifyLabel\">Specified by:</span></dt>\n" +
- "<dd><code><a href=\"../pkg/PrivateInterface.html#methodInterface-int-\">" +
- "methodInterface</a></code> in interface <code>" +
- "<a href=\"../pkg/PrivateInterface.html\" title=\"interface in pkg\">" +
- "PrivateInterface</a></code></dd>"},
- // Method inheritence from non-public superinterface.
- { "pkg/PublicInterface.html",
- "Methods inherited from interface pkg." +
- "<a href=\"../pkg/PrivateInterface.html\" title=\"interface in pkg\">" +
- "PrivateInterface</a>"
- },
- { "pkg/PrivateInterface.html",
- "<a href=\"../pkg/PrivateInterface.html#methodInterface-int-\">" +
- "methodInterface</a>"
- },
- // Should mention that any documentation was copied.
- { "pkg/PublicChild.html",
- "Description copied from"},
- // Extend documented private classes or interfaces
- { "pkg/PublicChild.html",
- "extends"},
- { "pkg/PublicInterface.html",
- "extends"},
- { "pkg/PublicInterface.html",
- "All Superinterfaces"},
+ @Test
+ void testPrivate() {
+ javadoc("-d", "out-private",
+ "-sourcepath", testSrc,
+ "-private",
+ "pkg", "pkg2");
+ checkExit(Exit.OK);
+
+ checkOutput("pkg/PublicChild.html", true,
+ // Field inheritence from non-public superclass.
+ "Fields inherited from class pkg."
+ + "<a href=\"../pkg/PrivateParent.html\" title=\"class in pkg\">"
+ + "PrivateParent</a>",
+ "<a href=\"../pkg/PrivateParent.html#fieldInheritedFromParent\">"
+ + "fieldInheritedFromParent</a>",
+ // Method inheritence from non-public superclass.
+ "Methods inherited from class pkg."
+ + "<a href=\"../pkg/PrivateParent.html\" title=\"class in pkg\">"
+ + "PrivateParent</a>",
+ "<a href=\"../pkg/PrivateParent.html#methodInheritedFromParent-int-\">"
+ + "methodInheritedFromParent</a>",
+ // Should document that a method overrides method from private class.
+ "<dt><span class=\"overrideSpecifyLabel\">Overrides:</span></dt>\n"
+ + "<dd><code><a href=\"../pkg/PrivateParent.html#methodOverridenFromParent-char:A-int-T-V-java.util.List-\">"
+ + "methodOverridenFromParent</a></code> in class <code>"
+ + "<a href=\"../pkg/PrivateParent.html\" title=\"class in pkg\">"
+ + "PrivateParent</a></code></dd>",
+ // Should document that a method is specified by private interface.
+ "<dt><span class=\"overrideSpecifyLabel\">Specified by:</span></dt>\n"
+ + "<dd><code><a href=\"../pkg/PrivateInterface.html#methodInterface-int-\">"
+ + "methodInterface</a></code> in interface <code>"
+ + "<a href=\"../pkg/PrivateInterface.html\" title=\"interface in pkg\">"
+ + "PrivateInterface</a></code></dd>",
+ // Should mention that any documentation was copied.
+ "Description copied from",
+ // Extend documented private classes or interfaces
+ "extends",
+ "<dl>\n"
+ + "<dt>All Implemented Interfaces:</dt>\n"
+ + "<dd><a href=\"../pkg/PrivateInterface.html\" title=\"interface in pkg\">"
+ + "PrivateInterface</a>, "
+ + "<a href=\"../pkg/PublicInterface.html\" title=\"interface in pkg\">"
+ + "PublicInterface</a></dd>\n"
+ + "</dl>",
+ "<pre>public class <span class=\"typeNameLabel\">PublicChild</span>");
- //Make sure implemented interfaces from private superclass are inherited
- { "pkg/PublicInterface.html",
- "<dl>\n" +
- "<dt>All Known Implementing Classes:</dt>\n" +
- "<dd><a href=\"../pkg/PrivateParent.html\" title=\"class in pkg\">" +
- "PrivateParent</a>, " +
- "<a href=\"../pkg/PublicChild.html\" title=\"class in pkg\">PublicChild" +
- "</a></dd>\n" +
- "</dl>"},
-
- { "pkg/PublicChild.html",
- "<dl>\n" +
- "<dt>All Implemented Interfaces:</dt>\n" +
- "<dd><a href=\"../pkg/PrivateInterface.html\" title=\"interface in pkg\">" +
- "PrivateInterface</a>, " +
- "<a href=\"../pkg/PublicInterface.html\" title=\"interface in pkg\">" +
- "PublicInterface</a></dd>\n" +
- "</dl>"},
-
- //Since private flag is used, we can document that private interface method
- //with generic parameters has been implemented.
- { "pkg2/C.html",
- "<span class=\"descfrmTypeLabel\">Description copied from interface: <code>" +
- "<a href=\"../pkg2/I.html#hello-T-\">I</a></code></span>"},
+ checkOutput("pkg/PublicInterface.html", true,
+ // Field inheritence from non-public superinterface.
+ "Fields inherited from interface pkg."
+ + "<a href=\"../pkg/PrivateInterface.html\" title=\"interface in pkg\">"
+ + "PrivateInterface</a>",
+ "<a href=\"../pkg/PrivateInterface.html#fieldInheritedFromInterface\">"
+ + "fieldInheritedFromInterface</a>",
+ // Method inheritance from non-public superinterface.
+ "Methods inherited from interface pkg."
+ + "<a href=\"../pkg/PrivateInterface.html\" title=\"interface in pkg\">"
+ + "PrivateInterface</a>",
+ // Extend documented private classes or interfaces
+ "extends",
+ "All Superinterfaces",
+ //Make sure implemented interfaces from private superclass are inherited
+ "<dl>\n"
+ + "<dt>All Known Implementing Classes:</dt>\n"
+ + "<dd><a href=\"../pkg/PrivateParent.html\" title=\"class in pkg\">"
+ + "PrivateParent</a>, "
+ + "<a href=\"../pkg/PublicChild.html\" title=\"class in pkg\">PublicChild"
+ + "</a></dd>\n"
+ + "</dl>");
- { "pkg2/C.html",
- "<dt><span class=\"overrideSpecifyLabel\">Specified by:</span></dt>\n" +
- "<dd><code><a href=\"../pkg2/I.html#hello-T-\">hello</a></code>" +
- " in interface <code>" +
- "<a href=\"../pkg2/I.html\" title=\"interface in pkg2\">I</a>" +
- "<java.lang.String></code></dd>"},
-
- //Make sure when no modifier appear in the class signature, the
- //signature is displayed correctly without extra space at the beginning.
- { "pkg/PrivateParent.html",
- "<pre>class <span class=\"typeNameLabel\">PrivateParent</span>"},
+ checkOutput("pkg/PrivateInterface.html", true,
+ "<a href=\"../pkg/PrivateInterface.html#methodInterface-int-\">"
+ + "methodInterface</a>"
+ );
- { "pkg/PublicChild.html",
- "<pre>public class <span class=\"typeNameLabel\">PublicChild</span>"},
- };
- private static final String[][] NEGATED_TEST2 = {
- { "pkg/PrivateParent.html",
- "<pre> class <span class=\"typeNameLabel\">PrivateParent</span>"},
- };
+ checkOutput("pkg2/C.html", true,
+ //Since private flag is used, we can document that private interface method
+ //with generic parameters has been implemented.
+ "<span class=\"descfrmTypeLabel\">Description copied from interface: <code>"
+ + "<a href=\"../pkg2/I.html#hello-T-\">I</a></code></span>",
+ "<dt><span class=\"overrideSpecifyLabel\">Specified by:</span></dt>\n"
+ + "<dd><code><a href=\"../pkg2/I.html#hello-T-\">hello</a></code>"
+ + " in interface <code>"
+ + "<a href=\"../pkg2/I.html\" title=\"interface in pkg2\">I</a>"
+ + "<java.lang.String></code></dd>");
- /**
- * The entry point of the test.
- * @param args the array of command line arguments.
- */
- public static void main(String[] args) {
- TestPrivateClasses tester = new TestPrivateClasses();
- tester.run(ARGS1, TEST1, NEGATED_TEST1);
- tester.run(ARGS2, TEST2, NEGATED_TEST2);
- tester.printSummary();
+ checkOutput("pkg/PrivateParent.html", true,
+ //Make sure when no modifier appear in the class signature, the
+ //signature is displayed correctly without extra space at the beginning.
+ "<pre>class <span class=\"typeNameLabel\">PrivateParent</span>");
+
+ checkOutput("pkg/PrivateParent.html", false,
+ "<pre> class <span class=\"typeNameLabel\">PrivateParent</span>");
}
}