8232186 : Add verification for pkg and dmg tests JDK-8200758-branch
authorherrick
Thu, 31 Oct 2019 11:18:41 -0400
branchJDK-8200758-branch
changeset 58888 d802578912f3
parent 58887 920f6770d71c
child 58889 f04c0704a006
8232186 : Add verification for pkg and dmg tests Submitted-by: almatvee Reviewed-by: aherrick, asemenyuk
src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacAppBundler.java
src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacAppImageBuilder.java
src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/resources/Info-lite.plist.template
src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java
src/jdk.jpackage/share/classes/jdk/jpackage/internal/ValidOptions.java
test/jdk/tools/jpackage/apps/image/Hello.java
test/jdk/tools/jpackage/helpers/JPackageHelper.java
test/jdk/tools/jpackage/helpers/jdk/jpackage/test/FileAssociations.java
test/jdk/tools/jpackage/helpers/jdk/jpackage/test/HelloApp.java
test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacHelper.java
test/jdk/tools/jpackage/helpers/jdk/jpackage/test/PackageTest.java
test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TKit.java
test/jdk/tools/jpackage/linux/ShortcutHintTest.java
test/jdk/tools/jpackage/macosx/NameWithSpaceTest.java
test/jdk/tools/jpackage/macosx/SigningPackageTest.java
test/jdk/tools/jpackage/macosx/base/OptionsBase.java
test/jdk/tools/jpackage/macosx/dmg/OptionsTest.java
test/jdk/tools/jpackage/macosx/dmg/install.sh
test/jdk/tools/jpackage/macosx/dmg/uninstall.sh
test/jdk/tools/jpackage/macosx/pkg/OptionsTest.java
test/jdk/tools/jpackage/macosx/pkg/install.sh
test/jdk/tools/jpackage/macosx/pkg/uninstall.sh
test/jdk/tools/jpackage/manage_packages.sh
test/jdk/tools/jpackage/share/AddLaunchersTest.java
test/jdk/tools/jpackage/share/AdditionalLaunchersTest.java
test/jdk/tools/jpackage/share/FileAssociationsTest.java
test/jdk/tools/jpackage/share/InstallDirTest.java
test/jdk/tools/jpackage/share/jdk/jpackage/tests/BasicTest.java
--- a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacAppBundler.java	Thu Oct 31 11:11:42 2019 -0400
+++ b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacAppBundler.java	Thu Oct 31 11:18:41 2019 -0400
@@ -44,64 +44,6 @@
 
     private static final String TEMPLATE_BUNDLE_ICON = "java.icns";
 
-    public static Map<String, String> getMacCategories() {
-        Map<String, String> map = new HashMap<>();
-        map.put("Business", "public.app-category.business");
-        map.put("Developer Tools", "public.app-category.developer-tools");
-        map.put("Education", "public.app-category.education");
-        map.put("Entertainment", "public.app-category.entertainment");
-        map.put("Finance", "public.app-category.finance");
-        map.put("Games", "public.app-category.games");
-        map.put("Graphics & Design", "public.app-category.graphics-design");
-        map.put("Healthcare & Fitness",
-                "public.app-category.healthcare-fitness");
-        map.put("Lifestyle", "public.app-category.lifestyle");
-        map.put("Medical", "public.app-category.medical");
-        map.put("Music", "public.app-category.music");
-        map.put("News", "public.app-category.news");
-        map.put("Photography", "public.app-category.photography");
-        map.put("Productivity", "public.app-category.productivity");
-        map.put("Reference", "public.app-category.reference");
-        map.put("Social Networking", "public.app-category.social-networking");
-        map.put("Sports", "public.app-category.sports");
-        map.put("Travel", "public.app-category.travel");
-        map.put("Utilities", "public.app-category.utilities");
-        map.put("Video", "public.app-category.video");
-        map.put("Weather", "public.app-category.weather");
-
-        map.put("Action Games", "public.app-category.action-games");
-        map.put("Adventure Games", "public.app-category.adventure-games");
-        map.put("Arcade Games", "public.app-category.arcade-games");
-        map.put("Board Games", "public.app-category.board-games");
-        map.put("Card Games", "public.app-category.card-games");
-        map.put("Casino Games", "public.app-category.casino-games");
-        map.put("Dice Games", "public.app-category.dice-games");
-        map.put("Educational Games", "public.app-category.educational-games");
-        map.put("Family Games", "public.app-category.family-games");
-        map.put("Kids Games", "public.app-category.kids-games");
-        map.put("Music Games", "public.app-category.music-games");
-        map.put("Puzzle Games", "public.app-category.puzzle-games");
-        map.put("Racing Games", "public.app-category.racing-games");
-        map.put("Role Playing Games", "public.app-category.role-playing-games");
-        map.put("Simulation Games", "public.app-category.simulation-games");
-        map.put("Sports Games", "public.app-category.sports-games");
-        map.put("Strategy Games", "public.app-category.strategy-games");
-        map.put("Trivia Games", "public.app-category.trivia-games");
-        map.put("Word Games", "public.app-category.word-games");
-
-        return map;
-    }
-
-    public static final EnumeratedBundlerParam<String> MAC_CATEGORY =
-            new EnumeratedBundlerParam<>(
-                    Arguments.CLIOptions.MAC_APP_STORE_CATEGORY.getId(),
-                    String.class,
-                    params -> "Unknown",
-                    (s, p) -> s,
-                    getMacCategories(),
-                    false //strict - for MacStoreBundler this should be strict
-            );
-
     public static final BundlerParamInfo<String> MAC_CF_BUNDLE_NAME =
             new StandardBundlerParam<>(
                     Arguments.CLIOptions.MAC_BUNDLE_NAME.getId(),
--- a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacAppImageBuilder.java	Thu Oct 31 11:11:42 2019 -0400
+++ b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacAppImageBuilder.java	Thu Oct 31 11:18:41 2019 -0400
@@ -92,16 +92,6 @@
                     params -> Boolean.FALSE,
                     (s, p) -> Boolean.valueOf(s));
 
