TestSpecialArgs.java revision 4954
4680N/A/*
4680N/A * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
4680N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4680N/A *
4680N/A * This code is free software; you can redistribute it and/or modify it
4680N/A * under the terms of the GNU General Public License version 2 only, as
4680N/A * published by the Free Software Foundation.
4680N/A *
4680N/A * This code is distributed in the hope that it will be useful, but WITHOUT
4680N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4680N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4680N/A * version 2 for more details (a copy is included in the LICENSE file that
4680N/A * accompanied this code).
4680N/A *
4680N/A * You should have received a copy of the GNU General Public License version
4680N/A * 2 along with this work; if not, write to the Free Software Foundation,
4680N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4680N/A *
4680N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4680N/A * or visit www.oracle.com if you need additional information or have any
4680N/A * questions.
4680N/A */
4680N/A
4680N/A/*
4680N/A * @test
4954N/A * @bug 7124089 7131021
4954N/A * @summary Checks for MacOSX specific flags are accepted or rejected, and
4954N/A * MacOSX platforms specific environment is consistent.
4954N/A * @compile -XDignore.symbol.file TestSpecialArgs.java EnvironmentVariables.java
4680N/A * @run main TestSpecialArgs
4680N/A */
4680N/Aimport java.util.HashMap;
4954N/Aimport java.util.HashSet;
4680N/Aimport java.util.Map;
4954N/Aimport java.util.Set;
4680N/A
4954N/Apublic class TestSpecialArgs extends TestHelper {
4680N/A
4680N/A public static void main(String... args) {
4680N/A final Map<String, String> envMap = new HashMap<>();
4680N/A envMap.put("_JAVA_LAUNCHER_DEBUG", "true");
4680N/A
4954N/A TestResult tr = doExec(envMap, javaCmd, "-XstartOnFirstThread", "-version");
4954N/A if (isMacOSX) {
4680N/A if (!tr.contains("In same thread")) {
4680N/A System.out.println(tr);
4680N/A throw new RuntimeException("Error: not running in the same thread ?");
4680N/A }
4680N/A if (!tr.isOK()) {
4680N/A System.out.println(tr);
4680N/A throw new RuntimeException("Error: arg was rejected ????");
4680N/A }
4680N/A } else {
4680N/A if (tr.isOK()) {
4680N/A System.out.println(tr);
4680N/A throw new RuntimeException("Error: argument was accepted ????");
4680N/A }
4680N/A }
4680N/A
4954N/A tr = doExec(javaCmd, "-Xdock:/tmp/not-available", "-version");
4954N/A if (isMacOSX) {
4680N/A if (!tr.isOK()) {
4680N/A System.out.println(tr);
4680N/A throw new RuntimeException("Error: arg was rejected ????");
4680N/A }
4680N/A } else {
4680N/A if (tr.isOK()) {
4680N/A System.out.println(tr);
4680N/A throw new RuntimeException("Error: argument was accepted ????");
4680N/A }
4680N/A }
4954N/A // MacOSX specific tests ensue......
4954N/A if (!isMacOSX)
4954N/A return;
4954N/A Set<String> envToRemove = new HashSet<>();
4954N/A Map<String, String> map = System.getenv();
4954N/A for (String s : map.keySet()) {
4954N/A if (s.startsWith("JAVA_MAIN_CLASS_")
4954N/A || s.startsWith("APP_NAME_")
4954N/A || s.startsWith("APP_ICON_")) {
4954N/A envToRemove.add(s);
4954N/A }
4954N/A }
4954N/A runTest(envToRemove, javaCmd, "-cp", TEST_CLASSES_DIR.getAbsolutePath(),
4954N/A "EnvironmentVariables", "JAVA_MAIN_CLASS_*",
4954N/A "EnvironmentVariables");
4954N/A
4954N/A runTest(envToRemove, javaCmd, "-cp", TEST_CLASSES_DIR.getAbsolutePath(),
4954N/A "-Xdock:name=TestAppName", "EnvironmentVariables",
4954N/A "APP_NAME_*", "TestAppName");
4954N/A
4954N/A runTest(envToRemove, javaCmd, "-cp", TEST_CLASSES_DIR.getAbsolutePath(),
4954N/A "-Xdock:icon=TestAppIcon", "EnvironmentVariables",
4954N/A "APP_ICON_*", "TestAppIcon");
4954N/A }
4954N/A
4954N/A static void runTest(Set<String> envToRemove, String... args) {
4954N/A TestResult tr = doExec(null, envToRemove, args);
4954N/A if (!tr.isOK()) {
4954N/A System.err.println(tr.toString());
4954N/A throw new RuntimeException("Test Fails");
4954N/A }
4680N/A }
4680N/A}