test/jdk/tools/launcher/modules/addreads/AddReadsTestWarningError.java
author iignatyev
Fri, 07 Sep 2018 14:01:52 -0700
changeset 51675 b487c1e914d0
parent 47216 71c04702a3d5
permissions -rw-r--r--
8210112: remove jdk.testlibrary.ProcessTools Reviewed-by: alanb, sspitsyn, jcbeyler
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42774
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
     1
/*
51675
b487c1e914d0 8210112: remove jdk.testlibrary.ProcessTools
iignatyev
parents: 47216
diff changeset
     2
 * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
42774
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
     4
 *
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
     7
 * published by the Free Software Foundation.
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
     8
 *
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    13
 * accompanied this code).
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    14
 *
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    18
 *
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    21
 * questions.
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    22
 */
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    23
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    24
/**
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    25
 * @test
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    26
 * @bug 8168836
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    27
 * @summary  Basic argument validation for --add-reads
51675
b487c1e914d0 8210112: remove jdk.testlibrary.ProcessTools
iignatyev
parents: 47216
diff changeset
    28
 * @library /test/lib
42774
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    29
 * @modules jdk.compiler
45467
99c87a16a8e4 8181761: add explicit @build actions for jdk.test.lib classes in all :tier2 tests
iignatyev
parents: 45191
diff changeset
    30
 * @build jdk.test.lib.compiler.ModuleInfoMaker
99c87a16a8e4 8181761: add explicit @build actions for jdk.test.lib classes in all :tier2 tests
iignatyev
parents: 45191
diff changeset
    31
 * @build jdk.test.lib.compiler.CompilerUtils
45191
ba48b1679390 8180724: move ModuleInfoMaker to the top level testlibrary
iignatyev
parents: 44359
diff changeset
    32
 * @build AddReadsTestWarningError
42774
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    33
 * @run testng AddReadsTestWarningError
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    34
 */
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    35
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    36
import java.io.BufferedOutputStream;
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    37
import java.io.ByteArrayOutputStream;
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    38
import java.io.PrintStream;
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    39
import java.nio.file.Path;
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    40
import java.nio.file.Paths;
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    41
import java.util.Arrays;
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    42
import java.util.stream.Stream;
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    43
45191
ba48b1679390 8180724: move ModuleInfoMaker to the top level testlibrary
iignatyev
parents: 44359
diff changeset
    44
import jdk.test.lib.compiler.ModuleInfoMaker;
51675
b487c1e914d0 8210112: remove jdk.testlibrary.ProcessTools
iignatyev
parents: 47216
diff changeset
    45
import jdk.test.lib.process.OutputAnalyzer;
b487c1e914d0 8210112: remove jdk.testlibrary.ProcessTools
iignatyev
parents: 47216
diff changeset
    46