-    public static final EnumeratedBundlerParam<String> MAC_CATEGORY =
-            new EnumeratedBundlerParam<>(
-                    Arguments.CLIOptions.MAC_APP_STORE_CATEGORY.getId(),
-                    String.class,
-                    params -> "Unknown",
-                    (s, p) -> s,
-                    MacAppBundler.getMacCategories(),
-                    false //strict - for MacStoreBundler this should be strict
-            );
-
     public static final BundlerParamInfo<String> MAC_CF_BUNDLE_NAME =
             new StandardBundlerParam<>(
                     Arguments.CLIOptions.MAC_BUNDLE_NAME.getId(),
@@ -470,7 +460,6 @@
         data.put("DEPLOY_BUNDLE_CFBUNDLE_VERSION",
                 MAC_CF_BUNDLE_VERSION.fetchFrom(params) != null ?
                 MAC_CF_BUNDLE_VERSION.fetchFrom(params) : "100");
-        data.put("DEPLOY_BUNDLE_CATEGORY", MAC_CATEGORY.fetchFrom(params));
 
         boolean hasMainJar = MAIN_JAR.fetchFrom(params) != null;
         boolean hasMainModule =
--- a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/resources/Info-lite.plist.template	Thu Oct 31 11:11:42 2019 -0400
+++ b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/resources/Info-lite.plist.template	Thu Oct 31 11:18:41 2019 -0400
@@ -26,7 +26,7 @@
   <string>????</string>
   <!-- See https://developer.apple.com/app-store/categories/ for list of AppStore categories -->
   <key>LSApplicationCategoryType</key>
-  <string>DEPLOY_BUNDLE_CATEGORY</string>
+  <string>Unknown</string>
   <key>CFBundleVersion</key>
   <string>DEPLOY_BUNDLE_CFBUNDLE_VERSION</string>
   <key>NSHumanReadableCopyright</key>
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java	Thu Oct 31 11:11:42 2019 -0400
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java	Thu Oct 31 11:18:41 2019 -0400
@@ -272,9 +272,6 @@
         MAC_BUNDLE_IDENTIFIER("mac-package-identifier",
                     OptionCategories.PLATFORM_MAC),
 
-        MAC_APP_STORE_CATEGORY ("mac-app-store-category",
-                    OptionCategories.PLATFORM_MAC),
-
         MAC_BUNDLE_SIGNING_PREFIX ("mac-package-signing-prefix",
                     OptionCategories.PLATFORM_MAC),
 
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/ValidOptions.java	Thu Oct 31 11:11:42 2019 -0400
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/ValidOptions.java	Thu Oct 31 11:18:41 2019 -0400
@@ -112,7 +112,6 @@
                     USE.ALL);
             options.put(CLIOptions.MAC_SIGNING_KEY_NAME.getId(), USE.ALL);
             options.put(CLIOptions.MAC_SIGNING_KEYCHAIN.getId(), USE.ALL);
-            options.put(CLIOptions.MAC_APP_STORE_CATEGORY.getId(), USE.ALL);
             options.put(CLIOptions.MAC_APP_STORE_ENTITLEMENTS.getId(),
                     USE.ALL);
         }
--- a/test/jdk/tools/jpackage/apps/image/Hello.java	Thu Oct 31 11:11:42 2019 -0400
+++ b/test/jdk/tools/jpackage/apps/image/Hello.java	Thu Oct 31 11:18:41 2019 -0400
@@ -21,39 +21,157 @@
  * questions.
  */
 
-import java.io.BufferedOutputStream;
-import java.io.FileOutputStream;
-import java.io.PrintStream;
+import java.awt.AWTError;
+import java.awt.Desktop;
+import java.awt.GraphicsEnvironment;
+import java.awt.desktop.OpenFilesEvent;
+import java.awt.desktop.OpenFilesHandler;
+import java.io.File;
 import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.nio.file.Path;
+import java.nio.file.Files;
+import java.util.stream.Collectors;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.stream.Stream;
+import java.util.Collections;
 
