modules/fxpackager/src/test/java/com/oracle/tools/packager/linux/LinuxDebBundlerTest.java

Print this page




  36 import com.oracle.tools.packager.UnsupportedPlatformException;
  37 import org.junit.After;
  38 import org.junit.Assume;
  39 import org.junit.Before;
  40 import org.junit.BeforeClass;
  41 import org.junit.Test;
  42 
  43 import java.io.File;
  44 import java.io.IOException;
  45 import java.util.ArrayList;
  46 import java.util.Arrays;
  47 import java.util.Collection;
  48 import java.util.HashMap;
  49 import java.util.HashSet;
  50 import java.util.List;
  51 import java.util.Map;
  52 import java.util.Set;
  53 import java.util.TreeMap;
  54 
  55 import static com.oracle.tools.packager.StandardBundlerParam.*;

  56 import static com.oracle.tools.packager.linux.LinuxDebBundler.BUNDLE_NAME;
  57 import static com.oracle.tools.packager.linux.LinuxDebBundler.EMAIL;
  58 import static org.junit.Assert.*;
  59 
  60 public class LinuxDebBundlerTest {
  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 linux
  72         Assume.assumeTrue(System.getProperty("os.name").toLowerCase().startsWith("linux"));
  73 



  74         Assume.assumeTrue(LinuxDebBundler.testTool(LinuxDebBundler.TOOL_DPKG, "1"));
  75 
  76         Log.setLogger(new Log.Logger(true));
  77         Log.setDebug(true);
  78 
  79         retain = Boolean.parseBoolean(System.getProperty("RETAIN_PACKAGER_TESTS"));
  80 
  81         workDir = new File("build/tmp/tests", "linuxdeb");
  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) {


 569         bundleParams.put(SERVICE_HINT.getID(), true);
 570         bundleParams.put(SYSTEM_WIDE.getID(), false);
 571 
 572         bundler.validate(bundleParams);
 573     }
 574 
 575     @Test
 576     public void perSystemDaemonTest() throws ConfigException, UnsupportedPlatformException {
 577         AbstractBundler bundler = new LinuxDebBundler();
 578 
 579         Map<String, Object> bundleParams = new HashMap<>();
 580         
 581         bundleParams.put(BUILD_ROOT.getID(), tmpBase);
 582         bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
 583 
 584         bundleParams.put(SERVICE_HINT.getID(), true);
 585         bundleParams.put(SYSTEM_WIDE.getID(), true);
 586 
 587         bundler.validate(bundleParams);
 588     }
































 589 }


  36 import com.oracle.tools.packager.UnsupportedPlatformException;
  37 import org.junit.After;
  38 import org.junit.Assume;
  39 import org.junit.Before;
  40 import org.junit.BeforeClass;
  41 import org.junit.Test;
  42 
  43 import java.io.File;
  44 import java.io.IOException;
  45 import java.util.ArrayList;
  46 import java.util.Arrays;
  47 import java.util.Collection;
  48 import java.util.HashMap;
  49 import java.util.HashSet;
  50 import java.util.List;
  51 import java.util.Map;
  52 import java.util.Set;
  53 import java.util.TreeMap;
  54 
  55 import static com.oracle.tools.packager.StandardBundlerParam.*;
  56 import static com.oracle.tools.packager.linux.LinuxAppBundler.LINUX_RUNTIME;
  57 import static com.oracle.tools.packager.linux.LinuxDebBundler.BUNDLE_NAME;
  58 import static com.oracle.tools.packager.linux.LinuxDebBundler.EMAIL;
  59 import static org.junit.Assert.*;
  60 
  61 public class LinuxDebBundlerTest {
  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 linux
  75         Assume.assumeTrue(System.getProperty("os.name").toLowerCase().startsWith("linux"));
  76 
  77         runtimeJdk = System.getenv("PACKAGER_JDK_ROOT");
  78         runtimeJre = System.getenv("PACKAGER_JRE_ROOT");
  79 
  80         Assume.assumeTrue(LinuxDebBundler.testTool(LinuxDebBundler.TOOL_DPKG, "1"));
  81 
  82         Log.setLogger(new Log.Logger(true));
  83         Log.setDebug(true);
  84 
  85         retain = Boolean.parseBoolean(System.getProperty("RETAIN_PACKAGER_TESTS"));
  86 
  87         workDir = new File("build/tmp/tests", "linuxdeb");
  88         appResourcesDir = new File("build/tmp/tests", "appResources");
  89         fakeMainJar = new File(appResourcesDir, "mainApp.jar");
  90 
  91         appResources = new HashSet<>(Arrays.asList(fakeMainJar,
  92                 new File(appResourcesDir, "LICENSE"),
  93                 new File(appResourcesDir, "LICENSE2")
  94         ));
  95     }
  96 
  97     @Before
  98     public void createTmpDir() throws IOException {
  99         if (retain) {


 575         bundleParams.put(SERVICE_HINT.getID(), true);
 576         bundleParams.put(SYSTEM_WIDE.getID(), false);
 577 
 578         bundler.validate(bundleParams);
 579     }
 580 
 581     @Test
 582     public void perSystemDaemonTest() throws ConfigException, UnsupportedPlatformException {
 583         AbstractBundler bundler = new LinuxDebBundler();
 584 
 585         Map<String, Object> bundleParams = new HashMap<>();
 586         
 587         bundleParams.put(BUILD_ROOT.getID(), tmpBase);
 588         bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
 589 
 590         bundleParams.put(SERVICE_HINT.getID(), true);
 591         bundleParams.put(SYSTEM_WIDE.getID(), true);
 592 
 593         bundler.validate(bundleParams);
 594     }
 595 
 596 
 597     /**
 598      * Turn on AppCDS
 599      */
 600     @Test
 601     public void testAppCDS() throws IOException, ConfigException, UnsupportedPlatformException {
 602         Bundler bundler = new LinuxDebBundler();
 603 
 604         Map<String, Object> bundleParams = new HashMap<>();
 605 
 606         // not part of the typical setup, for testing
 607         bundleParams.put(BUILD_ROOT.getID(), tmpBase);
 608         bundleParams.put(VERBOSE.getID(), true);
 609         if (runtimeJdk != null) {
 610             bundleParams.put(LINUX_RUNTIME.getID(), runtimeJdk);
 611         }
 612 
 613         bundleParams.put(APP_NAME.getID(), "AppCDS");
 614         bundleParams.put(IDENTIFIER.getID(), "com.example.appcds.deb.Test");
 615         bundleParams.put(APP_RESOURCES.getID(), new RelativeFileSet(appResourcesDir, appResources));
 616         bundleParams.put(UNLOCK_COMMERCIAL_FEATURES.getID(), true);
 617         bundleParams.put(ENABLE_APP_CDS.getID(), true);
 618 
 619         boolean valid = bundler.validate(bundleParams);
 620         assertTrue(valid);
 621 
 622         File output = bundler.execute(bundleParams, new File(workDir, "CDSTest"));
 623         System.err.println("Bundle at - " + output);
 624         assertNotNull(output);
 625         assertTrue(output.exists());
 626     }
 627 }