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

Print this page




  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.WindowsBundlerParam.WIN_RUNTIME;
  56 import static com.oracle.tools.packager.windows.WindowsBundlerParam.MENU_GROUP;
  57 import static com.oracle.tools.packager.windows.WindowsBundlerParam.INSTALLDIR_CHOOSER;
  58 import static org.junit.Assert.*;
  59  
  60 public class WinExeBundlerTest {
  61 
  62     static File tmpBase;
  63     static File workDir;
  64     static File appResourcesDir;
  65     static File fakeMainJar;


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



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


 494         for (int i = 0; i < description.length; i++) {
 495             Map<String, Object> fileAssociation = new HashMap<>();
 496             fileAssociation.put(FA_DESCRIPTION.getID(), description[i]);
 497             fileAssociation.put(FA_EXTENSIONS.getID(), extensions[i]);
 498             fileAssociation.put(FA_CONTENT_TYPE.getID(), contentType[i]);
 499             fileAssociation.put(FA_ICON.getID(), icon[i]);
 500 
 501             associations.add(fileAssociation);
 502         }
 503 
 504         bundleParams.put(FILE_ASSOCIATIONS.getID(), associations);
 505 
 506         boolean valid = bundler.validate(bundleParams);
 507         assertTrue(valid);
 508 
 509         File result = bundler.execute(bundleParams, new File(workDir, APP_FS_NAME.fetchFrom(bundleParams)));
 510         System.err.println("Bundle at - " + result);
 511         assertNotNull(result);
 512         assertTrue(result.exists());
 513     }
































 514 }


  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.WindowsBundlerParam.WIN_RUNTIME;
  56 import static com.oracle.tools.packager.windows.WindowsBundlerParam.MENU_GROUP;
  57 import static com.oracle.tools.packager.windows.WindowsBundlerParam.INSTALLDIR_CHOOSER;
  58 import static org.junit.Assert.*;
  59  
  60 public class WinExeBundlerTest {
  61 
  62     static File tmpBase;
  63     static File workDir;
  64     static File appResourcesDir;
  65     static File fakeMainJar;
  66     static String runtimeJdk;
  67     static String runtimeJre;
  68     static Set<File> appResources;
  69     static boolean retain = false;
  70 
  71     @BeforeClass
  72     public static void prepareApp() {
  73         // only run on windows
  74         Assume.assumeTrue(System.getProperty("os.name").toLowerCase().startsWith("win"));
  75 
  76         runtimeJdk = System.getenv("PACKAGER_JDK_ROOT");
  77         runtimeJre = System.getenv("PACKAGER_JRE_ROOT");
  78 
  79         // only run if we have InnoSetup installed
  80         Assume.assumeNotNull(WinExeBundler.TOOL_INNO_SETUP_COMPILER_EXECUTABLE.fetchFrom(new HashMap<>()));
  81 
  82         Log.setLogger(new Log.Logger(true));
  83 
  84         retain = Boolean.parseBoolean(System.getProperty("RETAIN_PACKAGER_TESTS"));
  85 
  86         workDir = new File("build/tmp/tests", "winexe");
  87         appResourcesDir = new File("build/tmp/tests", "appResources");
  88         fakeMainJar = new File(appResourcesDir, "mainApp.jar");
  89 
  90         appResources = new HashSet<>(Arrays.asList(fakeMainJar,
  91                 new File(appResourcesDir, "LICENSE"),
  92                 new File(appResourcesDir, "LICENSE2")
  93         ));
  94     }
  95 
  96     @Before
  97     public void createTmpDir() throws IOException {
  98         if (retain) {


 499         for (int i = 0; i < description.length; i++) {
 500             Map<String, Object> fileAssociation = new HashMap<>();
 501             fileAssociation.put(FA_DESCRIPTION.getID(), description[i]);
 502             fileAssociation.put(FA_EXTENSIONS.getID(), extensions[i]);
 503             fileAssociation.put(FA_CONTENT_TYPE.getID(), contentType[i]);
 504             fileAssociation.put(FA_ICON.getID(), icon[i]);
 505 
 506             associations.add(fileAssociation);
 507         }
 508 
 509         bundleParams.put(FILE_ASSOCIATIONS.getID(), associations);
 510 
 511         boolean valid = bundler.validate(bundleParams);
 512         assertTrue(valid);
 513 
 514         File result = bundler.execute(bundleParams, new File(workDir, APP_FS_NAME.fetchFrom(bundleParams)));
 515         System.err.println("Bundle at - " + result);
 516         assertNotNull(result);
 517         assertTrue(result.exists());
 518     }
 519 
 520     /**
 521      * Turn on AppCDS
 522      */
 523     @Test
 524     public void testAppCDS() throws IOException, ConfigException, UnsupportedPlatformException {
 525         Bundler bundler = new WinExeBundler();
 526 
 527         Map<String, Object> bundleParams = new HashMap<>();
 528 
 529         // not part of the typical setup, for testing
 530         bundleParams.put(BUILD_ROOT.getID(), tmpBase);
 531         bundleParams.put(VERBOSE.getID(), true);
 532         if (runtimeJdk != null) {
 533             bundleParams.put(WIN_RUNTIME.getID(), runtimeJdk);
 534         }
 535 
 536         bundleParams.put(APP_NAME.getID(), "AppCDS");
 537         bundleParams.put(IDENTIFIER.getID(), "com.example.appcds.exe.Test");
 538         bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
 539         bundleParams.put(UNLOCK_COMMERCIAL_FEATURES.getID(), true);
 540         bundleParams.put(ENABLE_APP_CDS.getID(), true);
 541 
 542         boolean valid = bundler.validate(bundleParams);
 543         assertTrue(valid);
 544 
 545         File output = bundler.execute(bundleParams, new File(workDir, "CDSTest"));
 546         System.err.println("Bundle at - " + output);
 547         assertNotNull(output);
 548         assertTrue(output.exists());
 549     }
 550     
 551 }