Path: blob/master/test/jdk/sun/security/krb5/auto/ModuleName.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* @bug 8164437 819448626* @summary GSSContext type when jdk.security.jgss is not available27* @library /test/lib28* @compile -XDignore.symbol.file ModuleName.java29* @build jdk.test.lib.Utils30* jdk.test.lib.Asserts31* jdk.test.lib.JDKToolFinder32* jdk.test.lib.JDKToolLauncher33* jdk.test.lib.Platform34* jdk.test.lib.process.*35* @run main jdk.test.lib.FileInstaller TestHosts TestHosts36* @run main/othervm -Djdk.net.hosts.file=TestHosts ModuleName37*/3839import jdk.test.lib.process.ProcessTools;40import sun.security.jgss.GSSUtil;4142import java.util.List;43import java.util.stream.Stream;4445public class ModuleName {4647public static void main(String[] args) throws Throwable {4849if (args.length == 0) { // jtreg launched here5051// With all modules52test("jdk.security.jgss");5354// With limited modules55List<String> cmd = ProcessTools.createJavaProcessBuilder().command();56Stream.of(jdk.internal.misc.VM.getRuntimeArguments())57.filter(arg -> arg.startsWith("--add-exports=") ||58arg.startsWith("--add-opens="))59.forEach(cmd::add);60cmd.addAll(List.of(61"-Djdk.net.hosts.file=TestHosts",62"-Dtest.src=" + System.getProperty("test.src"),63"--add-modules",64"java.base,java.security.jgss,jdk.security.auth",65"--limit-modules",66"java.security.jgss,jdk.security.auth",67"ModuleName",68"launched-limited"));69ProcessTools.executeCommand(cmd.toArray(new String[cmd.size()]))70.shouldHaveExitValue(0);71} else { // Launched by ProcessTools above, with limited modules.72test("java.security.jgss");73}74}7576static void test(String expected) throws Exception {7778new OneKDC(null).writeJAASConf();7980Context c = Context.fromJAAS("client");81c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID);8283String moduleName = c.x().getClass().getModule().getName();84if (!moduleName.equals(expected)) {85throw new Exception("Expected: " + expected86+ ". Actual: " + moduleName);87}88}89}909192