Skip to content

Commit

Permalink
Runtime detection product tests stability improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
rhopp authored and psrna committed Feb 9, 2016
1 parent ebba7aa commit eb8c730
Show file tree
Hide file tree
Showing 13 changed files with 134 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.jboss.tools.runtime.reddeer.wizard;

import org.jboss.reddeer.common.exception.RedDeerException;
import org.jboss.reddeer.jface.wizard.WizardPage;
import org.jboss.reddeer.swt.impl.button.CancelButton;
import org.jboss.reddeer.swt.impl.button.OkButton;
Expand All @@ -26,7 +27,11 @@ public void addCredentials(String username, String password){
new OkButton().click();

//Do not store this to secure storage
new DefaultShell("Secure Storage Password");
try{
new DefaultShell("Secure Storage Password");
}catch(RedDeerException e){
new DefaultShell("Secure Storage");
}
new CancelButton().click();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
package org.jboss.tools.runtime.reddeer.wizard;

import org.jboss.reddeer.common.exception.WaitTimeoutExpiredException;
import org.jboss.reddeer.core.exception.CoreLayerException;
import java.util.ArrayList;
import java.util.List;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.hamcrest.Matcher;
import org.jboss.reddeer.common.wait.WaitUntil;
import org.jboss.reddeer.core.condition.WidgetIsFound;
import org.jboss.reddeer.core.matcher.ClassMatcher;
import org.jboss.reddeer.core.matcher.WithMnemonicTextMatcher;
import org.jboss.reddeer.core.matcher.WithStyleMatcher;
import org.jboss.reddeer.jface.wizard.WizardPage;
import org.jboss.reddeer.swt.impl.button.RadioButton;

public class TaskWizardSecondPage extends WizardPage{

public void acceptLicense(boolean accept){
if(accept){

try {
new RadioButton("I accept the terms of the license agreement").click();
} catch (CoreLayerException e) {
// This can sometimes fail. Try again
new RadioButton("I accept the terms of the license agreement").click();
}
new WaitUntil(new WidgetIsFound<Button>(getRadioButtonMatchers("I accept the terms of the license agreement")));
new RadioButton("I accept the terms of the license agreement").click();
}else {
new RadioButton("I do not accept the terms of the license agreement").click();
}
}

private Matcher<?>[] getRadioButtonMatchers(String text){
List<Matcher<?>> list= new ArrayList<Matcher<?>>();
list.add(new WithStyleMatcher(SWT.RADIO));
list.add(new WithMnemonicTextMatcher(text));
list.add(new ClassMatcher(Button.class));
return list.toArray(new Matcher[list.size()]);
}

}
7 changes: 4 additions & 3 deletions tests/org.jboss.tools.runtime.as.ui.bot.test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<reddeer.config>${project.build.directory}/../resources/generated_resources</reddeer.config>

<surefire.timeout>7200</surefire.timeout>
<systemProperties>${integrationTestsSystemProperties} -Drd.config=${reddeer.config}</systemProperties>
<systemProperties>${integrationTestsSystemProperties} -Drd.config=${reddeer.config} -Djbt.cdk_git_uri=${jbt.cdk_git_uri} ${productProperties}</systemProperties>
</properties>

<profiles>
Expand All @@ -37,7 +37,7 @@
<jboss-seam-2.3.0.Final>${requirementsDirectory}/jboss-seam-2.3.0.Final/</jboss-seam-2.3.0.Final>
<jboss-seam-2.2.2>${requirementsDirectory}/jboss-seam-2.2.2.Final/</jboss-seam-2.2.2>

<test.class>org.jboss.tools.runtime.as.ui.bot.test.ProjectTestsSuite</test.class>
<test.class>org.jboss.tools.runtime.as.ui.bot.test.StableTestsSuite</test.class>
</properties>
<build>
<plugins>
Expand Down Expand Up @@ -196,7 +196,7 @@
<jboss-seam-2.3.x>${requirementsDirectory}/jboss-seam-2.3.x/jboss-wfk-2.5.0/jboss-seam-2.3.3.Final-redhat-1/</jboss-seam-2.3.x>

<product-download-properties-file>resources/products-download.properties</product-download-properties-file>
<systemProperties> ${systemProperties} -Djboss.org.username=${jboss.org.username} -Djboss.org.password=${jboss.org.password}</systemProperties>
<productProperties>-Djboss.org.username=${jboss.org.username} -Djboss.org.password=${jboss.org.password}</productProperties>
</properties>
<build>
<plugins>
Expand Down Expand Up @@ -409,6 +409,7 @@
<dependency>
<type>p2-installable-unit</type>
<artifactId>org.eclipse.jgit.feature.group</artifactId>
<artifactId>org.jboss.tools.openshift.cdk.feature.feature.group</artifactId>
<version>0.0.0</version>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.jboss.tools.runtime.as.ui.bot.test.detector.server.wildfly90.DetectWildFly90;
import org.jboss.tools.runtime.as.ui.bot.test.detector.server.wildfly90.OperateWildFly90;
import org.jboss.tools.runtime.as.ui.bot.test.detector.server.wildfly90web.DetectWildFly90Web;
import org.jboss.tools.runtime.as.ui.bot.test.detector.server.wildfly90web.OperateWildFly90Web;
import org.jboss.tools.runtime.as.ui.bot.test.download.ProductRuntimeDownload;
import org.jboss.tools.runtime.as.ui.bot.test.download.ProjectRuntimeDownload;
import org.junit.runner.RunWith;
Expand All @@ -50,6 +51,7 @@
OperateWildFly90.class,

DetectWildFly90Web.class,
OperateWildFly90Web.class,

DetectWildFly81.class,
OperateWildFly81.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public class DetectCDK2fromGit extends DetectRuntimeTemplate {

@BeforeClass
public static void setup(){
if (GIT_REPOSITORY_URI==null){
fail("\"jbt.cdk_git_uri\" property was not set.");
}
File gitRepositoryDir = new File("target/cdk-git");
if (gitRepositoryDir.exists()){
try {
Expand All @@ -35,6 +38,7 @@ public static void setup(){
try {
Git.cloneRepository().setURI(GIT_REPOSITORY_URI).setDirectory(gitRepositoryDir).call();
} catch (GitAPIException e) {
e.printStackTrace();
fail("Unable to clone git repository");
}
}
Expand All @@ -50,7 +54,7 @@ protected List<Runtime> getExpectedRuntimes() {
expectedServer.setName("cdk-v2");
expectedServer.setVersion("2.0");
expectedServer.setType("CDK");
expectedServer.setLocation(RuntimeProperties.getInstance().getRuntimePath(SERVER_ID));
expectedServer.setLocation(new File("target/cdk-git/cdk-v2").getAbsolutePath());
return Arrays.asList(expectedServer);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class DetectSeam23x extends DetectRuntimeTemplate {

public static final String PATH_ID = "jboss-seam-2.3.x";

public static final String VERSION = "2.3.1.Final";
public static final String VERSION = "2.3.3.Final-redhat-1";

public static final String NAME = "jboss-seam-" + VERSION;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.jboss.reddeer.requirements.jre.JRERequirement.JRE;
import org.jboss.tools.runtime.as.ui.bot.test.template.OperateServerTemplate;

@JRE(cleanup=true)
@JRE(cleanup=true, value=1.7)
public class OperateEAP63 extends OperateServerTemplate {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
import java.util.Arrays;
import java.util.List;

import org.jboss.reddeer.requirements.jre.JRERequirement.JRE;
import org.jboss.tools.runtime.as.ui.bot.test.RuntimeProperties;
import org.jboss.tools.runtime.as.ui.bot.test.entity.Runtime;
import org.jboss.tools.runtime.as.ui.bot.test.template.DetectRuntimeTemplate;

@JRE(value=1.7, cleanup=true)
public class DetectJPP61x extends DetectRuntimeTemplate {

public static final String SERVER_ID = "jboss-jpp-6.1.x";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package org.jboss.tools.runtime.as.ui.bot.test.download;

import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;

import org.hamcrest.core.StringContains;
import org.jboss.reddeer.swt.api.Text;
import org.jboss.reddeer.swt.exception.SWTLayerException;
import org.jboss.reddeer.common.condition.WaitCondition;
import org.jboss.reddeer.common.wait.WaitWhile;
import org.jboss.reddeer.core.exception.CoreLayerException;
import org.jboss.reddeer.swt.impl.progressbar.DefaultProgressBar;
import org.jboss.reddeer.swt.impl.text.DefaultText;
import org.junit.Test;

/**
Expand All @@ -23,16 +24,16 @@ public class ProductRuntimeDownload extends ProductRuntimeDownloadTestBase {
* credentials
*/
@Test
public void useInvalidCredentials() {
public void useInvalidCredentials() {
invokeDownloadRuntimesWizard();

processSelectingRuntime("JBoss EAP 6.2.0");
processInsertingCredentials("Invalid username", "Invalid password");

try {
Text errorText = new org.jboss.reddeer.swt.impl.text.DefaultText(0);
assertThat(errorText.getText(), StringContains.containsString("Please use your jboss.org single sign-on credentials to begin your download."));
} catch(SWTLayerException e) {
new WaitWhile(new ValidatingCredentialsProgressBarIsRunning());
new DefaultText(" Your credentials are incorrect. Please review the values and try again.");
} catch (CoreLayerException e) {
fail("Error text not found\n" + e.getMessage());
}
}
Expand All @@ -54,4 +55,28 @@ public void downloadEAP62() {
public void downloadJPP610() {
downloadRuntime("JBoss Portal Platform 6.1.0");
}

private class ValidatingCredentialsProgressBarIsRunning implements WaitCondition{

@Override
public boolean test() {
try{
new DefaultProgressBar("Validating Credentials");
return true;
}catch(CoreLayerException e){
return false;
}
}

@Override
public String description() {
return "Validating Credentials progress bar is running";
}

@Override
public String errorMessage() {
return "Validating Credentials progress bar is not running";
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@
import java.io.File;
import java.io.IOException;

import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.jboss.reddeer.common.condition.WaitCondition;
import org.jboss.reddeer.common.wait.TimePeriod;
import org.jboss.reddeer.common.wait.WaitUntil;
import org.jboss.reddeer.common.wait.WaitWhile;
import org.jboss.reddeer.core.condition.JobIsRunning;
import org.jboss.reddeer.core.condition.ShellWithTextIsAvailable;
import org.jboss.reddeer.core.exception.CoreLayerException;
import org.jboss.reddeer.jface.wizard.WizardDialog;
import org.jboss.reddeer.swt.impl.button.PushButton;
import org.jboss.reddeer.swt.impl.progressbar.DefaultProgressBar;
import org.jboss.reddeer.swt.impl.shell.DefaultShell;
import org.jboss.reddeer.workbench.ui.dialogs.WorkbenchPreferenceDialog;
import org.jboss.tools.common.reddeer.utils.FileUtils;
import org.jboss.tools.runtime.as.ui.bot.test.template.RuntimeDetectionTestCase;
Expand Down Expand Up @@ -79,7 +84,9 @@ protected void processInsertingCredentials(String username, String password) {
if (!credentialsPage.containsUsername(username)){
credentialsPage.addCredentials(username, password);
}
new DefaultShell("Download Runtimes").setFocus();
credentialsPage.setUsername(username);
new WaitWhile(new JobIsRunning());
runtimeDownloadWizard.next();
new WaitWhile(new JobIsRunning());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import org.hamcrest.core.Is;
import org.jboss.reddeer.core.condition.ShellWithTextIsAvailable;
import org.jboss.reddeer.eclipse.wst.server.ui.RuntimePreferencePage;
import org.jboss.reddeer.eclipse.wst.server.ui.view.Server;
import org.jboss.reddeer.eclipse.wst.server.ui.view.ServersView;
import org.jboss.reddeer.swt.impl.button.PushButton;
import org.jboss.reddeer.swt.impl.shell.DefaultShell;
import org.jboss.reddeer.workbench.ui.dialogs.WorkbenchPreferenceDialog;
Expand Down Expand Up @@ -59,6 +61,14 @@ public static void setupClass(){
preferenceDialog.select(runtimePage);
runtimePage.removeAllRuntimes();
preferenceDialog.ok();

//delete all servers (because of CDK server)
ServersView serversView = new ServersView();
serversView.open();
List<Server> servers = serversView.getServers();
for (Server server : servers) {
server.delete();
}
}

@Test
Expand All @@ -83,7 +93,7 @@ public void removePath() {
preferenceDialog.select(runtimeDetectionPage);

List<String> allPaths = runtimeDetectionPage.getAllPaths();
String requiredPath = RuntimeProperties.getInstance().getRuntimePath(getPathID());
String requiredPath = new File(RuntimeProperties.getInstance().getRuntimePath(getPathID())).getAbsolutePath();
assertTrue("Expected is presence of path " + requiredPath + " but there are:\n"
+ Arrays.toString(allPaths.toArray()), allPaths.contains(requiredPath));

Expand Down
Loading

0 comments on commit eb8c730

Please sign in to comment.