diff -r 000000000000 -r 9a66ca7c79fa test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java Sat Dec 01 00:00:00 2007 +0000 @@ -0,0 +1,583 @@ +/* + * Copyright 2003-2006 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 4789689 4905985 4927164 4827184 4993906 5004549 + * @summary Run Javadoc on a set of source files that demonstrate new + * language features. Check the output to ensure that the new + * language features are properly documented. + * @author jamieh + * @library ../lib/ + * @build JavadocTester + * @build TestNewLanguageFeatures + * @run main TestNewLanguageFeatures + */ + +public class TestNewLanguageFeatures extends JavadocTester { + + //Test information. + private static final String BUG_ID = "4789689-4905985-4927164-4827184-4993906"; + + //Javadoc arguments. + private static final String[] ARGS = new String[] { + "-d", BUG_ID, "-use", "-source", "1.5", "-sourcepath", SRC_DIR, "pkg", "pkg1", "pkg2" + }; + + //Input for string search tests. + private static final String[][] TEST = + { + //================================= + // ENUM TESTING + //================================= + //Make sure enum header is correct. + {BUG_ID + FS + "pkg" + FS + "Coin.html", "Enum Coin"}, + //Make sure enum signature is correct. + {BUG_ID + FS + "pkg" + FS + "Coin.html", "public enum "+ + "Coin
E
- " +
+ "the type parameter for this class."},
+ //Type parameters in @see/@link
+ {BUG_ID + FS + "pkg" + FS + "TypeParameters.html",
+ "TypeParameters
"},
+ //Method that uses class type parameter.
+ {BUG_ID + FS + "pkg" + FS + "TypeParameters.html",
+ "(E param)"},
+ //Method type parameter section.
+ {BUG_ID + FS + "pkg" + FS + "TypeParameters.html",
+ "Type Parameters:T
- This is the first " +
+ "type parameter.V
- This is the second type " +
+ "parameter."},
+ //Signature of method with type parameters
+ {BUG_ID + FS + "pkg" + FS + "TypeParameters.html",
+ "public <T extends java.util.List,V> " +
+ "java.lang.String[] methodThatHasTypeParameters"},
+ //Wildcard testing.
+ {BUG_ID + FS + "pkg" + FS + "Wildcards.html",
+ "" +
+ "TypeParameters<? super java.lang.String> a"},
+ {BUG_ID + FS + "pkg" + FS + "Wildcards.html",
+ "" +
+ "TypeParameters<? extends java.lang.StringBuffer> b"},
+ {BUG_ID + FS + "pkg" + FS + "Wildcards.html",
+ "" +
+ "TypeParameters c"},
+ //Bad type parameter warnings.
+ {WARNING_OUTPUT, "warning - @param argument " +
+ "\"" + NL + + "public void methodWithParams(@AnnotationType(optional=\"Parameter Annotation\",required=1994)" + NL + + " int documented," + NL + + " int undocmented)"}, + + //CONSTRUCTOR PARAMS + {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html", + "
" + NL + + "public AnnotationTypeUsage(@AnnotationType(optional=\"Constructor Param Annotation\",required=1994)" + NL + + " int documented," + NL + + " int undocmented)"}, + + //================================= + // ANNOTATION TYPE USAGE TESTING (All Different Types). + //================================= + + //Integer + {BUG_ID + FS + "pkg1" + FS + "B.html", + "d=3.14,"}, + + //Double + {BUG_ID + FS + "pkg1" + FS + "B.html", + "d=3.14,"}, + + //Boolean + {BUG_ID + FS + "pkg1" + FS + "B.html", + "b=true,"}, + + //String + {BUG_ID + FS + "pkg1" + FS + "B.html", + "s=\"sigh\","}, + + //Class + {BUG_ID + FS + "pkg1" + FS + "B.html", + "c=Foo.class,"}, + + //Bounded Class + {BUG_ID + FS + "pkg1" + FS + "B.html", + "w=TypeParameterSubClass.class,"}, + + //Enum + {BUG_ID + FS + "pkg1" + FS + "B.html", + "e=Penny,"}, + + //Annotation Type + {BUG_ID + FS + "pkg1" + FS + "B.html", + "a=@AnnotationType(optional=\"foo\",required=1994),"}, + + //String Array + {BUG_ID + FS + "pkg1" + FS + "B.html", + "sa={\"up\",\"down\"},"}, + + //Primitive + {BUG_ID + FS + "pkg1" + FS + "B.html", + "primitiveClassTest=boolean.class,"}, + + //XXX: Add array test case after this if fixed: + //5020899: Incorrect internal representation of class-valued annotation elements + + //Make sure that annotations are surrounded by
and+ {BUG_ID + FS + "pkg1" + FS + "B.html", + "
@A"}, + {BUG_ID + FS + "pkg1" + FS + "B.html", + "public interface B" + NL + + ""}, + + + //============================================================== + // Handle multiple bounds. + //============================================================== + {BUG_ID + FS + "pkg" + FS + "MultiTypeParameters.html", + "public <T extends java.lang.Number & java.lang.Runnable> T foo(T t)"}, + + //============================================================== + // Test Class-Use Documenation for Type Parameters. + //============================================================== + + //ClassUseTest1:
ClassUseTest1<T extends Foo & Foo2>
"
+ },
+ {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo.html",
+ "ClassUseTest1.method(T t)
"
+ },
+ {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo.html",
+ "ClassUseTest1<T extends Foo & Foo2>
"
+ },
+ {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo2.html",
+ "ClassUseTest1.method(T t)
"
+ },
+
+ //ClassUseTest2: ClassUseTest2<T extends ParamTest<Foo3>>
"
+ },
+ {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html",
+ "ClassUseTest2.method(T t)
"
+ },
+ {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html",
+ "ClassUseTest2<T extends ParamTest<Foo3>>
"
+ },
+ {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo3.html",
+ "ClassUseTest2.method(T t)
"
+ },
+ {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo3.html",
+ "ClassUseTest3<T extends ParamTest2<java.util.List<? extends Foo4>>>
"
+ },
+ {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest2.html",
+ "ClassUseTest3.method(T t)
"
+ },
+ {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest2.html",
+ "ClassUseTest3<T extends ParamTest2<java.util.List<? extends Foo4>>>
"
+ },
+ {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html",
+ "ClassUseTest3.method(T t)
"
+ },
+ {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html",
+ " void
ClassUseTest3.method(java.util.Set<Foo4> p)
"
+ },
+ {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html",
+ "ClassUseTest3(java.util.Set<Foo4> p)
"
+ },
+
+ //=================================
+ // Annotatation Type Usage
+ //=================================
+ {BUG_ID + FS + "pkg" + FS + "class-use" + FS + "AnnotationType.html",
+ "" + NL +
+ "Packages with annotations of type AnnotationType" + NL +
+ " class
AnnotationTypeUsage
"
+ },
+
+ {BUG_ID + FS + "pkg" + FS + "class-use" + FS + "AnnotationType.html",
+ "Fields in pkg with annotations of type AnnotationType" + NL +
+ " int
AnnotationTypeUsage.field
"
+ },
+
+ {BUG_ID + FS + "pkg" + FS + "class-use" + FS + "AnnotationType.html",
+ "Methods in pkg with annotations of type AnnotationType" + NL +
+ " void
AnnotationTypeUsage.method()
"
+ },
+
+ {BUG_ID + FS + "pkg" + FS + "class-use" + FS + "AnnotationType.html",
+ "Method parameters in pkg with annotations of type AnnotationType" + NL +
+ " void
AnnotationTypeUsage.methodWithParams(int documented," + NL +
+ " int undocmented)
"
+ },
+
+ {BUG_ID + FS + "pkg" + FS + "class-use" + FS + "AnnotationType.html",
+ "Constructors in pkg with annotations of type AnnotationType" + NL +
+ "AnnotationTypeUsage()
"
+ },
+
+ {BUG_ID + FS + "pkg" + FS + "class-use" + FS + "AnnotationType.html",
+ "Constructor parameters in pkg with annotations of type AnnotationType" + NL +
+ "AnnotationTypeUsage(int documented," + NL +
+ " int undocmented)
"
+ },
+
+ //=================================
+ // TYPE PARAMETER IN INDEX
+ //=================================
+ {BUG_ID + FS + "index-all.html",
+ "method(Vector<Object>)"
+ },
+ //=================================
+ // TYPE PARAMETER IN INDEX
+ //=================================
+ {BUG_ID + FS + "index-all.html",
+ "method(Vector<Object>)"
+ },
+ };
+ private static final String[][] NEGATED_TEST = {
+ //=================================
+ // ENUM TESTING
+ //=================================
+ //NO constructor section
+ {BUG_ID + FS + "pkg" + FS + "Coin.html", "Constructor Summary"},
+ //=================================
+ // TYPE PARAMETER TESTING
+ //=================================
+ //No type parameters in class frame.
+ {BUG_ID + FS + "allclasses-frame.html",
+ "" +
+ "TypeParameters<E>"
+ },
+
+ //==============================================================
+ // ANNOTATION TYPE USAGE TESTING (When @Documented is omitted)
+ //===============================================================
+
+ //CLASS
+ {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html",
+ "" + NL +
+ "@AnnotationTypeUndocumented(optional=\"Class Annotation\"," + NL +
+ " required=1994)" + NL +
+ "public class AnnotationTypeUsage