Path: blob/master/test/jdk/tools/launcher/modules/showmoduleresolution/ShowModuleResolutionTest.java
41152 views
/*1* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/**24* @test25* @requires !vm.graal.enabled26* @modules jdk.jdeps jdk.zipfs27* @library /test/lib28* @build ShowModuleResolutionTest29* @run testng ShowModuleResolutionTest30* @summary Basic test for java --show-module-resolution31*/3233import jdk.test.lib.process.ProcessTools;3435import org.testng.annotations.Test;36import static org.testng.Assert.*;3738@Test39public class ShowModuleResolutionTest {4041/**42* Test that the resolution does not bind any services43*/44private void expectJavaBase(String... args) throws Exception {45int exitValue = ProcessTools.executeTestJava(args)46.outputTo(System.out)47.errorTo(System.out)48.stdoutShouldContain("root java.base")49.stdoutShouldNotContain("java.base binds")50.getExitValue();51assertTrue(exitValue == 0);52}5354/**55* Test that the resolution binds services that resolves additional56* modules57*/58private void expectProviders(String... args) throws Exception {59int exitValue = ProcessTools.executeTestJava(args)60.outputTo(System.out)61.errorTo(System.out)62.stdoutShouldContain("root java.base")63.stdoutShouldContain("root java.compiler")64.stdoutShouldContain("root jdk.compiler")65.stdoutShouldContain("root java.compiler")66.stdoutShouldContain("jdk.compiler requires java.compiler")67.stdoutShouldContain("java.base binds jdk.compiler")68.stdoutShouldContain("java.base binds jdk.jdeps")69.stdoutShouldContain("java.base binds jdk.zipfs")70.stdoutShouldContain("java.compiler binds jdk.compiler")71.stdoutShouldContain("jdk.jdeps requires jdk.compiler")72.getExitValue();73assertTrue(exitValue == 0);74}7576public void test() throws Exception {77expectJavaBase("--show-module-resolution",78"--limit-modules", "java.base",79"-version");80expectProviders("--show-module-resolution",81"--limit-modules", "java.base,jdk.jdeps,jdk.zipfs",82"-version");83}84}858687