changeset 8188:4816e2a6847d

[test-only] RT-38146 - add option to disable native bundler codesign Summary: The supported versions of junit don't allow assumptions inside of expected exception annotated methods, so we need to hand craft the exception checking.
author shemnon
date Fri, 10 Oct 2014 09:47:26 -0600
parents 3d7a7674e47a
children caae08ece959
files 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/MacPkgBundlerTest.java
diffstat 3 files changed, 110 insertions(+), 88 deletions(-) [+]
line wrap: on
line diff
--- a/modules/fxpackager/src/test/java/com/oracle/tools/packager/mac/MacAppBundlerTest.java	Fri Oct 10 02:32:26 2014 -0700
+++ b/modules/fxpackager/src/test/java/com/oracle/tools/packager/mac/MacAppBundlerTest.java	Fri Oct 10 09:47:26 2014 -0600
@@ -545,28 +545,36 @@
     /**
      * User a JRE instead of a JDK
      */
-    @Test(expected = ConfigException.class)
+    @Test
     public void testJRE() throws IOException, ConfigException, UnsupportedPlatformException {
         String jre = runtimeJre == null ? "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/" : runtimeJre;
         Assume.assumeTrue(new File(jre).isDirectory());
+        
+        try {
+            Bundler bundler = new MacAppBundler();
+    
+            Map<String, Object> bundleParams = new HashMap<>();
+    
+            // not part of the typical setup, for testing
+            bundleParams.put(BUILD_ROOT.getID(), tmpBase);
+    
+            bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
+            bundleParams.put(MAC_RUNTIME.getID(), jre);
+    
+            boolean valid = bundler.validate(bundleParams);
+            assertTrue(valid);
+    
+            File output = bundler.execute(bundleParams, new File(workDir, "JRETest"));
+            System.err.println("Bundle at - " + output);
+            assertNotNull(output);
+            assertTrue(output.exists());
+         
+            // if we get here we fail
+            assertTrue("ConfigException should have been thrown", false);
+        } catch (ConfigException ignore) {
+            // expected
+        }
 
-        Bundler bundler = new MacAppBundler();
-
-        Map<String, Object> bundleParams = new HashMap<>();
-
-        // not part of the typical setup, for testing
-        bundleParams.put(BUILD_ROOT.getID(), tmpBase);
-
-        bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
-        bundleParams.put(MAC_RUNTIME.getID(), jre);
-
-        boolean valid = bundler.validate(bundleParams);
-        assertTrue(valid);
-
-        File output = bundler.execute(bundleParams, new File(workDir, "JRETest"));
-        System.err.println("Bundle at - " + output);
-        assertNotNull(output);
-        assertTrue(output.exists());
     }
 
 
--- a/modules/fxpackager/src/test/java/com/oracle/tools/packager/mac/MacAppStoreBundlerTest.java	Fri Oct 10 02:32:26 2014 -0700
+++ b/modules/fxpackager/src/test/java/com/oracle/tools/packager/mac/MacAppStoreBundlerTest.java	Fri Oct 10 09:47:26 2014 -0600
@@ -290,42 +290,49 @@
     /**
      * User a JRE instead of a JDK
      */
-    @Test(expected = ConfigException.class)
+    @Test
     public void testJRE() throws IOException, ConfigException, UnsupportedPlatformException {
         String jre = runtimeJre == null ? "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/" : runtimeJre;
         Assume.assumeTrue(new File(jre).isDirectory());
 
-        AbstractBundler bundler = new MacAppStoreBundler();
+        try {
+            AbstractBundler bundler = new MacAppStoreBundler();
+    
+            assertNotNull(bundler.getName());
+            assertNotNull(bundler.getID());
+            assertNotNull(bundler.getDescription());
+    
+            Map<String, Object> bundleParams = new HashMap<>();
+    
+            bundleParams.put(BUILD_ROOT.getID(), tmpBase);
+    
+            bundleParams.put(APP_NAME.getID(), "Smoke Test");
+            bundleParams.put(MAIN_CLASS.getID(), "hello.HelloRectangle");
+            bundleParams.put(PREFERENCES_ID.getID(), "the/really/long/preferences/id");
+            bundleParams.put(MAIN_JAR.getID(),
+                    new RelativeFileSet(fakeMainJar.getParentFile(),
+                            new HashSet<>(Arrays.asList(fakeMainJar)))
+            );
+            bundleParams.put(CLASSPATH.getID(), "mainApp.jar");
+            bundleParams.put(IDENTIFIER.getID(), "com.example.javapacakger.hello.TestPackager");
+            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);
+    
+            File result = bundler.execute(bundleParams, new File(workDir, "jre"));
+            System.err.println("Bundle at - " + result);
+    
+            checkFiles(result);
 
-        assertNotNull(bundler.getName());
-        assertNotNull(bundler.getID());
-        assertNotNull(bundler.getDescription());
-
-        Map<String, Object> bundleParams = new HashMap<>();
-
-        bundleParams.put(BUILD_ROOT.getID(), tmpBase);
-
-        bundleParams.put(APP_NAME.getID(), "Smoke Test");
-        bundleParams.put(MAIN_CLASS.getID(), "hello.HelloRectangle");
-        bundleParams.put(PREFERENCES_ID.getID(), "the/really/long/preferences/id");
-        bundleParams.put(MAIN_JAR.getID(),
-                new RelativeFileSet(fakeMainJar.getParentFile(),
-                        new HashSet<>(Arrays.asList(fakeMainJar)))
-        );
-        bundleParams.put(CLASSPATH.getID(), "mainApp.jar");
-        bundleParams.put(IDENTIFIER.getID(), "com.example.javapacakger.hello.TestPackager");
-        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);
-
-        File result = bundler.execute(bundleParams, new File(workDir, "jre"));
-        System.err.println("Bundle at - " + result);
-
-        checkFiles(result);
+            // if we get here we fail
+            assertTrue("ConfigException should have been thrown", false);
+        } catch (ConfigException ignore) {
+            // expected
+        }
     }
 
     /**
--- a/modules/fxpackager/src/test/java/com/oracle/tools/packager/mac/MacPkgBundlerTest.java	Fri Oct 10 02:32:26 2014 -0700
+++ b/modules/fxpackager/src/test/java/com/oracle/tools/packager/mac/MacPkgBundlerTest.java	Fri Oct 10 09:47:26 2014 -0600
@@ -357,50 +357,57 @@
     /**
      * Test a misconfiguration where signature is requested but no key is specified.
      */
