test/jdk/tools/launcher/FXLauncherTest.java
author mr
Wed, 16 Jan 2019 16:27:21 -0800
changeset 53372 4003935e6e5f
parent 50090 94e11b6edcdd
permissions -rw-r--r--
8216532: tools/launcher/Test7029048.java fails (Solaris) Reviewed-by: rriggs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
     1
/*
48522
c674ff28c69d 8194287: tools/launcher/RunpathTest.java fails with java.lang.NullPointerException
ksrini
parents: 47216
diff changeset
     2
 * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
     4
 *
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
     7
 * published by the Free Software Foundation.
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
     8
 *
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    13
 * accompanied this code).
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    14
 *
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    18
 *
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    21
 * questions.
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    22
 */
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    23
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    24
/*
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    25
 * @test
50090
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
    26
 * @library /test/lib
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
    27
 * @build FXLauncherTest jdk.test.lib.compiler.CompilerUtils
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
    28
 * @bug 8001533 8004547 8035782 8202553
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    29
 * @summary Test launching FX application with java -jar
50090
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
    30
 * Test uses main method and blank main method, a jfx app class and an incorrect
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    31
 * jfx app class, a main-class for the manifest, a bogus one and none.
50090
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
    32
 * Now that FX is no longer bundled with the JDK, this test uses a
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
    33
 * "mock" javafx.graphics module to test the FX launcher. It also verifies
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
    34
 * that FX is, in fact, not included with the JDK.
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    35
 * All should execute except the incorrect fx app class entries.
30371
aa862dad6ad9 8078225: tools/launcher/FXLauncherTest.java fails intermittently (win)
ksrini
parents: 24254
diff changeset
    36
 * @run main/othervm FXLauncherTest
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    37
 */
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    38
import java.io.File;
50090
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
    39
import java.nio.file.Path;
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
    40
import java.nio.file.Paths;
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    41
import java.io.IOException;
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    42
import java.util.ArrayList;
50090
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
    43
import java.util.Arrays;
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    44
import java.util.List;
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    45
50090
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
    46
