TestSerializedForm.java revision 3233:b5d08bc0d224
1/* 2 * Copyright (c) 2001, 2015, 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 4341304 4485668 4966728 8032066 27 * @summary Test that methods readResolve and writeReplace show 28 * up in serialized-form.html the same way that readObject and writeObject do. 29 * If the doclet includes readResolve and writeReplace in the serialized-form 30 * documentation that same way the it includes readObject and writeObject, the 31 * test passes. This also tests that throws tag information is correctly shown 32 * in the serialized form page. 33 * Make sure see tags work in serialized form. 34 * @author jamieh 35 * @library ../lib/ 36 * @modules jdk.javadoc 37 * @build JavadocTester 38 * @build TestSerializedForm 39 * @run main TestSerializedForm 40 */ 41 42import java.io.*; 43 44public class TestSerializedForm extends JavadocTester implements Serializable { 45 public static void main(String... args) throws Exception { 46 TestSerializedForm tester = new TestSerializedForm(); 47 tester.runTests(); 48// tester.run(ARGS, TEST, NEGATED_TEST); 49// tester.run(ARGS_PRIVATE, TEST_PRIVATE, NEGATED_TEST_PRIVATE); 50// tester.printSummary(); 51 } 52 53 @Test 54 void testDefault() { 55 javadoc("-d", "out-default", 56 "-sourcepath", testSrc, 57 testSrc("TestSerializedForm.java"), "pkg1"); 58 checkExit(Exit.OK); 59 60 checkOutput("serialized-form.html", true, 61 "protected java.lang.Object readResolve()", 62 "protected java.lang.Object writeReplace()", 63 "protected java.lang.Object readObjectNoData()", 64 "See Also", 65 "<h3>Class pkg1.NestedInnerClass.InnerClass.ProNestedInnerClass " 66 + "extends java.lang.Object implements Serializable</h3>", 67 "<h3>Class pkg1.PrivateIncludeInnerClass.PriInnerClass extends " 68 + "java.lang.Object implements Serializable</h3>", 69 "<h3>Class pkg1.ProtectedInnerClass.ProInnerClass extends " 70 + "java.lang.Object implements Serializable</h3>"); 71 72 checkOutput("serialized-form.html", false, 73 "<h3>Class <a href=\"pkg1/NestedInnerClass.InnerClass.ProNestedInnerClass.html\" " 74 + "title=\"class in pkg1\">pkg1.NestedInnerClass.InnerClass.ProNestedInnerClass</a> " 75 + "extends java.lang.Object implements Serializable</h3>", 76 "<h3>Class <a href=\"pkg1/PrivateInnerClass.PriInnerClass.html\" title=\"class in pkg1\">" 77 + "pkg1.PrivateInnerClass.PriInnerClass</a> extends java.lang.Object implements Serializable</h3>", 78 "<h3>Class <a href=\"pkg1/ProtectedInnerClass.ProInnerClass.html\" title=\"class in pkg1\">" 79 + "pkg1.ProtectedInnerClass.ProInnerClass</a> extends java.lang.Object implements Serializable</h3>", 80 "<h3>Class pkg1.PublicExcludeInnerClass.PubInnerClass extends java.lang.Object implements " 81 + "Serializable</h3>"); 82 } 83 84 @Test 85 void testPrivate() { 86 javadoc("-private", 87 "-d", "out-private", 88 "-sourcepath", testSrc, 89 testSrc("TestSerializedForm.java"), "pkg1"); 90 checkExit(Exit.OK); 91 92 checkOutput("serialized-form.html", true, 93 "<h3>Class <a href=\"pkg1/NestedInnerClass.InnerClass.ProNestedInnerClass.html\" " 94 + "title=\"class in pkg1\">pkg1.NestedInnerClass.InnerClass.ProNestedInnerClass</a> " 95 + "extends java.lang.Object implements Serializable</h3>", 96 "<h3>Class <a href=\"pkg1/PrivateIncludeInnerClass.PriInnerClass.html\" title=\"class in pkg1\">" 97 + "pkg1.PrivateIncludeInnerClass.PriInnerClass</a> extends java.lang.Object implements Serializable</h3>", 98 "<h3>Class <a href=\"pkg1/ProtectedInnerClass.ProInnerClass.html\" title=\"class in pkg1\">" 99 + "pkg1.ProtectedInnerClass.ProInnerClass</a> extends java.lang.Object implements Serializable</h3>"); 100 101 checkOutput("serialized-form.html", false, 102 "<h3>Class pkg1.NestedInnerClass.InnerClass.ProNestedInnerClass " 103 + "extends java.lang.Object implements Serializable</h3>", 104 "<h3>Class pkg1.PrivateInnerClass.PriInnerClass extends " 105 + "java.lang.Object implements Serializable</h3>", 106 "<h3>Class pkg1.ProtectedInnerClass.ProInnerClass extends " 107 + "java.lang.Object implements Serializable</h3>", 108 "<h3>Class <a href=\"pkg1/PublicExcludeInnerClass.PubInnerClass.html\" " 109 + "title=\"class in pkg1\">pkg1.PublicExcludeInnerClass.PubInnerClass</a> " 110 + "extends java.lang.Object implements Serializable</h3>"); 111 } 112 113 /** 114 * @serial 115 * @see TestSerializedForm 116 */ 117 public final int SERIALIZABLE_CONSTANT = 1; 118 119 /** 120 * The entry point of the test. 121 * @param args the array of command line arguments. 122 */ 123 124 /** 125 * @param s ObjectInputStream. 126 * @throws IOException when there is an I/O error. 127 * @serial 128 */ 129 private void readObject(ObjectInputStream s) throws IOException {} 130 131 /** 132 * @param s ObjectOutputStream. 133 * @throws IOException when there is an I/O error. 134 * @serial 135 */ 136 private void writeObject(ObjectOutputStream s) throws IOException {} 137 138 /** 139 * @throws IOException when there is an I/O error. 140 * @serialData This is a serial data comment. 141 * @return an object. 142 */ 143 protected Object readResolve() throws IOException {return null;} 144 145 /** 146 * @throws IOException when there is an I/O error. 147 * @serialData This is a serial data comment. 148 * @return an object. 149 */ 150 protected Object writeReplace() throws IOException {return null;} 151 152 /** 153 * @throws IOException when there is an I/O error. 154 * @serialData This is a serial data comment. 155 * @return an object. 156 */ 157 protected Object readObjectNoData() throws IOException { 158 return null; 159 } 160 161} 162