modules/fxpackager/src/test/java/com/oracle/tools/packager/windows/WinAppBundlerTest.java

Print this page




 205             assertTrue(valid);
 206         } catch (ConfigException ce) {
 207             assertTrue(ce.getMessage().contains("Java Runtime does not include"));
 208         }
 209 
 210     }
 211 
 212     public void validatePackageCfg(File root, Map<String, ? super Object> params) throws IOException {
 213         try (FileInputStream fis = new FileInputStream(new File(root, WinAppBundler.getLauncherCfgName(params)))) {
 214             Properties p = new Properties();
 215             p.load(fis);
 216             
 217             // - verify we have app.mainjar, app.version, app.id, app.preferences, app.mainclass, and app.classpath
 218             assertNotNull(p.getProperty("app.runtime"));
 219             assertNotNull(p.getProperty("app.mainjar"));
 220             assertNotNull(p.getProperty("app.version"));
 221             assertNotNull(p.getProperty("app.id"));
 222             assertNotNull(p.getProperty("app.preferences.id"));
 223             assertNotNull(p.getProperty("app.mainclass"));
 224             assertNotNull(p.getProperty("app.classpath"));

 225 
 226             // - make sure 'app.classpath=null' doesn't show up, prefer 'app.classpath='
 227             assertFalse(p.getProperty("app.classpath").equals("null"));
 228         }
 229     }
 230 
 231     /**
 232      * Test a misconfiguration where the runtime is misconfigured.
 233      */
 234     @Test(expected = ConfigException.class)
 235     public void runtimeBad() throws IOException, ConfigException, UnsupportedPlatformException {
 236         Bundler bundler = new WinExeBundler();
 237 
 238         Map<String, Object> bundleParams = new HashMap<>();
 239 
 240         bundleParams.put(BUILD_ROOT.getID(), tmpBase);
 241         bundleParams.put(VERBOSE.getID(), true);
 242 
 243         bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
 244         bundleParams.put(WIN_RUNTIME.getID(), APP_RESOURCES.fetchFrom(bundleParams));


 362         Assume.assumeTrue(runtimeJre != null && new File(runtimeJre).isDirectory());
 363 
 364         Bundler bundler = new WinAppBundler();
 365 
 366         Map<String, Object> bundleParams = new HashMap<>();
 367 
 368         // not part of the typical setup, for testing
 369         bundleParams.put(BUILD_ROOT.getID(), tmpBase);
 370 
 371         bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
 372         bundleParams.put(WIN_RUNTIME.getID(), runtimeJre);
 373 
 374         boolean valid = bundler.validate(bundleParams);
 375         assertTrue(valid);
 376 
 377         File output = bundler.execute(bundleParams, new File(workDir, "JRETest"));
 378         System.err.println("Bundle at - " + output);
 379         assertNotNull(output);
 380         assertTrue(output.exists());
 381     }    































 382 }


 205             assertTrue(valid);
 206         } catch (ConfigException ce) {
 207             assertTrue(ce.getMessage().contains("Java Runtime does not include"));
 208         }
 209 
 210     }
 211 
 212     public void validatePackageCfg(File root, Map<String, ? super Object> params) throws IOException {
 213         try (FileInputStream fis = new FileInputStream(new File(root, WinAppBundler.getLauncherCfgName(params)))) {
 214             Properties p = new Properties();
 215             p.load(fis);
 216             
 217             // - verify we have app.mainjar, app.version, app.id, app.preferences, app.mainclass, and app.classpath
 218             assertNotNull(p.getProperty("app.runtime"));
 219             assertNotNull(p.getProperty("app.mainjar"));
 220             assertNotNull(p.getProperty("app.version"));
 221             assertNotNull(p.getProperty("app.id"));
 222             assertNotNull(p.getProperty("app.preferences.id"));
 223             assertNotNull(p.getProperty("app.mainclass"));
 224             assertNotNull(p.getProperty("app.classpath"));
 225             assertNotNull(p.getProperty("app.identifier"));
 226 
 227             // - make sure 'app.classpath=null' doesn't show up, prefer 'app.classpath='
 228             assertFalse(p.getProperty("app.classpath").equals("null"));
 229         }
 230     }
 231 
 232     /**
 233      * Test a misconfiguration where the runtime is misconfigured.
 234      */
 235     @Test(expected = ConfigException.class)
 236     public void runtimeBad() throws IOException, ConfigException, UnsupportedPlatformException {
 237         Bundler bundler = new WinExeBundler();
 238 
 239         Map<String, Object> bundleParams = new HashMap<>();
 240 
 241         bundleParams.put(BUILD_ROOT.getID(), tmpBase);
 242         bundleParams.put(VERBOSE.getID(), true);
 243 
 244         bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
 245         bundleParams.put(WIN_RUNTIME.getID(), APP_RESOURCES.fetchFrom(bundleParams));


 363         Assume.assumeTrue(runtimeJre != null && new File(runtimeJre).isDirectory());
 364 
 365         Bundler bundler = new WinAppBundler();
 366 
 367         Map<String, Object> bundleParams = new HashMap<>();
 368 
 369         // not part of the typical setup, for testing
 370         bundleParams.put(BUILD_ROOT.getID(), tmpBase);
 371 
 372         bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
 373         bundleParams.put(WIN_RUNTIME.getID(), runtimeJre);
 374 
 375         boolean valid = bundler.validate(bundleParams);
 376         assertTrue(valid);
 377 
 378         File output = bundler.execute(bundleParams, new File(workDir, "JRETest"));
 379         System.err.println("Bundle at - " + output);
 380         assertNotNull(output);
 381         assertTrue(output.exists());
 382     }
 383 
 384     /**
 385      * Turn on AppCDS
 386      */
 387     @Test
 388     public void testAppCDS() throws IOException, ConfigException, UnsupportedPlatformException {
 389         Bundler bundler = new WinAppBundler();
 390 
 391         Map<String, Object> bundleParams = new HashMap<>();
 392 
 393         // not part of the typical setup, for testing
 394         bundleParams.put(BUILD_ROOT.getID(), tmpBase);
 395         bundleParams.put(VERBOSE.getID(), true);
 396         if (runtimeJdk != null) {
 397             bundleParams.put(WIN_RUNTIME.getID(), runtimeJdk);
 398         }
 399 
 400         bundleParams.put(APP_NAME.getID(), "AppCDS");
 401         bundleParams.put(IDENTIFIER.getID(), "com.example.appcds.image.Test");
 402         bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
 403         bundleParams.put(UNLOCK_COMMERCIAL_FEATURES.getID(), true);
 404         bundleParams.put(ENABLE_APP_CDS.getID(), true);
 405 
 406         boolean valid = bundler.validate(bundleParams);
 407         assertTrue(valid);
 408 
 409         File output = bundler.execute(bundleParams, new File(workDir, "CDSTest"));
 410         System.err.println("Bundle at - " + output);
 411         assertNotNull(output);
 412         assertTrue(output.exists());
 413     }
 414 }