import jdk.test.lib.compiler.CompilerUtils;
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
    47
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    48
public class FXLauncherTest extends TestHelper {
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    49
    private static final String FX_MARKER_CLASS = "javafx.application.Application";
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    50
    private static void line() {
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    51
        System.out.println("_____________________________________________");
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    52
    }
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    53
    private static File MainJavaFile = null;
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    54
    private static final File FXtestJar =  new File("fxtest.jar");
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    55
    private static final File ManifestFile = new File("manifest.txt");
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    56
    private static final File ScratchDir = new File(".");
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    57
50090
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
    58
    private static final Path SRC_DIR =
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
    59
        TEST_SOURCES_DIR.toPath().resolve("mockfx/src");
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
    60
    private static final Path MODS_DIR = Paths.get("mods");
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
    61
    private static final String MODULE_DIR = MODS_DIR.toString();
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
    62
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    63
    /* standard main class can be used as java main for fx app class */
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    64
    static final String StdMainClass = "helloworld.HelloWorld";
15003
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
    65
    static final String ExtMainClass = "helloworld.ExtHello";
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
    66
    static final String NonFXMainClass = "helloworld.HelloJava";
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    67
    static int testcount = 0;
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    68
50090
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
    69
    static final String LAUNCH_MODE_CLASS = "LM_CLASS";
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
    70
    static final String LAUNCH_MODE_JAR = "LM_JAR";
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
    71
    static final String LAUNCH_MODE_MODULE = "LM_MODULE";
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
    72
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    73
    /* a main method and a blank. */
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    74
    static final String[] MAIN_METHODS = {
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    75
        "public static void main(String[] args) { launch(args); }",
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    76
        " "
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    77
    };
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    78
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    79
    // Array of parameters to pass to fx application.
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    80
    static final String[] APP_PARMS = { "one", "two" };
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    81
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    82
    // Create fx java file for test application
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    83
    static void createJavaFile(String mainmethod) {
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    84
        try {
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    85
            String mainClass = "HelloWorld";
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    86
            List<String> contents = new ArrayList<>();
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    87
            contents.add("package helloworld;");
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    88
            contents.add("import javafx.application.Application;");
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    89
            contents.add("import javafx.stage.Stage;");
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    90
            contents.add("public class HelloWorld extends Application {");
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    91
            contents.add(mainmethod);
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    92
            contents.add("@Override");
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    93
            contents.add("public void start(Stage primaryStage) {");
50090
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
    94
            contents.add("    throw new InternalError(\"should never get here\");");
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    95
            contents.add("}");
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    96
            contents.add("}");
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    97
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    98
            // Create and compile java source.
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
    99
            MainJavaFile = new File(mainClass + JAVA_FILE_EXT);
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   100
            createFile(MainJavaFile, contents);
50090
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   101
            doFxCompile("-d", ".", mainClass + JAVA_FILE_EXT);
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   102
        } catch (java.io.IOException ioe) {
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   103
            ioe.printStackTrace();
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   104
            throw new RuntimeException("Failed creating HelloWorld.");
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   105
        }
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   106
    }
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   107
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   108
    /*
15003
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   109
     * Create class that extends HelloWorld instead of Application
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   110
     */
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   111
    static void createExtJavaFile(String mainmethod) {
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   112
        try {
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   113
            String mainClass = "ExtHello";
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   114
            List<String> contents = new ArrayList<>();
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   115
            contents.add("package helloworld;");
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   116
            contents.add("public class ExtHello extends HelloWorld {");
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   117
            contents.add(mainmethod);
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   118
            contents.add("}");
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   119
            // Create and compile java source.
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   120
            MainJavaFile = new File(mainClass + JAVA_FILE_EXT);
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   121
            createFile(MainJavaFile, contents);
50090
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   122
            doFxCompile("-cp", ".", "-d", ".", mainClass + JAVA_FILE_EXT);
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   123
        } catch (java.io.IOException ioe) {
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   124
            ioe.printStackTrace();
15003
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   125
            throw new RuntimeException("Failed creating ExtHello.");
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   126
        }
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   127
    }
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   128
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   129
    /*
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   130
     * Create non-JavaFX class for testing if jfxrt.jar is being loaded
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   131
     * when it shouldn't be
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   132
     */
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   133
    static void createNonFXJavaFile() {
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   134
        try {
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   135
            String mainClass = "HelloJava";
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   136
            List<String> contents = new ArrayList<>();
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   137
            contents.add("package helloworld;");
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   138
            contents.add("public class HelloJava {");
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   139
            contents.add("    public static void main(String[] args) {");
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   140
            contents.add("        for(String aa : args)");
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   141
            contents.add("            System.out.println(\"arg: \" + aa);" );
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   142
            contents.add("    }");
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   143
            contents.add("}");
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   144
            // Create and compile java source.
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   145
            MainJavaFile = new File(mainClass + JAVA_FILE_EXT);
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   146
            createFile(MainJavaFile, contents);
50090
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   147
            doFxCompile("-cp", ".", "-d", ".", mainClass + JAVA_FILE_EXT);
15003
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   148
        } catch (java.io.IOException ioe) {
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   149
            ioe.printStackTrace();
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   150
            throw new RuntimeException("Failed creating HelloJava.");
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   151
        }
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   152
    }
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   153
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   154
    // Create manifest for test fx application
15003
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   155
    static List<String> createManifestContents(String mainClassEntry, String fxMainEntry) {
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   156
        List<String> mcontents = new ArrayList<>();
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   157
        mcontents.add("Manifest-Version: 1.0");
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   158
        mcontents.add("Created-By: FXLauncherTest");
15003
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   159
        if (mainClassEntry != null) {
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   160
            mcontents.add("Main-Class: " + mainClassEntry);
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   161
            System.out.println("Main-Class: " + mainClassEntry);
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   162
        }
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   163
        if (fxMainEntry != null) {
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   164
            mcontents.add("JavaFX-Application-Class: " + fxMainEntry);
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   165
            System.out.println("JavaFX-Application-Class: " + fxMainEntry);
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   166
        }
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   167
        return mcontents;
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   168
    }
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   169
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   170
    // Method to marshal createJar to TestHelper.createJar()
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   171
    static void createJar(File theJar, File manifestFile) {
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   172
        createJar("cvmf", manifestFile.getName(),
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   173
                  theJar.getAbsolutePath(), "helloworld");
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   174
    }
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   175
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   176
    static void saveFile(String tname, int testcount, File srcFile) {
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   177
        File newFile = new File(tname + "-" + testcount + "-" + srcFile.getName());
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   178
        System.out.println("renaming " + srcFile.getName() +
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   179
                           " to " + newFile.getName());
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   180
        srcFile.renameTo(newFile);
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   181
    }
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   182
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   183
    static void cleanupFiles() throws IOException {
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   184
        for(File f : ScratchDir.listFiles()) {
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   185
            recursiveDelete(f);
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   186
        }
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   187
    }
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   188
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   189
    static void checkStatus(TestResult tr, String testName, int testCount,
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   190
                            String mainclass) throws Exception {
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   191
        if (tr.testStatus) {
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   192
            System.out.println("PASS: " + testName + ":" + testCount +
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   193
                               " : test with " + mainclass);
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   194
            cleanupFiles();
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   195
        } else {
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   196
            saveFile(testName, testcount, FXtestJar);
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   197
            System.out.println("FAIL: " + testName + ":" + testCount +
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   198
                               " : test with " + mainclass);
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   199
            cleanupFiles();
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   200
            System.err.println(tr);
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   201
            throw new Exception("Failed: " + testName + ":" + testCount);
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   202
        }
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   203
    }
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   204
50090
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   205
    public static void compileFXModule() {
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   206
        final String JAVAFX_GRAPHICS_MODULE = "javafx.graphics";
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   207
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   208
        try {
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   209
            // Compile mockfx/src/javafx.graphics/** into mods/javafx.graphics
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   210
            boolean compiled
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   211
                = CompilerUtils.compile(SRC_DIR.resolve(JAVAFX_GRAPHICS_MODULE),
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   212
                                        MODS_DIR.resolve(JAVAFX_GRAPHICS_MODULE));
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   213
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   214
            if (!compiled) {
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   215
                throw new RuntimeException("Error compiling mock javafx.graphics module");
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   216
            }
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   217
        } catch (IOException ioe) {
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   218
            throw new RuntimeException(ioe);
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   219
        }
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   220
    }
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   221
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   222
    static void doFxCompile(String...compilerArgs) {
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   223
        compileFXModule();
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   224
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   225
        List<String> fxCompilerArgs = new ArrayList<>();
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   226
        fxCompilerArgs.add("--module-path=" + MODULE_DIR);
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   227
        fxCompilerArgs.add("--add-modules=javafx.graphics");
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   228
        fxCompilerArgs.addAll(Arrays.asList(compilerArgs));
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   229
        compile(fxCompilerArgs.toArray(new String[fxCompilerArgs.size()]));
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   230
    }
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   231
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   232
    static TestResult doFxExec(String...cmds) {
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   233
        List<String> fxCmds = new ArrayList<>();
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   234
        fxCmds.addAll(Arrays.asList(cmds));
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   235
        fxCmds.add(1, "--module-path=" + MODULE_DIR);
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   236
        fxCmds.add(2, "--add-modules=javafx.graphics");
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   237
        return doExec(fxCmds.toArray(new String[fxCmds.size()]));
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   238
    }
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   239
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   240
    /*
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   241
     * Set Main-Class and iterate main_methods.
15003
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   242
     * Try launching with both -jar and -cp methods, with and without FX main
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   243
     * class manifest entry.
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   244
     * All cases should run.
15003
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   245
     *
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   246
     * See sun.launcher.LauncherHelper$FXHelper for more details on how JavaFX
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   247
     * applications are launched.
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   248
     */
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   249
    @Test
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   250
    static void testBasicFXApp() throws Exception {
15003
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   251
        testBasicFXApp(true, false);    // -cp, no JAC
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   252
        testBasicFXApp(false, true);    // -jar, with JAC
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   253
        testBasicFXApp(false, false);   // -jar, no JAC
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   254
    }
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   255
15003
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   256
    static void testBasicFXApp(boolean useCP, boolean setFXMainClass) throws Exception {
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   257
        String testname = "testBasicFXApp";
15003
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   258
        if (useCP) {
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   259
            testname = testname.concat("_useCP");
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   260
        }
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   261
        String fxMC = StdMainClass;
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   262
        if (!setFXMainClass) {
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   263
            testname = testname.concat("_noJAC");
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   264
            fxMC = null;
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   265
        }
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   266
        for (String mm : MAIN_METHODS) {
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   267
            testcount++;
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   268
            line();
15003
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   269
            System.out.println("test# " + testcount + "-  Main method: " + mm);
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   270
            createJavaFile(mm);
15003
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   271
            createFile(ManifestFile, createManifestContents(StdMainClass, fxMC));
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   272
            createJar(FXtestJar, ManifestFile);
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   273
            String sTestJar = FXtestJar.getAbsolutePath();
50090
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   274
            String launchMode;
37540
e92d95400f31 8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents: 30371
diff changeset
   275
            final TestResult tr;
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   276
            if (useCP) {
50090
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   277
                tr = doFxExec(javaCmd, "-cp", sTestJar, StdMainClass, APP_PARMS[0], APP_PARMS[1]);
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   278
                launchMode = LAUNCH_MODE_CLASS;
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   279
            } else {
50090
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   280
                tr = doFxExec(javaCmd, "-jar", sTestJar, APP_PARMS[0], APP_PARMS[1]);
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   281
                launchMode = LAUNCH_MODE_JAR;
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   282
            }
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   283
            tr.checkPositive();
50090
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   284
            if (tr.testStatus) {
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   285
                if (!tr.contains(launchMode)) {
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   286
                    System.err.println("ERROR: Did not find "
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   287
                            + launchMode + " in output!");
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   288
                }
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   289
                for (String p : APP_PARMS) {
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   290
                    if (!tr.contains(p)) {
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   291
                        System.err.println("ERROR: Did not find "
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   292
                                + p + " in output!");
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   293
                    }
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   294
                }
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   295
            }
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   296
            checkStatus(tr, testname, testcount, StdMainClass);
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   297
        }
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   298
    }
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   299
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   300
    /*
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   301
     * Set Main-Class and iterate main methods.
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   302
     * Main class extends another class that extends Application.
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   303
     * Try launching with both -jar and -cp methods.
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   304
     * All cases should run.
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   305
     */
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   306
    @Test
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   307
    static void testExtendFXApp() throws Exception {
15003
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   308
        testExtendFXApp(true, false);   // -cp, no JAC
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   309
        testExtendFXApp(false, true);   // -jar, with JAC
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   310
        testExtendFXApp(false, false);  // -jar, no JAC
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   311
    }
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   312
15003
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   313
    static void testExtendFXApp(boolean useCP, boolean setFXMainClass) throws Exception {
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   314
        String testname = "testExtendFXApp";
15003
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   315
        if (useCP) {
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   316
            testname = testname.concat("_useCP");
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   317
        }
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   318
        String fxMC = ExtMainClass;
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   319
        if (!setFXMainClass) {
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   320
            testname = testname.concat("_noJAC");
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   321
            fxMC = null;
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   322
        }
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   323
        for (String mm : MAIN_METHODS) {
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   324
            testcount++;
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   325
            line();
15003
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   326
            System.out.println("test# " + testcount + "-  Main method: " + mm);
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   327
            createJavaFile(mm);
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   328
            createExtJavaFile(mm);
15003
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   329
            createFile(ManifestFile, createManifestContents(ExtMainClass, fxMC));
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   330
            createJar(FXtestJar, ManifestFile);
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   331
            String sTestJar = FXtestJar.getAbsolutePath();
50090
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   332
            String launchMode;
37540
e92d95400f31 8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents: 30371
diff changeset
   333
            final TestResult tr;
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   334
            if (useCP) {
50090
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   335
                tr = doFxExec(javaCmd, "-cp", sTestJar, ExtMainClass, APP_PARMS[0], APP_PARMS[1]);
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   336
                launchMode = LAUNCH_MODE_CLASS;
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   337
            } else {
50090
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   338
                tr = doFxExec(javaCmd, "-jar", sTestJar, APP_PARMS[0], APP_PARMS[1]);
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   339
                launchMode = LAUNCH_MODE_JAR;
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   340
            }
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   341
            tr.checkPositive();
50090
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   342
            if (tr.testStatus) {
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   343
                if (!tr.contains(launchMode)) {
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   344
                    System.err.println("ERROR: Did not find "
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   345
                            + launchMode + " in output!");
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   346
                }
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   347
                for (String p : APP_PARMS) {
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   348
                    if (!tr.contains(p)) {
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   349
                        System.err.println("ERROR: Did not find "
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   350
                                + p + " in output!");
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   351
                    }
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   352
                }
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   353
            }
15003
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   354
            checkStatus(tr, testname, testcount, ExtMainClass);
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   355
        }
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   356
    }
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   357
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   358
    /*
15003
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   359
     * Ensure we can NOT launch a FX app jar with no Main-Class manifest entry
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   360
     */
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   361
    @Test
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   362
    static void testMissingMC() throws Exception {
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   363
        String testname = "testMissingMC";
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   364
        testcount++;
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   365
        line();
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   366
        System.out.println("test# " + testcount + ": abort on missing Main-Class");
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   367
        createJavaFile(" "); // no main() needed
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   368
        createFile(ManifestFile, createManifestContents(null, StdMainClass)); // No MC, but supply JAC
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   369
        createJar(FXtestJar, ManifestFile);
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   370
        String sTestJar = FXtestJar.getAbsolutePath();
50090
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   371
        TestResult tr = doFxExec(javaCmd, "-jar", sTestJar, APP_PARMS[0], APP_PARMS[1]);
15003
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   372
        tr.checkNegative(); // should abort if no Main-Class
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   373
        if (tr.testStatus) {
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   374
            if (!tr.contains("no main manifest attribute")) {
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   375
                System.err.println("ERROR: launcher did not abort properly");
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   376
            }
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   377
        } else {
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   378
            System.err.println("ERROR: jar executed with no Main-Class!");
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   379
        }
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   380
        checkStatus(tr, testname, testcount, StdMainClass);
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   381
    }
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   382
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   383
    /*
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   384
     * test to ensure that we don't load any extraneous fx jars when
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   385
     * launching a standard java application
15003
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   386
     * Test both -cp and -jar methods since they use different code paths.
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   387
     * Neither case should cause jfxrt.jar to be loaded.
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   388
     */
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   389
    @Test
15003
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   390
    static void testExtraneousJars() throws Exception {
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   391
        testExtraneousJars(true);
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   392
        testExtraneousJars(false);
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   393
    }
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   394
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   395
    static void testExtraneousJars(boolean useCP) throws Exception {
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   396
        String testname = "testExtraneousJars";
15003
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   397
        if (useCP) {
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   398
            testname = testname.concat("_useCP");
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   399
        }
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   400
        testcount++;
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   401
        line();
15003
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   402
        System.out.println("test# " + testcount
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   403
                + ": test for erroneous jfxrt.jar loading");
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   404
        createNonFXJavaFile();
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   405
        createFile(ManifestFile, createManifestContents(NonFXMainClass, null));
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   406
        createJar(FXtestJar, ManifestFile);
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   407
        String sTestJar = FXtestJar.getAbsolutePath();
37540
e92d95400f31 8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents: 30371
diff changeset
   408
        final TestResult tr;
15003
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   409
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   410
        if (useCP) {
50090
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   411
            tr = doFxExec(javaCmd, "-verbose:class", "-cp", sTestJar, NonFXMainClass, APP_PARMS[0], APP_PARMS[1]);
15003
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   412
        } else {
50090
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   413
            tr = doFxExec(javaCmd, "-verbose:class", "-jar", sTestJar, APP_PARMS[0], APP_PARMS[1]);
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   414
        }
15003
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   415
        tr.checkPositive();
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   416
        if (tr.testStatus) {
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   417
            if (!tr.notContains("jfxrt.jar")) {
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   418
                System.out.println("testing for extraneous jfxrt jar");
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   419
                System.out.println(tr);
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   420
                throw new Exception("jfxrt.jar is being loaded, it should not be!");
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   421
            }
24254
2da866863b98 8035782: sun/launcher/LauncherHelper$FXHelper loaded unnecessarily
ksrini
parents: 20201
diff changeset
   422
            if (!tr.notContains("sun.launcher.LauncherHelper$FXHelper")) {
2da866863b98 8035782: sun/launcher/LauncherHelper$FXHelper loaded unnecessarily
ksrini
parents: 20201
diff changeset
   423
                System.out.println("testing for extraneous 'sun.launcher.LauncherHelper$FXHelper'");
2da866863b98 8035782: sun/launcher/LauncherHelper$FXHelper loaded unnecessarily
ksrini
parents: 20201
diff changeset
   424
                System.out.println(tr);
2da866863b98 8035782: sun/launcher/LauncherHelper$FXHelper loaded unnecessarily
ksrini
parents: 20201
diff changeset
   425
                throw new Exception("FXHelper is being loaded, it should not be!");
2da866863b98 8035782: sun/launcher/LauncherHelper$FXHelper loaded unnecessarily
ksrini
parents: 20201
diff changeset
   426
            }
15003
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   427
            for (String p : APP_PARMS) {
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   428
                if (!tr.contains(p)) {
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   429
                    System.err.println("ERROR: Did not find "
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   430
                            + p + " in output!");
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   431
                }
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   432
            }
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   433
        }
364408faddeb 8004547: Extend JavaFX launcher support to allow full JavaFX launch feature set
ksrini
parents: 14519
diff changeset
   434
        checkStatus(tr, testname, testcount, NonFXMainClass);
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   435
    }
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   436
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   437
    public static void main(String... args) throws Exception {
50090
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   438
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   439
        // Ensure that FX is not part of jdk
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   440
        Class<?> fxClass = null;
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   441
        try {
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   442
            fxClass = Class.forName(FX_MARKER_CLASS);
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   443
        } catch (ClassNotFoundException ex) {
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   444
            // do nothing
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   445
        }
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   446
        if (fxClass != null) {
50090
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   447
            throw new RuntimeException("JavaFX modules erroneously included in the JDK");
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   448
        }
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   449
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   450
        FXLauncherTest fxt = new FXLauncherTest();
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   451
        fxt.run(args);
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   452
        if (testExitValue > 0) {
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   453
            System.out.println("Total of " + testExitValue
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   454
                    + " failed. Test cases covered: "
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   455
                    + FXLauncherTest.testcount);
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   456
            System.exit(1);
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   457
        } else {
50090
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   458
            System.out.println("All tests pass. Test cases covered: "
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   459
                    + FXLauncherTest.testcount);
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   460
        }
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   461
    }
50090
94e11b6edcdd 8202553: Update FXLauncherTest as part of removing JavaFX from JDK
kcr
parents: 48522
diff changeset
   462
14519
73d8a1fdacd6 8003660: (launcher) 8001533 regression tests
ksrini
parents:
diff changeset
   463
}