1 
   2 package com.oracle.appbundlers.tests.functionality;
   3 
   4 import static com.oracle.appbundlers.utils.installers.AbstractBundlerUtils.OUTPUT_CONTAINS;
   5 import static com.oracle.appbundlers.utils.installers.AbstractBundlerUtils.SECOND_LAUNCHER_MULTI_OUTPUT_CONTAINS;
   6 import static java.util.Arrays.asList;
   7 
   8 import java.io.IOException;
   9 import java.util.ArrayList;
  10 import java.util.HashMap;
  11 import java.util.List;
  12 import java.util.Map;
  13 
  14 import com.oracle.appbundlers.tests.functionality.functionalinterface.AdditionalParams;
  15 import com.oracle.appbundlers.tests.functionality.functionalinterface.VerifiedOptions;
  16 import com.oracle.appbundlers.utils.BundlerUtils;
  17 import com.oracle.appbundlers.utils.BundlingManagers;
  18 import com.oracle.appbundlers.utils.ExtensionType;
  19 
  20 import javafx.util.Pair;
  21 
  22 /**
  23  *
  24  * @author Dmitry Zinkevich <dmitry.zinkevich@oracle.com&gt
  25  */
  26 public class CoupleSecondaryLaunchersTest extends TestBase {
  27 
  28     private static final String appName = "SQE-TEST-APP";
  29     private static final String secondAppName = "app2";
  30     private static final String thirdAppName = "app3";
  31 
  32     @Override
  33     public String getResultingAppName() {
  34         return appName;
  35     }
  36 
  37     @Override
  38     protected BundlingManagers[] getBundlingManagers() {
  39         return new BundlingManagers[] { BundlingManagers.ANT,
  40                 BundlingManagers.JAVA_API };
  41     }
  42 
  43     @Override
  44     protected BundlerUtils[] getBundlerUtils() {
  45         return new BundlerUtils[] {
  46                 /* Linux */
  47                 BundlerUtils.DEB, BundlerUtils.RPM, BundlerUtils.LINUX_APP,
  48                 /* Windows */
  49                 BundlerUtils.EXE, BundlerUtils.MSI, BundlerUtils.WIN_APP
  50                 /*
  51                  * MacOS is not supported. See
  52                  * https://bugs.openjdk.java.net/browse/JDK-8096558
  53                  */
  54         };
  55     }
  56 
  57     public AdditionalParams getAdditionalParams() {
  58         return () -> {
  59             Map<String, Object> additionalParams = new HashMap<>();
  60             additionalParams.put(APP_NAME_REPLACEMENT_STATEMENT, appName);
  61 
  62             List<Map<String, Object>> launchers = new ArrayList<>();
  63 
  64             Map<String, Object> launcherParams = new HashMap<>();
  65             launcherParams.put(APP_NAME_REPLACEMENT_STATEMENT, secondAppName);
  66             launcherParams.put(APPLICATION_CLASS, APP1_FULLNAME);
  67             launcherParams.put(ARGUMENTS, asList(secondAppName));
  68 
  69             launchers.add(launcherParams);
  70 
  71             launcherParams = new HashMap<>();
  72             launcherParams.put(APP_NAME_REPLACEMENT_STATEMENT, thirdAppName);
  73             launcherParams.put(APPLICATION_CLASS, APP2_FULLNAME);
  74             launcherParams.put(ARGUMENTS, asList(thirdAppName));
  75             launchers.add(launcherParams);
  76 
  77             additionalParams.put(SECONDARY_LAUNCHERS, launchers);
  78 
  79             return additionalParams;
  80         };
  81 
  82     }
  83 
  84     public VerifiedOptions getVerifiedOptions() {
  85         return () -> {
  86             Map<String, Object> verifiedOptions = getAdditionalParams()
  87                     .getAdditionalParams();
  88             verifiedOptions.put(SECOND_LAUNCHER_MULTI_OUTPUT_CONTAINS,
  89                     new Pair<>(secondAppName, asList(PASS_1, secondAppName)));
  90             verifiedOptions.put(SECOND_LAUNCHER_MULTI_OUTPUT_CONTAINS,
  91                     new Pair<>(thirdAppName, asList(PASS_2, thirdAppName)));
  92             verifiedOptions.put(OUTPUT_CONTAINS, PASS_1);
  93             return verifiedOptions;
  94         };
  95     }
  96 
  97     @Override
  98     public void overrideParameters(ExtensionType intermediate)
  99             throws IOException {
 100         this.currentParameter.setAdditionalParams(getAdditionalParams());
 101         this.currentParameter.setVerifiedOptions(getVerifiedOptions());
 102     }
 103 }