1 /* 2 * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * @test 26 * @bug 4906940 8130302 27 * @summary -providerPath, -providerClass, -addprovider, and -providerArg 28 * @library /test/lib 29 * @modules java.base/jdk.internal.misc 30 * @build jdk.test.lib.util.JarUtils 31 * jdk.test.lib.compiler.CompilerUtils 32 * jdk.test.lib.Utils 33 * jdk.test.lib.Asserts 34 * jdk.test.lib.JDKToolFinder 35 * jdk.test.lib.JDKToolLauncher 36 * jdk.test.lib.Platform 37 * jdk.test.lib.process.* 38 * @run main AltProvider 39 */ 40 41 import jdk.test.lib.JDKToolLauncher; 42 import jdk.test.lib.process.OutputAnalyzer; 43 import jdk.test.lib.process.ProcessTools; 44 import jdk.test.lib.util.JarUtils; 45 import jdk.test.lib.compiler.CompilerUtils; 46 149 150 // Test jarsigner with extra options and check exitValue and output 151 private static void testJarsigner(String args, int exitValue, String contains) 152 throws Throwable { 153 tool("jarsigner", jsCommand + " " + args) 154 .shouldHaveExitValue(exitValue) 155 .shouldContain(contains); 156 } 157 158 // Launch a tool with args (space separated string) 159 private static OutputAnalyzer tool(String tool, String args) 160 throws Throwable { 161 JDKToolLauncher l = JDKToolLauncher.createUsingTestJDK(tool); 162 for (String a: args.split("\\s+")) { 163 if (a.startsWith("-J")) { 164 l.addVMArg(a.substring(2)); 165 } else { 166 l.addToolArg(a); 167 } 168 } 169 return ProcessTools.executeCommand(l.getCommand()); 170 } 171 } | 1 /* 2 * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * @test 26 * @bug 4906940 8130302 8194152 27 * @summary -providerPath, -providerClass, -addprovider, and -providerArg 28 * @library /test/lib 29 * @modules java.base/jdk.internal.misc 30 * @build jdk.test.lib.util.JarUtils 31 * jdk.test.lib.compiler.CompilerUtils 32 * jdk.test.lib.Utils 33 * jdk.test.lib.Asserts 34 * jdk.test.lib.JDKToolFinder 35 * jdk.test.lib.JDKToolLauncher 36 * jdk.test.lib.Platform 37 * jdk.test.lib.process.* 38 * @run main AltProvider 39 */ 40 41 import jdk.test.lib.JDKToolLauncher; 42 import jdk.test.lib.process.OutputAnalyzer; 43 import jdk.test.lib.process.ProcessTools; 44 import jdk.test.lib.util.JarUtils; 45 import jdk.test.lib.compiler.CompilerUtils; 46 149 150 // Test jarsigner with extra options and check exitValue and output 151 private static void testJarsigner(String args, int exitValue, String contains) 152 throws Throwable { 153 tool("jarsigner", jsCommand + " " + args) 154 .shouldHaveExitValue(exitValue) 155 .shouldContain(contains); 156 } 157 158 // Launch a tool with args (space separated string) 159 private static OutputAnalyzer tool(String tool, String args) 160 throws Throwable { 161 JDKToolLauncher l = JDKToolLauncher.createUsingTestJDK(tool); 162 for (String a: args.split("\\s+")) { 163 if (a.startsWith("-J")) { 164 l.addVMArg(a.substring(2)); 165 } else { 166 l.addToolArg(a); 167 } 168 } 169 170 // Set locale to en-US so that the output are not translated into other languages. 171 l.addVMArg("-Duser.language=en"); 172 l.addVMArg("-Duser.country=US"); 173 174 return ProcessTools.executeCommand(l.getCommand()); 175 } 176 } |