/* * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
@Test // That that we can correctly handle the module longform argument option // when supplied in an argument file publicvoid modulesInArgsFile() throws IOException {
File cwd = new File(".");
File testModuleDir = new File(cwd, "modules_test");
if (!tr.isOK()) {
System.out.println("test did not compile"); thrownew RuntimeException("Error: modules test did not compile");
}
// verify the terminating ability of --module= through environment variables
File argFile = createArgFile("cmdargs", List.of("--module-path", MODS_DIR.toString(), MODULE_OPTION, "--hello"));
env.put(JDK_JAVA_OPTIONS, "@cmdargs");
tr = doExec(env, javaCmd);
tr.checkNegative();
tr.contains("Error: Option " + MODULE_OPTION + " in @cmdargs is not allowed in environment variable JDK_JAVA_OPTIONS"); if (!tr.testStatus) {
System.out.println(tr); thrownew RuntimeException("test fails");
}
// check that specifying --module and --module-path with file works
tr = doExec(javaCmd, "-Dfile.encoding=UTF-8", "@cmdargs");
tr.contains("[--hello]"); if (!tr.testStatus) {
System.out.println(tr); thrownew RuntimeException("test fails");
}
// check with reversed --module-path and --module in the arguments file, this will fail, --module= is terminating
File argFile1 = createArgFile("cmdargs1", List.of(MODULE_OPTION, "--module-path", MODS_DIR.toString(), "--hello"));
tr = doExec(javaCmd, "-Dfile.encoding=UTF-8", "@cmdargs1");
tr.checkNegative(); if (!tr.testStatus) {
System.out.println(tr); thrownew RuntimeException("test fails");
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.