-public class Hello {
+public class Hello implements OpenFilesHandler {
+
+    public static void main(String[] args) throws IOException, InterruptedException {
+        var faFiles = getFaFiles();
+        if (faFiles != null) {
+            // Some files got opened through fa mechanizm.
+            // They are the arguments then.
+            args = faFiles.toArray(String[]::new);
+        }
+
+        var lines = printArgs(args);
+
+        lines.forEach(System.out::println);
+
+        var outputFile = getOutputFile(args);
+        trace(String.format("Output file: [%s]", outputFile));
+        Files.write(outputFile, lines);
+    }
+
+    private static List<String> printArgs(String[] args) {
+        List<String> lines = new ArrayList<>();
+        lines.add(MSG);
+
+        lines.add("args.length: " + args.length);
+
+        lines.addAll(List.of(args));
+
+        for (int index = 1; index <= EXPECTED_NUM_OF_PARAMS; index++) {
+            String value = System.getProperty("param" + index);
+            if (value != null) {
+                lines.add("-Dparam" + index + "=" + value);
+            }
+        }
+
+        return lines;
+    }
+
+    private static Path getOutputFile(String[] args) {
+        Path outputFilePath = Path.of("appOutput.txt");
+
+        // If first arg is a file (most likely from fa), then put output in the same folder as
+        // the file from fa.
+        if (args.length >= 1) {
+            Path faPath = Path.of(args[0]);
+            if (Files.exists(faPath)) {
+                return faPath.toAbsolutePath().getParent().resolve(outputFilePath);
+            }
+        }
+
+        try {
+            // Try writing in the default output file.
+            Files.write(outputFilePath, Collections.emptyList());
+            return outputFilePath;
+        } catch (IOException ex) {
+            // Log reason of a failure.
+            StringWriter errors = new StringWriter();
+            ex.printStackTrace(new PrintWriter(errors));
+            Stream.of(errors.toString().split("\\R")).forEachOrdered(Hello::trace);
+        }
+
+        return Path.of(System.getProperty("user.home")).resolve(outputFilePath);
+    }
+
+    @Override
+    public void openFiles(OpenFilesEvent e) {
+        synchronized(lock) {
+            trace("openFiles");
+            files = e.getFiles().stream()
+                .map(File::toString)
+                .collect(Collectors.toList());
+
+            lock.notifyAll();
+        }
+    }
+
+    private static List<String> getFaFiles() throws InterruptedException {
+        if (openFilesHandler == null) {
+            return null;
+        }
+
+        synchronized(openFilesHandler.lock) {
+            trace("getFaFiles: wait");
+            openFilesHandler.lock.wait(1000);
+            if (openFilesHandler.files == null) {
+                trace(String.format("getFaFiles: no files"));
+                return null;
+            }
+            // Return copy of `files` to keep access to `files` field synchronized.
+            trace(String.format("getFaFiles: file count %d",
+                    openFilesHandler.files.size()));
+            return new ArrayList<>(openFilesHandler.files);
+        }
+    }
+
+    private List<String> files;
+    private final Object lock = new Object();
+    private final static Hello openFilesHandler = createInstance();
+
+    private static Hello createInstance() {
+        if (GraphicsEnvironment.isHeadless()) {
+            return null;
+        }
+
+        trace("Environment supports a display");
+
+        try {
+            // Disable JAB.
+            // Needed to suppress error:
+            // Exception in thread "main" java.awt.AWTError: Assistive Technology not found: com.sun.java.accessibility.AccessBridge
+            System.setProperty("javax.accessibility.assistive_technologies", "");
+        } catch (SecurityException ex) {
+            ex.printStackTrace();
+        }
+
+        try {
+            var desktop = Desktop.getDesktop();
+            if (desktop.isSupported(Desktop.Action.APP_OPEN_FILE)) {
+                trace("Set file handler");
+                Hello instance = new Hello();
+                desktop.setOpenFileHandler(instance);
+                return instance;
+            }
+        } catch (AWTError ex) {
+            trace("Set file handler failed");
+            ex.printStackTrace();
+        }
+
+        return null;
+    }
 
     private static final String MSG = "jpackage test application";
     private static final int EXPECTED_NUM_OF_PARAMS = 3; // Starts at 1
 
-    public static void main(String[] args) throws IOException {
-        printArgs(args, System.out);
-
-        try (PrintStream out = new PrintStream(new BufferedOutputStream(
-                new FileOutputStream("appOutput.txt")))) {
-            printArgs(args, out);
-        }
-    }
-
-    private static void printArgs(String[] args, PrintStream out) {
-        out.println(MSG);
-
-        out.println("args.length: " + args.length);
-
-        for (String arg : args) {
-            out.println(arg);
-        }
-
-        for (int index = 1; index <= EXPECTED_NUM_OF_PARAMS; index++) {
-            String value = System.getProperty("param" + index);
-            if (value != null) {
-                out.println("-Dparam" + index + "=" + value);
-            }
-        }
+    private static void trace(String msg) {
+        System.out.println("hello: " + msg);
     }
 }
--- a/test/jdk/tools/jpackage/helpers/JPackageHelper.java	Thu Oct 31 11:11:42 2019 -0400
+++ b/test/jdk/tools/jpackage/helpers/JPackageHelper.java	Thu Oct 31 11:18:41 2019 -0400
@@ -34,7 +34,8 @@
 import java.nio.file.attribute.BasicFileAttributes;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Arrays;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 import java.util.spi.ToolProvider;
 
@@ -569,21 +570,11 @@
             return null;
         }
 
-        String[] result = output.split("\n");
-        if (result == null || result.length == 0) {
-            return result;
-        }
-
-        List<String> origList = new ArrayList(Arrays.asList(result));
-        List<String> newlist = new ArrayList();
-        origList.stream().filter((str) ->
-                (!str.startsWith("Picked up") &&
-                 !str.startsWith("WARNING: Using experimental")))
-                .forEachOrdered((str) -> {
-            newlist.add(str);
-        });
-
-        return newlist.toArray(new String[newlist.size()]);
+        return Stream.of(output.split("\\R"))
+                .filter(str -> !str.startsWith("Picked up"))
+                .filter(str -> !str.startsWith("WARNING: Using experimental"))
+                .filter(str -> !str.startsWith("hello: "))
+                .collect(Collectors.toList()).toArray(String[]::new);
     }
 
     private static String quote(String in, boolean toolProvider) {
--- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/FileAssociations.java	Thu Oct 31 11:11:42 2019 -0400
+++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/FileAssociations.java	Thu Oct 31 11:18:41 2019 -0400
@@ -34,7 +34,7 @@
         setDescription("jpackage test extention");
     }
 
