test/langtools/jdk/javadoc/doclet/testGroupName/TestGroupName.java
author jjg
Wed, 25 Oct 2017 18:12:15 -0700
changeset 47452 dae01bc69f86
child 47847 7640bc1eb94f
permissions -rw-r--r--
8190003: Special characters in group names should be escaped Reviewed-by: ksrini, bpatel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47452
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
     1
/*
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
     2
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
     4
 *
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
     7
 * published by the Free Software Foundation.
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
     8
 *
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    13
 * accompanied this code).
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    14
 *
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    18
 *
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    21
 * questions.
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    22
 */
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    23
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    24
/*
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    25
 * @test
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    26
 * @bug 8190003
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    27
 * @summary Special characters in group names should be escaped
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    28
 * @library /tools/lib ../lib
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    29
 * @modules jdk.javadoc/jdk.javadoc.internal.tool
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    30
 * @build toolbox.ToolBox JavadocTester
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    31
 * @run main TestGroupName
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    32
 */
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    33
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    34
import java.io.IOException;
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    35
import java.nio.file.Path;
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    36
import java.nio.file.Paths;
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    37
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    38
import toolbox.*;
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    39
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    40
public class TestGroupName extends JavadocTester {
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    41
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    42
    public final ToolBox tb;
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    43
    public static void main(String... args) throws Exception {
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    44
        TestGroupName tester = new TestGroupName();
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    45
        tester.runTests(m -> new Object[] { Paths.get(m.getName()) });
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    46
    }
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    47
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    48
    public TestGroupName() {
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    49
        tb = new ToolBox();
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    50
    }
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    51
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    52
    @Test
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    53
    public void testPackageGroups(Path base) throws IOException {
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    54
        Path src = base.resolve("src");
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    55
        tb.writeJavaFiles(src,
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    56
                "package p1; public class C1 { }",
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    57
                "package p2; public class C2 { }",
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    58
                "package p3; public class C3 { }");
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    59
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    60
        javadoc("-d", base.resolve("out").toString(),
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    61
                "-sourcepath", src.toString(),
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    62
                "-group", "abc < & > def", "p1",
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    63
                "p1", "p2", "p3");
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    64
        checkExit(Exit.OK);
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    65
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    66
        checkOutput("overview-summary.html", true,
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    67
                "<span><a href=\"javascript:showGroups(1);\">abc &lt; &amp; &gt; def</a></span>");
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    68
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    69
        checkOutput("overview-summary.html", false,
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    70
                "abc < & > def");
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    71
    }
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    72
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    73
    @Test
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    74
    public void testModuleGroups(Path base) throws IOException {
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    75
        Path src = base.resolve("src");
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    76
        tb.writeJavaFiles(src.resolve("ma"),
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    77
                "module ma { exports pa1; }",
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    78
                "package pa1; public class CA1 { }",
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    79
                "package pa2; public class CA2 { }",
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    80
                "package pa3; public class CA3 { }");
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    81
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    82
        tb.writeJavaFiles(src.resolve("mb"),
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    83
                "module mb { exports pb1; }",
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    84
                "package pb1; public class CB1 { }",
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    85
                "package pb2; public class CB2 { }",
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    86
                "package pb3; public class CB3 { }");
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    87
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    88
        tb.writeJavaFiles(src.resolve("mc"),
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    89
                "module mc { exports pc1; }",
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    90
                "package pc1; public class CC1 { }",
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    91
                "package pc2; public class CC2 { }",
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    92
                "package pc3; public class CC3 { }");
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    93
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    94
        javadoc("-d", base.resolve("out").toString(),
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    95
                "--module-source-path", src.toString(),
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    96
                "-group", "abc < & > def", "ma",
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    97
                "--module", "ma,mb,mc");
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    98
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
    99
        checkExit(Exit.OK);
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
   100
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
   101
        checkOutput("overview-summary.html", true,
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
   102
                "<span><a href=\"javascript:showGroups(1);\">abc &lt; &amp; &gt; def</a></span>");
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
   103
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
   104
        checkOutput("overview-summary.html", false,
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
   105
                "abc < & > def");
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
   106
    }
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
   107
}
dae01bc69f86 8190003: Special characters in group names should be escaped
jjg
parents:
diff changeset
   108