test/tools/apt/Basics/CheckAptIsRemovedTest.java

Tue, 19 Feb 2013 17:53:16 +0000

author
vromero
date
Tue, 19 Feb 2013 17:53:16 +0000
changeset 1591
dc8b7aa7cef3
parent 0
959103a6100f
permissions
-rw-r--r--

8006212: javac, convert jtreg tests from shell script to java
Reviewed-by: jjg

     1 /*
     2  * Copyright (c) 2013, 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  */
    24 /*
    25  * @test
    26  * @bug 4908512 5024825 4957203 4993280 4996963 6174696 6177059 7041249
    27  * @summary Make sure apt is removed and doesn't come back
    28  * @library /tools/javac/lib
    29  * @build ToolBox
    30  * @run main CheckAptIsRemovedTest
    31  */
    33 import java.nio.file.Files;
    34 import java.nio.file.Path;
    35 import java.nio.file.Paths;
    37 //original test: test/tools/apt/Basics/apt.sh
    38 public class CheckAptIsRemovedTest {
    39     //I think this class can be let with the imports only and that should be enough for as test's purpose
    40     private static final String NullAPFSrc =
    41         "import com.sun.mirror.apt.*;\n" +
    42         "import com.sun.mirror.declaration.*;\n" +
    43         "import com.sun.mirror.type.*;\n" +
    44         "import com.sun.mirror.util.*;\n" +
    45         "import java.util.Collection;\n" +
    46         "import java.util.Set;\n\n" +
    48         "public class NullAPF implements AnnotationProcessorFactory {\n" +
    49         "    static class NullAP implements AnnotationProcessor {\n" +
    50         "        NullAP(AnnotationProcessorEnvironment ape) {}\n" +
    51         "        public void process() {return;}\n" +
    52         "    }\n\n" +
    54         "    static Collection<String> supportedTypes;\n\n" +
    55         "    static {\n" +
    56         "        String types[] = {\"*\"};\n" +
    57         "        supportedTypes = java.util.Arrays.asList(types);\n" +
    58         "    }\n\n" +
    60         "    public Collection<String> supportedOptions() {\n" +
    61         "        return java.util.Collections.emptySet();\n" +
    62         "    }\n\n" +
    64         "    public Collection<String> supportedAnnotationTypes() {\n" +
    65         "        return supportedTypes;\n" +
    66         "    }\n\n" +
    68         "    public AnnotationProcessor getProcessorFor(" +
    69         "        Set<AnnotationTypeDeclaration> atds,\n" +
    70         "        AnnotationProcessorEnvironment env) {\n" +
    71         "        return new NullAP(env);\n" +
    72         "    }\n" +
    73         "}";
    75     public static void main(String[] args) throws Exception {
    76         String testJDK = System.getProperty("test.jdk");
    77         Path aptLin = Paths.get(testJDK, "bin", "apt");
    78         Path aptWin = Paths.get(testJDK, "bin", "apt.exe");
    80 //        if [ -f "${TESTJAVA}/bin/apt" -o -f "${TESTJAVA}/bin/apt.exe" ];then
    81         if (Files.exists(aptLin) || Files.exists(aptWin)) {
    82             throw new AssertionError("apt executable should not exist");
    83         }
    85 //        JAVAC="${TESTJAVA}/bin/javac ${TESTTOOLVMOPTS} -source 1.5 -sourcepath ${TESTSRC} -classpath ${TESTJAVA}/lib/tools.jar -d . "
    86 //        $JAVAC ${TESTSRC}/NullAPF.java
    87         Path classpath = Paths.get(testJDK, "lib", "tools.jar");
    88         ToolBox.JavaToolArgs javacArgs =
    89                 new ToolBox.JavaToolArgs(ToolBox.Expect.FAIL)
    90                 .setOptions("-source", "1.5", "-sourcepath", ".",
    91                     "-classpath", classpath.toString())
    92                 .setSources(NullAPFSrc);
    93         ToolBox.javac(javacArgs);
    94     }
    96 }

mercurial