langtools/test/com/sun/javadoc/testSerializedForm/TestSerializedForm.java
author akulyakh
Thu, 21 May 2015 11:41:04 -0700
changeset 30730 d3ce7619db2c
parent 24399 af1a0220d0fa
permissions -rw-r--r--
8076543: Add @modules as needed to the langtools tests Reviewed-by: jjg, shurailine
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
30730
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 24399
diff changeset
     2
 * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
06bc494ca11e Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1787
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1787
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1787
diff changeset
    21
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
/*
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
 * @test
23805
3ef77c1ebf0b 8032066: Serialized form has broken links to non private inner classes of package private
bpatel
parents: 7681
diff changeset
    26
 * @bug 4341304 4485668 4966728 8032066
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
 * @summary Test that methods readResolve and writeReplace show
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
 * up in serialized-form.html the same way that readObject and writeObject do.
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
 * If the doclet includes readResolve and writeReplace in the serialized-form
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
 * documentation that same way the it includes readObject and writeObject, the
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
 * test passes.  This also tests that throws tag information is correctly shown
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
 * in the serialized form page.
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
 * Make sure see tags work in serialized form.
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
 * @author jamieh
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 * @library ../lib/
30730
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 24399
diff changeset
    36
 * @modules jdk.javadoc
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 * @build JavadocTester
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 * @build TestSerializedForm
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 * @run main TestSerializedForm
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
24072
e7549dcbc4af 8040903: Clean up use of BUG_ID in javadoc tests
jjg
parents: 24065
diff changeset
    42
import java.io.*;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
24072
e7549dcbc4af 8040903: Clean up use of BUG_ID in javadoc tests
jjg
parents: 24065
diff changeset
    44
public class TestSerializedForm extends JavadocTester implements Serializable {
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    45
    public static void main(String... args) throws Exception {
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    46
        TestSerializedForm tester = new TestSerializedForm();
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    47
        tester.runTests();
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    48
//        tester.run(ARGS, TEST, NEGATED_TEST);
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    49
//        tester.run(ARGS_PRIVATE, TEST_PRIVATE, NEGATED_TEST_PRIVATE);
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    50
//        tester.printSummary();
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    51
    }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    53
    @Test
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    54
    void testDefault() {
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    55
        javadoc("-d", "out-default",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    56
                "-sourcepath", testSrc,
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    57
                testSrc("TestSerializedForm.java"), "pkg1");
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    58
        checkExit(Exit.OK);
23805
3ef77c1ebf0b 8032066: Serialized form has broken links to non private inner classes of package private
bpatel
parents: 7681
diff changeset
    59
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    60
        checkOutput("serialized-form.html", true,
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    61
                "protected java.lang.Object readResolve()",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    62
                "protected java.lang.Object writeReplace()",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    63
                "protected java.lang.Object readObjectNoData()",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    64
                "See Also",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    65
                "<h3>Class pkg1.NestedInnerClass.InnerClass.ProNestedInnerClass "
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    66
                + "extends java.lang.Object implements Serializable</h3>",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    67
                "<h3>Class pkg1.PrivateIncludeInnerClass.PriInnerClass extends "
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    68
                + "java.lang.Object implements Serializable</h3>",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    69
                "<h3>Class pkg1.ProtectedInnerClass.ProInnerClass extends "
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    70
                + "java.lang.Object implements Serializable</h3>");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    72
        checkOutput("serialized-form.html", false,
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    73
                "<h3>Class <a href=\"pkg1/NestedInnerClass.InnerClass.ProNestedInnerClass.html\" "
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    74
                + "title=\"class in pkg1\">pkg1.NestedInnerClass.InnerClass.ProNestedInnerClass</a> "
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    75
                + "extends java.lang.Object implements Serializable</h3>",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    76
                "<h3>Class <a href=\"pkg1/PrivateInnerClass.PriInnerClass.html\" title=\"class in pkg1\">"
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    77
                + "pkg1.PrivateInnerClass.PriInnerClass</a> extends java.lang.Object implements Serializable</h3>",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    78
                "<h3>Class <a href=\"pkg1/ProtectedInnerClass.ProInnerClass.html\" title=\"class in pkg1\">"
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    79
                + "pkg1.ProtectedInnerClass.ProInnerClass</a> extends java.lang.Object implements Serializable</h3>",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    80
                "<h3>Class pkg1.PublicExcludeInnerClass.PubInnerClass extends java.lang.Object implements "
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    81
                + "Serializable</h3>");
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    82
    }
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    83
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    84
    @Test
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    85
    void testPrivate() {
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    86
        javadoc("-private",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    87
                "-d", "out-private",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    88
                "-sourcepath", testSrc,
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    89
                testSrc("TestSerializedForm.java"), "pkg1");
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    90
        checkExit(Exit.OK);
23805
3ef77c1ebf0b 8032066: Serialized form has broken links to non private inner classes of package private
bpatel
parents: 7681
diff changeset
    91
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    92
        checkOutput("serialized-form.html", true,
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    93
                "<h3>Class <a href=\"pkg1/NestedInnerClass.InnerClass.ProNestedInnerClass.html\" "
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    94
                + "title=\"class in pkg1\">pkg1.NestedInnerClass.InnerClass.ProNestedInnerClass</a> "
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    95
                + "extends java.lang.Object implements Serializable</h3>",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    96
                "<h3>Class <a href=\"pkg1/PrivateIncludeInnerClass.PriInnerClass.html\" title=\"class in pkg1\">"
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    97
                + "pkg1.PrivateIncludeInnerClass.PriInnerClass</a> extends java.lang.Object implements Serializable</h3>",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    98
                "<h3>Class <a href=\"pkg1/ProtectedInnerClass.ProInnerClass.html\" title=\"class in pkg1\">"
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    99
                + "pkg1.ProtectedInnerClass.ProInnerClass</a> extends java.lang.Object implements Serializable</h3>");
23805
3ef77c1ebf0b 8032066: Serialized form has broken links to non private inner classes of package private
bpatel
parents: 7681
diff changeset
   100
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
   101
        checkOutput("serialized-form.html", false,
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
   102
                "<h3>Class pkg1.NestedInnerClass.InnerClass.ProNestedInnerClass "
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
   103
                + "extends java.lang.Object implements Serializable</h3>",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
   104
                "<h3>Class pkg1.PrivateInnerClass.PriInnerClass extends "
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
   105
                + "java.lang.Object implements Serializable</h3>",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
   106
                "<h3>Class pkg1.ProtectedInnerClass.ProInnerClass extends "
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
   107
                + "java.lang.Object implements Serializable</h3>",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
   108
                "<h3>Class <a href=\"pkg1/PublicExcludeInnerClass.PubInnerClass.html\" "
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
   109
                + "title=\"class in pkg1\">pkg1.PublicExcludeInnerClass.PubInnerClass</a> "
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
   110
                + "extends java.lang.Object implements Serializable</h3>");
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
   111
    }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
     * @serial
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
     * @see TestSerializedForm
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
    public final int SERIALIZABLE_CONSTANT = 1;
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
     * The entry point of the test.
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
     * @param args the array of command line arguments.
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
    /**
23805
3ef77c1ebf0b 8032066: Serialized form has broken links to non private inner classes of package private
bpatel
parents: 7681
diff changeset
   125
     * @param s ObjectInputStream.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
     * @throws IOException when there is an I/O error.
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
     * @serial
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
     */
