Path: blob/master/test/jdk/tools/launcher/modules/describe/DescribeModuleTest.java
41154 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* @modules java.xml26* @library /test/lib27* @build DescribeModuleTest28* @run testng DescribeModuleTest29* @summary Basic test for java --describe-module30*/3132import jdk.test.lib.process.ProcessTools;3334import org.testng.annotations.Test;35import static org.testng.Assert.*;3637@Test38public class DescribeModuleTest {3940/**41* Test that the output describes java.base42*/43private void expectJavaBase(String... args) throws Exception {44int exitValue = ProcessTools.executeTestJava(args)45.outputTo(System.out)46.errorTo(System.out)47.stdoutShouldContain("java.base")48.stdoutShouldContain("exports java.lang")49.stdoutShouldContain("uses java.nio.file.spi.FileSystemProvider")50.stdoutShouldContain("contains sun.launcher")51.stdoutShouldNotContain("requires ")52.getExitValue();53assertTrue(exitValue == 0);54}5556/**57* Test that the output describes java.xml58*/59private void expectJavaXml(String... args) throws Exception {60int exitValue = ProcessTools.executeTestJava(args)61.outputTo(System.out)62.errorTo(System.out)63.stdoutShouldContain("java.xml")64.stdoutShouldContain("exports javax.xml")65.stdoutShouldContain("requires java.base")66.stdoutShouldContain("uses javax.xml.stream.XMLInputFactory")67.getExitValue();68assertTrue(exitValue == 0);69}7071/**72* Test output/exitValue when describing an unknown module73*/74private void expectUnknownModule(String... args) throws Exception {75int exitValue = ProcessTools.executeTestJava(args)76.outputTo(System.out)77.errorTo(System.out)78.stdoutShouldNotContain("requires java.base")79.getExitValue();80assertTrue(exitValue != 0);81}828384public void testDescribeJavaBase() throws Exception {85expectJavaBase("--describe-module", "java.base");86expectJavaBase("--describe-module=java.base");87expectJavaBase("-d", "java.base");88}8990public void testDescribeJavaXml() throws Exception {91expectJavaXml("--describe-module", "java.xml");92expectJavaXml("--describe-module=java.xml");93expectJavaXml("-d", "java.xml");94}9596public void testDescribeUnknownModule() throws Exception {97expectUnknownModule("--describe-module", "jdk.rhubarb");98expectUnknownModule("--describe-module=jdk.rhubarb");99expectUnknownModule("-d", "jdk.rhubarb");100}101102}103104105