import static jdk.test.lib.process.ProcessTools.*;
42774
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    47
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    48
import org.testng.annotations.BeforeTest;
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    49
import org.testng.annotations.DataProvider;
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    50
import org.testng.annotations.Test;
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    51
import static org.testng.Assert.*;
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    52
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    53
@Test
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    54
public class AddReadsTestWarningError {
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    55
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    56
    private static final Path MODS_DIR = Paths.get("mods");
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    57
    private static final Path SRC_DIR = Paths.get("src");
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    58
    private static final String M1_MAIN = "m1/p1.C1";
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    59
    private static final String M4_MAIN = "m4/p4.C4";
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    60
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    61
    @BeforeTest
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    62
    public void setup() throws Exception {
42993
d761de69e27f 8172215: java launcher no longer accepts -cp "" empty string
mchung
parents: 42774
diff changeset
    63
        ModuleInfoMaker builder = new ModuleInfoMaker(SRC_DIR);
42774
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    64
        builder.writeJavaFiles("m1",
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    65
            "module m1 { requires m4; }",
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    66
            "package p1; public class C1 { " +
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    67
            "    public static void main(String... args) {" +
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    68
            "        p2.C2 c2 = new p2.C2();" +
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    69
            "        p3.C3 c3 = new p3.C3();" +
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    70
            "    }" +
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    71
            "}"
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    72
        );
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    73
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    74
        builder.writeJavaFiles("m2",
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    75
            "module m2 { exports p2; }",
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    76
            "package p2; public class C2 { }"
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    77
        );
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    78
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    79
        builder.writeJavaFiles("m3",
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    80
            "module m3 { exports p3; }",
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    81
            "package p3; public class C3 { }"
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    82
        );
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    83
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    84
        builder.writeJavaFiles("m4",
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    85
            "module m4 { requires m2; requires m3; }",
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    86
            "package p4; public class C4 { " +
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    87
            "    public static void main(String... args) {}" +
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    88
            "}"
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    89
        );
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    90
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    91
        builder.compile("m2", MODS_DIR);
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    92
        builder.compile("m3", MODS_DIR);
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    93
        builder.compile("m4", MODS_DIR);
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    94
        builder.compile("m1", MODS_DIR, "--add-reads", "m1=m2,m3");
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    95
    }
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    96
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    97
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    98
    @DataProvider(name = "goodcases")
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
    99
    public Object[][] goodCases() {
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   100
        return new Object[][]{
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   101
            // empty items
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   102
            { "m1=,m2,m3",       null },
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   103
            { "m1=m2,,m3",       null },
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   104
            { "m1=m2,m3,",       null },
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   105
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   106
            // duplicates
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   107
            { "m1=m2,m2,m3,,",  null },
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   108
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   109
        };
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   110
    }
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   111
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   112
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   113
    @Test(dataProvider = "goodcases")
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   114
    public void test(String value, String ignore) throws Exception {
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   115
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   116
        PrintStream ps = new PrintStream(new BufferedOutputStream(baos));
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   117
        OutputAnalyzer outputAnalyzer =
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   118
            executeTestJava("--add-reads", value,
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   119
                            "--module-path", MODS_DIR.toString(),
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   120
                            "-m", M1_MAIN)
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   121
                .outputTo(ps)
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   122
                .errorTo(ps);
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   123
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   124
        assertTrue(outputAnalyzer.getExitValue() == 0);
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   125
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   126
        System.out.println(baos.toString());
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   127
        String[] output = baos.toString().split("\\R");
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   128
        assertFalse(Arrays.stream(output)
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   129
                          .filter(s -> !s.matches("WARNING: Module name .* may soon be illegal"))
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   130
                          .filter(s -> s.startsWith("WARNING:"))
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   131
                          .findAny().isPresent());
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   132
    }
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   133
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   134
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   135
    @DataProvider(name = "illFormedAddReads")
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   136
    public Object[][] illFormedAddReads() {
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   137
        return new Object[][]{
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   138
            { "m1",         "Unable to parse --add-reads <module>=<value>: m1" },
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   139
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   140
            // missing source part
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   141
            { "=m2",        "Unable to parse --add-reads <module>=<value>: =m2" },
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   142
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   143
            // empty list, missing target
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   144
            { "m1=",        "Unable to parse --add-reads <module>=<value>: m1=" },
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   145
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   146
            // empty list
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   147
            { "m1=,,",      "Target must be specified: --add-reads m1=,," },
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   148
        };
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   149
    }
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   150
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   151
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   152
    @Test(dataProvider = "illFormedAddReads")
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   153
    public void testIllFormedAddReads(String value, String msg) throws Exception {
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   154
        int exitValue =
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   155
            executeTestJava("--add-reads", value,
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   156
                            "--module-path", MODS_DIR.toString(),
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   157
                            "-m", M4_MAIN)
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   158
                .outputTo(System.out)
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   159
                .errorTo(System.out)
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   160
                .shouldContain(msg)
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   161
                .getExitValue();
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   162
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   163
        assertTrue(exitValue != 0);
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   164
    }
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   165
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   166
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   167
    @DataProvider(name = "unknownNames")
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   168
    public Object[][] unknownNames() {
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   169
        return new Object[][]{
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   170
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   171
            // source not found
44359
c6761862ca0b 8174823: Module system implementation refresh (3/2017)
alanb
parents: 42993
diff changeset
   172
            {"DoesNotExist=m2",    "WARNING: Unknown module: DoesNotExist specified to --add-reads"},
42774
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   173
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   174
            // target not found
44359
c6761862ca0b 8174823: Module system implementation refresh (3/2017)
alanb
parents: 42993
diff changeset
   175
            {"m2=DoesNotExist",    "WARNING: Unknown module: DoesNotExist specified to --add-reads"},
42774
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   176
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   177
            // bad names
44359
c6761862ca0b 8174823: Module system implementation refresh (3/2017)
alanb
parents: 42993
diff changeset
   178
            {"m*=m2",              "WARNING: Unknown module: m* specified to --add-reads"},
c6761862ca0b 8174823: Module system implementation refresh (3/2017)
alanb
parents: 42993
diff changeset
   179
            {"m2=m!",              "WARNING: Unknown module: m! specified to --add-reads"},
42774
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   180
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   181
        };
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   182
    }
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   183
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   184
    @Test(dataProvider = "unknownNames")
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   185
    public void testUnknownNames(String value, String msg) throws Exception {
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   186
        int exitValue =
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   187
            executeTestJava("--add-reads", value,
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   188
                            "--module-path", MODS_DIR.toString(),
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   189
                            "-m", M4_MAIN)
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   190
                .outputTo(System.out)
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   191
                .errorTo(System.out)
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   192
                .shouldContain(msg)
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   193
                .getExitValue();
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   194
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   195
        assertTrue(exitValue == 0);
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   196
    }
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   197
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   198
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   199
    @DataProvider(name = "missingArguments")
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   200
    public Object[][] missingArguments() {
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   201
        return new Object[][]{
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   202
            { new String[] {"--add-reads" },
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   203
                "Error: --add-reads requires modules to be specified"},
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   204
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   205
            { new String[] { "--add-reads=" },
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   206
                "Error: --add-reads= requires modules to be specified"},
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   207
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   208
            { new String[] { "--add-reads", "" },
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   209
                "Error: --add-reads requires modules to be specified"},
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   210
        };
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   211
    }
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   212
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   213
    @Test(dataProvider = "missingArguments")
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   214
    public void testEmptyArgument(String[] options, String msg) throws Exception {
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   215
        String[] args = Stream.concat(Arrays.stream(options), Stream.of("-version"))
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   216
                              .toArray(String[]::new);
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   217
        int exitValue = executeTestJava(args)
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   218
            .outputTo(System.out)
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   219
            .errorTo(System.out)
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   220
            .shouldContain(msg)
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   221
            .getExitValue();
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   222
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   223
        assertTrue(exitValue != 0);
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   224
    }
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents:
diff changeset
   225
}