changeset 7753:946598c40f55

RT-37439: Install packaged JDK and JRE on Mac Build Servers Summary: update tests to respect the new environmental parameters when present.
author shemnon
date Thu, 21 Aug 2014 12:41:49 -0600
parents 5f6c2a2877d1
children 72e18dfa5a2a
files modules/fxpackager/src/main/java/com/oracle/tools/packager/mac/MacAppStoreBundler.java modules/fxpackager/src/main/resources/com/oracle/tools/packager/mac/MacAppStoreBundler.properties modules/fxpackager/src/test/java/com/oracle/tools/packager/CLITest.java modules/fxpackager/src/test/java/com/oracle/tools/packager/mac/MacAppBundlerTest.java modules/fxpackager/src/test/java/com/oracle/tools/packager/mac/MacAppStoreBundlerTest.java modules/fxpackager/src/test/java/com/oracle/tools/packager/mac/MacDaemonBundlerTest.java modules/fxpackager/src/test/java/com/oracle/tools/packager/mac/MacDmgBundlerTest.java modules/fxpackager/src/test/java/com/oracle/tools/packager/mac/MacPkgBundlerTest.java
diffstat 8 files changed, 174 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/modules/fxpackager/src/main/java/com/oracle/tools/packager/mac/MacAppStoreBundler.java	Thu Aug 21 10:27:31 2014 -0700
+++ b/modules/fxpackager/src/main/java/com/oracle/tools/packager/mac/MacAppStoreBundler.java	Thu Aug 21 12:41:49 2014 -0600
@@ -47,6 +47,7 @@
 import java.util.ResourceBundle;
 
 import static com.oracle.tools.packager.StandardBundlerParam.*;
+import static com.oracle.tools.packager.mac.MacAppBundler.*;
 
 public class MacAppStoreBundler extends MacBaseInstallerBundler {
 
@@ -114,10 +115,10 @@
 
         // first, load in some overrides
         // icns needs @2 versions, so load in the @2 default
-        p.put(MacAppBundler.DEFAULT_ICNS_ICON.getID(), TEMPLATE_BUNDLE_ICON_HIDPI);
+        p.put(DEFAULT_ICNS_ICON.getID(), TEMPLATE_BUNDLE_ICON_HIDPI);
 
         // next we need to change the jdk/jre stripping to strip gstreamer
-        p.put(MacAppBundler.MAC_RULES.getID(), createMacAppStoreRuntimeRules(p));
+        p.put(MAC_RULES.getID(), createMacAppStoreRuntimeRules(p));
 
         // now we create the app
         File appImageDir = APP_IMAGE_BUILD_ROOT.fetchFrom(p);
@@ -125,13 +126,13 @@
             appImageDir.mkdirs();
 
             // first, make sure we don't use the local signing key
-            p.put(MacAppBundler.DEVELOPER_ID_APP_SIGNING_KEY.getID(), null);
+            p.put(DEVELOPER_ID_APP_SIGNING_KEY.getID(), null);
             File appLocation = prepareAppBundle(p);
 
             prepareEntitlements(p);
 
             String signingIdentity = MAC_APP_STORE_APP_SIGNING_KEY.fetchFrom(p);
-            String identifierPrefix = MacAppBundler.BUNDLE_ID_SIGNING_PREFIX.fetchFrom(p);
+            String identifierPrefix = BUNDLE_ID_SIGNING_PREFIX.fetchFrom(p);
             String entitlementsFile = getConfig_Entitlements(p).toString();
             String inheritEntitlements = getConfig_Inherit_Entitlements(p).toString();
 
@@ -217,11 +218,11 @@
     }
 
     private String getEntitlementsFileName(Map<String, ? super Object> params) {
-        return MacAppBundler.MAC_BUNDLER_PREFIX+ APP_NAME.fetchFrom(params) +".entitlements";
+        return MAC_BUNDLER_PREFIX+ APP_NAME.fetchFrom(params) +".entitlements";
     }
 
     private String getInheritEntitlementsFileName(Map<String, ? super Object> params) {
-        return MacAppBundler.MAC_BUNDLER_PREFIX+ APP_NAME.fetchFrom(params) +"_Inherit.entitlements";
+        return MAC_BUNDLER_PREFIX+ APP_NAME.fetchFrom(params) +"_Inherit.entitlements";
     }
 
 