23805
3ef77c1ebf0b 8032066: Serialized form has broken links to non private inner classes of package private
bpatel
parents: 7681
diff changeset
   129
    private void readObject(ObjectInputStream s) throws IOException {}
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
    /**
23805
3ef77c1ebf0b 8032066: Serialized form has broken links to non private inner classes of package private
bpatel
parents: 7681
diff changeset
   132
     * @param s ObjectOutputStream.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
     * @throws IOException when there is an I/O error.
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
     * @serial
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
     */
23805
3ef77c1ebf0b 8032066: Serialized form has broken links to non private inner classes of package private
bpatel
parents: 7681
diff changeset
   136
    private void writeObject(ObjectOutputStream s) throws IOException {}
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
     * @throws IOException when there is an I/O error.
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
     * @serialData This is a serial data comment.
23805
3ef77c1ebf0b 8032066: Serialized form has broken links to non private inner classes of package private
bpatel
parents: 7681
diff changeset
   141
     * @return an object.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
     */
23805
3ef77c1ebf0b 8032066: Serialized form has broken links to non private inner classes of package private
bpatel
parents: 7681
diff changeset
   143
    protected Object readResolve() throws IOException {return null;}
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
     * @throws IOException when there is an I/O error.
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
     * @serialData This is a serial data comment.
23805
3ef77c1ebf0b 8032066: Serialized form has broken links to non private inner classes of package private
bpatel
parents: 7681
diff changeset
   148
     * @return an object.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
     */
23805
3ef77c1ebf0b 8032066: Serialized form has broken links to non private inner classes of package private
bpatel
parents: 7681
diff changeset
   150
    protected Object writeReplace() throws IOException {return null;}
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
     * @throws IOException when there is an I/O error.
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
     * @serialData This is a serial data comment.
23805
3ef77c1ebf0b 8032066: Serialized form has broken links to non private inner classes of package private
bpatel
parents: 7681
diff changeset
   155
     * @return an object.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
     */
23805
3ef77c1ebf0b 8032066: Serialized form has broken links to non private inner classes of package private
bpatel
parents: 7681
diff changeset
   157
    protected Object readObjectNoData() throws IOException {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
        return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
}