jdk/test/tools/launcher/modules/addreads/AddReadsTest.java
author alanb
Thu, 17 Mar 2016 19:04:16 +0000
changeset 36511 9d0388c6b336
child 37779 7c84df693837
permissions -rw-r--r--
8142968: Module System implementation Summary: Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282 Reviewed-by: alanb, mchung, naoto, rriggs, psandoz, plevart, mullan, ascarpino, vinnie, prr, sherman, dfuchs, mhaupt Contributed-by: alan.bateman@oracle.com, alex.buckley@oracle.com, jonathan.gibbons@oracle.com, karen.kinnear@oracle.com, mandy.chung@oracle.com, mark.reinhold@oracle.com, chris.hegarty@oracle.com, alexandr.scherbatiy@oracle.com, amy.lu@oracle.com, calvin.cheung@oracle.com, daniel.fuchs@oracle.com, erik.joelsson@oracle.com, harold.seigel@oracle.com, jaroslav.bachorik@oracle.com, jean-francois.denise@oracle.com, jan.lahoda@oracle.com, james.laskey@oracle.com, lois.foltan@oracle.com, miroslav.kos@oracle.com, huaming.li@oracle.com, sean.mullan@oracle.com, naoto.sato@oracle.com, masayoshi.okutsu@oracle.com, peter.levart@gmail.com, philip.race@oracle.com, claes.redestad@oracle.com, sergey.bylokhov@oracle.com, alexandre.iline@oracle.com, volker.simonis@gmail.com, staffan.larsen@oracle.com, stuart.marks@oracle.com, semyon.sadetsky@oracle.com, serguei.spitsyn@oracle.com, sundararajan.athijegannathan@oracle.com, valerie.peng@oracle.com, vincent.x.ryan@oracle.com, weijun.wang@oracle.com, yuri.nesterenko@oracle.com, yekaterina.kantserova@oracle.com, alexander.kulyakhtin@oracle.com, felix.yang@oracle.com, andrei.eremeev@oracle.com, frank.yuan@oracle.com, sergei.pikalev@oracle.com, sibabrata.sahoo@oracle.com, tiantian.du@oracle.com, sha.jiang@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     1
/*
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     4
 *
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     7
 * published by the Free Software Foundation.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     8
 *
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    13
 * accompanied this code).
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    14
 *
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    18
 *
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    21
 * questions.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    22
 */
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    23
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    24
/**
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    25
 * @test
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    26
 * @library /lib/testlibrary
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    27
 * @modules jdk.compiler
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    28
 * @build AddReadsTest CompilerUtils jdk.testlibrary.*
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    29
 * @run testng AddReadsTest
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    30
 * @summary Basic tests for java -XaddReads
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    31
 */
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    32
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    33
import java.nio.file.Path;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    34
import java.nio.file.Paths;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    35
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    36
import jdk.testlibrary.OutputAnalyzer;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    37
import static jdk.testlibrary.ProcessTools.*;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    38
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    39
import org.testng.annotations.BeforeTest;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    40
import org.testng.annotations.DataProvider;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    41
import org.testng.annotations.Test;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    42
import static org.testng.Assert.*;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    43
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    44
/**
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    45
 * The tests consists of two modules: m1 and junit.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    46
 * Code in module m1 calls into code in module junit but the module-info.java
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    47
 * does not have a 'requires'. Instead a read edge is added via the command
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    48
 * line option -XaddReads.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    49
 */
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    50
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    51
@Test
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    52
public class AddReadsTest {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    53
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    54
    private static final String TEST_SRC = System.getProperty("test.src");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    55
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    56
    private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    57
    private static final Path CLASSES_DIR = Paths.get("classes");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    58
    private static final Path MODS_DIR = Paths.get("mods");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    59
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    60
    private static final String MAIN = "m1/p.Main";
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    61
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    62
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    63
    @BeforeTest
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    64
    public void setup() throws Exception {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    65
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    66
        // javac -d classes src/junit/**
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    67
        assertTrue(CompilerUtils
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    68
            .compile(SRC_DIR.resolve("junit"), CLASSES_DIR));
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    69
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    70
        // javac -d mods/m1 -cp classes/ src/m1/**
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    71
        assertTrue(CompilerUtils
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    72
            .compile(SRC_DIR.resolve("m1"),
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    73
                    MODS_DIR.resolve("m1"),
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    74
                    "-cp", CLASSES_DIR.toString(),
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    75
                    "-XaddReads:m1=ALL-UNNAMED"));
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    76
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    77
        // jar cf mods/junit.jar -C classes .
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    78
        JarUtils.createJarFile(MODS_DIR.resolve("junit.jar"), CLASSES_DIR);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    79
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    80
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    81
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    82
    private OutputAnalyzer run(String... options) throws Exception {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    83
        return executeTestJava(options)
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    84
            .outputTo(System.out)
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    85
            .errorTo(System.out);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    86
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    87
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    88
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    89
    /**
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    90
     * Run with junit as a module on the module path.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    91
     */
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    92
    public void testJUnitOnModulePath() throws Exception {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    93
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    94
        // java -mp mods -addmods junit -XaddReads:m1=junit -m ..
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    95
        int exitValue
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    96
            = run("-mp", MODS_DIR.toString(),
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    97
                  "-addmods", "junit",
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    98
                  "-XaddReads:m1=junit",
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    99
                  "-m", MAIN)
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   100
                .getExitValue();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   101
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   102
        assertTrue(exitValue == 0);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   103
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   104
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   105
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   106
    /**
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   107
     * Exercise -XaddReads:m1=ALL-UNNAMED by running with junit on the
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   108
     * class path.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   109
     */
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   110
    public void testJUnitOnClassPath() throws Exception {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   111
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   112
        // java -mp mods -cp mods/junit.jar -XaddReads:m1=ALL-UNNAMED -m ..
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   113
        String cp = MODS_DIR.resolve("junit.jar").toString();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   114
        int exitValue
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   115
            = run("-mp", MODS_DIR.toString(),
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   116
                  "-cp", cp,
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   117
                  "-XaddReads:m1=ALL-UNNAMED",
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   118
                  "-m", MAIN)
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   119
                .getExitValue();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   120
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   121
        assertTrue(exitValue == 0);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   122
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   123
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   124
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   125
    /**
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   126
     * Run with junit as a module on the module path but without -XaddReads.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   127
     */
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   128
    public void testJUnitOnModulePathMissingAddReads() throws Exception {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   129
        // java -mp mods -addmods junit -m ..
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   130
        int exitValue
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   131
            = run("-mp", MODS_DIR.toString(),
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   132
                  "-addmods", "junit",
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   133
                  "-m", MAIN)
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   134
                .shouldContain("IllegalAccessError")
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   135
                .getExitValue();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   136
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   137
        assertTrue(exitValue != 0);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   138
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   139
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   140
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   141
    /**
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   142
     * Run with junit on the class path but without -XaddReads.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   143
     */
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   144
    public void testJUnitOnClassPathMissingAddReads() throws Exception {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   145
        // java -mp mods -cp mods/junit.jar -m ..
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   146
        String cp = MODS_DIR.resolve("junit.jar").toString();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   147
        int exitValue
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   148
            = run("-mp", MODS_DIR.toString(),
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   149
                  "-cp", cp,
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   150
                  "-m", MAIN)
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   151
                .shouldContain("IllegalAccessError")
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   152
                .getExitValue();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   153
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   154
        assertTrue(exitValue != 0);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   155
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   156
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   157
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   158
    /**
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   159
     * Exercise -XaddReads with a more than one source module.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   160
     */
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   161
    public void testJUnitWithMultiValueOption() throws Exception {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   162
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   163
        int exitValue
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   164
            = run("-mp", MODS_DIR.toString(),
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   165
                  "-addmods", "java.xml,junit",
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   166
                  "-XaddReads:m1=java.xml,junit",
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   167
                  "-m", MAIN)
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   168
                .getExitValue();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   169
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   170
        assertTrue(exitValue == 0);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   171
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   172
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   173
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   174
    /**
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   175
     * Exercise -XaddReads where the target module is specified more than once
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   176
     */
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   177
    public void testWithTargetSpecifiedManyTimes() throws Exception {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   178
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   179
        int exitValue
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   180
            = run("-mp", MODS_DIR.toString(),
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   181
                "-addmods", "java.xml,junit",
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   182
                "-XaddReads:m1=java.xml",
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   183
                "-XaddReads:m1=junit",
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   184
                "-m", MAIN)
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   185
                .shouldContain("specified more than once")
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   186
                .getExitValue();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   187
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   188
        assertTrue(exitValue != 0);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   189
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   190
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   191
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   192
    /**
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   193
     * Exercise -XaddReads with bad values
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   194
     */
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   195
    @Test(dataProvider = "badvalues")
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   196
    public void testWithBadValue(String value, String ignore) throws Exception {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   197
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   198
        //  -XaddExports:$VALUE -version
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   199
        assertTrue(run("-XaddReads:" + value, "-version").getExitValue() != 0);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   200
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   201
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   202
    @DataProvider(name = "badvalues")
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   203
    public Object[][] badValues() {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   204
        return new Object[][]{
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   205
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   206
            { "java.base",                  null }, // missing source
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   207
            { "java.monkey=java.base",      null }, // unknown module
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   208
            { "java.base=sun.monkey",       null }, // unknown source
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   209
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   210
        };
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   211
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   212
}