@@ -233,12 +234,12 @@
 
         List<JreUtils.Rule> rules = new ArrayList<>();
 
-        rules.addAll(Arrays.asList(MacAppBundler.createMacRuntimeRules(params)));
+        rules.addAll(Arrays.asList(createMacRuntimeRules(params)));
 
         File baseDir;
 
-        if (params.containsKey(MacAppBundler.MAC_RUNTIME.getID())) {
-            Object o = params.get(MacAppBundler.MAC_RUNTIME.getID());
+        if (params.containsKey(MAC_RUNTIME.getID())) {
+            Object o = params.get(MAC_RUNTIME.getID());
             if (o instanceof RelativeFileSet) {
 
                 baseDir = ((RelativeFileSet) o).getBaseDirectory();
@@ -317,7 +318,7 @@
     @Override
     public Collection<BundlerParamInfo<?>> getBundleParameters() {
         Collection<BundlerParamInfo<?>> results = new LinkedHashSet<>();
-        results.addAll(MacAppBundler.getAppBundleParameters());
+        results.addAll(getAppBundleParameters());
         results.addAll(getPKGBundleParameters());
         return results;
     }
@@ -325,8 +326,8 @@
     public Collection<BundlerParamInfo<?>> getPKGBundleParameters() {
         Collection<BundlerParamInfo<?>> results = new LinkedHashSet<>();
 
-        results.addAll(MacAppBundler.getAppBundleParameters());
-        results.remove(MacAppBundler.DEVELOPER_ID_APP_SIGNING_KEY);
+        results.addAll(getAppBundleParameters());
+        results.remove(DEVELOPER_ID_APP_SIGNING_KEY);
         results.addAll(Arrays.asList(
                 MAC_APP_STORE_APP_SIGNING_KEY,
                 MAC_APP_STORE_ENTITLEMENTS,
@@ -339,17 +340,24 @@
     @Override
     public boolean validate(Map<String, ? super Object> params) throws UnsupportedPlatformException, ConfigException {
         try {
-            if (params == null) throw new ConfigException(
-                    I18N.getString("error.parameters-null"),
-                    I18N.getString("error.parameters-null.advice"));
+            if (params == null) {
+                throw new ConfigException(
+                        I18N.getString("error.parameters-null"),
+                        I18N.getString("error.parameters-null.advice"));
+            }
 
             // hdiutil is always available so there's no need to test for availability.
             //run basic validation to ensure requirements are met
 
-            //run basic validation to ensure requirements are met
+            // Mac App Store apps cannot use the system runtime
+            if (params.containsKey(MAC_RUNTIME.getID()) && params.get(MAC_RUNTIME.getID()) == null) {
+                throw new ConfigException(
+                        I18N.getString("error.no-system-runtime"),
+                        I18N.getString("error.no-system-runtime.advice"));
+            }
 
             //we need to change the jdk/jre stripping to strip qtkit code
-            params.put(MacAppBundler.MAC_RULES.getID(), createMacAppStoreRuntimeRules(params));
+            params.put(MAC_RULES.getID(), createMacAppStoreRuntimeRules(params));
 
             //we are not interested in return code, only possible exception
             validateAppImageAndBundeler(params);
--- a/modules/fxpackager/src/main/resources/com/oracle/tools/packager/mac/MacAppStoreBundler.properties	Thu Aug 21 10:27:31 2014 -0700
+++ b/modules/fxpackager/src/main/resources/com/oracle/tools/packager/mac/MacAppStoreBundler.properties	Thu Aug 21 12:41:49 2014 -0600
@@ -17,6 +17,8 @@
 error.parameters-null.advice=Pass in a non-null parameters map.
 error.cannot-create-output-dir=Output directory {0} cannot be created.
 error.cannot-write-to-output-dir=Output directory {0} is not writable.
+error.no-system-runtime=Bundle Configured to use the System JRE
+error.no-system-runtime.advice=Do not set 'runtime' to null, either don't set it or set it to a valid value.
 error.no-app-signing-key=No Mac App Store App Signing Key
 error.no-app-signing-key.advice=Install your app signing keys into your Mac Keychain using XCode.
 error.no-pkg-signing-key=No Mac App Store Installer Signing Key
--- a/modules/fxpackager/src/test/java/com/oracle/tools/packager/CLITest.java	Thu Aug 21 10:27:31 2014 -0700
+++ b/modules/fxpackager/src/test/java/com/oracle/tools/packager/CLITest.java	Thu Aug 21 12:41:49 2014 -0600
@@ -71,6 +71,12 @@
 
     @Test
     public void smokeParams() throws Exception {
+
+        String packagerJdkRoot = System.getenv("PACKAGER_JDK_ROOT");
+        String runtime = packagerJdkRoot == null
+                ? System.getProperty("java.home")
+                : packagerJdkRoot;
+
         com.sun.javafx.tools.packager.Main.main("-deploy",
                 "-verbose", // verbose is required or test will call System.exit() on failures and break the build
                 "-srcfiles", fakeMainJar.getCanonicalPath(),
@@ -82,7 +88,7 @@
                 "-BOptionThatWillNeverExist=true",
                 "-BdesktopHint=false",
                 "-BshortcutHint=true",
-                "-Bruntime=" + System.getProperty("java.home"));
+                "-Bruntime=" + runtime);
     }
 
     @Test
--- a/modules/fxpackager/src/test/java/com/oracle/tools/packager/mac/MacAppBundlerTest.java	Thu Aug 21 10:27:31 2014 -0700
+++ b/modules/fxpackager/src/test/java/com/oracle/tools/packager/mac/MacAppBundlerTest.java	Thu Aug 21 12:41:49 2014 -0600
@@ -61,6 +61,8 @@
     static File appResourcesDir;
     static File fakeMainJar;
     static File hdpiIcon;
+    static File runtimeJdk;
+    static File runtimeJre;
     static Set<File> appResources;
     static boolean retain = false;
 
@@ -69,9 +71,15 @@
         // only run on mac
         Assume.assumeTrue(System.getProperty("os.name").toLowerCase().contains("os x"));
 
+        String packagerJdkRoot = System.getenv("PACKAGER_JDK_ROOT");
+        runtimeJdk = packagerJdkRoot == null ? null : new File(packagerJdkRoot);
+
+        String packagerJreRoot = System.getenv("PACKAGER_JRE_ROOT");
+        runtimeJre = packagerJreRoot == null ? null : new File(packagerJreRoot);
+
         // and only if we have the correct JRE settings
         String jre = System.getProperty("java.home").toLowerCase();
-        Assume.assumeTrue(jre.endsWith("/contents/home/jre") || jre.endsWith("/contents/home/jre"));
+        Assume.assumeTrue(packagerJdkRoot != null || jre.endsWith("/contents/home/jre") || jre.endsWith("/contents/home/jre"));
 
         Log.setLogger(new Log.Logger(true));
 
@@ -221,6 +229,10 @@
         bundleParams.put(DEVELOPER_ID_APP_SIGNING_KEY.getID(), null); // force no signing
         bundleParams.put(ICON.getID(), "java-logo2.gif"); // force no signing
 
+        if (runtimeJdk != null) {
+            bundleParams.put(MAC_RUNTIME.getID(), runtimeJdk);
+        }
+
         boolean valid = bundler.validate(bundleParams);
         assertTrue(valid);
 
@@ -253,6 +265,10 @@
         bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
         bundleParams.put(VERBOSE.getID(), true);
 
+        if (runtimeJdk != null) {
+            bundleParams.put(MAC_RUNTIME.getID(), runtimeJdk);
+        }
+
         boolean valid = bundler.validate(bundleParams);
         assertTrue(valid);
 
@@ -289,6 +305,10 @@
 
         bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
 
+        if (runtimeJdk != null) {
+            bundleParams.put(MAC_RUNTIME.getID(), runtimeJdk);
+        }
+
         File output = bundler.execute(bundleParams, new File(workDir, "BareMinimum"));
         System.err.println("Bundle at - " + output);
         assertNotNull(output);
@@ -332,7 +352,7 @@
         bundleParams.put(MAC_CF_BUNDLE_IDENTIFIER.getID(), "com.example.everything.cf-bundle-identifier");
         bundleParams.put(MAC_CF_BUNDLE_NAME.getID(), "Everything CF Bundle Name");
         bundleParams.put(MAC_CF_BUNDLE_VERSION.getID(), "8.2.0");
-        bundleParams.put(MAC_RUNTIME.getID(), System.getProperty("java.home"));
+        bundleParams.put(MAC_RUNTIME.getID(), runtimeJdk);
         bundleParams.put(MAIN_CLASS.getID(), "hello.TestPackager");
         bundleParams.put(MAIN_JAR.getID(), "mainApp.jar");
         bundleParams.put(CLASSPATH.getID(), "mainApp.jar");
@@ -407,6 +427,10 @@
             bundleParams.put(VERBOSE.getID(), true);
             bundleParams.put(DEVELOPER_ID_APP_SIGNING_KEY.getID(), null); // force no signing
 
+            if (runtimeJdk != null) {
+                bundleParams.put(MAC_RUNTIME.getID(), runtimeJdk);
+            }
+
             boolean valid = bundler.validate(bundleParams);
             assertTrue(valid);
 
@@ -421,9 +445,10 @@
     /**
      * User a JRE instead of a JDK
      */
-    @Test
+    @Test(expected = ConfigException.class)
     public void testJRE() throws IOException, ConfigException, UnsupportedPlatformException {
-        Assume.assumeTrue(new File("/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/").isDirectory());
+        File jre = runtimeJre == null ? new File("/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/") : runtimeJre;
+        Assume.assumeTrue(jre.isDirectory());
 
         Bundler bundler = new MacAppBundler();
 
@@ -433,7 +458,10 @@
         bundleParams.put(BUILD_ROOT.getID(), tmpBase);
 
         bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
-        bundleParams.put(MAC_RUNTIME.getID(), System.getProperty("/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/"));
+        bundleParams.put(MAC_RUNTIME.getID(), jre.toString());
+
+        boolean valid = bundler.validate(bundleParams);
+        assertTrue(valid);
 
         File output = bundler.execute(bundleParams, new File(workDir, "JRETest"));
         System.err.println("Bundle at - " + output);
--- a/modules/fxpackager/src/test/java/com/oracle/tools/packager/mac/MacAppStoreBundlerTest.java	Thu Aug 21 10:27:31 2014 -0700
+++ b/modules/fxpackager/src/test/java/com/oracle/tools/packager/mac/MacAppStoreBundlerTest.java	Thu Aug 21 12:41:49 2014 -0600
@@ -66,6 +66,8 @@
     static File appResourcesDir;
     static File fakeMainJar;
     static File hdpiIcon;
+    static File runtimeJdk;
+    static File runtimeJre;
     static Set<File> appResources;
     static boolean retain = false;
 
@@ -74,9 +76,15 @@
         // only run on mac
         Assume.assumeTrue(System.getProperty("os.name").toLowerCase().contains("os x"));
 
+        String packagerJdkRoot = System.getenv("PACKAGER_JDK_ROOT");
+        runtimeJdk = packagerJdkRoot == null ? null : new File(packagerJdkRoot);
+
+        String packagerJreRoot = System.getenv("PACKAGER_JRE_ROOT");
+        runtimeJre = packagerJreRoot == null ? null : new File(packagerJreRoot);
+
         // and only if we have the correct JRE settings
         String jre = System.getProperty("java.home").toLowerCase();
-        Assume.assumeTrue(jre.endsWith("/contents/home/jre") || jre.endsWith("/contents/home/jre"));
+        Assume.assumeTrue(packagerJdkRoot != null || jre.endsWith("/contents/home/jre") || jre.endsWith("/contents/home/jre"));
 
         // make sure we have a default signing key
         String signingKeyName = MacAppStoreBundler.MAC_APP_STORE_APP_SIGNING_KEY.fetchFrom(new TreeMap<>());
@@ -181,6 +189,10 @@
         bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
         bundleParams.put(VERBOSE.getID(), true);
 
+        if (runtimeJdk != null) {
+            bundleParams.put(MAC_RUNTIME.getID(), runtimeJdk);
+        }
+
         boolean valid = bundler.validate(bundleParams);
         assertTrue(valid);
 
@@ -227,7 +239,7 @@
         bundleParams.put(MAC_CF_BUNDLE_IDENTIFIER.getID(), "com.example.everything.cf-bundle-identifier");
         bundleParams.put(MAC_CF_BUNDLE_NAME.getID(), "Everything CF Bundle Name");
         bundleParams.put(MAC_CF_BUNDLE_VERSION.getID(), "8.2.0");
-        bundleParams.put(MAC_RUNTIME.getID(), System.getProperty("java.home"));
+        bundleParams.put(MAC_RUNTIME.getID(), runtimeJdk == null ? System.getProperty("java.home") : runtimeJdk);
         bundleParams.put(MAIN_CLASS.getID(), "hello.TestPackager");
         bundleParams.put(MAIN_JAR.getID(), "mainApp.jar");
         bundleParams.put(CLASSPATH.getID(), "mainApp.jar");
@@ -280,10 +292,11 @@
     /**
      * User a JRE instead of a JDK
      */
-    @Test
+    @Test(expected = ConfigException.class)
     public void testJRE() throws IOException, ConfigException, UnsupportedPlatformException {
 
-        Assume.assumeTrue(new File("/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/").isDirectory());
+        File jre = runtimeJre == null ? new File("/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/") : runtimeJre;
+        Assume.assumeTrue(jre.isDirectory());
 
         AbstractBundler bundler = new MacAppStoreBundler();
 
@@ -307,6 +320,7 @@
         bundleParams.put(MacAppBundler.MAC_CATEGORY.getID(), "public.app-category.developer-tools");
         bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
         bundleParams.put(VERBOSE.getID(), true);
+        bundleParams.put(MAC_RUNTIME.getID(), jre);
 
         boolean valid = bundler.validate(bundleParams);
         assertTrue(valid);
--- a/modules/fxpackager/src/test/java/com/oracle/tools/packager/mac/MacDaemonBundlerTest.java	Thu Aug 21 10:27:31 2014 -0700
+++ b/modules/fxpackager/src/test/java/com/oracle/tools/packager/mac/MacDaemonBundlerTest.java	Thu Aug 21 12:41:49 2014 -0600
@@ -46,6 +46,8 @@
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
+
+import static com.oracle.tools.packager.mac.MacAppBundler.MAC_RUNTIME;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
@@ -54,6 +56,7 @@
 
     static File tmpBase;
     static File workDir;
+    static File runtimeJdk;
     static boolean retain = false;
 
     @BeforeClass
@@ -61,9 +64,12 @@
         // only run on mac
         Assume.assumeTrue(System.getProperty("os.name").toLowerCase().contains("os x"));
 
+        String packagerJdkRoot = System.getenv("PACKAGER_JDK_ROOT");
+        runtimeJdk = packagerJdkRoot == null ? null : new File(packagerJdkRoot);
+
         // and only if we have the correct JRE settings
         String jre = System.getProperty("java.home").toLowerCase();
-        Assume.assumeTrue(jre.endsWith("/contents/home/jre") || jre.endsWith("/contents/home/jre"));
+        Assume.assumeTrue(packagerJdkRoot != null || jre.endsWith("/contents/home/jre") || jre.endsWith("/contents/home/jre"));
 
         Log.setLogger(new Log.Logger(true));
 
@@ -129,6 +135,10 @@
         bundleParams.put(IDENTIFIER.getID(), "smoke.app");        
         bundleParams.put(VERBOSE.getID(), true);
 
+        if (runtimeJdk != null) {
+            bundleParams.put(MAC_RUNTIME.getID(), runtimeJdk);
+        }
+
         boolean valid = bundler.validate(bundleParams);
         assertTrue(valid);
 
--- a/modules/fxpackager/src/test/java/com/oracle/tools/packager/mac/MacDmgBundlerTest.java	Thu Aug 21 10:27:31 2014 -0700
+++ b/modules/fxpackager/src/test/java/com/oracle/tools/packager/mac/MacDmgBundlerTest.java	Thu Aug 21 12:41:49 2014 -0600
@@ -63,6 +63,7 @@
     static File appResourcesDir;
     static File fakeMainJar;
     static File hdpiIcon;
+    static File runtimeJdk;
     static Set<File> appResources;
     static boolean retain = false;
     static boolean full_tests = false;
@@ -72,9 +73,12 @@
         // only run on mac
         Assume.assumeTrue(System.getProperty("os.name").toLowerCase().contains("os x"));
 
+        String packagerJdkRoot = System.getenv("PACKAGER_JDK_ROOT");
+        runtimeJdk = packagerJdkRoot == null ? null : new File(packagerJdkRoot);
+
         // and only if we have the correct JRE settings
         String jre = System.getProperty("java.home").toLowerCase();
-        Assume.assumeTrue(jre.endsWith("/contents/home/jre") || jre.endsWith("/contents/home/jre"));
+        Assume.assumeTrue(packagerJdkRoot != null || jre.endsWith("/contents/home/jre") || jre.endsWith("/contents/home/jre"));
 
         Log.setLogger(new Log.Logger(true));
         Log.setDebug(true);
@@ -161,6 +165,10 @@
         bundleParams.put(VERBOSE.getID(), true);
         bundleParams.put(SYSTEM_WIDE.getID(), false);
 
+        if (runtimeJdk != null) {
+            bundleParams.put(MAC_RUNTIME.getID(), runtimeJdk);
+        }
+
         boolean valid = bundler.validate(bundleParams);
         assertTrue(valid);
 
@@ -193,6 +201,13 @@
 
         bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
 
+        if (runtimeJdk != null) {
+            bundleParams.put(MAC_RUNTIME.getID(), runtimeJdk);
+        }
+
+        boolean valid = bundler.validate(bundleParams);
+        assertTrue(valid);
+
         File output = bundler.execute(bundleParams, new File(workDir, "BareMinimum"));
         System.err.println("Bundle at - " + output);
         assertNotNull(output);
@@ -220,7 +235,13 @@
         appBundleParams.put(IDENTIFIER.getID(), "com.example.dmg.external");
         appBundleParams.put(VERBOSE.getID(), true);
 
-        appBundler.validate(appBundleParams);
+        if (runtimeJdk != null) {
+            appBundleParams.put(MAC_RUNTIME.getID(), runtimeJdk);
+        }
+
+        boolean valid = appBundler.validate(appBundleParams);
+        assertTrue(valid);
+
         File appOutput = appBundler.execute(appBundleParams, new File(workDir, "DMGExternalApp1"));
         System.err.println("App at - " + appOutput);
         assertNotNull(appOutput);
@@ -239,7 +260,13 @@
 
         dmgBundleParams.put(VERBOSE.getID(), true);
 
-        dmgBundler.validate(dmgBundleParams);
+        if (runtimeJdk != null) {
+            dmgBundleParams.put(MAC_RUNTIME.getID(), runtimeJdk);
+        }
+
+        valid = dmgBundler.validate(dmgBundleParams);
+        assertTrue(valid);
+
         File dmgOutput = dmgBundler.execute(dmgBundleParams, new File(workDir, "DMGExternalApp2"));
         System.err.println(".dmg at - " + dmgOutput);
         assertNotNull(dmgOutput);
@@ -264,7 +291,13 @@
         appBundleParams.put(IDENTIFIER.getID(), "com.example.dmg.external");
         appBundleParams.put(VERBOSE.getID(), true);
 
-        appBundler.validate(appBundleParams);
+        if (runtimeJdk != null) {
+            appBundleParams.put(MAC_RUNTIME.getID(), runtimeJdk);
+        }
+
+        boolean valid = appBundler.validate(appBundleParams);
+        assertTrue(valid);
+
         File appOutput = appBundler.execute(appBundleParams, new File(workDir, "DMGExternalApp1"));
         System.err.println("App at - " + appOutput);
         assertNotNull(appOutput);
@@ -284,7 +317,13 @@
 
         dmgBundleParams.put(VERBOSE.getID(), true);
 
-        dmgBundler.validate(dmgBundleParams);
+        if (runtimeJdk != null) {
+            dmgBundleParams.put(MAC_RUNTIME.getID(), runtimeJdk);
+        }
+
+        valid = dmgBundler.validate(dmgBundleParams);
+        assertTrue(valid);
+
         File dmgOutput = dmgBundler.execute(dmgBundleParams, new File(workDir, "DMGExternalApp3"));
         System.err.println(".dmg at - " + dmgOutput);
         assertNotNull(dmgOutput);
--- a/modules/fxpackager/src/test/java/com/oracle/tools/packager/mac/MacPkgBundlerTest.java	Thu Aug 21 10:27:31 2014 -0700
+++ b/modules/fxpackager/src/test/java/com/oracle/tools/packager/mac/MacPkgBundlerTest.java	Thu Aug 21 12:41:49 2014 -0600
@@ -64,6 +64,7 @@
     static File appResourcesDir;
     static File fakeMainJar;
     static File hdpiIcon;
+    static File runtimeJdk;
     static Set<File> appResources;
     static boolean retain = false;
 
@@ -72,9 +73,12 @@
         // only run on mac
         Assume.assumeTrue(System.getProperty("os.name").toLowerCase().contains("os x"));
 
+        String packagerJdkRoot = System.getenv("PACKAGER_JDK_ROOT");
+        runtimeJdk = packagerJdkRoot == null ? null : new File(packagerJdkRoot);
+
         // and only if we have the correct JRE settings
         String jre = System.getProperty("java.home").toLowerCase();
-        Assume.assumeTrue(jre.endsWith("/contents/home/jre") || jre.endsWith("/contents/home/jre"));
+        Assume.assumeTrue(packagerJdkRoot != null || jre.endsWith("/contents/home/jre") || jre.endsWith("/contents/home/jre"));
 
         Log.setLogger(new Log.Logger(true));
 
@@ -158,6 +162,10 @@
         bundleParams.put(DEVELOPER_ID_APP_SIGNING_KEY.getID(), null); // force no signing
         bundleParams.put(DEVELOPER_ID_INSTALLER_SIGNING_KEY.getID(), null); // force no signing
 
+        if (runtimeJdk != null) {
+            bundleParams.put(MAC_RUNTIME.getID(), runtimeJdk);
+        }
+
         boolean valid = bundler.validate(bundleParams);
         assertTrue(valid);
 
@@ -190,6 +198,10 @@
         bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
         bundleParams.put(VERBOSE.getID(), true);
 
+        if (runtimeJdk != null) {
+            bundleParams.put(MAC_RUNTIME.getID(), runtimeJdk);
+        }
+
         boolean valid = bundler.validate(bundleParams);
         assertTrue(valid);
 
@@ -226,6 +238,13 @@
 
         bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
 
+        if (runtimeJdk != null) {
+            bundleParams.put(MAC_RUNTIME.getID(), runtimeJdk);
+        }
+
+        boolean valid = bundler.validate(bundleParams);
+        assertTrue(valid);
+
         File output = bundler.execute(bundleParams, new File(workDir, "BareMinimum"));
         System.err.println("Bundle at - " + output);
         assertNotNull(output);
@@ -253,7 +272,13 @@
         appBundleParams.put(IDENTIFIER.getID(), "com.example.pkg.external");
         appBundleParams.put(VERBOSE.getID(), true);
 
-        appBundler.validate(appBundleParams);
+        if (runtimeJdk != null) {
+            appBundleParams.put(MAC_RUNTIME.getID(), runtimeJdk);
+        }
+
+        boolean valid = appBundler.validate(appBundleParams);
+        assertTrue(valid);
+
         File appOutput = appBundler.execute(appBundleParams, new File(workDir, "PKGExternalApp1"));
         System.err.println("App at - " + appOutput);
         assertNotNull(appOutput);
@@ -272,7 +297,13 @@
 
         pkgBundleParams.put(VERBOSE.getID(), true);
 
-        pkgBundler.validate(pkgBundleParams);
+        if (runtimeJdk != null) {
+            pkgBundleParams.put(MAC_RUNTIME.getID(), runtimeJdk);
+        }
+
+        valid = pkgBundler.validate(pkgBundleParams);
+        assertTrue(valid);
+
         File pkgOutput = pkgBundler.execute(pkgBundleParams, new File(workDir, "PKGExternalApp2"));
         System.err.println(".pkg at - " + pkgOutput);
         assertNotNull(pkgOutput);