-    public void createFile() {
+    private void createFile() {
         Map<String, String> entries = new HashMap<>(Map.of(
             "extension", suffixName,
             "mime-type", getMime(),
@@ -65,18 +65,28 @@
         return this;
     }
 
-    public Path getPropertiesFile() {
+    Path getPropertiesFile() {
         return file;
     }
 
-    public String getSuffix() {
+    String getSuffix() {
         return "." + suffixName;
     }
 
-    public String getMime() {
+    String getMime() {
         return "application/x-jpackage-" + suffixName;
     }
 
+    public void applyTo(PackageTest test) {
+        test.notForTypes(PackageType.MAC_DMG, () -> {
+            test.addInitializer(cmd -> {
+                createFile();
+                cmd.addArguments("--file-associations", getPropertiesFile());
+            });
+            test.addHelloAppFileAssociationsVerifier(this);
+        });
+    }
+
     private Path file;
     final private String suffixName;
     private String description;
--- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/HelloApp.java	Thu Oct 31 11:11:42 2019 -0400
+++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/HelloApp.java	Thu Oct 31 11:18:41 2019 -0400
@@ -63,6 +63,7 @@
             TKit.createTextFile(moduleInfoFile, List.of(
                     String.format("module %s {", moduleName),
                     String.format("    exports %s;", packageName),
+                    "    requires java.desktop;",
                     "}"
             ));
             jarBuilder.addSourceFile(moduleInfoFile);
@@ -72,7 +73,9 @@
         // Add package directive and replace class name in java source file.
         // Works with simple test Hello.java.
         // Don't expect too much from these regexps!
-        Pattern classDeclaration = Pattern.compile("(^.*\\bclass\\s+)Hello(.*$)");
+        Pattern classNameRegex = Pattern.compile("\\bHello\\b");
+        Pattern classDeclaration = Pattern.compile(
+                "(^.*\\bclass\\s+)\\bHello\\b(.*$)");
         Pattern importDirective = Pattern.compile(
                 "(?<=import (?:static )?+)[^;]+");
         AtomicBoolean classDeclared = new AtomicBoolean();
@@ -85,11 +88,14 @@
         });
 
         Files.write(srcFile, Files.readAllLines(HELLO_JAVA).stream().map(line -> {
+            Matcher m;
             if (classDeclared.getPlain()) {
+                if ((m = classNameRegex.matcher(line)).find()) {
+                    line = m.replaceAll(className);
+                }
                 return line;
             }
 
-            Matcher m;
             if (!packageInserted.getPlain() && importDirective.matcher(line).find()) {
                 line = packageInserter.apply(line);
             } else if ((m = classDeclaration.matcher(line)).find()) {
@@ -214,6 +220,7 @@
         new Executor()
                 .setDirectory(outputFile.getParent())
                 .setExecutable(helloAppLauncher)
+                .dumpOutput()
                 .execute()
                 .assertExitCodeIsZero();
 
--- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacHelper.java	Thu Oct 31 11:11:42 2019 -0400
+++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacHelper.java	Thu Oct 31 11:18:41 2019 -0400
@@ -94,9 +94,8 @@
 
     static Path getInstallationDirectory(JPackageCommand cmd) {
         cmd.verifyIsOfType(PackageType.MAC);
-        String installDir = Path.of(cmd.getArgumentValue("--install-dir",
-                () -> ""), cmd.name()).toString() + ".app";
-        return Path.of("/Applications", installDir);
+        return Path.of(cmd.getArgumentValue("--install-dir", () -> "/Applications"))
+                .resolve(cmd.name() + ".app");
     }
 
     private static String getPackageName(JPackageCommand cmd) {
--- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/PackageTest.java	Thu Oct 31 11:11:42 2019 -0400
+++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/PackageTest.java	Thu Oct 31 11:18:41 2019 -0400
@@ -23,12 +23,14 @@
 package jdk.jpackage.test;
 
 import java.awt.Desktop;
+import java.awt.GraphicsEnvironment;
 import java.io.File;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.*;
 import java.util.function.BiConsumer;
 import java.util.function.Consumer;
+import java.util.function.Predicate;
 import java.util.function.Supplier;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
@@ -56,6 +58,7 @@
      */
     public PackageTest() {
         action = DEFAULT_ACTION;
+        excludeTypes = new HashSet<>();
         forTypes();
         setExpectedExitCode(0);
         handlers = new HashMap<>();
@@ -63,15 +66,26 @@
         currentTypes.forEach(v -> handlers.put(v, new Handler(v)));
     }
 
+    public PackageTest excludeTypes(PackageType... types) {
+        excludeTypes.addAll(Stream.of(types).collect(Collectors.toSet()));
+        return forTypes(currentTypes);
+    }
+
+    public PackageTest excludeTypes(Collection<PackageType> types) {
+        return excludeTypes(types.toArray(PackageType[]::new));
+    }
+
     public PackageTest forTypes(PackageType... types) {
         Collection<PackageType> newTypes;
         if (types == null || types.length == 0) {
             newTypes = PackageType.NATIVE;
         } else {
-            newTypes = Set.of(types);
+            newTypes = Stream.of(types).collect(Collectors.toSet());
         }
-        currentTypes = newTypes.stream().filter(type -> type.isSupported()).collect(
-                Collectors.toUnmodifiableSet());
+        currentTypes = newTypes.stream()
+                .filter(PackageType::isSupported)
+                .filter(Predicate.not(excludeTypes::contains))
+                .collect(Collectors.toUnmodifiableSet());
         return this;
     }
 
@@ -79,6 +93,16 @@
         return forTypes(types.toArray(PackageType[]::new));
     }
 
+    public PackageTest notForTypes(PackageType... types) {
+        return notForTypes(List.of(types));
+    }
+
+    public PackageTest notForTypes(Collection<PackageType> types) {
+        Set<PackageType> workset = new HashSet<>(currentTypes);
+        workset.removeAll(types);
+        return forTypes(workset);
+    }
+
     public PackageTest setExpectedExitCode(int v) {
         expectedJPackageExitCode = v;
         return this;
@@ -163,19 +187,30 @@
         });
     }
 
-    public PackageTest addHelloAppFileAssociationsVerifier(FileAssociations fa,
+    PackageTest addHelloAppFileAssociationsVerifier(FileAssociations fa,
             String... faLauncherDefaultArgs) {
 
+        // Setup test app to have valid jpackage command line before
+        // running check of type of environment.
         addInitializer(cmd -> new HelloApp(null).addTo(cmd), "HelloApp");
+
+        String noActionMsg = "Not running file associations test";
+        if (GraphicsEnvironment.isHeadless()) {
+            TKit.trace(String.format(
+                    "%s because running in headless environment", noActionMsg));
+            return this;
+        }
+
         addInstallVerifier(cmd -> {
-            if (cmd.isFakeRuntime("Not running file associations test")) {
+            if (cmd.isFakeRuntime(noActionMsg)) {
                 return;
             }
 
             withTestFileAssociationsFile(fa, testFile -> {
                 testFile = testFile.toAbsolutePath().normalize();
 
-                final Path appOutput = Path.of(HelloApp.OUTPUT_FILENAME);
+                final Path appOutput = testFile.getParent()
+                        .resolve(HelloApp.OUTPUT_FILENAME);
                 Files.deleteIfExists(appOutput);
 
                 TKit.trace(String.format("Use desktop to open [%s] file",
@@ -217,6 +252,16 @@
         return forTypes(List.of(type), action);
     }
 
+    PackageTest notForTypes(Collection<PackageType> types, Runnable action) {
+        Set<PackageType> workset = new HashSet<>(currentTypes);
+        workset.removeAll(types);
+        return forTypes(workset, action);
+    }
+
+    PackageTest notForTypes(PackageType type, Runnable action) {
+        return notForTypes(List.of(type), action);
+    }
+
     public PackageTest configureHelloApp() {
         return configureHelloApp(null);
     }
@@ -381,6 +426,7 @@
     }
 
     private Collection<PackageType> currentTypes;
+    private Set<PackageType> excludeTypes;
     private int expectedJPackageExitCode;
     private Map<PackageType, Handler> handlers;
     private Set<String> namedInitializers;
--- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TKit.java	Thu Oct 31 11:11:42 2019 -0400
+++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TKit.java	Thu Oct 31 11:18:41 2019 -0400
@@ -469,7 +469,8 @@
     static void waitForFileCreated(Path fileToWaitFor,
             long timeoutSeconds) throws IOException {
 
-        trace(String.format("Wait for file [%s] to be available", fileToWaitFor));
+        trace(String.format("Wait for file [%s] to be available",
+                                                fileToWaitFor.toAbsolutePath()));
 
         WatchService ws = FileSystems.getDefault().newWatchService();
 
--- a/test/jdk/tools/jpackage/linux/ShortcutHintTest.java	Thu Oct 31 11:11:42 2019 -0400
+++ b/test/jdk/tools/jpackage/linux/ShortcutHintTest.java	Thu Oct 31 11:18:41 2019 -0400
@@ -114,14 +114,11 @@
      */
     @Test
     public static void testFileAssociations() {
-        createTest().addInitializer(cmd -> {
-            cmd.setFakeRuntime();
-
-            FileAssociations fa = new FileAssociations(
-                    "ShortcutHintTest_testFileAssociations");
-            fa.createFile();
-            cmd.addArguments("--file-associations", fa.getPropertiesFile());
-        }).run();
+        PackageTest test = createTest().addInitializer(
+                JPackageCommand::setFakeRuntime);
+        new FileAssociations("ShortcutHintTest_testFileAssociations").applyTo(
+                test);
+        test.run();
     }
 
     /**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/tools/jpackage/macosx/NameWithSpaceTest.java	Thu Oct 31 11:18:41 2019 -0400
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2018, 2019, 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.
+ */
+
+import jdk.jpackage.test.PackageTest;
+import jdk.jpackage.test.Annotations.Test;
+
+/**
+ * Name with space packaging test. Output of the test should be
+ * "Name With Space-*.*" package bundle.
+ *
+ * macOS only:
+ *
+ * Test should generates basic pkg and dmg. Name of packages and application itself
+ * should have name: "Name With Space". Package should be installed into "/Applications"
+ * folder and verified that it can be installed and run.
+ */
+
+/*
+ * @test
+ * @summary jpackage test with name containing spaces
+ * @library ../helpers
+ * @build jdk.jpackage.test.*
+ * @modules jdk.jpackage/jdk.jpackage.internal
+ * @compile NameWithSpaceTest.java
+ * @requires (os.family == "mac")
+ * @key jpackagePlatformPackage
+ * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main
+ *  --jpt-run=NameWithSpaceTest
+ */
+public class NameWithSpaceTest {
+
+    @Test
+    public static void test() {
+        new PackageTest()
+        .configureHelloApp()
+        .addBundleDesktopIntegrationVerifier(false)
+        .addInitializer(cmd -> {
+            cmd.setArgumentValue("--name", "Name With Space");
+        })
+        .run();
+    }
+}
--- a/test/jdk/tools/jpackage/macosx/SigningPackageTest.java	Thu Oct 31 11:11:42 2019 -0400
+++ b/test/jdk/tools/jpackage/macosx/SigningPackageTest.java	Thu Oct 31 11:18:41 2019 -0400
@@ -62,12 +62,11 @@
     }
 
     private static void verifyAppImageInDMG(JPackageCommand cmd) {
-        MacHelper.withExplodedDmg(cmd, disk -> {
-            Path appImageInDMG = disk.resolve(cmd.name() + ".app");
-            Path launcherPath = appImageInDMG.resolve(Path.of("Contents", "MacOS", cmd.name()));
+        MacHelper.withExplodedDmg(cmd, dmgImage -> {
+            Path launcherPath = dmgImage.resolve(Path.of("Contents", "MacOS", cmd.name()));
             SigningBase.verifyCodesign(launcherPath, true);
-            SigningBase.verifyCodesign(appImageInDMG, true);
-            SigningBase.verifySpctl(appImageInDMG, "exec");
+            SigningBase.verifyCodesign(dmgImage, true);
+            SigningBase.verifySpctl(dmgImage, "exec");
         });
     }
 
--- a/test/jdk/tools/jpackage/macosx/base/OptionsBase.java	Thu Oct 31 11:11:42 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,176 +0,0 @@
-/*
- * Copyright (c) 2019, 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.
- */
-
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamReader;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileReader;
-
-public class OptionsBase {
-
-    static final String TEST_BUNDLE_NAME = "TestBundleName";
-    static final String TEST_BUNDLE_IDENTIFIER = "net.java.openjdk.packagerTest";
-    static final String TEST_CATECORY = "public.app-category.test";
-    private static String TEST_NAME;
-    private static String EXT;
-    private static String OUTPUT;
-    private static String[] CMD;
-
-    private static void testCreateInstaller() throws Exception {
-        JPackageHelper.executeCLI(true, CMD);
-
-        if (EXT.equals("dmg")) {
-            String disk = null;
-            try {
-                var log = new File("hdiutil.log");
-                JPackageHelper.execute(log, "/usr/bin/hdiutil",
-                        "attach", OUTPUT);
-                try(var br = new BufferedReader(new FileReader(log))) {
-                    var line = br.lines().reduce((a, b) -> b).orElse(null)
-                            .split("\t");
-                    if ((line.length < 3) || !line[2].contains(TEST_NAME)) {
-                        throw new AssertionError(
-                                "expected attach output to contain test name: "
-                                + TEST_NAME);
-                    }
-                }
-            } finally {
-                if (disk != null) {
-                    JPackageHelper.execute(null,
-                            "/usr/bin/hdiutil", "detach", disk);
-                }
-            }
-        } else {
-            testPkg(OUTPUT);
-        }
-    }
-
-    private static void testPkg(String path) throws Exception {
-        JPackageHelper.execute(null, "/usr/sbin/pkgutil",
-                "--expand-full", path, "expand");
-        var info = new File("expand/" + TEST_NAME + "-app.pkg/Payload/"
-                + TEST_NAME + ".app/Contents/Info.plist");
-        if (!info.exists()) {
-            throw new AssertionError("Info.plist not found");
-        }
-
-        String bundleName = null;
-        String bundleIdentifier = null;
-        String categoryType = null;
-        try (FileInputStream fis = new FileInputStream(info)) {
-            var xmlInFact = XMLInputFactory.newInstance();
-            xmlInFact.setProperty(XMLInputFactory.SUPPORT_DTD, false);
-            xmlInFact.setProperty(
-                        XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false);
-            var reader = xmlInFact.createXMLStreamReader(fis);
-            while (reader.hasNext()) {
-                if (reader.next() == XMLStreamConstants.CHARACTERS) {
-                    switch (reader.getText()) {
-                        case "CFBundleName": {
-                            bundleName = readValue(reader);
-                            break;
-                        }
-                        case "CFBundleIdentifier" : {
-                            bundleIdentifier = readValue(reader);
-                            break;
-                        }
-                        case "LSApplicationCategoryType" : {
-                            categoryType = readValue(reader);
-                            break;
-                        }
-                    }
-                }
-            }
-        }
-        boolean passed = true;
-        if (!TEST_BUNDLE_NAME.equals(bundleName)) {
-            passed = false;
-            System.err.println("Wrong bundle name [" + bundleName +
-                    "] expected [" + TEST_BUNDLE_NAME + "]" );
-        }
-        if (!TEST_BUNDLE_IDENTIFIER.equals(bundleIdentifier)) {
-            passed = false;
-            System.err.println("Wrong bundle identifier [" +
-                    bundleIdentifier + "] expected [" + TEST_BUNDLE_IDENTIFIER
-                    + "]" );
-        }
-        if (!TEST_CATECORY.equals(categoryType)) {
-            passed = false;
-            System.err.println("Wrong appstore category [" + categoryType +
-                    "] expected [" + TEST_CATECORY + "]" );
-        }
-
-        if (!passed) {
-            throw new AssertionError("Test failed");
-        }
-    }
-
-    static private String readValue(XMLStreamReader reader) throws Exception {
-        while (reader.hasNext() && reader.next() != XMLStreamConstants.START_ELEMENT);
-        return reader.hasNext() ? reader.getElementText() : null;
-    }
-
-    private static void verifyInstall() throws Exception {
-        String app = JPackagePath.getOSXInstalledApp("jpackage", TEST_NAME);
-        JPackageInstallerHelper.validateApp(app);
-    }
-
-    private static void verifyUnInstall() throws Exception {
-        // Not needed on OS X, since we just deleting installed application
-        // without using generated installer. We keeping this for consistnency
-        // between platforms.
-    }
-
-    private static void init(String name, String ext) {
-        TEST_NAME = name;
-        EXT = ext;
-        OUTPUT = "output" + File.separator + TEST_NAME + "-1.0." + EXT;
-        CMD = new String[] {
-            "--package-type", EXT,
-            "--input", "input",
-            "--dest", "output",
-            "--name", TEST_NAME,
-            "--main-jar", "hello.jar",
-            "--main-class", "Hello",
-            "--mac-package-name", TEST_BUNDLE_NAME,
-            "--mac-package-identifier", TEST_BUNDLE_IDENTIFIER,
-            "--mac-app-store-category", TEST_CATECORY
-        };
-    }
-
-    public static void run(String name, String ext) throws Exception {
-        init(name, ext);
-
-        if (JPackageInstallerHelper.isVerifyInstall()) {
-            verifyInstall();
-        } else if (JPackageInstallerHelper.isVerifyUnInstall()) {
-            verifyUnInstall();
-        } else {
-            JPackageHelper.createHelloInstallerJar();
-            testCreateInstaller();
-        }
-    }
-}
--- a/test/jdk/tools/jpackage/macosx/dmg/OptionsTest.java	Thu Oct 31 11:11:42 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2019, 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
- * @summary jpackage create installer test
- * @library ../../helpers
- * @library ../base
- * @build JPackageHelper
- * @build JPackagePath
- * @build JPackageInstallerHelper
- * @build OptionsBase
- * @requires (os.family == "mac")
- * @modules jdk.jpackage
- * @modules jdk.jpackage/jdk.jpackage.internal
- * @run main/othervm -Xmx512m OptionsTest
- */
-public class OptionsTest {
-    private static final String TEST_NAME = "OptionsTest";
-    private static final String EXT = "dmg";
-
-    public static void main(String[] args) throws Exception {
-        if (jdk.jpackage.internal.MacDmgBundler.isSupported()) {
-            OptionsBase.run(TEST_NAME, EXT);
-        }
-    }
-}
--- a/test/jdk/tools/jpackage/macosx/dmg/install.sh	Thu Oct 31 11:11:42 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-echo "Note: This script will install DMG files silently. In order to verify UI, each .dmg needs to launched manually via Finder."
-
-# OptionsTest
-hdiutil attach OptionsTest-1.0.dmg
-sudo /usr/sbin/installer -pkg /Volumes/OptionsTest/OptionsTest-1.0.pkg -target /
-hdiutil detach /Volumes/OptionsTest/
--- a/test/jdk/tools/jpackage/macosx/dmg/uninstall.sh	Thu Oct 31 11:11:42 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-sudo rm -rf /Applications/OptionsTest.app
--- a/test/jdk/tools/jpackage/macosx/pkg/OptionsTest.java	Thu Oct 31 11:11:42 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2019, 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
- * @summary jpackage create installer test
- * @library ../../helpers
- * @library ../base
- * @build JPackageHelper
- * @build JPackagePath
- * @build JPackageInstallerHelper
- * @build OptionsBase
- * @requires (os.family == "mac")
- * @modules jdk.jpackage
- * @run main/othervm -Xmx512m OptionsTest
- */
-public class OptionsTest {
-    private static final String TEST_NAME = "OptionsTest";
-    private static final String EXT = "pkg";
-
-    public static void main(String[] args) throws Exception {
-        OptionsBase.run(TEST_NAME, EXT);
-    }
-}
--- a/test/jdk/tools/jpackage/macosx/pkg/install.sh	Thu Oct 31 11:11:42 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-echo Note: This script will install packages silently. In order to verify UI, each .pkg needs to launched manually via Finder.
-sudo /usr/sbin/installer -pkg OptionsTest-1.0.pkg -target /
--- a/test/jdk/tools/jpackage/macosx/pkg/uninstall.sh	Thu Oct 31 11:11:42 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-sudo rm -rf /Applications/OptionsDirTest.app
--- a/test/jdk/tools/jpackage/manage_packages.sh	Thu Oct 31 11:11:42 2019 -0400
+++ b/test/jdk/tools/jpackage/manage_packages.sh	Thu Oct 31 11:18:41 2019 -0400
@@ -64,6 +64,12 @@
   exit 1
 }
 
+# For macOS
+if !(type "tac" &> /dev/null;) then
+    tac_cmd='tail -r'
+else
+    tac_cmd=tac
+fi
 
 # Directory where to look for package files.
 package_dir=$PWD
@@ -101,10 +107,10 @@
 
 function find_packages ()
 {
-    local package_suffixes=(deb rpm msi exe)
+    local package_suffixes=(deb rpm msi exe pkg dmg)
     for suffix in "${package_suffixes[@]}"; do
         if [ "$mode" == "uninstall" ]; then
-            packages=$(find_packages_of_type $suffix | tac)
+            packages=$(find_packages_of_type $suffix | $tac_cmd)
         else
             packages=$(find_packages_of_type $suffix)
         fi
@@ -158,6 +164,45 @@
     error No implemented
 }
 
+# PKG
+install_cmd_pkg ()
+{
+    echo sudo /usr/sbin/installer -allowUntrusted -pkg "\"$@\"" -target /
+}
+uninstall_cmd_pkg ()
+{
+    local pname=`basename $@`
+    local appname="$(cut -d'-' -f1 <<<"$pname")"
+    if [ "$appname" = "CommonInstallDirTest" ]; then
+        echo sudo rm -rf "/Applications/jpackage/\"$appname.app\""
+    else
+        echo sudo rm -rf "/Applications/\"$appname.app\""
+    fi
+}
+
+# DMG
+install_cmd_dmg ()
+{
+    local pname=`basename $@`
+    local appname="$(cut -d'-' -f1 <<<"$pname")"
+    local command=()
+    if [ "$appname" = "CommonLicenseTest" ]; then
+        command+=("{" yes "|" hdiutil attach "\"$@\"" ">" /dev/null)
+    else
+        command+=("{" hdiutil attach "\"$@\"" ">" /dev/null)
+    fi
+
+    command+=(";" sudo cp -R "\"/Volumes/$appname/$appname.app\"" /Applications ">" /dev/null)
+    command+=(";" hdiutil detach "\"/Volumes/$appname\"" ">" /dev/null ";}")
+
+    echo "${command[@]}"
+}
+uninstall_cmd_dmg ()
+{
+    local pname=`basename $@`
+    local appname="$(cut -d'-' -f1 <<<"$pname")"
+    echo sudo rm -rf "/Applications/\"$appname.app\""
+}
 
 # Find packages
 packages=
@@ -169,6 +214,7 @@
 
 # Build list of commands to execute
 declare -a commands
+IFS=$'\n'
 for p in $packages; do
     commands[${#commands[@]}]=$(${mode}_cmd_${package_type} "$p")
 done
@@ -177,7 +223,7 @@
     # Run commands
     for cmd in "${commands[@]}"; do
         echo Running: $cmd
-        $cmd || true;
+        eval $cmd || true;
     done
 else
     # Print commands
--- a/test/jdk/tools/jpackage/share/AddLaunchersTest.java	Thu Oct 31 11:11:42 2019 -0400
+++ b/test/jdk/tools/jpackage/share/AddLaunchersTest.java	Thu Oct 31 11:18:41 2019 -0400
@@ -42,7 +42,7 @@
         "--main-jar", "hello.jar",
         "--main-class", "Hello",
         "--module-path", "module",
-        "--add-modules", "com.hello",
+        "--add-modules", "com.hello,java.desktop",
         "--add-launcher", "test3=j1.properties",
         "--add-launcher", "test4=m1.properties"};
 
--- a/test/jdk/tools/jpackage/share/AdditionalLaunchersTest.java	Thu Oct 31 11:11:42 2019 -0400
+++ b/test/jdk/tools/jpackage/share/AdditionalLaunchersTest.java	Thu Oct 31 11:18:41 2019 -0400
@@ -58,22 +58,19 @@
 
     @Test
     public void test() {
-        FileAssociations fa = new FileAssociations(
-                MethodHandles.lookup().lookupClass().getSimpleName());
-
         // Configure a bunch of additional launchers and also setup
         // file association to make sure it will be linked only to the main
         // launcher.
 
-        PackageTest packageTest = new PackageTest().configureHelloApp()
-        .addInitializer(cmd -> {
-            fa.createFile();
-            cmd.addArguments("--file-associations", fa.getPropertiesFile());
+        PackageTest packageTest = new PackageTest().configureHelloApp();
+        packageTest.addInitializer(cmd -> {
             cmd.addArguments("--arguments", "Duke", "--arguments", "is",
                     "--arguments", "the", "--arguments", "King");
         });
 
-        packageTest.addHelloAppFileAssociationsVerifier(fa);
+        new FileAssociations(
+                MethodHandles.lookup().lookupClass().getSimpleName()).applyTo(
+                packageTest);
 
         new AdditionalLauncher("Baz2").setArguments().applyTo(packageTest);
         new AdditionalLauncher("foo").setArguments("yep!").applyTo(packageTest);
@@ -93,6 +90,8 @@
         int lastDotIndex = fname.lastIndexOf(".");
         if (lastDotIndex != -1) {
             fname = newFileName + fname.substring(lastDotIndex);
+        } else {
+            fname = newFileName;
         }
         return path.getParent().resolve(fname);
     }
@@ -156,4 +155,4 @@
         private Path icon;
         private final String name;
     }
-}
+}
\ No newline at end of file
--- a/test/jdk/tools/jpackage/share/FileAssociationsTest.java	Thu Oct 31 11:11:42 2019 -0400
+++ b/test/jdk/tools/jpackage/share/FileAssociationsTest.java	Thu Oct 31 11:18:41 2019 -0400
@@ -24,6 +24,7 @@
 import java.nio.file.Path;
 import jdk.jpackage.test.TKit;
 import jdk.jpackage.test.PackageTest;
+import jdk.jpackage.test.PackageType;
 import jdk.jpackage.test.FileAssociations;
 import jdk.jpackage.test.Annotations.Test;
 
@@ -66,23 +67,21 @@
     public static void test() {
         PackageTest packageTest = new PackageTest();
 
-        applyFileAssociations(packageTest, new FileAssociations("jptest1"));
+        // Not supported
+        packageTest.excludeTypes(PackageType.MAC_DMG);
+
+        new FileAssociations("jptest1").applyTo(packageTest);
 
         Path icon = TKit.TEST_SRC_ROOT.resolve(Path.of("resources", "icon"
                 + TKit.ICON_SUFFIX));
 
         icon = TKit.createRelativePathCopy(icon);
 
-        applyFileAssociations(packageTest,
-                new FileAssociations("jptest2").setFilename("fa2").setIcon(icon));
+        new FileAssociations("jptest2")
+                .setFilename("fa2")
+                .setIcon(icon)
+                .applyTo(packageTest);
+
         packageTest.run();
     }
-
-    private static void applyFileAssociations(PackageTest test,
-            FileAssociations fa) {
-        test.addInitializer(cmd -> {
-            fa.createFile();
-            cmd.addArguments("--file-associations", fa.getPropertiesFile());
-        }).addHelloAppFileAssociationsVerifier(fa);
-    }
 }
--- a/test/jdk/tools/jpackage/share/InstallDirTest.java	Thu Oct 31 11:11:42 2019 -0400
+++ b/test/jdk/tools/jpackage/share/InstallDirTest.java	Thu Oct 31 11:18:41 2019 -0400
@@ -89,13 +89,12 @@
             reply.put(PackageType.LINUX_DEB, Path.of("/opt/jpackage"));
             reply.put(PackageType.LINUX_RPM, reply.get(PackageType.LINUX_DEB));
 
-            reply.put(PackageType.MAC_PKG, Path.of("/Application/jpackage"));
-            reply.put(PackageType.MAC_DMG, reply.get(PackageType.MAC_PKG));
+            reply.put(PackageType.MAC_PKG, Path.of("/Applications/jpackage"));
 
             return reply;
         }).get();
 
-        new PackageTest().configureHelloApp()
+        new PackageTest().excludeTypes(PackageType.MAC_DMG).configureHelloApp()
         .addInitializer(cmd -> {
             cmd.addArguments("--install-dir", INSTALL_DIRS.get(
                     cmd.packageType()));
--- a/test/jdk/tools/jpackage/share/jdk/jpackage/tests/BasicTest.java	Thu Oct 31 11:11:42 2019 -0400
+++ b/test/jdk/tools/jpackage/share/jdk/jpackage/tests/BasicTest.java	Thu Oct 31 11:18:41 2019 -0400
@@ -307,13 +307,19 @@
             cmd.executePrerequisiteActions();
         }
 
-        TKit.withTempDirectory("runtime", runtimeDir -> {
-            TKit.deleteDirectoryRecursive(runtimeDir, String.format(
-                    "Delete [%s] output directory for jlink command", runtimeDir));
+        TKit.withTempDirectory("runtime", tempDir -> {
+            final Path runtimeDir = tempDir.resolve("data");
+
+            // List of modules required for test app.
+            final var modules = new String[] {
+                "java.base",
+                "java.desktop"
+            };
+
             Executor jlink = getToolProvider(JavaTool.JLINK)
             .saveOutput(false)
             .addArguments(
-                    "--add-modules", "java.base",
+                    "--add-modules", String.join(",", modules),
                     "--output", runtimeDir.toString(),
                     "--strip-debug",
                     "--no-header-files",
@@ -329,38 +335,6 @@
 
             cmd.addArguments("--runtime-image", runtimeDir);
             cmd.executeAndAssertHelloAppImageCreated();
-
-            final Path appImageRuntimePath = cmd.appRuntimeDirectory();
-
-            //
-            // This is an overkill to list modules in jlink output as we have
-            // already verified that Java app is functional and thus app's runtime
-            // is likely to be OK, but let's double check.
-            //
-            // Filter out all first strings with whitespace. They are java
-            // launcher output like `Picked up ...` unrelated to module names.
-            //
-            Pattern whitespaceChar = Pattern.compile("\\s");
-            List<String> moduleList = new Executor().dumpOutput().setExecutable(
-                    appImageRuntimePath.resolve(
-                            JPackageCommand.relativePathInRuntime(JavaTool.JAVA))).addArguments(
-                    "--list-modules").executeAndGetOutput().stream().dropWhile(
-                            s -> whitespaceChar.matcher(s).find()).sorted().collect(
-                            Collectors.toList());
-
-            List<String> expectedModules = new ArrayList<>();
-            expectedModules.add(String.format("java.base@%s",
-                    System.getProperty("java.version")));
-            if (moduleName != null) {
-                expectedModules.add(moduleName);
-            }
-            expectedModules = expectedModules.stream().sorted().collect(
-                    Collectors.toList());
-
-            TKit.assertStringListEquals(expectedModules, moduleList,
-                    String.format(
-                            "Check modules in application image runtime directory at [%s]",
-                            appImageRuntimePath));
         });
     }