1 /*
   2  * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.oracle.tools.packager.windows;
  27 
  28 import com.oracle.tools.packager.AbstractBundler;
  29 import com.oracle.tools.packager.Bundler;
  30 import com.oracle.tools.packager.BundlerParamInfo;
  31 import com.oracle.tools.packager.ConfigException;
  32 import com.oracle.tools.packager.Log;
  33 import com.oracle.tools.packager.RelativeFileSet;
  34 import com.oracle.tools.packager.UnsupportedPlatformException;
  35 import org.junit.After;
  36 import org.junit.Assume;
  37 import org.junit.Before;
  38 import org.junit.BeforeClass;
  39 import org.junit.Test;
  40 
  41 import java.io.File;
  42 import java.io.IOException;
  43 import java.util.ArrayList;
  44 import java.util.Arrays;
  45 import java.util.Collection;
  46 import java.util.HashMap;
  47 import java.util.HashSet;
  48 import java.util.List;
  49 import java.util.Map;
  50 import java.util.Set;
  51 import java.util.TreeMap;
  52 
  53 import static com.oracle.tools.packager.StandardBundlerParam.*;
  54 import static com.oracle.tools.packager.windows.WinAppBundler.ICON_ICO;
  55 import static com.oracle.tools.packager.windows.WinMsiBundler.PRODUCT_VERSION;
  56 import static com.oracle.tools.packager.windows.WindowsBundlerParam.WIN_RUNTIME;
  57 import static com.oracle.tools.packager.windows.WindowsBundlerParam.MENU_GROUP;
  58 import static com.oracle.tools.packager.windows.WindowsBundlerParam.INSTALLDIR_CHOOSER;
  59 import static org.junit.Assert.*;
  60 
  61 public class WinMsiBundlerTest {
  62 
  63     static File tmpBase;
  64     static File workDir;
  65     static File appResourcesDir;
  66     static File fakeMainJar;
  67     static String runtimeJdk;
  68     static String runtimeJre;
  69     static Set<File> appResources;
  70     static boolean retain = false;
  71 
  72     @BeforeClass
  73     public static void prepareApp() {
  74         // only run on windows
  75         Assume.assumeTrue(System.getProperty("os.name").toLowerCase().startsWith("win"));
  76 
  77         runtimeJdk = System.getenv("PACKAGER_JDK_ROOT");
  78         runtimeJre = System.getenv("PACKAGER_JRE_ROOT");
  79 
  80         // only run if we have Wix tools installed
  81         Assume.assumeNotNull(WinMsiBundler.TOOL_LIGHT_EXECUTABLE.fetchFrom(new HashMap<>()));
  82         Assume.assumeNotNull(WinMsiBundler.TOOL_CANDLE_EXECUTABLE.fetchFrom(new HashMap<>()));
  83 
  84         Log.setLogger(new Log.Logger(true));
  85 
  86         retain = Boolean.parseBoolean(System.getProperty("RETAIN_PACKAGER_TESTS"));
  87 
  88         workDir = new File("build/tmp/tests", "winmsi");
  89         appResourcesDir = new File("build/tmp/tests", "appResources");
  90         fakeMainJar = new File(appResourcesDir, "mainApp.jar");
  91 
  92         appResources = new HashSet<>(Arrays.asList(fakeMainJar,
  93                 new File(appResourcesDir, "LICENSE"),
  94                 new File(appResourcesDir, "LICENSE2")
  95         ));
  96     }
  97 
  98     @Before
  99     public void createTmpDir() throws IOException {
 100         if (retain) {
 101             tmpBase = new File("build/tmp/tests/winmsi");
 102         } else {
 103             tmpBase = BUILD_ROOT.fetchFrom(new TreeMap<>());
 104         }
 105         tmpBase.mkdir();
 106     }
 107 
 108     @After
 109     public void maybeCleanupTmpDir() {
 110         if (!retain) {
 111             attemptDelete(tmpBase);
 112         }
 113     }
 114 
 115     private void attemptDelete(File tmpBase) {
 116         if (tmpBase.isDirectory()) {
 117             File[] children = tmpBase.listFiles();
 118             if (children != null) {
 119                 for (File f : children) {
 120                     attemptDelete(f);
 121                 }
 122             }
 123         }
 124         boolean success;
 125         try {
 126             success = !tmpBase.exists() || tmpBase.delete();
 127         } catch (SecurityException se) {
 128             success = false;
 129         }
 130         if (!success) {
 131             System.err.println("Could not clean up " + tmpBase.toString());
 132         }
 133     }
 134 
 135     /**
 136      * See if smoke comes out
 137      */
 138     @Test
 139     public void smokeTest() throws IOException, ConfigException, UnsupportedPlatformException {
 140         Bundler bundler = new WinMsiBundler();
 141 
 142         assertNotNull(bundler.getName());
 143         assertNotNull(bundler.getID());
 144         assertNotNull(bundler.getDescription());
 145         //assertNotNull(bundler.getBundleParameters());
 146 
 147         Map<String, Object> bundleParams = new HashMap<>();
 148 
 149         bundleParams.put(BUILD_ROOT.getID(), tmpBase);
 150         
 151         bundleParams.put(APP_NAME.getID(), "Smoke Test");
 152         bundleParams.put(MAIN_CLASS.getID(), "hello.HelloRectangle");
 153         bundleParams.put(PREFERENCES_ID.getID(), "the/really/long/preferences/id");
 154         bundleParams.put(MAIN_JAR.getID(),
 155                 new RelativeFileSet(fakeMainJar.getParentFile(),
 156                         new HashSet<>(Arrays.asList(fakeMainJar)))
 157         );
 158         bundleParams.put(CLASSPATH.getID(), "mainApp.jar");
 159         bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
 160         bundleParams.put(LICENSE_FILE.getID(), Arrays.asList("LICENSE", "LICENSE2"));
 161         bundleParams.put(VERBOSE.getID(), true);
 162 
 163         boolean valid = bundler.validate(bundleParams);
 164         assertTrue(valid);
 165 
 166         File result = bundler.execute(bundleParams, new File(workDir, "smoke"));
 167         System.err.println("Bundle at - " + result);
 168         assertNotNull(result);
 169         assertTrue(result.exists());
 170     }
 171 
 172     /**
 173      * The bare minimum configuration needed to make it work
 174      * <ul>
 175      *     <li>Where to build it</li>
 176      *     <li>The jar containing the application (with a main-class attribute)</li>
 177      * </ul>
 178      * 
 179      * All other values will be driven off of those two values.
 180      */
 181     @Test
 182     public void minimumConfig() throws IOException, ConfigException, UnsupportedPlatformException {
 183         Bundler bundler = new WinMsiBundler();
 184 
 185         Map<String, Object> bundleParams = new HashMap<>();
 186 
 187         bundleParams.put(BUILD_ROOT.getID(), tmpBase);
 188 
 189         bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
 190 
 191         File output = bundler.execute(bundleParams, new File(workDir, "BareMinimum"));
 192         System.err.println("Bundle at - " + output);
 193         assertNotNull(output);
 194         assertTrue(output.exists());
 195     }
 196 
 197     /**
 198      * Test a misconfiguration where the wix tools are misconfigured.
 199      */
 200     @Test
 201     public void configLightBad() throws IOException, ConfigException, UnsupportedPlatformException {
 202         Bundler bundler = new WinMsiBundler();
 203 
 204         Map<String, Object> bundleParams = new HashMap<>();
 205 
 206         bundleParams.put(BUILD_ROOT.getID(), tmpBase);
 207         bundleParams.put(VERBOSE.getID(), true);
 208 
 209         bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
 210 
 211         bundleParams.put(WinMsiBundler.TOOL_LIGHT_EXECUTABLE.getID(), "c:\\MissingTool.exe");
 212 
 213         File output = bundler.execute(bundleParams, new File(workDir, "BadLight"));
 214         assertNull(output);
 215     }
 216 
 217     /**
 218      * Test a misconfiguration where the wix tools are misconfigured.
 219      */
 220     @Test
 221     public void configLightNull() throws IOException, ConfigException, UnsupportedPlatformException {
 222         Bundler bundler = new WinMsiBundler();
 223 
 224         Map<String, Object> bundleParams = new HashMap<>();
 225 
 226         bundleParams.put(BUILD_ROOT.getID(), tmpBase);
 227         bundleParams.put(VERBOSE.getID(), true);
 228 
 229         bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
 230 
 231         bundleParams.put(WinMsiBundler.TOOL_LIGHT_EXECUTABLE.getID(), null);
 232 
 233         File output = bundler.execute(bundleParams, new File(workDir, "NullLight"));
 234         assertNull(output);
 235     }
 236 
 237     /**
 238      * Test a misconfiguration where the Wix tools are misconfigured.
 239      */
 240     @Test
 241     public void configCandleBad() throws IOException, ConfigException, UnsupportedPlatformException {
 242         Bundler bundler = new WinMsiBundler();
 243 
 244         Map<String, Object> bundleParams = new HashMap<>();
 245 
 246         bundleParams.put(BUILD_ROOT.getID(), tmpBase);
 247         bundleParams.put(VERBOSE.getID(), true);
 248 
 249         bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
 250 
 251         bundleParams.put(WinMsiBundler.TOOL_CANDLE_EXECUTABLE.getID(), "c:\\MissingTool.exe");
 252 
 253         File output = bundler.execute(bundleParams, new File(workDir, "BadCandle"));
 254         assertNull(output);
 255     }
 256 
 257     /**
 258      * Test a misconfiguration where the wix tools are misconfigured.
 259      */
 260     @Test
 261     public void configCandleNull() throws IOException, ConfigException, UnsupportedPlatformException {
 262         Bundler bundler = new WinMsiBundler();
 263 
 264         Map<String, Object> bundleParams = new HashMap<>();
 265 
 266         bundleParams.put(BUILD_ROOT.getID(), tmpBase);
 267         bundleParams.put(VERBOSE.getID(), true);
 268 
 269         bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
 270 
 271         bundleParams.put(WinMsiBundler.TOOL_CANDLE_EXECUTABLE.getID(), null);
 272 
 273         File output = bundler.execute(bundleParams, new File(workDir, "NullCandle"));
 274         assertNull(output);
 275     }
 276 
 277     @Test(expected = ConfigException.class)
 278     public void invalidLicenseFile() throws ConfigException, UnsupportedPlatformException {
 279         Bundler bundler = new WinMsiBundler();
 280 
 281         Map<String, Object> bundleParams = new HashMap<>();
 282 
 283         bundleParams.put(BUILD_ROOT.getID(), tmpBase);
 284 
 285         bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
 286         bundleParams.put(LICENSE_FILE.getID(), "BOGUS_LICENSE");
 287 
 288         bundler.validate(bundleParams);
 289     }
 290     
 291     @Test
 292     public void testValidateVersion() {
 293         String validVersions[] = {null, "1", "255", "1.0", "255.255.0", "255.255.6000"};
 294         String invalidVersions[] = {"alpha", "1.0-alpha", "10.300", "300", "10.10.100000"};
 295 
 296         for(String v: validVersions) {
 297             assertTrue("Expect to be valid ["+v+"]",
 298                     com.oracle.tools.packager.windows.WinMsiBundler.isVersionStringValid(v));
 299         }
 300 
 301         for(String v: invalidVersions) {
 302             assertFalse("Expect to be invalid ["+v+"]",
 303                     com.oracle.tools.packager.windows.WinMsiBundler.isVersionStringValid(v));
 304         }
 305     }
 306 
 307     @Test
 308     public void configureEverything() throws Exception {
 309         AbstractBundler bundler = new WinMsiBundler();
 310         Collection<BundlerParamInfo<?>> parameters = bundler.getBundleParameters();
 311 
 312         Map<String, Object> bundleParams = new HashMap<>();
 313 
 314         bundleParams.put(APP_NAME.getID(), "Everything App Name");
 315         bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
 316         bundleParams.put(ARGUMENTS.getID(), Arrays.asList("He Said", "She Said"));
 317         bundleParams.put(CLASSPATH.getID(), "mainApp.jar");
 318         bundleParams.put(ICON_ICO.getID(), new File(appResourcesDir, "javalogo_white_48.ico"));
 319         bundleParams.put(JVM_OPTIONS.getID(), "-Xms128M");
 320         bundleParams.put(JVM_PROPERTIES.getID(), "everything.jvm.property=everything.jvm.property.value");
 321         bundleParams.put(MAIN_CLASS.getID(), "hello.HelloRectangle");
 322         bundleParams.put(MAIN_JAR.getID(), "mainApp.jar");
 323         bundleParams.put(PREFERENCES_ID.getID(), "everything/preferences/id");
 324         bundleParams.put(PRELOADER_CLASS.getID(), "hello.HelloPreloader");
 325         bundleParams.put(PRODUCT_VERSION.getID(), "1.2.3");
 326         bundleParams.put(USER_JVM_OPTIONS.getID(), "-Xmx=256M\n");
 327         bundleParams.put(VERSION.getID(), "1.2.3-beta_20140604");
 328         bundleParams.put(WIN_RUNTIME.getID(), System.getProperty("java.home"));
 329 
 330         bundleParams.put(DESCRIPTION.getID(), "Everything Description");
 331         bundleParams.put(LICENSE_FILE.getID(), "LICENSE");
 332         bundleParams.put(MENU_GROUP.getID(), "EverythingMenuGroup");
 333         bundleParams.put(MENU_HINT.getID(), true);
 334 //                RUN_AT_STARTUP,
 335         bundleParams.put(SHORTCUT_HINT.getID(), true);
 336 //                SERVICE_HINT,
 337 //                START_ON_INSTALL,
 338 //                STOP_ON_UNINSTALL,
 339         bundleParams.put(SYSTEM_WIDE.getID(), false);
 340         bundleParams.put(INSTALLDIR_CHOOSER.getID(), true);
 341         bundleParams.put(VENDOR.getID(), "Everything Vendor");
 342         System.out.println(bundleParams.keySet());
 343 
 344         // assert they are set
 345         for (BundlerParamInfo bi :parameters) {
 346             assertTrue("Bundle args should contain " + bi.getID(), bundleParams.containsKey(bi.getID()));
 347         }
 348 
 349         // and only those are set
 350         bundleParamLoop:
 351         for (String s :bundleParams.keySet()) {
 352             for (BundlerParamInfo<?> bpi : parameters) {
 353                 if (s.equals(bpi.getID())) {
 354                     continue bundleParamLoop;
 355                 }
 356             }
 357             fail("Enumerated parameters does not contain " + s);
 358         }
 359 
 360         // assert they resolve
 361         for (BundlerParamInfo bi :parameters) {
 362             bi.fetchFrom(bundleParams);
 363         }
 364 
 365         // add verbose now that we are done scoping out parameters
 366         bundleParams.put(BUILD_ROOT.getID(), tmpBase);
 367         bundleParams.put(VERBOSE.getID(), true);
 368 
 369         // assert it validates
 370         boolean valid = bundler.validate(bundleParams);
 371         assertTrue(valid);
 372 
 373         // only run the bundle with full tests
 374         Assume.assumeTrue(Boolean.parseBoolean(System.getProperty("FULL_TEST")));
 375 
 376         File result = bundler.execute(bundleParams, new File(workDir, "everything"));
 377         System.err.println("Bundle at - " + result);
 378         assertNotNull(result);
 379         assertTrue(result.exists());
 380     }
 381 
 382 
 383     /**
 384      * multiple launchers
 385      */
 386     @Test
 387     public void twoLaunchersTest() throws IOException, ConfigException, UnsupportedPlatformException {
 388         Bundler bundler = new WinMsiBundler();
 389 
 390         assertNotNull(bundler.getName());
 391         assertNotNull(bundler.getID());
 392         assertNotNull(bundler.getDescription());
 393         //assertNotNull(bundler.getBundleParameters());
 394 
 395         Map<String, Object> bundleParams = new HashMap<>();
 396 
 397         bundleParams.put(BUILD_ROOT.getID(), tmpBase);
 398 
 399         bundleParams.put(APP_NAME.getID(), "Two Launchers Test");
 400         bundleParams.put(MAIN_CLASS.getID(), "hello.HelloRectangle");
 401         bundleParams.put(PREFERENCES_ID.getID(), "the/really/long/preferences/id");
 402         bundleParams.put(MAIN_JAR.getID(),
 403                 new RelativeFileSet(fakeMainJar.getParentFile(),
 404                         new HashSet<>(Arrays.asList(fakeMainJar)))
 405         );
 406         bundleParams.put(CLASSPATH.getID(), "mainApp.jar");
 407         bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
 408         bundleParams.put(VERBOSE.getID(), true);
 409 
 410         List<Map<String, ? super Object>> secondaryLaunchers = new ArrayList<>();
 411         for (String name : new String[] {"Fire", "More Fire"}) {
 412             Map<String, ? super Object> launcher = new HashMap<>();
 413             launcher.put(APP_NAME.getID(), name);
 414             launcher.put(PREFERENCES_ID.getID(), "secondary/launcher/" + name);
 415             secondaryLaunchers.add(launcher);
 416         }
 417         bundleParams.put(SECONDARY_LAUNCHERS.getID(), secondaryLaunchers);
 418 
 419         boolean valid = bundler.validate(bundleParams);
 420         assertTrue(valid);
 421 
 422         File output = bundler.execute(bundleParams, new File(workDir, "launchers"));
 423         assertNotNull(output);
 424         assertTrue(output.exists());
 425     }
 426 
 427     /**
 428      * Set File Association
 429      */
 430     @Test
 431     public void testFileAssociation()
 432         throws IOException, ConfigException, UnsupportedPlatformException
 433     {
 434         // only run the bundle with full tests
 435         Assume.assumeTrue(Boolean.parseBoolean(System.getProperty("FULL_TEST")));
 436 
 437         testFileAssociation("FASmoke 1", "Bogus File", "bogus", "application/x-vnd.test-bogus",
 438                             new File(appResourcesDir, "small.ico"));
 439     }
 440 
 441     @Test
 442     public void testFileAssociationWithNullExtension()
 443         throws IOException, ConfigException, UnsupportedPlatformException
 444     {
 445         // association with no extension is still valid case (see RT-38625)
 446         testFileAssociation("FASmoke null", "Bogus File", null, "application/x-vnd.test-bogus",
 447                             new File(appResourcesDir, "small.ico"));
 448     }
 449 
 450     @Test
 451     public void testFileAssociationWithMultipleExtension()
 452         throws IOException, ConfigException, UnsupportedPlatformException
 453     {
 454         // only run the bundle with full tests
 455         Assume.assumeTrue(Boolean.parseBoolean(System.getProperty("FULL_TEST")));
 456 
 457         testFileAssociation("FASmoke ME", "Bogus File", "bogus fake", "application/x-vnd.test-bogus",
 458                             new File(appResourcesDir, "small.ico"));
 459     }
 460 
 461     @Test
 462     public void testMultipleFileAssociation()
 463         throws IOException, ConfigException, UnsupportedPlatformException
 464     {
 465         // only run the bundle with full tests
 466         Assume.assumeTrue(Boolean.parseBoolean(System.getProperty("FULL_TEST")));
 467 
 468         testFileAssociationMultiples("FASmoke MA",
 469                 new String[]{"Bogus File", "Fake file"},
 470                 new String[]{"bogus", "fake"},
 471                 new String[]{"application/x-vnd.test-bogus", "application/x-vnd.test-fake"},
 472                 new File[]{new File(appResourcesDir, "small.ico"), new File(appResourcesDir, "small.ico")});
 473     }
 474 
 475     @Test
 476     public void testMultipleFileAssociationWithMultipleExtension()
 477         throws IOException, ConfigException, UnsupportedPlatformException
 478     {
 479         // association with no extension is still valid case (see RT-38625)
 480         testFileAssociationMultiples("FASmoke MAME",
 481                 new String[]{"Bogus File", "Fake file"},
 482                 new String[]{"bogus boguser", "fake faker"},
 483                 new String[]{"application/x-vnd.test-bogus", "application/x-vnd.test-fake"},
 484                 new File[]{new File(appResourcesDir, "small.ico"), new File(appResourcesDir, "small.ico")});
 485     }
 486     
 487     private void testFileAssociation(String appName, String description, String extensions,
 488                                      String contentType, File icon)
 489         throws IOException, ConfigException, UnsupportedPlatformException
 490     {
 491         testFileAssociationMultiples(appName, new String[] {description}, new String[] {extensions},
 492                 new String[] {contentType}, new File[] {icon});
 493     }
 494 
 495     private void testFileAssociationMultiples(String appName, String[] description, String[] extensions,
 496                                      String[] contentType, File[] icon)
 497         throws IOException, ConfigException, UnsupportedPlatformException
 498     {
 499         assertEquals("Sanity: description same length as extensions", description.length, extensions.length);
 500         assertEquals("Sanity: extensions same length as contentType", extensions.length, contentType.length);
 501         assertEquals("Sanity: contentType same length as icon", contentType.length, icon.length);
 502         
 503         AbstractBundler bundler = new WinMsiBundler();
 504 
 505         assertNotNull(bundler.getName());
 506         assertNotNull(bundler.getID());
 507         assertNotNull(bundler.getDescription());
 508         //assertNotNull(bundler.getBundleParameters());
 509 
 510         Map<String, Object> bundleParams = new HashMap<>();
 511 
 512         bundleParams.put(BUILD_ROOT.getID(), tmpBase);
 513 
 514         bundleParams.put(APP_NAME.getID(), appName);
 515         bundleParams.put(MAIN_CLASS.getID(), "hello.HelloRectangle");
 516         bundleParams.put(MAIN_JAR.getID(),
 517                 new RelativeFileSet(fakeMainJar.getParentFile(),
 518                         new HashSet<>(Arrays.asList(fakeMainJar)))
 519         );
 520         bundleParams.put(CLASSPATH.getID(), "mainApp.jar");
 521         bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
 522         bundleParams.put(VERBOSE.getID(), true);
 523         bundleParams.put(SYSTEM_WIDE.getID(), true);
 524         bundleParams.put(VENDOR.getID(), "Packager Tests");
 525 
 526         List<Map<String, Object>> associations = new ArrayList<>();
 527         
 528         for (int i = 0; i < description.length; i++) {
 529             Map<String, Object> fileAssociation = new HashMap<>();
 530             fileAssociation.put(FA_DESCRIPTION.getID(), description[i]);
 531             fileAssociation.put(FA_EXTENSIONS.getID(), extensions[i]);
 532             fileAssociation.put(FA_CONTENT_TYPE.getID(), contentType[i]);
 533             fileAssociation.put(FA_ICON.getID(), icon[i]);
 534 
 535             associations.add(fileAssociation);
 536         }
 537 
 538         bundleParams.put(FILE_ASSOCIATIONS.getID(), associations);
 539 
 540         boolean valid = bundler.validate(bundleParams);
 541         assertTrue(valid);
 542 
 543         File result = bundler.execute(bundleParams, new File(workDir, APP_FS_NAME.fetchFrom(bundleParams)));
 544         System.err.println("Bundle at - " + result);
 545         assertNotNull(result);
 546         assertTrue(result.exists());            
 547     }
 548 
 549 
 550     /**
 551      * Turn on AppCDS
 552      */
 553     @Test
 554     public void testAppCDS() throws IOException, ConfigException, UnsupportedPlatformException {
 555         Bundler bundler = new WinMsiBundler();
 556 
 557         Map<String, Object> bundleParams = new HashMap<>();
 558 
 559         // not part of the typical setup, for testing
 560         bundleParams.put(BUILD_ROOT.getID(), tmpBase);
 561         bundleParams.put(VERBOSE.getID(), true);
 562         if (runtimeJdk != null) {
 563             bundleParams.put(WIN_RUNTIME.getID(), runtimeJdk);
 564         }
 565 
 566         bundleParams.put(APP_NAME.getID(), "AppCDS");
 567         bundleParams.put(IDENTIFIER.getID(), "com.example.appcds.msi.Test");
 568         bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
 569         bundleParams.put(UNLOCK_COMMERCIAL_FEATURES.getID(), true);
 570         bundleParams.put(ENABLE_APP_CDS.getID(), true);
 571 
 572         boolean valid = bundler.validate(bundleParams);
 573         assertTrue(valid);
 574 
 575         File output = bundler.execute(bundleParams, new File(workDir, "CDSTest"));
 576         System.err.println("Bundle at - " + output);
 577         assertNotNull(output);
 578         assertTrue(output.exists());
 579     }
 580 }