< prev index next >

functional/appBundlerTestsJDK9/appBundlerTestsJDK9/test/com/oracle/appbundlers/tests/functionality/TestBase.java

Print this page

        

*** 28,38 **** import static com.oracle.appbundlers.utils.Utils.isWindows; import static java.util.stream.Collectors.toList; import java.io.IOException; import java.lang.reflect.Method; - import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.concurrent.ExecutionException; --- 28,37 ----
*** 77,116 **** */ public abstract class TestBase implements Constants { protected BundlingManager bundlingManager; protected Parameters currentParameter; ! protected Map<ExtensionType, Parameters> intermediateToParametersMap = new HashMap<ExtensionType, Parameters>(); protected static final Logger LOG = Logger .getLogger(TestBase.class.getName()); protected Method testMethod = null; - protected void populateIntermediateToParametersMap() { - for (ExtensionType extension : getExtensionArray()) { - switch (extension) { - case NormalJar: - intermediateToParametersMap.put(extension, - new NormalJarParameters()); - break; - case ModularJar: - intermediateToParametersMap.put(extension, - new ModularJarParameters()); - break; - case ExplodedModules: - intermediateToParametersMap.put(extension, - new ExplodedModuleParameters()); - break; - case Jmods: - intermediateToParametersMap.put(extension, - new JmodParameters()); - break; - } - } - } - // method block: should be overridden in some tests // all these implementations are just "default-values" protected BundlerUtils[] getBundlerUtils() { return BundlerUtils.values(); } --- 76,104 ---- */ public abstract class TestBase implements Constants { protected BundlingManager bundlingManager; protected Parameters currentParameter; ! protected Map<ExtensionType, Parameters> intermediateToParametersMap = new HashMap<ExtensionType, Parameters>() { ! /** ! * serial version UID ! */ ! private static final long serialVersionUID = -9110787670838081437L; ! ! { ! put(ExtensionType.NormalJar, new NormalJarParameters()); ! put(ExtensionType.ModularJar, new ModularJarParameters()); ! put(ExtensionType.ExplodedModules, new ExplodedModuleParameters()); ! put(ExtensionType.Jmods, new JmodParameters()); ! } ! }; protected static final Logger LOG = Logger .getLogger(TestBase.class.getName()); protected Method testMethod = null; // method block: should be overridden in some tests // all these implementations are just "default-values" protected BundlerUtils[] getBundlerUtils() { return BundlerUtils.values(); }
*** 132,164 **** protected void prepareApp(final AppWrapper app, ExtensionType extension) throws IOException, ExecutionException { app.preinstallApp(extension); app.writeSourcesToAppDirectory(); ! app.compileApp(extension); app.jarApp(extension); } @BeforeClass public void setupApplication() throws Exception { Log.setLogger(new Log.Logger(true)); - populateIntermediateToParametersMap(); prepareTestEnvironment(); customBeforeClassHook(); } public void customBeforeClassHook() throws Exception { } protected void prepareTestEnvironment() throws Exception { ! for (ExtensionType extension : getExtensionArray()) { ! if(!isTestCaseApplicableForExtensionType(extension)) { ! continue; ! } this.currentParameter = this.intermediateToParametersMap ! .get(extension); ! overrideParameters(extension); initializeAndPrepareApp(); } } protected void initializeAndPrepareApp() throws Exception { --- 120,148 ---- protected void prepareApp(final AppWrapper app, ExtensionType extension) throws IOException, ExecutionException { app.preinstallApp(extension); app.writeSourcesToAppDirectory(); ! app.compileApp(); app.jarApp(extension); } @BeforeClass public void setupApplication() throws Exception { Log.setLogger(new Log.Logger(true)); prepareTestEnvironment(); customBeforeClassHook(); } public void customBeforeClassHook() throws Exception { } protected void prepareTestEnvironment() throws Exception { ! for (ExtensionType intermediate : ExtensionType.values()) { this.currentParameter = this.intermediateToParametersMap ! .get(intermediate); ! overrideParameters(intermediate); initializeAndPrepareApp(); } } protected void initializeAndPrepareApp() throws Exception {
*** 174,199 **** testMethod = method; } @Test(dataProvider = "getBundlers") public void runTest(BundlingManager bundlingManager) throws Exception { this.currentParameter = intermediateToParametersMap ! .get(bundlingManager.getExtensionType()); ! if (!isTestCaseApplicableForExtensionType( ! bundlingManager.getExtensionType())) { ! return; } ! Map<String, Object> allParams = getAllParams(); String testName = this.getClass().getName() + "::" + testMethod.getName() + "$" + bundlingManager.toString(); this.bundlingManager = bundlingManager; LOG.log(Level.INFO, "Starting test \"{0}\".", testName); try { validate(); if (isConfigExceptionExpected(bundlingManager.getBundler())) { ! Assert.fail("ConfigException is expected, but isn't thrown"); } } catch (ConfigException ex) { if (isConfigExceptionExpected(bundlingManager.getBundler())) { return; } else { --- 158,184 ---- testMethod = method; } @Test(dataProvider = "getBundlers") public void runTest(BundlingManager bundlingManager) throws Exception { + for (ExtensionType extension : getExtensionArray()) { this.currentParameter = intermediateToParametersMap ! .get(extension); ! if (!isTestCaseApplicableForExtensionType(extension)) { ! continue; } ! Map<String, Object> allParams = getAllParams(extension); String testName = this.getClass().getName() + "::" + testMethod.getName() + "$" + bundlingManager.toString(); this.bundlingManager = bundlingManager; LOG.log(Level.INFO, "Starting test \"{0}\".", testName); try { validate(); if (isConfigExceptionExpected(bundlingManager.getBundler())) { ! Assert.fail( ! "ConfigException is expected, but isn't thrown"); } } catch (ConfigException ex) { if (isConfigExceptionExpected(bundlingManager.getBundler())) { return; } else {
*** 202,242 **** throw ex; } } try { ! bundlingManager.execute(allParams, this.currentParameter.getApp()); String path = bundlingManager.install( this.currentParameter.getApp(), getResultingAppName(), false); LOG.log(Level.INFO, "Installed at: {0}", path); Pair<TimeUnit, Integer> tuple = getDelayAfterInstall(); tuple.getKey().sleep(tuple.getValue()); AppWrapper app2 = this.currentParameter.getApp(); ! this.currentParameter.getVerifiedOptions() ! .forEach((name, value) -> bundlingManager.verifyOption(name, value, app2, getResultingAppName())); ! } finally { ! uninstallApp(); LOG.log(Level.INFO, "Finished test: {0}", testName); } } public boolean isTestCaseApplicableForExtensionType( ExtensionType extension) { return true; } public ExtensionType[] getExtensionArray() { return ExtensionType.values(); } ! protected void uninstallApp() throws Exception { ! if (this.bundlingManager != null) { ! String appName = this.bundlingManager.getAppName(getAllParams()); ! this.bundlingManager.uninstall(this.currentParameter.getApp(), appName); } } @AfterClass protected void cleanUp() throws IOException { --- 187,232 ---- throw ex; } } try { ! bundlingManager.execute(allParams, ! this.currentParameter.getApp()); String path = bundlingManager.install( this.currentParameter.getApp(), getResultingAppName(), false); LOG.log(Level.INFO, "Installed at: {0}", path); Pair<TimeUnit, Integer> tuple = getDelayAfterInstall(); tuple.getKey().sleep(tuple.getValue()); AppWrapper app2 = this.currentParameter.getApp(); ! this.currentParameter.getVerifiedOptions().forEach( ! (name, value) -> bundlingManager.verifyOption(name, value, app2, getResultingAppName())); ! } ! ! finally { ! uninstallApp(extension); LOG.log(Level.INFO, "Finished test: {0}", testName); } } + } public boolean isTestCaseApplicableForExtensionType( ExtensionType extension) { return true; } public ExtensionType[] getExtensionArray() { return ExtensionType.values(); } ! protected void uninstallApp(ExtensionType intermediate) throws Exception { ! if (bundlingManager != null) { ! String appName = bundlingManager ! .getAppName(getAllParams(intermediate)); ! bundlingManager.uninstall(this.currentParameter.getApp(), appName); } } @AfterClass protected void cleanUp() throws IOException {
*** 265,275 **** .of(getBundlerUtils()).filter(BundlerUtils::isSupported) .filter(PackageTypeFilter::accept) .map(BundlerUtils::getBundlerUtils).collect(toList()); return BundlerProvider.createBundlingManagers(installationPackageTypes, ! packagerInterfaces, Arrays.asList(getExtensionArray())); } public boolean mustBeSupported(String bundlerId) { if (isLinux()) { return bundlerId.equals("linux.app") || bundlerId.equals("deb") --- 255,265 ---- .of(getBundlerUtils()).filter(BundlerUtils::isSupported) .filter(PackageTypeFilter::accept) .map(BundlerUtils::getBundlerUtils).collect(toList()); return BundlerProvider.createBundlingManagers(installationPackageTypes, ! packagerInterfaces); } public boolean mustBeSupported(String bundlerId) { if (isLinux()) { return bundlerId.equals("linux.app") || bundlerId.equals("deb")
*** 286,307 **** protected Pair<TimeUnit, Integer> getDelayAfterInstall() { return new Pair<TimeUnit, Integer>(TimeUnit.MILLISECONDS, 100); } ! protected Map<String, Object> getAllParams() throws Exception { Map<String, Object> basicParams = this.currentParameter .getBasicParams(); Map<String, Object> allParams = new HashMap<String, Object>(); allParams.put(APP_NAME, getResultingAppName()); allParams.putAll(basicParams); allParams.putAll(this.currentParameter.getAdditionalParams()); return allParams; } public void validate() throws Exception { ! this.bundlingManager.validate(this.currentParameter.getBasicParams()); } public Parameters getParameters() { return this.currentParameter; } --- 276,298 ---- protected Pair<TimeUnit, Integer> getDelayAfterInstall() { return new Pair<TimeUnit, Integer>(TimeUnit.MILLISECONDS, 100); } ! protected Map<String, Object> getAllParams(ExtensionType intermediate) ! throws Exception { Map<String, Object> basicParams = this.currentParameter .getBasicParams(); Map<String, Object> allParams = new HashMap<String, Object>(); allParams.put(APP_NAME, getResultingAppName()); allParams.putAll(basicParams); allParams.putAll(this.currentParameter.getAdditionalParams()); return allParams; } public void validate() throws Exception { ! bundlingManager.validate(this.currentParameter.getBasicParams()); } public Parameters getParameters() { return this.currentParameter; }
< prev index next >