From 1e18a7b0bb747b36e3d4932973079a2706010d65 Mon Sep 17 00:00:00 2001 From: Ondrej Dockal Date: Thu, 19 Apr 2018 12:55:01 +0200 Subject: [PATCH] JBIDE-25870 - Add CDK runtime download integration tests - ITests for downloading container runtimes CDK 3.x, CDK 3.2+ and Minishift 1.14 - Checking passing of credentials in download runtime wizard - Tests downloading into default folders Signed-off-by: Ondrej Dockal --- .../META-INF/MANIFEST.MF | 6 +- .../cdk/ui/bot/test/CDKAbstractTest.java | 18 +- .../cdk/ui/bot/test/CDKAllTestsSuite.java | 14 +- .../cdk/ui/bot/test/CDKSmokeTestsSuite.java | 10 +- .../cdk/ui/bot/test/CDKUITestsSuite.java | 62 +++++++ .../ui/bot/test/MinishiftAllTestsSuite.java | 2 + .../CDK32ServerAdapterProfilesTest.java | 4 +- .../server/adapter/CDK3IntegrationTest.java | 2 +- .../adapter/CDKServerAdapterAbstractTest.java | 11 ++ .../MinishiftServerAdapterProfilesTest.java | 5 +- .../CDKImageRegistryUrlAbstractTest.java | 2 +- .../CDKImageRegistryUrlDiscoveryTest.java | 4 +- .../CDKImageRegistryUrlValidatorTest.java | 3 +- .../server/wizard/CDK32ServerWizardTest.java | 21 ++- .../server/wizard/CDK3ServerWizardTest.java | 19 +- .../wizard/CDKServerWizardAbstractTest.java | 34 +--- .../wizard/MinishiftServerWizardTest.java | 19 +- .../download/CDK32DownloadRuntimeTest.java | 46 +++++ .../download/CDK3DownloadRuntimeTest.java | 43 +++++ .../DownloadContainerRuntimeAbstractTest.java | 164 ++++++++++++++++++ ...adContainerRuntimeDefaultSettingsTest.java | 38 ++++ .../download/DownloadRuntimesWizardTest.java | 64 +++++++ .../MinishiftDownloadRuntimeTest.java | 33 ++++ .../cdk/ui/bot/test/utils/CDKTestUtils.java | 20 +++ .../utils/DownloadCDKRuntimesUtility.java | 150 ++++++++++++++++ .../META-INF/MANIFEST.MF | 5 +- .../core/condition/ProgressBarIsRunning.java | 50 ++++++ .../cdk/reddeer/core/enums/CDKRuntimeOS.java | 27 +-- .../cdk/reddeer/core/enums/CDKVersion.java | 63 +++++++ .../cdk/reddeer/core/label/CDKLabel.java | 21 ++- .../CleanDockerExplorerRequirement.java | 16 +- .../ui/wizard/NewCDK3ServerWizardPage.java | 7 + .../download/DownloadCDKRuntimesWizard.java | 65 +++++++ .../tools/cdk/reddeer/utils/CDKUtils.java | 4 + 34 files changed, 956 insertions(+), 96 deletions(-) create mode 100644 itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/CDKUITestsSuite.java create mode 100644 itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/download/CDK32DownloadRuntimeTest.java create mode 100644 itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/download/CDK3DownloadRuntimeTest.java create mode 100644 itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/download/DownloadContainerRuntimeAbstractTest.java create mode 100644 itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/download/DownloadContainerRuntimeDefaultSettingsTest.java create mode 100644 itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/download/DownloadRuntimesWizardTest.java create mode 100644 itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/download/MinishiftDownloadRuntimeTest.java create mode 100644 itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/utils/DownloadCDKRuntimesUtility.java create mode 100644 test-framework/org.jboss.tools.cdk.reddeer/src/org/jboss/tools/cdk/reddeer/core/condition/ProgressBarIsRunning.java create mode 100644 test-framework/org.jboss.tools.cdk.reddeer/src/org/jboss/tools/cdk/reddeer/core/enums/CDKVersion.java create mode 100644 test-framework/org.jboss.tools.cdk.reddeer/src/org/jboss/tools/cdk/reddeer/server/ui/wizard/download/DownloadCDKRuntimesWizard.java diff --git a/itests/org.jboss.tools.cdk.ui.bot.test/META-INF/MANIFEST.MF b/itests/org.jboss.tools.cdk.ui.bot.test/META-INF/MANIFEST.MF index 3cd6e2c021..5b40cf5639 100644 --- a/itests/org.jboss.tools.cdk.ui.bot.test/META-INF/MANIFEST.MF +++ b/itests/org.jboss.tools.cdk.ui.bot.test/META-INF/MANIFEST.MF @@ -5,7 +5,7 @@ Bundle-SymbolicName: org.jboss.tools.cdk.ui.bot.test Bundle-Version: 3.5.0.qualifier Bundle-Vendor: Red Hat Require-Bundle: org.junit, - org.eclipse.reddeer.go;bundle-version="[2.0.0,3.0.0)", + org.eclipse.reddeer.go;bundle-version="[2.1.0,3.0.0)", org.eclipse.wst.server.core;bundle-version="1.5.0", org.eclipse.wst.server.ui;bundle-version="1.5.200", org.eclipse.jdt.launching;bundle-version="3.7.0", @@ -16,7 +16,6 @@ Require-Bundle: org.junit, org.eclipse.core.externaltools;bundle-version="1.0.300", org.eclipse.equinox.security;bundle-version="1.2.100", org.eclipse.debug.ui;bundle-version="3.11.0", - org.eclipse.linuxtools.docker.core;bundle-version="[4.0.0,5.0.0)", org.eclipse.linuxtools.docker.reddeer, org.eclipse.tm.terminal.view.core;bundle-version="4.0.0", org.eclipse.tm.terminal.view.ui;bundle-version="4.0.0", @@ -43,7 +42,8 @@ Require-Bundle: org.junit, org.jboss.ide.eclipse.as.core;bundle-version="3.0.0", org.jboss.ide.eclipse.as.wtp.core;bundle-version="3.1.1", org.jboss.ide.eclipse.as.wtp.ui;bundle-version="3.1.1", - org.jboss.tools.common.reddeer + org.jboss.tools.common.reddeer, + org.jboss.tools.runtime.reddeer Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Eclipse-BundleShape: jar Bundle-Localization: plugin diff --git a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/CDKAbstractTest.java b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/CDKAbstractTest.java index ab8c1d3d15..1cf63d0f87 100644 --- a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/CDKAbstractTest.java +++ b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/CDKAbstractTest.java @@ -16,6 +16,7 @@ import org.eclipse.reddeer.common.exception.RedDeerException; import org.jboss.tools.cdk.reddeer.core.enums.CDKHypervisor; +import org.jboss.tools.cdk.reddeer.utils.CDKUtils; import org.jboss.tools.cdk.ui.bot.test.utils.CDKTestUtils; import org.jboss.tools.openshift.common.core.utils.StringUtils; @@ -27,19 +28,18 @@ public abstract class CDKAbstractTest { public static final String SERVER_ADAPTER_32 = "Container Development Environment 3.2+"; public static final String SERVER_ADAPTER_MINISHIFT = "Minishift 1.7+"; - // General parameters - public static final boolean IS_WINDOWS = System.getProperty("os.name").toLowerCase().contains("win"); - public static final boolean IS_LINUX = System.getProperty("os.name").toLowerCase().contains("linux"); - public static final String FOLDER = IS_LINUX ? "linux" : (IS_WINDOWS ? "win" : "mac"); + // General parameters + public static final String FOLDER = CDKUtils.IS_LINUX ? "linux" : (CDKUtils.IS_WINDOWS ? "win" : "mac"); public static final String separator = System.getProperty("file.separator"); public static final String MINISHIFT_CONFIG_MINIMAL = " --disk-size 5GB --memory 2GB --cpus 1"; public static final String SKIP_REGISTRATION = "--skip-registration"; + public static final String RUNTIMES_DIRECTORY= System.getProperty("user.dir") + separator + "runtimes"; // mock files - protected static final String MOCK_CDK320 = getProjectAbsolutePath("resources/cdk-files/" + FOLDER + "/cdk-3.2.0-mock" + (IS_WINDOWS ? ".bat" : "")); - protected static final String MOCK_CDK311 = getProjectAbsolutePath("resources/cdk-files/" + FOLDER + "/cdk-3.1.1-mock" + (IS_WINDOWS ? ".bat" : "")); - protected static final String MOCK_MINISHIFT131 = getProjectAbsolutePath("resources/cdk-files/" + FOLDER + "/minishift-1.3.1-mock" + (IS_WINDOWS ? ".bat" : "")); - protected static final String MOCK_MINISHIFT170 = getProjectAbsolutePath("resources/cdk-files/" + FOLDER + "/minishift-1.7.0-mock" + (IS_WINDOWS ? ".bat" : "")); + protected static final String MOCK_CDK320 = getProjectAbsolutePath("resources/cdk-files/" + FOLDER + "/cdk-3.2.0-mock" + (CDKUtils.IS_WINDOWS ? ".bat" : "")); + protected static final String MOCK_CDK311 = getProjectAbsolutePath("resources/cdk-files/" + FOLDER + "/cdk-3.1.1-mock" + (CDKUtils.IS_WINDOWS ? ".bat" : "")); + protected static final String MOCK_MINISHIFT131 = getProjectAbsolutePath("resources/cdk-files/" + FOLDER + "/minishift-1.3.1-mock" + (CDKUtils.IS_WINDOWS ? ".bat" : "")); + protected static final String MOCK_MINISHIFT170 = getProjectAbsolutePath("resources/cdk-files/" + FOLDER + "/minishift-1.7.0-mock" + (CDKUtils.IS_WINDOWS ? ".bat" : "")); // CDK Test suite parameters public static final String MINISHIFT_PROFILE = "minishift"; @@ -58,7 +58,7 @@ public abstract class CDKAbstractTest { CDK_MINISHIFT = CDKTestUtils.getSystemProperty("cdk.minishift"); CDK32_MINISHIFT = CDKTestUtils.getSystemProperty("cdk32.minishift"); MINISHIFT_HYPERVISOR = CDKTestUtils.getSystemProperty("hypervisor"); - DEFAULT_MINISHIFT_HOME = System.getProperty("user.home") + separator + ".minishift"; + DEFAULT_MINISHIFT_HOME = System.getProperty("user.home") + separator + ".minishift"; } public static String assignMinishiftHypervisor() { diff --git a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/CDKAllTestsSuite.java b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/CDKAllTestsSuite.java index cedba06ce6..b03240cfcf 100644 --- a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/CDKAllTestsSuite.java +++ b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/CDKAllTestsSuite.java @@ -25,6 +25,11 @@ import org.jboss.tools.cdk.ui.bot.test.server.wizard.CDK32ServerWizardTest; import org.jboss.tools.cdk.ui.bot.test.server.wizard.CDK3ServerWizardTest; import org.jboss.tools.cdk.ui.bot.test.server.wizard.MinishiftServerWizardTest; +import org.jboss.tools.cdk.ui.bot.test.server.wizard.download.DownloadContainerRuntimeDefaultSettingsTest; +import org.jboss.tools.cdk.ui.bot.test.server.wizard.download.CDK32DownloadRuntimeTest; +import org.jboss.tools.cdk.ui.bot.test.server.wizard.download.CDK3DownloadRuntimeTest; +import org.jboss.tools.cdk.ui.bot.test.server.wizard.download.DownloadRuntimesWizardTest; +import org.jboss.tools.cdk.ui.bot.test.server.wizard.download.MinishiftDownloadRuntimeTest; import org.junit.runner.RunWith; import org.junit.runners.Suite; @@ -34,10 +39,17 @@ // UI integration tests // Wizard tests by server adapter type - CDK3ServerWizardTest.class, + /*CDK3ServerWizardTest.class, CDK32ServerWizardTest.class, MinishiftServerWizardTest.class, + // Downloading and installation of CDK/Minishift runtimes via new server wizard + CDK3DownloadRuntimeTest.class, + CDK32DownloadRuntimeTest.class, + MinishiftDownloadRuntimeTest.class, + DownloadContainerRuntimeDefaultSettingsTest.class, + DownloadRuntimesWizardTest.class,*/ + // Server editor tests by server adapter type CDK3ServerEditorTest.class, CDK32ServerEditorTest.class, diff --git a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/CDKSmokeTestsSuite.java b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/CDKSmokeTestsSuite.java index f341ddb046..01662f761f 100644 --- a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/CDKSmokeTestsSuite.java +++ b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/CDKSmokeTestsSuite.java @@ -12,6 +12,7 @@ import org.eclipse.reddeer.junit.runner.RedDeerSuite; import org.jboss.tools.cdk.ui.bot.test.server.adapter.CDK32IntegrationTest; +import org.jboss.tools.cdk.ui.bot.test.server.adapter.CDK32ServerAdapterProfilesTest; import org.jboss.tools.cdk.ui.bot.test.server.adapter.openshift.CDKImageRegistryUrlDiscoveryTest; import org.jboss.tools.cdk.ui.bot.test.server.editor.CDK32ServerEditorTest; import org.jboss.tools.cdk.ui.bot.test.server.editor.CDK3ServerEditorTest; @@ -20,6 +21,9 @@ import org.jboss.tools.cdk.ui.bot.test.server.wizard.CDK32ServerWizardTest; import org.jboss.tools.cdk.ui.bot.test.server.wizard.CDK3ServerWizardTest; import org.jboss.tools.cdk.ui.bot.test.server.wizard.MinishiftServerWizardTest; +import org.jboss.tools.cdk.ui.bot.test.server.wizard.download.CDK32DownloadRuntimeTest; +import org.jboss.tools.cdk.ui.bot.test.server.wizard.download.DownloadRuntimesWizardTest; +import org.jboss.tools.cdk.ui.bot.test.server.wizard.download.MinishiftDownloadRuntimeTest; import org.junit.runner.RunWith; import org.junit.runners.Suite; @@ -28,12 +32,16 @@ CDK3ServerWizardTest.class, CDK32ServerWizardTest.class, MinishiftServerWizardTest.class, + CDK32DownloadRuntimeTest.class, + MinishiftDownloadRuntimeTest.class, + DownloadRuntimesWizardTest.class, CDK3ServerEditorTest.class, CDK32ServerEditorTest.class, MinishiftServerEditorTest.class, CDKLaunchConfigurationTest.class, CDKImageRegistryUrlDiscoveryTest.class, - CDK32IntegrationTest.class + CDK32IntegrationTest.class, + CDK32ServerAdapterProfilesTest.class }) /** * @author ondrej dockal diff --git a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/CDKUITestsSuite.java b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/CDKUITestsSuite.java new file mode 100644 index 0000000000..923f0f6997 --- /dev/null +++ b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/CDKUITestsSuite.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2018 Red Hat, Inc. + * Distributed under license by Red Hat, Inc. All rights reserved. + * This program is made available under the terms of the + * Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + ******************************************************************************/ +package org.jboss.tools.cdk.ui.bot.test; + +import org.eclipse.reddeer.junit.runner.RedDeerSuite; +import org.jboss.tools.cdk.ui.bot.test.server.adapter.CDKServerAdapterSetupCDKTest; +import org.jboss.tools.cdk.ui.bot.test.server.editor.CDK32ServerEditorTest; +import org.jboss.tools.cdk.ui.bot.test.server.editor.CDK3ServerEditorTest; +import org.jboss.tools.cdk.ui.bot.test.server.editor.MinishiftServerEditorTest; +import org.jboss.tools.cdk.ui.bot.test.server.editor.launch.CDKLaunchConfigurationTest; +import org.jboss.tools.cdk.ui.bot.test.server.wizard.CDK32ServerWizardTest; +import org.jboss.tools.cdk.ui.bot.test.server.wizard.CDK3ServerWizardTest; +import org.jboss.tools.cdk.ui.bot.test.server.wizard.MinishiftServerWizardTest; +import org.jboss.tools.cdk.ui.bot.test.server.wizard.download.CDK32DownloadRuntimeTest; +import org.jboss.tools.cdk.ui.bot.test.server.wizard.download.CDK3DownloadRuntimeTest; +import org.jboss.tools.cdk.ui.bot.test.server.wizard.download.DownloadContainerRuntimeDefaultSettingsTest; +import org.jboss.tools.cdk.ui.bot.test.server.wizard.download.DownloadRuntimesWizardTest; +import org.jboss.tools.cdk.ui.bot.test.server.wizard.download.MinishiftDownloadRuntimeTest; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(RedDeerSuite.class) +@Suite.SuiteClasses({ + + // UI integration tests + + // Wizard tests by server adapter type + CDK3ServerWizardTest.class, + CDK32ServerWizardTest.class, + MinishiftServerWizardTest.class, + + // Downloading and installation of CDK/Minishift runtimes via new server wizard + CDK3DownloadRuntimeTest.class, + CDK32DownloadRuntimeTest.class, + MinishiftDownloadRuntimeTest.class, + DownloadContainerRuntimeDefaultSettingsTest.class, + DownloadRuntimesWizardTest.class, + + // Server editor tests by server adapter type + CDK3ServerEditorTest.class, + CDK32ServerEditorTest.class, + MinishiftServerEditorTest.class, + CDKLaunchConfigurationTest.class, + + // Setup CDK context menu item tests + CDKServerAdapterSetupCDKTest.class, +}) +/** + * + * @author odockal + * + */ +public class CDKUITestsSuite { +} diff --git a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/MinishiftAllTestsSuite.java b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/MinishiftAllTestsSuite.java index d718b775a6..aa409e8673 100644 --- a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/MinishiftAllTestsSuite.java +++ b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/MinishiftAllTestsSuite.java @@ -15,6 +15,7 @@ import org.jboss.tools.cdk.ui.bot.test.server.adapter.MinishiftServerAdapterTest; import org.jboss.tools.cdk.ui.bot.test.server.editor.MinishiftServerEditorTest; import org.jboss.tools.cdk.ui.bot.test.server.wizard.MinishiftServerWizardTest; +import org.jboss.tools.cdk.ui.bot.test.server.wizard.download.MinishiftDownloadRuntimeTest; import org.junit.runner.RunWith; import org.junit.runners.Suite; @@ -23,6 +24,7 @@ MinishiftServerWizardTest.class, MinishiftServerEditorTest.class, MinishiftServerAdapterTest.class, + MinishiftDownloadRuntimeTest.class, MinishiftServerAdapterProfilesTest.class }) public class MinishiftAllTestsSuite { diff --git a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/adapter/CDK32ServerAdapterProfilesTest.java b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/adapter/CDK32ServerAdapterProfilesTest.java index f00e0d5eab..b258c45ac9 100644 --- a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/adapter/CDK32ServerAdapterProfilesTest.java +++ b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/adapter/CDK32ServerAdapterProfilesTest.java @@ -87,14 +87,14 @@ public void setupSecondAdapter() { @Test public void testCDK32ServerAdapterWithMultipleProfiles() { // fisrt adapter start verification - startServerAdapter(() -> { skipRegistration(getCDKServer());}, false); + startServerAdapter(() -> { skipRegistrationViaFlag(getCDKServer(), true);}, false); int conCount = view.getOpenShift3Connections().size(); int docCount = getDockerConnectionCreatedByCDK(dockerView, DOCKER_DAEMON_CONNECTION).size(); assertEquals("Expected only one OS connection, got " + conCount, 1, conCount); assertEquals("Expected only one Docker connection, got " + docCount, 1, docCount); // second adapter start verification startServerAdapter(getSecondCDKServer(), - () -> { skipRegistration(getSecondCDKServer()); + () -> { skipRegistrationViaFlag(getSecondCDKServer(), true); }, false); // check counts of connections conCount = view.getOpenShift3Connections().size(); diff --git a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/adapter/CDK3IntegrationTest.java b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/adapter/CDK3IntegrationTest.java index 216333e14c..117486e3f9 100644 --- a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/adapter/CDK3IntegrationTest.java +++ b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/adapter/CDK3IntegrationTest.java @@ -43,7 +43,7 @@ public static void setup() { @Test public void testCDK3ServerAdapter() { // cdk start verification - startServerAdapter(() -> skipRegistration(getCDKServer()), true); + startServerAdapter(() -> skipRegistrationViaFlag(getCDKServer(), true), true); // OS3 and docker connection created verification testOpenshiftConnection(null, OPENSHIFT_USERNAME); testDockerConnection(DOCKER_DAEMON_CONNECTION); diff --git a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/adapter/CDKServerAdapterAbstractTest.java b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/adapter/CDKServerAdapterAbstractTest.java index 5439706b64..85b93d0684 100644 --- a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/adapter/CDKServerAdapterAbstractTest.java +++ b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/adapter/CDKServerAdapterAbstractTest.java @@ -53,6 +53,7 @@ import org.jboss.tools.cdk.reddeer.server.exception.CDKServerException; import org.jboss.tools.cdk.reddeer.server.ui.CDKServer; import org.jboss.tools.cdk.reddeer.server.ui.CDKServersView; +import org.jboss.tools.cdk.reddeer.server.ui.editor.CDK32ServerEditor; import org.jboss.tools.cdk.reddeer.server.ui.editor.CDK3ServerEditor; import org.jboss.tools.cdk.reddeer.server.ui.editor.MinishiftServerEditor; import org.jboss.tools.cdk.reddeer.server.ui.editor.launch.configuration.CDKLaunchConfigurationDialog; @@ -181,6 +182,16 @@ protected void addParamsToCDKLaunchConfig(Server server, String paramsToAdd) { launchConfig.ok(); } + protected void skipRegistrationViaFlag(Server server, boolean checked) { + server.open(); + CDK32ServerEditor editor = new CDK32ServerEditor(server.getLabel().getName()); + editor.getAddSkipRegistrationOnStartCheckBox().toggle(checked); + new WaitUntil(new SystemJobIsRunning(new JobMatcher(CDKLabel.Job.MINISHIFT_VALIDATION_JOB)), TimePeriod.SHORT, false); + new WaitWhile(new SystemJobIsRunning(new JobMatcher(CDKLabel.Job.MINISHIFT_VALIDATION_JOB)), TimePeriod.DEFAULT, false); + CDKTestUtils.performSave(editor.getEditorPart()); + editor.close(); + } + protected void skipRegistration(Server server) { addParamsToCDKLaunchConfig(server, SKIP_REGISTRATION); } diff --git a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/adapter/MinishiftServerAdapterProfilesTest.java b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/adapter/MinishiftServerAdapterProfilesTest.java index c5dddceb37..3fe1006a06 100644 --- a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/adapter/MinishiftServerAdapterProfilesTest.java +++ b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/adapter/MinishiftServerAdapterProfilesTest.java @@ -87,15 +87,14 @@ public void setupSecondAdapter() { @Test public void testMinishiftServerAdapterWithMultipleProfiles() { // fisrt adapter start verification - startServerAdapter(() -> { skipRegistration(getCDKServer());}, false); + startServerAdapter(() -> {}, false); int conCount = view.getOpenShift3Connections().size(); int docCount = getDockerConnectionCreatedByCDK(dockerView, DOCKER_DAEMON_CONNECTION).size(); assertEquals("Expected only one OS connection, got " + conCount, 1, conCount); assertEquals("Expected only one Docker connection, got " + docCount, 1, docCount); // second adapter start verification startServerAdapter(getSecondCDKServer(), - () -> { skipRegistration(getCDKServer()); - }, false); + () -> {}, false); // check counts of connections conCount = view.getOpenShift3Connections().size(); docCount = getDockerConnectionCreatedByCDK(dockerView, DOCKER_DAEMON_CONNECTION).size(); diff --git a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/adapter/openshift/CDKImageRegistryUrlAbstractTest.java b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/adapter/openshift/CDKImageRegistryUrlAbstractTest.java index fe698c5ac2..3a851ef8e3 100644 --- a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/adapter/openshift/CDKImageRegistryUrlAbstractTest.java +++ b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/adapter/openshift/CDKImageRegistryUrlAbstractTest.java @@ -69,7 +69,7 @@ public static void tearDownCDKImageResgitryUrlAbstract() { @Before public void setupAdapter() { startServerAdapterIfNotRunning(() -> { - skipRegistration(getCDKServer()); + skipRegistrationViaFlag(getCDKServer(), true); }, false); wizard = getOpenshiftConnectionWizard(findOpenShiftConnection(null, OPENSHIFT_USERNAME)); assertTrue(wizard.getAuthSection().getMethod().equals(AuthenticationMethod.BASIC)); diff --git a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/adapter/openshift/CDKImageRegistryUrlDiscoveryTest.java b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/adapter/openshift/CDKImageRegistryUrlDiscoveryTest.java index 4aeea7cbd8..52c1e44faa 100644 --- a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/adapter/openshift/CDKImageRegistryUrlDiscoveryTest.java +++ b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/adapter/openshift/CDKImageRegistryUrlDiscoveryTest.java @@ -69,7 +69,7 @@ public void testImageRegistryUrlIsUpdated() { stopServerAdapter(); // start server adapter -> should bring up the value of registry url in existing // connection - startServerAdapter(() -> skipRegistration(getCDKServer()), false); + startServerAdapter(() -> skipRegistrationViaFlag(getCDKServer(), true), false); wizard = getOpenshiftConnectionWizard(findOpenShiftConnection(null, OPENSHIFT_USERNAME)); switchOffPasswordSaving(wizard); checkImageRegistryUrl(wizard, OPENSHIFT_REGISTRY); @@ -101,7 +101,7 @@ public void testAllConnectionsImageRegistryUrlUpdated() { newWizard = null; // stop and start server adapter stopServerAdapter(); - startServerAdapter(() -> skipRegistration(getCDKServer()), false); + startServerAdapter(() -> skipRegistrationViaFlag(getCDKServer(), true), false); // check that both connections have filled image registry url try { wizard = getOpenshiftConnectionWizard(findOpenShiftConnection(null, OPENSHIFT_USERNAME)); diff --git a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/adapter/openshift/CDKImageRegistryUrlValidatorTest.java b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/adapter/openshift/CDKImageRegistryUrlValidatorTest.java index e0ea8c6e42..41a949730b 100644 --- a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/adapter/openshift/CDKImageRegistryUrlValidatorTest.java +++ b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/adapter/openshift/CDKImageRegistryUrlValidatorTest.java @@ -13,6 +13,7 @@ import static org.junit.Assert.assertTrue; import org.eclipse.reddeer.junit.runner.RedDeerSuite; +import org.jboss.tools.cdk.reddeer.utils.CDKUtils; import org.jboss.tools.cdk.ui.bot.test.utils.CDKTestUtils; import org.junit.After; import org.junit.Test; @@ -48,7 +49,7 @@ public void testSettingOCToWorkspace() { setupOCForWorkspace(); wizard = getOpenshiftConnectionWizard(findOpenShiftConnection(null, OPENSHIFT_USERNAME)); assertStringContains(wizard.getConnectionMessage(), "OpenShift server"); - assertTrue(wizard.getOCLocationLabel().getText().endsWith(IS_WINDOWS ? "oc.exe" : "oc")); + assertTrue(wizard.getOCLocationLabel().getText().endsWith(CDKUtils.IS_WINDOWS ? "oc.exe" : "oc")); } /** diff --git a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/CDK32ServerWizardTest.java b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/CDK32ServerWizardTest.java index 4b5a390f36..50815af6bc 100644 --- a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/CDK32ServerWizardTest.java +++ b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/CDK32ServerWizardTest.java @@ -11,6 +11,8 @@ package org.jboss.tools.cdk.ui.bot.test.server.wizard; import static org.junit.Assert.assertTrue; +import static org.jboss.tools.cdk.ui.bot.test.utils.CDKTestUtils.assertDiffMessage; +import static org.jboss.tools.cdk.ui.bot.test.utils.CDKTestUtils.assertSameMessage; import org.eclipse.reddeer.common.wait.TimePeriod; import org.eclipse.reddeer.common.wait.WaitUntil; @@ -45,7 +47,7 @@ protected String getServerAdapter() { } @Test - public void testCDK3ServerType() { + public void testCDK32ServerType() { assertServerType(CDKLabel.Server.CDK32_SERVER_NAME); } @@ -69,28 +71,29 @@ public void testNewCDK32ServerWizard() { containerPage.setMinishiftBinary(EXISTING_PATH); // first the credentials are checked - assertSameMessage(dialog, NO_USER); + assertSameMessage(dialog, CDKLabel.Messages.NO_USER); containerPage.setCredentials(USERNAME, PASSWORD); - assertDiffMessage(dialog, NO_USER); + assertDiffMessage(dialog, CDKLabel.Messages.NO_USER); // checking of minishift binary validation // test that existing folder cannot be run containerPage.setMinishiftBinary(EXISTING_PATH); - assertSameMessage(dialog, CANNOT_RUN_PROGRAM); + assertSameMessage(dialog, CDKLabel.Messages.CANNOT_RUN_PROGRAM); containerPage.setMinishiftBinary(NON_EXECUTABLE_FILE); - assertSameMessage(dialog, NOT_EXECUTABLE); + assertSameMessage(dialog, CDKLabel.Messages.NOT_EXECUTABLE); containerPage.setMinishiftBinary(NON_EXISTING_PATH); - assertSameMessage(dialog, DOES_NOT_EXIST); + assertSameMessage(dialog, CDKLabel.Messages.DOES_NOT_EXIST); containerPage.setMinishiftBinary(EXECUTABLE_FILE); - assertSameMessage(dialog, CHECK_MINISHIFT_VERSION); + assertSameMessage(dialog, CDKLabel.Messages.CHECK_MINISHIFT_VERSION); // check compatibility of cdk version with server adapter containerPage.setMinishiftBinary(MOCK_CDK311); - assertSameMessage(dialog, NOT_COMPATIBLE); + assertSameMessage(dialog, CDKLabel.Messages.NOT_COMPATIBLE); // Positive test of proper minishift binary containerPage.setMinishiftBinary(CDK32_MINISHIFT); - assertDiffMessage(dialog, CHECK_MINISHIFT_VERSION); + assertDiffMessage(dialog, CDKLabel.Messages.CHECK_MINISHIFT_VERSION); + assertSameMessage(dialog, CDKLabel.Messages.SERVER_ADAPTER_REPRESENTING); new WaitUntil(new ControlIsEnabled(new FinishButton()), TimePeriod.MEDIUM, false); assertTrue("Expected Finish button is not enabled", dialog.isFinishEnabled()); dialog.cancel(); diff --git a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/CDK3ServerWizardTest.java b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/CDK3ServerWizardTest.java index 3ed50888ff..029687cd22 100644 --- a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/CDK3ServerWizardTest.java +++ b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/CDK3ServerWizardTest.java @@ -11,6 +11,8 @@ package org.jboss.tools.cdk.ui.bot.test.server.wizard; import static org.junit.Assert.assertTrue; +import static org.jboss.tools.cdk.ui.bot.test.utils.CDKTestUtils.assertDiffMessage; +import static org.jboss.tools.cdk.ui.bot.test.utils.CDKTestUtils.assertSameMessage; import org.eclipse.reddeer.common.wait.TimePeriod; import org.eclipse.reddeer.common.wait.WaitUntil; @@ -74,28 +76,29 @@ public void testNewCDK3ServerWizard() { containerPage.setMinishiftBinary(EXISTING_PATH); // first the credentials are checked - assertSameMessage(dialog, NO_USER); + assertSameMessage(dialog, CDKLabel.Messages.NO_USER); containerPage.setCredentials(USERNAME, PASSWORD); - assertDiffMessage(dialog, NO_USER); + assertDiffMessage(dialog, CDKLabel.Messages.NO_USER); // checking of minishift binary validation // test that existing folder cannot be run containerPage.setMinishiftBinary(EXISTING_PATH); - assertSameMessage(dialog, CANNOT_RUN_PROGRAM); + assertSameMessage(dialog, CDKLabel.Messages.CANNOT_RUN_PROGRAM); containerPage.setMinishiftBinary(NON_EXECUTABLE_FILE); - assertSameMessage(dialog, NOT_EXECUTABLE); + assertSameMessage(dialog, CDKLabel.Messages.NOT_EXECUTABLE); containerPage.setMinishiftBinary(NON_EXISTING_PATH); - assertSameMessage(dialog, DOES_NOT_EXIST); + assertSameMessage(dialog, CDKLabel.Messages.DOES_NOT_EXIST); containerPage.setMinishiftBinary(EXECUTABLE_FILE); - assertSameMessage(dialog, CHECK_MINISHIFT_VERSION); + assertSameMessage(dialog, CDKLabel.Messages.CHECK_MINISHIFT_VERSION); // check compatibility of cdk version with server adapter containerPage.setMinishiftBinary(MOCK_CDK320); - assertSameMessage(dialog, NOT_COMPATIBLE); + assertSameMessage(dialog, CDKLabel.Messages.NOT_COMPATIBLE); // Positive test of proper minishift binary containerPage.setMinishiftBinary(MINISHIFT_PATH); - assertDiffMessage(dialog, CHECK_MINISHIFT_VERSION); + assertDiffMessage(dialog, CDKLabel.Messages.CHECK_MINISHIFT_VERSION); + assertSameMessage(dialog, CDKLabel.Messages.SERVER_ADAPTER_REPRESENTING); new WaitUntil(new ControlIsEnabled(new FinishButton()), TimePeriod.MEDIUM, false); assertTrue("Expected Finish button is not enabled", dialog.isFinishEnabled()); dialog.cancel(); diff --git a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/CDKServerWizardAbstractTest.java b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/CDKServerWizardAbstractTest.java index 0cf3ef1e03..ea1af232e4 100644 --- a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/CDKServerWizardAbstractTest.java +++ b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/CDKServerWizardAbstractTest.java @@ -11,7 +11,6 @@ package org.jboss.tools.cdk.ui.bot.test.server.wizard; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -21,7 +20,6 @@ import org.eclipse.reddeer.common.wait.WaitUntil; import org.eclipse.reddeer.common.wait.WaitWhile; import org.eclipse.reddeer.core.exception.CoreLayerException; -import org.eclipse.reddeer.eclipse.selectionwizard.NewMenuWizard; import org.eclipse.reddeer.requirements.openperspective.OpenPerspectiveRequirement.OpenPerspective; import org.eclipse.reddeer.swt.api.TreeItem; import org.eclipse.reddeer.swt.condition.ControlIsEnabled; @@ -32,9 +30,7 @@ import org.eclipse.reddeer.swt.impl.text.LabeledText; import org.eclipse.reddeer.swt.impl.tree.DefaultTreeItem; import org.eclipse.reddeer.workbench.core.condition.JobIsRunning; -import org.jboss.tools.cdk.reddeer.core.condition.SystemJobIsRunning; import org.jboss.tools.cdk.reddeer.core.label.CDKLabel; -import org.jboss.tools.cdk.reddeer.core.matcher.JobMatcher; import org.jboss.tools.cdk.reddeer.requirements.DisableSecureStorageRequirement.DisableSecureStorage; import org.jboss.tools.cdk.reddeer.requirements.RemoveCDKServersRequirement.RemoveCDKServers; import org.jboss.tools.cdk.reddeer.server.ui.wizard.NewCDKServerWizard; @@ -54,21 +50,12 @@ @OpenPerspective(value=JBossPerspective.class) public abstract class CDKServerWizardAbstractTest extends CDKAbstractTest { - // page description messages - - protected static final String NO_USER = "Red Hat Access credentials"; - protected static final String DOES_NOT_EXIST = "does not exist"; - protected static final String CANNOT_RUN_PROGRAM = "Cannot run program"; - protected static final String NOT_EXECUTABLE = IS_WINDOWS ? CANNOT_RUN_PROGRAM : "is not executable"; - protected static final String CHECK_MINISHIFT_VERSION = "Unknown error while checking minishift version"; - protected static final String NOT_COMPATIBLE = "is not compatible with this server adapter"; - // possible dialog values passed by user protected static final String EXISTING_PATH = System.getProperty("user.dir"); protected static final String NON_EXISTING_PATH = EXISTING_PATH + separator + "some_random_filename"; protected static final String NON_EXECUTABLE_FILE = getProjectAbsolutePath("resources/non-executable"); - protected static final String EXECUTABLE_FILE = getProjectAbsolutePath("resources/" + (IS_WINDOWS ? "executable.bat" : "executable.sh")); + protected static final String EXECUTABLE_FILE = getProjectAbsolutePath("resources/" + (CDKUtils.IS_WINDOWS ? "executable.bat" : "executable.sh")); private static Logger log = Logger.getLogger(CDKServerWizardAbstractTest.class); @@ -107,31 +94,16 @@ protected void assertServerType(final String serverType) { } } - protected void checkWizardPagewidget(final String widgetLabel, final String servetType) { + protected void checkWizardPagewidget(final String widgetLabel, final String serverType) { // assert that based on choosen server type we got proper cdk server wizard page try { new LabeledText(widgetLabel); } catch (CoreLayerException exc) { - fail("According to choosen server type (" + servetType + ") " + fail("According to choosen server type (" + serverType + ") " + "it was expected to obtain proper CDK (2.x or 3) based server wizard page."); } } - protected void assertSameMessage(final NewMenuWizard dialog, final String message) { - new WaitWhile(new SystemJobIsRunning(new JobMatcher(CDKLabel.Job.MINISHIFT_VALIDATION_JOB)), TimePeriod.DEFAULT, false); - String description = dialog.getMessage(); - assertTrue("Expected page description should contain text: " + message + - " but has: " + description, - description.contains(message)); - } - - protected void assertDiffMessage(final NewMenuWizard dialog, final String message) { - new WaitWhile(new SystemJobIsRunning(new JobMatcher(CDKLabel.Job.MINISHIFT_VALIDATION_JOB)), TimePeriod.DEFAULT, false); - String description = dialog.getMessage(); - assertFalse("Page descrition should not contain: " + message, - description.contains(message)); - } - private void closeOpenShells() { try { new WaitWhile(new ShellIsAvailable("New Server"), TimePeriod.MEDIUM); diff --git a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/MinishiftServerWizardTest.java b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/MinishiftServerWizardTest.java index 82248fbe0a..690ff34857 100644 --- a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/MinishiftServerWizardTest.java +++ b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/MinishiftServerWizardTest.java @@ -11,6 +11,8 @@ package org.jboss.tools.cdk.ui.bot.test.server.wizard; import static org.junit.Assert.assertTrue; +import static org.jboss.tools.cdk.ui.bot.test.utils.CDKTestUtils.assertDiffMessage; +import static org.jboss.tools.cdk.ui.bot.test.utils.CDKTestUtils.assertSameMessage; import org.eclipse.reddeer.common.wait.TimePeriod; import org.eclipse.reddeer.common.wait.WaitUntil; @@ -71,29 +73,30 @@ public void testNewMinishiftServerWizard() { // checking of minishift binary validation // test that existing folder cannot be run containerPage.setMinishiftBinary(EXISTING_PATH); - assertSameMessage(dialog, CANNOT_RUN_PROGRAM); + assertSameMessage(dialog, CDKLabel.Messages.CANNOT_RUN_PROGRAM); containerPage.setMinishiftBinary(NON_EXECUTABLE_FILE); - assertSameMessage(dialog, NOT_EXECUTABLE); + assertSameMessage(dialog, CDKLabel.Messages.NOT_EXECUTABLE); containerPage.setMinishiftBinary(NON_EXISTING_PATH); - assertSameMessage(dialog, DOES_NOT_EXIST); + assertSameMessage(dialog, CDKLabel.Messages.DOES_NOT_EXIST); containerPage.setMinishiftBinary(EXECUTABLE_FILE); - assertSameMessage(dialog, CHECK_MINISHIFT_VERSION); + assertSameMessage(dialog, CDKLabel.Messages.CHECK_MINISHIFT_VERSION); // check compatibility of cdk version with server adapter containerPage.setMinishiftBinary(MOCK_CDK311); - assertSameMessage(dialog, NOT_COMPATIBLE); + assertSameMessage(dialog, CDKLabel.Messages.NOT_COMPATIBLE); // check compatibility of cdk version with server adapter containerPage.setMinishiftBinary(MOCK_CDK320); - assertSameMessage(dialog, NOT_COMPATIBLE); + assertSameMessage(dialog, CDKLabel.Messages.NOT_COMPATIBLE); // check compatibility of cdk version with server adapter containerPage.setMinishiftBinary(MOCK_MINISHIFT131); - assertSameMessage(dialog, NOT_COMPATIBLE); + assertSameMessage(dialog, CDKLabel.Messages.NOT_COMPATIBLE); // Positive test of proper minishift binary containerPage.setMinishiftBinary(MINISHIFT_PATH); - assertDiffMessage(dialog, CHECK_MINISHIFT_VERSION); + assertDiffMessage(dialog, CDKLabel.Messages.CHECK_MINISHIFT_VERSION); + assertSameMessage(dialog, CDKLabel.Messages.SERVER_ADAPTER_REPRESENTING); new WaitUntil(new ControlIsEnabled(new FinishButton()), TimePeriod.MEDIUM, false); assertTrue("Expected Finish button is not enabled", dialog.isFinishEnabled()); dialog.cancel(); diff --git a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/download/CDK32DownloadRuntimeTest.java b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/download/CDK32DownloadRuntimeTest.java new file mode 100644 index 0000000000..a082dfc747 --- /dev/null +++ b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/download/CDK32DownloadRuntimeTest.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (c) 2018 Red Hat, Inc. + * Distributed under license by Red Hat, Inc. All rights reserved. + * This program is made available under the terms of the + * Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + ******************************************************************************/ +package org.jboss.tools.cdk.ui.bot.test.server.wizard.download; + +import org.eclipse.reddeer.junit.runner.RedDeerSuite; +import org.jboss.tools.cdk.reddeer.core.enums.CDKVersion; +import org.junit.Test; +import org.junit.runner.RunWith; + +/** + * Class covers runtime download test for CDK 3.2+ versions + * @author odockal + * + */ +@RunWith(RedDeerSuite.class) +public class CDK32DownloadRuntimeTest extends DownloadContainerRuntimeAbstractTest { + + @Override + protected String getServerAdapter() { + return SERVER_ADAPTER_32; + } + + @Test + public void testDownloadingCDK320Runtime() { + downloadAndVerifyCDKRuntime(CDKVersion.CDK320, USERNAME, PASSWORD); + } + + @Test + public void testDownloadingCDK330Runtime() { + downloadAndVerifyCDKRuntime(CDKVersion.CDK330, USERNAME, PASSWORD); + } + + @Test + public void testDownloadingCDK340Runtime() { + downloadAndVerifyCDKRuntime(CDKVersion.CDK340, USERNAME, PASSWORD); + } + +} diff --git a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/download/CDK3DownloadRuntimeTest.java b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/download/CDK3DownloadRuntimeTest.java new file mode 100644 index 0000000000..be1dee766f --- /dev/null +++ b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/download/CDK3DownloadRuntimeTest.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2018 Red Hat, Inc. + * Distributed under license by Red Hat, Inc. All rights reserved. + * This program is made available under the terms of the + * Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + ******************************************************************************/ +package org.jboss.tools.cdk.ui.bot.test.server.wizard.download; + +import org.jboss.tools.cdk.reddeer.core.enums.CDKVersion; +import org.junit.Test; + +/** + * Class covers runtime download test for CDK 3.x versions + * @author odockal + * + */ +public class CDK3DownloadRuntimeTest extends DownloadContainerRuntimeAbstractTest { + + @Override + protected String getServerAdapter() { + return SERVER_ADAPTER_3; + } + + @Test + public void testDownloadingCDK300Runtime() { + downloadAndVerifyCDKRuntime(CDKVersion.CDK300, USERNAME, PASSWORD); + } + + @Test + public void testDownloadingCDK310Runtime() { + downloadAndVerifyCDKRuntime(CDKVersion.CDK310, USERNAME, PASSWORD); + } + + @Test + public void testDownloadingCDK311Runtime() { + downloadAndVerifyCDKRuntime(CDKVersion.CDK311, USERNAME, PASSWORD); + } + +} diff --git a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/download/DownloadContainerRuntimeAbstractTest.java b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/download/DownloadContainerRuntimeAbstractTest.java new file mode 100644 index 0000000000..f70a1fd07f --- /dev/null +++ b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/download/DownloadContainerRuntimeAbstractTest.java @@ -0,0 +1,164 @@ +/******************************************************************************* + * Copyright (c) 2018 Red Hat, Inc. + * Distributed under license by Red Hat, Inc. All rights reserved. + * This program is made available under the terms of the + * Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + ******************************************************************************/ +package org.jboss.tools.cdk.ui.bot.test.server.wizard.download; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.jboss.tools.cdk.ui.bot.test.utils.CDKTestUtils.assertSameMessage; + +import java.io.File; + +import org.eclipse.reddeer.common.condition.AbstractWaitCondition; +import org.eclipse.reddeer.common.exception.WaitTimeoutExpiredException; +import org.eclipse.reddeer.common.logging.Logger; +import org.eclipse.reddeer.common.wait.TimePeriod; +import org.eclipse.reddeer.common.wait.WaitUntil; +import org.eclipse.reddeer.eclipse.selectionwizard.NewMenuWizard; +import org.eclipse.reddeer.eclipse.wst.server.ui.wizard.NewServerWizardPage; +import org.eclipse.reddeer.jface.wizard.WizardDialog; +import org.eclipse.reddeer.swt.api.Link; +import org.eclipse.reddeer.swt.condition.ControlIsEnabled; +import org.eclipse.reddeer.swt.condition.ShellIsAvailable; +import org.jboss.tools.cdk.reddeer.core.condition.SystemJobIsRunning; +import org.jboss.tools.cdk.reddeer.core.enums.CDKVersion; +import org.jboss.tools.cdk.reddeer.core.label.CDKLabel; +import org.jboss.tools.cdk.reddeer.core.matcher.JobMatcher; +import org.jboss.tools.cdk.reddeer.server.ui.wizard.NewCDK32ServerWizardPage; +import org.jboss.tools.cdk.reddeer.server.ui.wizard.NewCDK3ServerWizardPage; +import org.jboss.tools.cdk.reddeer.server.ui.wizard.NewCDKServerWizard; +import org.jboss.tools.cdk.reddeer.server.ui.wizard.NewMinishiftServerWizardPage; +import org.jboss.tools.cdk.ui.bot.test.server.wizard.CDKServerWizardAbstractTest; +import org.jboss.tools.cdk.ui.bot.test.utils.CDKTestUtils; +import org.jboss.tools.cdk.ui.bot.test.utils.DownloadCDKRuntimesUtility; +import org.junit.Before; + +/** + * Abstract class providing core test features for CDK runtime download tests + * @author odockal + * + */ +public class DownloadContainerRuntimeAbstractTest extends CDKServerWizardAbstractTest { + + private WizardDialog dialog; + + private static final Logger log = Logger.getLogger(CDK32DownloadRuntimeTest.class); + + @Override + protected String getServerAdapter() { + return null; + } + + @Before + public void beforeDownloadRuntime() { + dialog = (NewCDKServerWizard)CDKTestUtils.openNewServerWizardDialog(); + } + + public NewCDK3ServerWizardPage chooseCDKWizardPage(CDKVersion version) { + switch (version.serverName()) { + case CDKLabel.Server.CDK3_SERVER_NAME: + return new NewCDK3ServerWizardPage(); + case CDKLabel.Server.CDK32_SERVER_NAME: + return new NewCDK32ServerWizardPage(); + case CDKLabel.Server.MINISHIFT_SERVER_NAME: + return new NewMinishiftServerWizardPage(); + default: + return null; + } + } + + public void downloadAndVerifyContainerRuntime(CDKVersion version, String username, String password, + String installFolder, String downloadFolder, boolean removeArtifacts, boolean useDefaults) { + chooseWizardPage(CDKLabel.Server.SERVER_TYPE_GROUP, version.serverName()); + NewCDK3ServerWizardPage wizardPage = inicializeDownloadRutimeDialog(version); + DownloadCDKRuntimesUtility util; + if (useDefaults) { + util = new DownloadCDKRuntimesUtility(true); + } else { + util = new DownloadCDKRuntimesUtility(installFolder, downloadFolder, removeArtifacts); + } + util.chooseRuntimeToDownload(version); + if (!(wizardPage instanceof NewMinishiftServerWizardPage)) { + util.processCredentials(username, password); + } + util.acceptLicense(); + util.downloadRuntime(); + try { + new WaitUntil(new AbstractWaitCondition() { + @Override + public boolean test() { + return wizardPage.getMinishiftBinaryLabeledText().getText().contains(version.downloadName()); + } + }, TimePeriod.DEFAULT); + new WaitUntil(new SystemJobIsRunning(new JobMatcher(CDKLabel.Job.MINISHIFT_VALIDATION_JOB)), TimePeriod.DEFAULT, false); + } catch (WaitTimeoutExpiredException waitExc) { + fail("Expected this path " + wizardPage.getMinishiftBinaryLabeledText().getText() + " to contain value: " + version.downloadName()); + } + // add verification that generated binary is valid + assertSameMessage((NewMenuWizard)dialog, CDKLabel.Messages.SERVER_ADAPTER_REPRESENTING); + // add test for downloaded artifacts - temporary + if (removeArtifacts || useDefaults) { + try { + assertFalse("Downloaded artifacts were not deleted from " + util.getDownloadFolder(), + verifyFileInFolder(util.getDownloadFolder(), version.downloadName())); + } catch (AssertionError err) { + log.error("Skipped due to JBIDE-25867"); + } + } else { + assertTrue("Downloaded artifacts were deleted from " + util.getDownloadFolder(), + verifyFileInFolder(util.getDownloadFolder(), version.downloadName())); + } + // add check that file was really downloaded, extracted and is readable + assertTrue("Installation folder does not contain downloaded file " + version.downloadName(), + verifyFileInFolder(util.getInstallFolder(), version.downloadName())); + dialog.finish(); + } + + public void downloadAndVerifyCDKRuntime(CDKVersion version, String username, String password) { + downloadAndVerifyContainerRuntime(version, username, password, + RUNTIMES_DIRECTORY + separator + version.name(), + RUNTIMES_DIRECTORY + separator + "tmp", + true, false); + } + + public void chooseWizardPage(String... pathToServer) { + log.info("Opening server wizard for " + pathToServer); + NewServerWizardPage page = new NewServerWizardPage(dialog); + + page.selectType(pathToServer); + page.setName(getServerAdapter()); + dialog.next(); + } + + public NewCDK3ServerWizardPage inicializeDownloadRutimeDialog(CDKVersion version) { + log.info("Inicializing " + version.name() + " wizard page"); + NewCDK3ServerWizardPage wizardPage = chooseCDKWizardPage(version); + Link link = wizardPage.getDownloadAndInstallLink(); + new WaitUntil(new ControlIsEnabled(link), TimePeriod.MEDIUM, false); + link.click(); + new WaitUntil(new ShellIsAvailable(CDKLabel.Shell.DOWNLOAD_RUNTIMES), TimePeriod.MEDIUM); + return wizardPage; + } + + public boolean verifyFileInFolder(String folderPath, String fileName) { + log.info("Verify that " + folderPath + " contains file containing name " + fileName); + File folder = new File(folderPath); + if (!folder.exists()) + return false; + for (File file : folder.listFiles()) { + if (file.getAbsolutePath().contains(fileName)) { + return true; + } + } + return false; + } + +} diff --git a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/download/DownloadContainerRuntimeDefaultSettingsTest.java b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/download/DownloadContainerRuntimeDefaultSettingsTest.java new file mode 100644 index 0000000000..7aa00e42a1 --- /dev/null +++ b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/download/DownloadContainerRuntimeDefaultSettingsTest.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright (c) 2018 Red Hat, Inc. + * Distributed under license by Red Hat, Inc. All rights reserved. + * This program is made available under the terms of the + * Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + ******************************************************************************/ +package org.jboss.tools.cdk.ui.bot.test.server.wizard.download; + +import org.jboss.tools.cdk.reddeer.core.enums.CDKVersion; +import org.junit.Test; + +/** + * Class covers runtime download test for defaults of CDK 3.2+ and Minishift 1.14 + * @author odockal + * + */ +public class DownloadContainerRuntimeDefaultSettingsTest extends DownloadContainerRuntimeAbstractTest { + + @Override + protected String getServerAdapter() { + return SERVER_ADAPTER_32; + } + + @Test + public void testDownloadingCDK340RuntimeDefaults() { + downloadAndVerifyContainerRuntime(CDKVersion.CDK340, USERNAME, PASSWORD, "", "", true, true); + } + + @Test + public void testDownloadingMinishiftRuntimeDefaults() { + downloadAndVerifyContainerRuntime(CDKVersion.MINISHIFT1140, "", "", "", "", true, true); + } + +} diff --git a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/download/DownloadRuntimesWizardTest.java b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/download/DownloadRuntimesWizardTest.java new file mode 100644 index 0000000000..69234741b4 --- /dev/null +++ b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/download/DownloadRuntimesWizardTest.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * Copyright (c) 2018 Red Hat, Inc. + * Distributed under license by Red Hat, Inc. All rights reserved. + * This program is made available under the terms of the + * Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + ******************************************************************************/ +package org.jboss.tools.cdk.ui.bot.test.server.wizard.download; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.eclipse.reddeer.common.wait.TimePeriod; +import org.eclipse.reddeer.common.wait.WaitWhile; +import org.eclipse.reddeer.workbench.core.condition.JobIsRunning; +import org.jboss.tools.cdk.reddeer.core.enums.CDKVersion; +import org.jboss.tools.cdk.reddeer.core.label.CDKLabel; +import org.jboss.tools.cdk.ui.bot.test.utils.DownloadCDKRuntimesUtility; +import org.junit.Test; + +/** + * Class covers integration testing of download runtimes wizard + * @author odockal + * + */ +public class DownloadRuntimesWizardTest extends DownloadContainerRuntimeAbstractTest { + + private static final CDKVersion version = CDKVersion.CDK340; + + @Override + protected String getServerAdapter() { + return SERVER_ADAPTER_32; + } + + @Test + public void validCredentialsValidationTest() { + chooseWizardPage(CDKLabel.Server.SERVER_TYPE_GROUP, version.serverName()); + inicializeDownloadRutimeDialog(version); + DownloadCDKRuntimesUtility util = new DownloadCDKRuntimesUtility(true); + util.chooseRuntimeToDownload(version); + util.processCredentials(USERNAME, PASSWORD); + util.acceptLicense(); + assertTrue(util.getDownloadWizard().getTitle().contains("Download Runtime")); + new WaitWhile(new JobIsRunning(), TimePeriod.LONG, false); + util.getDownloadWizard().cancel(); + } + + @Test + public void invalidCredentialsTest() { + chooseWizardPage(CDKLabel.Server.SERVER_TYPE_GROUP, version.serverName()); + inicializeDownloadRutimeDialog(version); + DownloadCDKRuntimesUtility util = new DownloadCDKRuntimesUtility(true); + util.chooseRuntimeToDownload(version); + util.processCredentials("invalidUsername", "invalidPassword"); + assertTrue(util.getDownloadWizard().getTitle().contains("JBoss.org Credentials")); + assertTrue(util.getDownloadWizard().getMessage().contains("Your credentials have failed to validate")); + assertFalse(util.getDownloadWizard().isNextEnabled()); + new WaitWhile(new JobIsRunning(), TimePeriod.LONG, false); + util.getDownloadWizard().cancel(); + } +} diff --git a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/download/MinishiftDownloadRuntimeTest.java b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/download/MinishiftDownloadRuntimeTest.java new file mode 100644 index 0000000000..1c2599915f --- /dev/null +++ b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/server/wizard/download/MinishiftDownloadRuntimeTest.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2018 Red Hat, Inc. + * Distributed under license by Red Hat, Inc. All rights reserved. + * This program is made available under the terms of the + * Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + ******************************************************************************/ +package org.jboss.tools.cdk.ui.bot.test.server.wizard.download; + +import org.jboss.tools.cdk.reddeer.core.enums.CDKVersion; +import org.junit.Test; + +/** + * Class covers runtime download test for Minishift 1.14 + * @author odockal + * + */ +public class MinishiftDownloadRuntimeTest extends DownloadContainerRuntimeAbstractTest { + + @Override + protected String getServerAdapter() { + return SERVER_ADAPTER_MINISHIFT; + } + + @Test + public void testDownloadingMinishiftRuntime() { + downloadAndVerifyCDKRuntime(CDKVersion.MINISHIFT1140, "", ""); + } + +} diff --git a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/utils/CDKTestUtils.java b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/utils/CDKTestUtils.java index 1c363e8166..9082312f25 100644 --- a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/utils/CDKTestUtils.java +++ b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/utils/CDKTestUtils.java @@ -10,6 +10,8 @@ ******************************************************************************/ package org.jboss.tools.cdk.ui.bot.test.utils; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.io.File; @@ -35,6 +37,7 @@ import org.eclipse.reddeer.core.condition.WidgetIsFound; import org.eclipse.reddeer.core.matcher.WithMnemonicTextMatcher; import org.eclipse.reddeer.core.matcher.WithTextMatcher; +import org.eclipse.reddeer.eclipse.selectionwizard.NewMenuWizard; import org.eclipse.reddeer.eclipse.wst.server.ui.cnf.Server; import org.eclipse.reddeer.eclipse.wst.server.ui.cnf.ServersView2; import org.eclipse.reddeer.jface.exception.JFaceLayerException; @@ -48,7 +51,9 @@ import org.eclipse.reddeer.workbench.handler.EditorHandler; import org.eclipse.reddeer.workbench.ui.dialogs.WorkbenchPreferenceDialog; import org.eclipse.ui.IEditorPart; +import org.jboss.tools.cdk.reddeer.core.condition.SystemJobIsRunning; import org.jboss.tools.cdk.reddeer.core.label.CDKLabel; +import org.jboss.tools.cdk.reddeer.core.matcher.JobMatcher; import org.jboss.tools.cdk.reddeer.server.exception.CDKException; import org.jboss.tools.cdk.reddeer.server.ui.CDKServersView; import org.jboss.tools.cdk.reddeer.server.ui.wizard.NewCDKServerWizard; @@ -163,6 +168,21 @@ public static void setOCToPreferences(String ocPath) { dialog.cancel(); } + public static void assertSameMessage(final NewMenuWizard dialog, final String message) { + new WaitWhile(new SystemJobIsRunning(new JobMatcher(CDKLabel.Job.MINISHIFT_VALIDATION_JOB)), TimePeriod.DEFAULT, false); + String description = dialog.getMessage(); + assertTrue("Expected page description should contain text: " + message + + " but has: " + description, + description.contains(message)); + } + + public static void assertDiffMessage(final NewMenuWizard dialog, final String message) { + new WaitWhile(new SystemJobIsRunning(new JobMatcher(CDKLabel.Job.MINISHIFT_VALIDATION_JOB)), TimePeriod.DEFAULT, false); + String description = dialog.getMessage(); + assertFalse("Page descrition should not contain: " + message, + description.contains(message)); + } + public static String findFileOnPath(String path, String fileToFind) { log.info("Searching for " + fileToFind + " on " + path); File startPath = new File(path); diff --git a/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/utils/DownloadCDKRuntimesUtility.java b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/utils/DownloadCDKRuntimesUtility.java new file mode 100644 index 0000000000..8ef167c7f5 --- /dev/null +++ b/itests/org.jboss.tools.cdk.ui.bot.test/src/org/jboss/tools/cdk/ui/bot/test/utils/DownloadCDKRuntimesUtility.java @@ -0,0 +1,150 @@ +/******************************************************************************* + * Copyright (c) 2018 Red Hat, Inc. + * Distributed under license by Red Hat, Inc. All rights reserved. + * This program is made available under the terms of the + * Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + ******************************************************************************/ +package org.jboss.tools.cdk.ui.bot.test.utils; + +import org.eclipse.reddeer.common.condition.WaitCondition; +import org.eclipse.reddeer.common.logging.Logger; +import org.eclipse.reddeer.common.wait.TimePeriod; +import org.eclipse.reddeer.common.wait.WaitUntil; +import org.eclipse.reddeer.common.wait.WaitWhile; +import org.eclipse.reddeer.jface.wizard.WizardDialog; +import org.eclipse.reddeer.swt.impl.button.CheckBox; +import org.eclipse.reddeer.swt.impl.text.LabeledText; +import org.jboss.tools.cdk.reddeer.core.condition.ProgressBarIsRunning; +import org.jboss.tools.cdk.reddeer.core.enums.CDKVersion; +import org.jboss.tools.cdk.reddeer.server.ui.wizard.download.DownloadCDKRuntimesWizard; +import org.jboss.tools.runtime.reddeer.wizard.TaskWizardFirstPage; +import org.jboss.tools.runtime.reddeer.wizard.TaskWizardLoginPage; +import org.jboss.tools.runtime.reddeer.wizard.TaskWizardSecondPage; +import org.jboss.tools.runtime.reddeer.wizard.TaskWizardThirdPage; + +/** + * Utility class covering processing Download CDK Runtime wizard + * @author odockal + * + */ +public class DownloadCDKRuntimesUtility { + + private WizardDialog downloadWizard; + + public WizardDialog getDownloadWizard() { + return downloadWizard; + } + + public void setDownloadWizard(WizardDialog downloadWizard) { + this.downloadWizard = downloadWizard; + } + + private String installFolder; + private String downloadFolder; + private boolean removeArtifacts; + private boolean useDefaults; + + private static final Logger log = Logger.getLogger(DownloadCDKRuntimesUtility.class); + + public DownloadCDKRuntimesUtility(String installationFolder, + String downloadFolder, boolean removeArtifacts) { + this.downloadWizard = new DownloadCDKRuntimesWizard(); + this.installFolder = installationFolder; + this.downloadFolder = downloadFolder; + this.removeArtifacts = removeArtifacts; + this.useDefaults = false; + } + + public DownloadCDKRuntimesUtility(boolean useDefaults) { + this.downloadWizard = new DownloadCDKRuntimesWizard(); + this.installFolder = ""; + this.downloadFolder = ""; + this.removeArtifacts = true; + this.useDefaults = useDefaults; + } + + public void chooseRuntimeToDownload(CDKVersion version) { + log.info("Choosing runtime to download: " + version.getTypeAndVersion()); + TaskWizardFirstPage page = new TaskWizardFirstPage(downloadWizard); + page.selectRuntime(version.getTypeAndVersion()); + downloadWizard.next(); + } + + public void processCredentials(String username, String password) { + log.info("Processing credentials page"); + TaskWizardLoginPage page = new TaskWizardLoginPage(downloadWizard); + if (!page.containsUsername(username)) { + log.info("Adding credentials"); + page.addCredentials(username, password); + } else { + page.setUsername(username); + } + downloadWizard.next(); + log.info("Wait for credentials being validated..."); + // here should have come validation of credentials waiting + WaitCondition barIsRunning = new ProgressBarIsRunning("Validating Credentials"); + new WaitUntil(barIsRunning, TimePeriod.MEDIUM, false); + new WaitWhile(barIsRunning, TimePeriod.LONG, false); + } + + public void acceptLicense() { + TaskWizardSecondPage licensePage = new TaskWizardSecondPage(downloadWizard); + log.info("Accept license"); + licensePage.acceptLicense(true); + downloadWizard.next(); + } + + public void downloadRuntime() { + log.info("Setting up download and install folder"); + if (!this.useDefaults) { + TaskWizardThirdPage downloadPage = new TaskWizardThirdPage(downloadWizard); + downloadPage.setInstallFolder(this.installFolder); + downloadPage.setDownloadFolder(this.downloadFolder); + downloadPage.setDeleteArchive(this.removeArtifacts); + } else { + log.info("Using default values"); + installFolder = new LabeledText(downloadWizard, "Install folder:").getText(); + downloadFolder = new LabeledText(downloadWizard, "Download folder:").getText(); + removeArtifacts = new CheckBox(downloadWizard, "Delete archive after installing").isChecked(); + } + + downloadWizard.finish(); + downloadWizard = null; + } + + public boolean isUseDefaults() { + return useDefaults; + } + + public void setUseDefaults(boolean useDefaults) { + this.useDefaults = useDefaults; + } + + public String getInstallFolder() { + return installFolder; + } + + public void setInstallFolder(String installFolder) { + this.installFolder = installFolder; + } + + public String getDownloadFolder() { + return downloadFolder; + } + + public void setDownloadFolder(String downloadFolder) { + this.downloadFolder = downloadFolder; + } + + public boolean isRemoveArtifacts() { + return removeArtifacts; + } + + public void setRemoveArtifacts(boolean removeArtifacts) { + this.removeArtifacts = removeArtifacts; + } +} diff --git a/test-framework/org.jboss.tools.cdk.reddeer/META-INF/MANIFEST.MF b/test-framework/org.jboss.tools.cdk.reddeer/META-INF/MANIFEST.MF index cdad47087e..c10148d623 100644 --- a/test-framework/org.jboss.tools.cdk.reddeer/META-INF/MANIFEST.MF +++ b/test-framework/org.jboss.tools.cdk.reddeer/META-INF/MANIFEST.MF @@ -8,11 +8,11 @@ Bundle-ActivationPolicy: lazy Bundle-Vendor: Red Hat Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Require-Bundle: org.junit, - org.eclipse.reddeer.go;bundle-version="[2.0.0,3.0.0)", + org.eclipse.reddeer.go;bundle-version="[2.1.0,3.0.0)", org.eclipse.ui.forms, org.eclipse.wst.server.core, org.eclipse.linuxtools.docker.reddeer, - org.eclipse.linuxtools.docker.core + org.jboss.tools.runtime.reddeer Export-Package: org.jboss.tools.cdk.reddeer.core.certificate, org.jboss.tools.cdk.reddeer.core.condition, org.jboss.tools.cdk.reddeer.core.enums, @@ -25,5 +25,6 @@ Export-Package: org.jboss.tools.cdk.reddeer.core.certificate, org.jboss.tools.cdk.reddeer.server.ui.editor, org.jboss.tools.cdk.reddeer.server.ui.editor.launch.configuration, org.jboss.tools.cdk.reddeer.server.ui.wizard, + org.jboss.tools.cdk.reddeer.server.ui.wizard.download, org.jboss.tools.cdk.reddeer.ui.preferences, org.jboss.tools.cdk.reddeer.utils diff --git a/test-framework/org.jboss.tools.cdk.reddeer/src/org/jboss/tools/cdk/reddeer/core/condition/ProgressBarIsRunning.java b/test-framework/org.jboss.tools.cdk.reddeer/src/org/jboss/tools/cdk/reddeer/core/condition/ProgressBarIsRunning.java new file mode 100644 index 0000000000..308f1819c4 --- /dev/null +++ b/test-framework/org.jboss.tools.cdk.reddeer/src/org/jboss/tools/cdk/reddeer/core/condition/ProgressBarIsRunning.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2018 Red Hat, Inc. + * Distributed under license by Red Hat, Inc. All rights reserved. + * This program is made available under the terms of the + * Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + ******************************************************************************/ +package org.jboss.tools.cdk.reddeer.core.condition; + +import org.eclipse.reddeer.common.condition.AbstractWaitCondition; +import org.eclipse.reddeer.core.exception.CoreLayerException; +import org.eclipse.reddeer.swt.impl.progressbar.DefaultProgressBar; + +/** + * Wait condition for parameterized progress bar object + * @author odockal + * + */ +public class ProgressBarIsRunning extends AbstractWaitCondition { + + private String name; + + public ProgressBarIsRunning(String name) { + this.name = name; + } + + @Override + public boolean test() { + try { + new DefaultProgressBar(name); + return true; + } catch(CoreLayerException e) { + return false; + } + } + + @Override + public String description() { + return name + " progress bar is running"; + } + + @Override + public String errorMessageUntil() { + return name + " progress bar is not running"; + } + +} diff --git a/test-framework/org.jboss.tools.cdk.reddeer/src/org/jboss/tools/cdk/reddeer/core/enums/CDKRuntimeOS.java b/test-framework/org.jboss.tools.cdk.reddeer/src/org/jboss/tools/cdk/reddeer/core/enums/CDKRuntimeOS.java index 8850d3a5f5..ee3e66a814 100644 --- a/test-framework/org.jboss.tools.cdk.reddeer/src/org/jboss/tools/cdk/reddeer/core/enums/CDKRuntimeOS.java +++ b/test-framework/org.jboss.tools.cdk.reddeer/src/org/jboss/tools/cdk/reddeer/core/enums/CDKRuntimeOS.java @@ -12,37 +12,44 @@ /** * CDK runtime OS enum types + * * @author odockal * */ public enum CDKRuntimeOS { - LINUX("linux", ""), - WINDOWS("win", ".exe"), - MAC("darwin", ""), + LINUX("linux", "linux", ""), + WINDOWS("win", "windows", ".exe"), + MAC("darwin", "darwin", ""), OTHER; - + String runtimeName; + String runtimeFullName; String suffix; - + CDKRuntimeOS() { this.runtimeName = System.getProperty("os.name"); this.suffix = ""; } - - CDKRuntimeOS(String name, String suffix) { + + CDKRuntimeOS(String name, String runtimeFullName, String suffix) { this.runtimeName = name; + this.runtimeFullName = runtimeFullName; this.suffix = suffix; } - + public String getRuntimeName() { return this.runtimeName; } - + + public String getRuntimeFullName() { + return this.runtimeFullName; + } + public String getSuffix() { return this.suffix; } - + public static CDKRuntimeOS get() { String baseOS = System.getProperty("os.name").toLowerCase(); if (baseOS.contains("linux")) { diff --git a/test-framework/org.jboss.tools.cdk.reddeer/src/org/jboss/tools/cdk/reddeer/core/enums/CDKVersion.java b/test-framework/org.jboss.tools.cdk.reddeer/src/org/jboss/tools/cdk/reddeer/core/enums/CDKVersion.java new file mode 100644 index 0000000000..7e00b81dfb --- /dev/null +++ b/test-framework/org.jboss.tools.cdk.reddeer/src/org/jboss/tools/cdk/reddeer/core/enums/CDKVersion.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2018 Red Hat, Inc. + * Distributed under license by Red Hat, Inc. All rights reserved. + * This program is made available under the terms of the + * Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + ******************************************************************************/ +package org.jboss.tools.cdk.reddeer.core.enums; + +import org.jboss.tools.cdk.reddeer.core.label.CDKLabel; + +/** + * Enum holding information for CDK/Minshift container runtimes + * @author odockal + * + */ +public enum CDKVersion { + + CDK2X ("CDK", "2.x", CDKLabel.Server.CDK_SERVER_NAME, ""), + CDK300 ("CDK", "3.0.0", CDKLabel.Server.CDK3_SERVER_NAME, "cdk-3.0-minishift-" + CDKRuntimeOS.get().getRuntimeFullName() + "-amd64" + CDKRuntimeOS.get().getSuffix()), + CDK310 ("CDK", "3.1.0", CDKLabel.Server.CDK3_SERVER_NAME, "cdk-3.1.0-1-minishift-" + CDKRuntimeOS.get().getRuntimeFullName() + "-amd64" + CDKRuntimeOS.get().getSuffix()), + CDK311 ("CDK", "3.1.1", CDKLabel.Server.CDK3_SERVER_NAME, "cdk-3.1.1-1-minishift-" + CDKRuntimeOS.get().getRuntimeFullName() + "-amd64" + CDKRuntimeOS.get().getSuffix()), + CDK320 ("CDK", "3.2.0", CDKLabel.Server.CDK32_SERVER_NAME, "cdk-3.2.0-1-minishift-" + CDKRuntimeOS.get().getRuntimeFullName() + "-amd64" + CDKRuntimeOS.get().getSuffix()), + CDK330 ("CDK", "3.3.0", CDKLabel.Server.CDK32_SERVER_NAME, "cdk-3.3.0-1-minishift-" + CDKRuntimeOS.get().getRuntimeFullName() + "-amd64" + CDKRuntimeOS.get().getSuffix()), + CDK340 ("CDK", "3.4.0", CDKLabel.Server.CDK32_SERVER_NAME, "cdk-3.4.0-2-minishift-" + CDKRuntimeOS.get().getRuntimeFullName() + "-amd64" + CDKRuntimeOS.get().getSuffix()), + MINISHIFT1140 ("MiniShift", "1.14.0", CDKLabel.Server.MINISHIFT_SERVER_NAME, "minishift-1.14.0-" + CDKRuntimeOS.get().getRuntimeFullName() + "-amd64"); + + private final String type; + private final String version; + private final String serverName; + private final String downloadName; + + CDKVersion(String type, String version, String serverName, String downloadName) { + this.type = type; + this.version = version; + this.serverName = serverName; + this.downloadName = downloadName; + } + + public String type() { + return this.type; + } + + public String version() { + return this.version; + } + + public String serverName() { + return serverName; + } + + public String downloadName() { + return downloadName; + } + + public String getTypeAndVersion() { + return this.type + " v" + this.version; + } + +} diff --git a/test-framework/org.jboss.tools.cdk.reddeer/src/org/jboss/tools/cdk/reddeer/core/label/CDKLabel.java b/test-framework/org.jboss.tools.cdk.reddeer/src/org/jboss/tools/cdk/reddeer/core/label/CDKLabel.java index ec6efd94a5..292dcb67ca 100644 --- a/test-framework/org.jboss.tools.cdk.reddeer/src/org/jboss/tools/cdk/reddeer/core/label/CDKLabel.java +++ b/test-framework/org.jboss.tools.cdk.reddeer/src/org/jboss/tools/cdk/reddeer/core/label/CDKLabel.java @@ -10,6 +10,8 @@ ******************************************************************************/ package org.jboss.tools.cdk.reddeer.core.label; +import org.jboss.tools.cdk.reddeer.utils.CDKUtils; + /** * Encapsulating class for statically accessed subclasses with labels * @author odockal @@ -18,7 +20,7 @@ public class CDKLabel { public static class Job { - public static final String MINISHIFT_VALIDATION_JOB = "Validate minishift location"; + public static final String MINISHIFT_VALIDATION_JOB = "Validate minishift location"; public static final String REFRESHING_SERVER_ADAPTER_LIST = "Refreshing server adapter list"; } @@ -40,6 +42,7 @@ public static class Shell { public static final String NEW_SERVER_WIZARD = "New Server"; public static final String WARNING_FOLDER_EXISTS = "Warning: Folder already exists!"; public static final String WARNING_CDK_NOT_INICIALIZED = "Warning: CDK has not been properly initialized!"; + public static final String DOWNLOAD_RUNTIMES = "Download Runtimes"; } public static class Labels { @@ -61,6 +64,10 @@ public static class Labels { public static final String SECURE_STORAGE = "Secure Storage"; } + public static class Links { + public static final String DOWNLOAD_AND_INSTALL_RUNTIME = "Download and install runtime..."; + } + public static class Sections { public static final String CDK_DETAILS = "CDK Details"; public static final String GENERAL = "General Information"; @@ -95,6 +102,18 @@ public static class Server { public static final String MINISHIFT_SERVER_NAME = "Minishift 1.7+"; } + public static class Messages { + // page description messages + + public static final String NO_USER = "Red Hat Access credentials"; + public static final String DOES_NOT_EXIST = "does not exist"; + public static final String CANNOT_RUN_PROGRAM = "Cannot run program"; + public static final String NOT_EXECUTABLE = CDKUtils.IS_WINDOWS ? CANNOT_RUN_PROGRAM : "is not executable"; + public static final String CHECK_MINISHIFT_VERSION = "Unknown error while checking minishift version"; + public static final String NOT_COMPATIBLE = "is not compatible with this server adapter"; + public static final String SERVER_ADAPTER_REPRESENTING = "server adapter representing"; + } + public static class Others { public static final String CREDENTIALS_DOMAIN = "access.redhat.com"; } diff --git a/test-framework/org.jboss.tools.cdk.reddeer/src/org/jboss/tools/cdk/reddeer/requirements/CleanDockerExplorerRequirement.java b/test-framework/org.jboss.tools.cdk.reddeer/src/org/jboss/tools/cdk/reddeer/requirements/CleanDockerExplorerRequirement.java index 400fecb406..9b41afb371 100644 --- a/test-framework/org.jboss.tools.cdk.reddeer/src/org/jboss/tools/cdk/reddeer/requirements/CleanDockerExplorerRequirement.java +++ b/test-framework/org.jboss.tools.cdk.reddeer/src/org/jboss/tools/cdk/reddeer/requirements/CleanDockerExplorerRequirement.java @@ -28,7 +28,7 @@ /** * Requirement assuring that all Docker connections are removed from Docker Explorer. - * @author odockal + * @author Ondrej Dockal, odockal@redhat.com * */ public class CleanDockerExplorerRequirement implements Requirement { @@ -42,7 +42,7 @@ public class CleanDockerExplorerRequirement implements Requirement getDockerConnections() { initializeExplorer(); + log.info("Getting all available Docker connections..."); try { return new DefaultTree().getItems().stream() .map(x -> new DockerConnection(x)) @@ -85,8 +93,10 @@ public List getDockerConnections() { return new ArrayList<>(); } + /** + * Removes all docker connections found + */ public void removeAllDockerConnections() { - log.info("Getting all available Docker connections..."); List connections = getDockerConnections(); if (!connections.isEmpty()) { connections.stream() diff --git a/test-framework/org.jboss.tools.cdk.reddeer/src/org/jboss/tools/cdk/reddeer/server/ui/wizard/NewCDK3ServerWizardPage.java b/test-framework/org.jboss.tools.cdk.reddeer/src/org/jboss/tools/cdk/reddeer/server/ui/wizard/NewCDK3ServerWizardPage.java index 8d35ddeac4..c8dd98f3d0 100644 --- a/test-framework/org.jboss.tools.cdk.reddeer/src/org/jboss/tools/cdk/reddeer/server/ui/wizard/NewCDK3ServerWizardPage.java +++ b/test-framework/org.jboss.tools.cdk.reddeer/src/org/jboss/tools/cdk/reddeer/server/ui/wizard/NewCDK3ServerWizardPage.java @@ -10,13 +10,20 @@ ******************************************************************************/ package org.jboss.tools.cdk.reddeer.server.ui.wizard; +import org.eclipse.reddeer.swt.api.Link; import org.eclipse.reddeer.swt.impl.combo.LabeledCombo; +import org.eclipse.reddeer.swt.impl.link.DefaultLink; import org.eclipse.reddeer.swt.impl.shell.DefaultShell; import org.eclipse.reddeer.swt.impl.text.LabeledText; import org.jboss.tools.cdk.reddeer.core.label.CDKLabel; public class NewCDK3ServerWizardPage extends NewServerContainerWizardPage { + public Link getDownloadAndInstallLink() { + new DefaultShell(CDKLabel.Shell.NEW_SERVER_WIZARD); + return new DefaultLink(CDKLabel.Links.DOWNLOAD_AND_INSTALL_RUNTIME); + } + public LabeledText getMinishiftBinaryLabeledText() { new DefaultShell(CDKLabel.Shell.NEW_SERVER_WIZARD); return new LabeledText(CDKLabel.Labels.MINISHIFT_BINARY); diff --git a/test-framework/org.jboss.tools.cdk.reddeer/src/org/jboss/tools/cdk/reddeer/server/ui/wizard/download/DownloadCDKRuntimesWizard.java b/test-framework/org.jboss.tools.cdk.reddeer/src/org/jboss/tools/cdk/reddeer/server/ui/wizard/download/DownloadCDKRuntimesWizard.java new file mode 100644 index 0000000000..60d0b80183 --- /dev/null +++ b/test-framework/org.jboss.tools.cdk.reddeer/src/org/jboss/tools/cdk/reddeer/server/ui/wizard/download/DownloadCDKRuntimesWizard.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * Copyright (c) 2018 Red Hat, Inc. + * Distributed under license by Red Hat, Inc. All rights reserved. + * This program is made available under the terms of the + * Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + ******************************************************************************/ +package org.jboss.tools.cdk.reddeer.server.ui.wizard.download; + +import org.eclipse.reddeer.common.condition.AbstractWaitCondition; +import org.eclipse.reddeer.common.wait.TimePeriod; +import org.eclipse.reddeer.common.wait.WaitUntil; +import org.eclipse.reddeer.common.wait.WaitWhile; +import org.eclipse.reddeer.jface.wizard.WizardDialog; +import org.eclipse.reddeer.swt.api.Button; +import org.eclipse.reddeer.swt.api.Shell; +import org.eclipse.reddeer.swt.condition.ShellIsAvailable; +import org.eclipse.reddeer.swt.impl.button.PushButton; +import org.eclipse.reddeer.swt.impl.shell.DefaultShell; +import org.eclipse.reddeer.workbench.core.condition.JobIsRunning; +import org.jboss.tools.cdk.reddeer.core.label.CDKLabel; + +/** + * Represent download runtime wizard reddeer implementation + * @author odockal + * + */ +public class DownloadCDKRuntimesWizard extends WizardDialog { + + public DownloadCDKRuntimesWizard() { + super(CDKLabel.Shell.DOWNLOAD_RUNTIMES); + } + + @Override + public void finish() { + log.info("Finish wizard"); + Button button = new PushButton(this, "Finish"); + button.click(); + new WaitUntil(new JobIsRunning(), TimePeriod.LONG, false); + new WaitWhile(new RuntimeIsDownloading(), TimePeriod.getCustom(600)); + } + + private class RuntimeIsDownloading extends AbstractWaitCondition{ + + @Override + public boolean test() { + if(new ShellIsAvailable("Question").test()){ + Shell questionShell = new DefaultShell("Question"); + new PushButton(questionShell, "Yes To All").click(); + new WaitWhile(new ShellIsAvailable(questionShell)); + } + return new JobIsRunning().test(); + } + + @Override + public String description() { + return "Runtime is downloading"; + } + + } + +} diff --git a/test-framework/org.jboss.tools.cdk.reddeer/src/org/jboss/tools/cdk/reddeer/utils/CDKUtils.java b/test-framework/org.jboss.tools.cdk.reddeer/src/org/jboss/tools/cdk/reddeer/utils/CDKUtils.java index 1e2cd11ee9..600b4d4237 100644 --- a/test-framework/org.jboss.tools.cdk.reddeer/src/org/jboss/tools/cdk/reddeer/utils/CDKUtils.java +++ b/test-framework/org.jboss.tools.cdk.reddeer/src/org/jboss/tools/cdk/reddeer/utils/CDKUtils.java @@ -32,6 +32,10 @@ */ public final class CDKUtils { + public static final boolean IS_WINDOWS = System.getProperty("os.name").toLowerCase().contains("win"); + + public static final boolean IS_LINUX = System.getProperty("os.name").toLowerCase().contains("linux"); + private static final Logger log = Logger.getLogger(CDKUtils.class); private CDKUtils() {}