test/jdk/tools/launcher/modules/showmoduleresolution/ShowModuleResolutionTest.java
author mr
Wed, 16 Jan 2019 16:27:21 -0800
changeset 53372 4003935e6e5f
parent 51675 b487c1e914d0
permissions -rw-r--r--
8216532: tools/launcher/Test7029048.java fails (Solaris) Reviewed-by: rriggs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
45004
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
     1
/*
51675
b487c1e914d0 8210112: remove jdk.testlibrary.ProcessTools
iignatyev
parents: 48397
diff changeset
     2
 * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
45004
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
     4
 *
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
     7
 * published by the Free Software Foundation.
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
     8
 *
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    13
 * accompanied this code).
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    14
 *
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    18
 *
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    21
 * questions.
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    22
 */
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    23
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    24
/**
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    25
 * @test
48397
ead47ddf5844 8191788: add jdk.internal.vm.compiler to --limit-modules if -Djvmci.Compiler=graal is in the command line
kvn
parents: 47216
diff changeset
    26
 * @requires !vm.graal.enabled
45004
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    27
 * @modules jdk.jdeps jdk.zipfs
51675
b487c1e914d0 8210112: remove jdk.testlibrary.ProcessTools
iignatyev
parents: 48397
diff changeset
    28
 * @library /test/lib
b487c1e914d0 8210112: remove jdk.testlibrary.ProcessTools
iignatyev
parents: 48397
diff changeset
    29
 * @build ShowModuleResolutionTest
45004
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    30
 * @run testng ShowModuleResolutionTest
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    31
 * @summary Basic test for java --show-module-resolution
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    32
 */
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    33
51675
b487c1e914d0 8210112: remove jdk.testlibrary.ProcessTools
iignatyev
parents: 48397
diff changeset
    34
import jdk.test.lib.process.ProcessTools;
45004
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    35
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    36
import org.testng.annotations.Test;
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    37
import static org.testng.Assert.*;
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    38
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    39
@Test
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    40
public class ShowModuleResolutionTest {
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    41
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    42
    /**
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    43
     * Test that the resolution does not bind any services
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    44
     */
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    45
    private void expectJavaBase(String... args) throws Exception {
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    46
        int exitValue = ProcessTools.executeTestJava(args)
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    47
                .outputTo(System.out)
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    48
                .errorTo(System.out)
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    49
                .stdoutShouldContain("root java.base")
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    50
                .stdoutShouldNotContain("java.base binds")
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    51
                .getExitValue();
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    52
        assertTrue(exitValue == 0);
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    53
    }
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    54
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    55
    /**
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    56
     * Test that the resolution binds services that resolves additional
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    57
     * modules
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    58
     */
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    59
    private void expectProviders(String... args) throws Exception {
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    60
        int exitValue = ProcessTools.executeTestJava(args)
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    61
                .outputTo(System.out)
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    62
                .errorTo(System.out)
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    63
                .stdoutShouldContain("root java.base")
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    64
                .stdoutShouldContain("root java.compiler")
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    65
                .stdoutShouldContain("root jdk.compiler")
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    66
                .stdoutShouldContain("root java.compiler")
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    67
                .stdoutShouldContain("jdk.compiler requires java.compiler")
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    68
                .stdoutShouldContain("java.base binds jdk.compiler")
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    69
                .stdoutShouldContain("java.base binds jdk.jdeps")
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    70
                .stdoutShouldContain("java.base binds jdk.zipfs")
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    71
                .stdoutShouldContain("java.compiler binds jdk.compiler")
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    72
                .stdoutShouldContain("jdk.jdeps requires jdk.compiler")
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    73
                .getExitValue();
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    74
        assertTrue(exitValue == 0);
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    75
    }
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    76
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    77
    public void test() throws Exception {
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    78
        expectJavaBase("--show-module-resolution",
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    79
                       "--limit-modules", "java.base",
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    80
                       "-version");
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    81
        expectProviders("--show-module-resolution",
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    82
                        "--limit-modules", "java.base,jdk.jdeps,jdk.zipfs",
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    83
                        "-version");
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    84
    }
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents:
diff changeset
    85
}