TestPrivateClasses.java revision 0
0N/A/*
2362N/A * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
2362N/A * CA 95054 USA or visit www.sun.com if you need additional information or
2362N/A * have any questions.
0N/A */
0N/A
0N/A/*
0N/A * @test
0N/A * @bug 4780441 4874845 4978816
0N/A * @summary Make sure that when the -private flag is not used, members
0N/A * inherited from package private class are documented in the child.
0N/A *
0N/A * Make sure that when a method inherits documentation from a method
0N/A * in a non-public class/interface, the non-public class/interface
0N/A * is not mentioned anywhere (not even in the signature or tree).
0N/A *
0N/A * Make sure that when a private interface method with generic parameters
0N/A * is implemented, the comments can be inherited properly.
0N/A * @author jamieh
0N/A * @library ../lib/
0N/A * @build JavadocTester
0N/A * @build TestPrivateClasses
0N/A * @run main TestPrivateClasses
0N/A */
0N/A
0N/Apublic class TestPrivateClasses extends JavadocTester {
0N/A
0N/A //Test information.
0N/A private static final String BUG_ID = "4780441-4874845-4978816";
0N/A
0N/A //Javadoc arguments.
0N/A private static final String[] ARGS1 = new String[] {
0N/A "-d", BUG_ID + "-1", "-sourcepath", SRC_DIR, "-source", "1.5", "pkg", "pkg2"
0N/A };
0N/A private static final String[] ARGS2 = new String[] {
0N/A "-d", BUG_ID + "-2", "-sourcepath", SRC_DIR, "-private",
0N/A "-source", "1.5", "pkg", "pkg2"
0N/A };
0N/A
0N/A // Test output when -private flag is not used.
0N/A private static final String[][] TEST1 = {
0N/A // Field inheritence from non-public superclass.
0N/A {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
0N/A "<A HREF=\"../pkg/PublicChild.html#fieldInheritedFromParent\">" +
0N/A "fieldInheritedFromParent</A>"
0N/A },
0N/A
0N/A // Method inheritence from non-public superclass.
0N/A {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
0N/A "<A HREF=\"../pkg/PublicChild.html#methodInheritedFromParent(int)\">" +
0N/A "methodInheritedFromParent</A>"
0N/A },
0N/A
0N/A // Field inheritence from non-public superinterface.
0N/A {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html",
0N/A "<A HREF=\"../pkg/PublicInterface.html#fieldInheritedFromInterface\">" +
0N/A "fieldInheritedFromInterface</A>"
0N/A },
0N/A
0N/A // Method inheritence from non-public superinterface.
0N/A {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html",
0N/A "<A HREF=\"../pkg/PublicInterface.html#methodInterface(int)\">" +
0N/A "methodInterface</A>"
0N/A },
0N/A
0N/A // private class does not show up in tree
0N/A {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
"<PRE>" + NL +
"java.lang.Object" + NL +
" <IMG SRC=\"../resources/inherit.gif\" " +
"ALT=\"extended by \"><B>pkg.PublicChild</B>" + NL +
"</PRE>"
},
// Method is documented as though it is declared in the inheriting method.
{BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
"public void <B>methodInheritedFromParent</B>(int&nbsp;p1)"
},
//Make sure implemented interfaces from private superclass are inherited
{BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html",
"<B>All Known Implementing Classes:</B> <DD><A HREF=\"../pkg/PublicChild.html\" " +
"title=\"class in pkg\">PublicChild</A>"},
{BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
"<B>All Implemented Interfaces:</B> <DD><A HREF=\"../pkg/PublicInterface.html\" " +
"title=\"interface in pkg\">PublicInterface</A>"},
//Generic interface method test.
{BUG_ID + "-1" + FS + "pkg2" + FS + "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.
{BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
"<B>Overrides:</B>"},
// Should not document that a method specified by private interface.
{BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
"<B>Specified by:</B>"},
{BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html",
"<B>Specified by:</B>"},
// Should not mention that any documentation was copied.
{BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
"Description copied from"},
{BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html",
"Description copied from"},
// Don't extend private classes or interfaces
{BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
"PrivateParent"},
{BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html",
"PrivateInterface"},
{BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
"PrivateInterface"},
{BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html",
"All Superinterfaces"},
// Make inherited constant are documented correctly.
{BUG_ID + "-1" + FS + "constant-values.html",
"PrivateInterface"},
//Do not inherit private interface method with generic parameters.
//This method has been implemented.
{BUG_ID + "-1" + FS + "pkg2" + FS + "C.html",
"<B><A HREF=\"../pkg2/I.html#hello(T)\">hello</A></B>"},
};
// Test output when -private flag is used.
private static final String[][] TEST2 = {
// Field inheritence from non-public superclass.
{BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
"Fields inherited from class " +
"pkg.<A HREF=\"../pkg/PrivateParent.html\" " +
"title=\"class in pkg\">PrivateParent</A>"
},
{BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
"<A HREF=\"../pkg/PrivateParent.html#fieldInheritedFromParent\">" +
"fieldInheritedFromParent</A>"
},
// Field inheritence from non-public superinterface.
{BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html",
"Fields inherited from interface " +
"pkg.<A HREF=\"../pkg/PrivateInterface.html\" " +
"title=\"interface in pkg\">PrivateInterface</A>"
},
{BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html",
"<A HREF=\"../pkg/PrivateInterface.html#fieldInheritedFromInterface\">" +
"fieldInheritedFromInterface</A>"
},
// Method inheritence from non-public superclass.
{BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
"Methods inherited from class " +
"pkg.<A HREF=\"../pkg/PrivateParent.html\" " +
"title=\"class in pkg\">PrivateParent</A>"
},
{BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
"<A HREF=\"../pkg/PrivateParent.html#methodInheritedFromParent(int)\">" +
"methodInheritedFromParent</A>"
},
// Should document that a method overrides method from private class.
{BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
"<B>Overrides:</B><DD><CODE>" +
"<A HREF=\"../pkg/PrivateParent.html#methodOverridenFromParent(char[], int, T, V, java.util.List)\">" +
"methodOverridenFromParent</A></CODE> in class <CODE>" +
"<A HREF=\"../pkg/PrivateParent.html\" title=\"class in pkg\">" +
"PrivateParent</A></CODE></DL>"},
// Should document that a method is specified by private interface.
{BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
"<B>Specified by:</B><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></DL>" + NL + "</DD>"},
// Method inheritence from non-public superinterface.
{BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html",
"Methods inherited from interface " +
"pkg.<A HREF=\"../pkg/PrivateInterface.html\" " +
"title=\"interface in pkg\">PrivateInterface</A>"
},
{BUG_ID + "-2" + FS + "pkg" + FS + "PrivateInterface.html",
"<A HREF=\"../pkg/PrivateInterface.html#methodInterface(int)\">" +
"methodInterface</A>"
},
// Should mention that any documentation was copied.
{BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
"Description copied from"},
// Extend documented private classes or interfaces
{BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
"extends"},
{BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html",
"extends"},
{BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html",
"All Superinterfaces"},
//Make sure implemented interfaces from private superclass are inherited
{BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html",
"<B>All Known Implementing Classes:</B> <DD><A HREF=\"../pkg/PrivateParent.html\" " +
"title=\"class in pkg\">PrivateParent</A>, " +
"<A HREF=\"../pkg/PublicChild.html\" title=\"class in pkg\">PublicChild</A>"},
{BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
"<B>All Implemented Interfaces:</B> <DD><A HREF=\"../pkg/PrivateInterface.html\" " +
"title=\"interface in pkg\">PrivateInterface</A>, " +
"<A HREF=\"../pkg/PublicInterface.html\" title=\"interface in pkg\">" +
"PublicInterface</A>"},
//Since private flag is used, we can document that private interface method
//with generic parameters has been implemented.
{BUG_ID + "-2" + FS + "pkg2" + FS + "C.html",
"<B>Description copied from interface: " +
"<CODE><A HREF=\"../pkg2/I.html#hello(T)\">I</A></CODE></B>"},
{BUG_ID + "-2" + FS + "pkg2" + FS + "C.html",
"<B>Specified by:</B><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>"},
};
private static final String[][] NEGATED_TEST2 = NO_TEST;
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestPrivateClasses tester = new TestPrivateClasses();
run(tester, ARGS1, TEST1, NEGATED_TEST1);
run(tester, ARGS2, TEST2, NEGATED_TEST2);
tester.printSummary();
}
/**
* {@inheritDoc}
*/
public String getBugId() {
return BUG_ID;
}
/**
* {@inheritDoc}
*/
public String getBugName() {
return getClass().getName();
}
}