Author: ljelinko
Date: 2012-05-22 10:33:31 -0400 (Tue, 22 May 2012)
New Revision: 41255
Added:
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/detector/ServerWithSeam.java
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/dialog/preferences/ServerRuntimesPreferencesDialog.java
Modified:
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/AllTestsSuite.java
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/dialog/preferences/RuntimeDetectionPreferencesDialog.java
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/dialog/preferences/SearchingForRuntimesDialog.java
Log:
Created test for combinations of adding server and seam runtimes.
Modified:
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/AllTestsSuite.java
===================================================================
---
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/AllTestsSuite.java 2012-05-22
13:30:42 UTC (rev 41254)
+++
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/AllTestsSuite.java 2012-05-22
14:33:31 UTC (rev 41255)
@@ -1,5 +1,6 @@
package org.jboss.tools.runtime.as.ui.bot.test;
+import org.jboss.tools.runtime.as.ui.bot.test.detector.ServerWithSeam;
import org.jboss.tools.runtime.as.ui.bot.test.detector.seam.seam22.CheckSeam22;
import org.jboss.tools.runtime.as.ui.bot.test.detector.seam.seam22.DetectSeam22;
import org.jboss.tools.runtime.as.ui.bot.test.detector.seam.seam23.CheckSeam23;
@@ -34,6 +35,7 @@
@RunWith(RequirementAwareSuite.class)
@Suite.SuiteClasses({
+ ServerWithSeam.class,
DetectJBoss7.class,
OperateJBoss7.class,
DetectEAP6.class,
Added:
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/detector/ServerWithSeam.java
===================================================================
---
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/detector/ServerWithSeam.java
(rev 0)
+++
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/detector/ServerWithSeam.java 2012-05-22
14:33:31 UTC (rev 41255)
@@ -0,0 +1,107 @@
+package org.jboss.tools.runtime.as.ui.bot.test.detector;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+import org.jboss.tools.runtime.as.ui.bot.test.RuntimeProperties;
+import org.jboss.tools.runtime.as.ui.bot.test.detector.server.eap5.DetectEAP5;
+import
org.jboss.tools.runtime.as.ui.bot.test.dialog.preferences.RuntimeDetectionPreferencesDialog;
+import org.jboss.tools.runtime.as.ui.bot.test.dialog.preferences.SeamPreferencesDialog;
+import
org.jboss.tools.runtime.as.ui.bot.test.dialog.preferences.SearchingForRuntimesDialog;
+import
org.jboss.tools.runtime.as.ui.bot.test.dialog.preferences.ServerRuntimesPreferencesDialog;
+import org.jboss.tools.ui.bot.ext.SWTTestExt;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Runtime detection of JBoss server containing also Seam runtime. Checks if the JBoss AS
and
+ * Seam can be added independently.
+ *
+ * @author Lucia Jelinkova
+ *
+ */
+public class ServerWithSeam extends SWTTestExt {
+
+ private RuntimeDetectionPreferencesDialog runtimeDetectionPreferences;
+
+ private SearchingForRuntimesDialog searchingForRuntimesDialog;
+
+ private SeamPreferencesDialog seamPreferences = new SeamPreferencesDialog();
+
+ private ServerRuntimesPreferencesDialog serverRuntimesPreferences = new
ServerRuntimesPreferencesDialog();
+
+ @Before
+ public void search(){
+ runtimeDetectionPreferences = new RuntimeDetectionPreferencesDialog();
+ runtimeDetectionPreferences.open();
+ runtimeDetectionPreferences.addPath(RuntimeProperties.getInstance().getRuntimePath(DetectEAP5.SERVER_ID));
+ searchingForRuntimesDialog = runtimeDetectionPreferences.search();
+ }
+
+ @Test
+ public void serverFirst(){
+ deselectRuntime("seam");
+
+ assertSeamRuntimesNumber(0);
+ assertServerRuntimesNumber(1);
+
+ addAllDetectedRuntimes();
+
+ assertSeamRuntimesNumber(1);
+ assertServerRuntimesNumber(1);
+ }
+
+ @Test
+ public void seamFirst(){
+ deselectRuntime(DetectEAP5.SERVER_ID);
+
+ assertSeamRuntimesNumber(1);
+ assertServerRuntimesNumber(0);
+
+ addAllDetectedRuntimes();
+
+ assertSeamRuntimesNumber(1);
+ assertServerRuntimesNumber(1);
+ }
+
+ @After
+ public void cleanup(){
+ runtimeDetectionPreferences.open();
+ runtimeDetectionPreferences.removePath(RuntimeProperties.getInstance().getRuntimePath(DetectEAP5.SERVER_ID));
+ runtimeDetectionPreferences.ok();
+
+ seamPreferences.open();
+ seamPreferences.removeAllRuntimes();
+ seamPreferences.ok();
+
+ serverRuntimesPreferences.open();
+ serverRuntimesPreferences.removeAllRuntimes();
+ serverRuntimesPreferences.ok();
+ }
+
+ private void deselectRuntime(String name) {
+ searchingForRuntimesDialog.deselect(name);
+ searchingForRuntimesDialog.ok();
+ runtimeDetectionPreferences.ok();
+ }
+
+ private void assertSeamRuntimesNumber(int expected) {
+ seamPreferences.open();
+ assertThat(seamPreferences.getRuntimes().size(), is(expected));
+ seamPreferences.ok();
+ }
+
+ private void assertServerRuntimesNumber(int expected) {
+ serverRuntimesPreferences.open();
+ assertThat(serverRuntimesPreferences.getRuntimes().size(), is(expected));
+ serverRuntimesPreferences.ok();
+ }
+
+ private void addAllDetectedRuntimes() {
+ runtimeDetectionPreferences.open();
+ searchingForRuntimesDialog = runtimeDetectionPreferences.search();
+ searchingForRuntimesDialog.ok();
+ runtimeDetectionPreferences.ok();
+ }
+}
Modified:
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/dialog/preferences/RuntimeDetectionPreferencesDialog.java
===================================================================
---
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/dialog/preferences/RuntimeDetectionPreferencesDialog.java 2012-05-22
13:30:42 UTC (rev 41254)
+++
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/dialog/preferences/RuntimeDetectionPreferencesDialog.java 2012-05-22
14:33:31 UTC (rev 41255)
@@ -2,11 +2,15 @@
import java.util.Set;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
import org.eclipse.swtbot.swt.finder.results.VoidResult;
+import org.eclipse.swtbot.swt.finder.waits.ICondition;
import org.jboss.tools.runtime.core.model.RuntimePath;
import org.jboss.tools.runtime.ui.RuntimeUIActivator;
import org.jboss.tools.ui.bot.ext.SWTBotFactory;
+import org.jboss.tools.ui.bot.ext.condition.TaskDuration;
public class RuntimeDetectionPreferencesDialog extends PreferencesDialog{
@@ -37,6 +41,36 @@
public SearchingForRuntimesDialog search(){
SWTBotFactory.getBot().button("Search...").click();
+ SWTBot bot = SWTBotFactory.getBot().shell("Searching for
runtimes...").bot();
+ bot.waitUntil(new RuntimeSearchedFinished(bot), TaskDuration.LONG.getTimeout());
return new SearchingForRuntimesDialog();
}
+
+ private static class RuntimeSearchedFinished implements ICondition {
+
+ private SWTBot bot;
+
+ public RuntimeSearchedFinished(SWTBot bot) {
+ this.bot = bot;
+ }
+
+ @Override
+ public void init(SWTBot bot) {
+ }
+
+ @Override
+ public boolean test() throws Exception {
+ try {
+ bot.label("Searching runtimes is finished.");
+ return true;
+ } catch (WidgetNotFoundException e){
+ return false;
+ }
+ }
+
+ @Override
+ public String getFailureMessage() {
+ return "The runtime search has not finished in the specified amount of
time";
+ }
+ }
}
Modified:
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/dialog/preferences/SearchingForRuntimesDialog.java
===================================================================
---
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/dialog/preferences/SearchingForRuntimesDialog.java 2012-05-22
13:30:42 UTC (rev 41254)
+++
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/dialog/preferences/SearchingForRuntimesDialog.java 2012-05-22
14:33:31 UTC (rev 41255)
@@ -3,26 +3,18 @@
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
-import org.eclipse.swtbot.swt.finder.waits.ICondition;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.jboss.tools.runtime.as.ui.bot.test.entity.Runtime;
import org.jboss.tools.ui.bot.ext.SWTBotFactory;
import org.jboss.tools.ui.bot.ext.SWTEclipseExt;
-import org.jboss.tools.ui.bot.ext.condition.TaskDuration;
public class SearchingForRuntimesDialog {
public List<Runtime> getRuntimes(){
List<Runtime> runtimes = new ArrayList<Runtime>();
- SWTBot bot = SWTBotFactory.getBot().shell("Searching for
runtimes...").bot();
- bot.waitUntil(new RuntimeSearchedFinished(bot), TaskDuration.LONG.getTimeout());
- SWTBotTree tree = bot.tree();
-
- for (SWTBotTreeItem treeItem :
SWTEclipseExt.getAllTreeItemsRecursive(SWTBotFactory.getBot(), tree, true)) {
+ for (SWTBotTreeItem treeItem : getRuntimesTreeItems()) {
Runtime runtime = new Runtime();
runtime.setName(treeItem.cell(0));
runtime.setVersion(treeItem.cell(1));
@@ -37,31 +29,16 @@
SWTBotFactory.getBot().button("OK").click();
}
- private static class RuntimeSearchedFinished implements ICondition {
-
- private SWTBot bot;
-
- public RuntimeSearchedFinished(SWTBot bot) {
- this.bot = bot;
- }
-
- @Override
- public void init(SWTBot bot) {
- }
-
- @Override
- public boolean test() throws Exception {
- try {
- bot.label("Searching runtimes is finished.");
- return true;
- } catch (WidgetNotFoundException e){
- return false;
+ public void deselect(String runtimeName){
+ for (SWTBotTreeItem treeItem : getRuntimesTreeItems()) {
+ if (treeItem.cell(0).equals(runtimeName)){
+ treeItem.uncheck();
}
}
-
- @Override
- public String getFailureMessage() {
- return "The runtime search has not finished in the specified amount of
time";
- }
}
+
+ private List<SWTBotTreeItem> getRuntimesTreeItems(){
+ SWTBotTree tree = SWTBotFactory.getBot().tree();
+ return SWTEclipseExt.getAllTreeItemsRecursive(SWTBotFactory.getBot(), tree, true);
+ }
}
Added:
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/dialog/preferences/ServerRuntimesPreferencesDialog.java
===================================================================
---
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/dialog/preferences/ServerRuntimesPreferencesDialog.java
(rev 0)
+++
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/dialog/preferences/ServerRuntimesPreferencesDialog.java 2012-05-22
14:33:31 UTC (rev 41255)
@@ -0,0 +1,44 @@
+package org.jboss.tools.runtime.as.ui.bot.test.dialog.preferences;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.keyboard.KeyboardFactory;
+import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
+import org.jboss.tools.runtime.as.ui.bot.test.entity.Runtime;
+import org.jboss.tools.ui.bot.ext.SWTBotFactory;
+
+public class ServerRuntimesPreferencesDialog extends PreferencesDialog {
+
+ public void open(){
+ open("Server", "Runtime Environments");
+ }
+
+ public List<Runtime> getRuntimes(){
+ List<Runtime> runtimes = new ArrayList<Runtime>();
+
+ SWTBotTable table = SWTBotFactory.getBot().table();
+
+ for (int i = 0; i < table.rowCount(); i++){
+ Runtime runtime = new Runtime();
+ runtime.setName(table.cell(i, 0));
+ runtime.setType(table.cell(i, 1));
+ runtimes.add(runtime);
+ }
+ return runtimes;
+ }
+
+ public void removeAllRuntimes(){
+ SWTBot bot = SWTBotFactory.getBot();
+ SWTBotTable table = bot.table();
+
+ for (int i = 0; i < table.rowCount(); i++){
+ table.click(0, 0);
+ bot.button("Remove").click();
+ KeyboardFactory.getAWTKeyboard().pressShortcut(Keystrokes.RIGHT, Keystrokes.CR,
Keystrokes.LF);
+ bot.shell("Preferences").activate();
+ }
+ }
+}
Show replies by date