-    @Test(expected = ConfigException.class)
+    @Test
     public void signButNoCert() throws IOException, ConfigException, UnsupportedPlatformException {
         // only run with full tests
         Assume.assumeTrue(Boolean.parseBoolean(System.getProperty("FULL_TEST")));
 
-        // first create the external app
-        Bundler appBundler = new MacAppBundler();
+        try {
+            // first create the external app
+            Bundler appBundler = new MacAppBundler();
+    
+            Map<String, Object> appBundleParams = new HashMap<>();
+    
+            appBundleParams.put(BUILD_ROOT.getID(), tmpBase);
+    
+            appBundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
+            appBundleParams.put(APP_NAME.getID(), "External APP PKG Negative Signature Test");
+            appBundleParams.put(IDENTIFIER.getID(), "com.example.pkg.external");
+            appBundleParams.put(VERBOSE.getID(), true);
+    
+            if (runtimeJdk != null) {
+                appBundleParams.put(MAC_RUNTIME.getID(), runtimeJdk);
+            }
+    
+            boolean valid = appBundler.validate(appBundleParams);
+            assertTrue(valid);
+    
+            File appOutput = appBundler.execute(appBundleParams, new File(workDir, "PKGExternalAppSignTest"));
+            System.err.println("App at - " + appOutput);
+            assertNotNull(appOutput);
+            assertTrue(appOutput.exists());
+    
+            // now create the PKG referencing this external app
+            Bundler pkgBundler = new MacPkgBundler();
+    
+            Map<String, Object> pkgBundleParams = new HashMap<>();
+    
+            pkgBundleParams.put(BUILD_ROOT.getID(), tmpBase);
+    
+            pkgBundleParams.put(MAC_APP_IMAGE.getID(), appOutput);
+            pkgBundleParams.put(APP_NAME.getID(), "Negative Signature Test");
+            pkgBundleParams.put(IDENTIFIER.getID(), "com.example.pkg.external");
+    
+            pkgBundleParams.put(SIGN_BUNDLE.getID(), true);
+            pkgBundleParams.put(DEVELOPER_ID_INSTALLER_SIGNING_KEY.getID(), null);
+    
+            pkgBundler.validate(pkgBundleParams);
 
-        Map<String, Object> appBundleParams = new HashMap<>();
-
-        appBundleParams.put(BUILD_ROOT.getID(), tmpBase);
-
-        appBundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
-        appBundleParams.put(APP_NAME.getID(), "External APP PKG Negative Signature Test");
-        appBundleParams.put(IDENTIFIER.getID(), "com.example.pkg.external");
-        appBundleParams.put(VERBOSE.getID(), true);
-
-        if (runtimeJdk != null) {
-            appBundleParams.put(MAC_RUNTIME.getID(), runtimeJdk);
-        }
-
-        boolean valid = appBundler.validate(appBundleParams);
-        assertTrue(valid);
-
-        File appOutput = appBundler.execute(appBundleParams, new File(workDir, "PKGExternalAppSignTest"));
-        System.err.println("App at - " + appOutput);
-        assertNotNull(appOutput);
-        assertTrue(appOutput.exists());
-
-        // now create the PKG referencing this external app
-        Bundler pkgBundler = new MacPkgBundler();
-
-        Map<String, Object> pkgBundleParams = new HashMap<>();
-
-        pkgBundleParams.put(BUILD_ROOT.getID(), tmpBase);
-
-        pkgBundleParams.put(MAC_APP_IMAGE.getID(), appOutput);
-        pkgBundleParams.put(APP_NAME.getID(), "Negative Signature Test");
-        pkgBundleParams.put(IDENTIFIER.getID(), "com.example.pkg.external");
-
-        pkgBundleParams.put(SIGN_BUNDLE.getID(), true);
-        pkgBundleParams.put(DEVELOPER_ID_INSTALLER_SIGNING_KEY.getID(), null);
-
-        pkgBundler.validate(pkgBundleParams);
+            // if we get here we fail
+            assertTrue("ConfigException should have been thrown", false);
+        } catch (ConfigException ignore) {
+            // expected
+        }            
     }
 
     @Test