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

Print this page




  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 Set<File> appResources;
  68     static boolean retain = false;
  69 
  70     @BeforeClass
  71     public static void prepareApp() {
  72         // only run on windows
  73         Assume.assumeTrue(System.getProperty("os.name").toLowerCase().startsWith("win"));
  74 



  75         // only run if we have Wix tools installed
  76         Assume.assumeNotNull(WinMsiBundler.TOOL_LIGHT_EXECUTABLE.fetchFrom(new HashMap<>()));
  77         Assume.assumeNotNull(WinMsiBundler.TOOL_CANDLE_EXECUTABLE.fetchFrom(new HashMap<>()));
  78 
  79         Log.setLogger(new Log.Logger(true));
  80 
  81         retain = Boolean.parseBoolean(System.getProperty("RETAIN_PACKAGER_TESTS"));
  82 
  83         workDir = new File("build/tmp/tests", "winmsi");
  84         appResourcesDir = new File("build/tmp/tests", "appResources");
  85         fakeMainJar = new File(appResourcesDir, "mainApp.jar");
  86 
  87         appResources = new HashSet<>(Arrays.asList(fakeMainJar,
  88                 new File(appResourcesDir, "LICENSE"),
  89                 new File(appResourcesDir, "LICENSE2")
  90         ));
  91     }
  92 
  93     @Before
  94     public void createTmpDir() throws IOException {


 523         for (int i = 0; i < description.length; i++) {
 524             Map<String, Object> fileAssociation = new HashMap<>();
 525             fileAssociation.put(FA_DESCRIPTION.getID(), description[i]);
 526             fileAssociation.put(FA_EXTENSIONS.getID(), extensions[i]);
 527             fileAssociation.put(FA_CONTENT_TYPE.getID(), contentType[i]);
 528             fileAssociation.put(FA_ICON.getID(), icon[i]);
 529 
 530             associations.add(fileAssociation);
 531         }
 532 
 533         bundleParams.put(FILE_ASSOCIATIONS.getID(), associations);
 534 
 535         boolean valid = bundler.validate(bundleParams);
 536         assertTrue(valid);
 537 
 538         File result = bundler.execute(bundleParams, new File(workDir, APP_FS_NAME.fetchFrom(bundleParams)));
 539         System.err.println("Bundle at - " + result);
 540         assertNotNull(result);
 541         assertTrue(result.exists());            
 542     }
































 543 }


  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 {


 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 }