[jbosstools-commits] JBoss Tools SVN: r41965 - in trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext: view and 1 other directory.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Thu Jun 14 07:41:07 EDT 2012
Author: ljelinko
Date: 2012-06-14 07:41:06 -0400 (Thu, 14 Jun 2012)
New Revision: 41965
Added:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/entity/XMLConfiguration.java
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ServersView.java
Log:
Added new methods to ServersView
Copied: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/entity/XMLConfiguration.java (from rev 41882, trunk/as/tests/org.jboss.ide.eclipse.as.ui.bot.test/src/org/jboss/ide/eclipse/as/ui/bot/test/entity/XMLConfiguration.java)
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/entity/XMLConfiguration.java (rev 0)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/entity/XMLConfiguration.java 2012-06-14 11:41:06 UTC (rev 41965)
@@ -0,0 +1,70 @@
+package org.jboss.tools.ui.bot.ext.entity;
+
+public class XMLConfiguration {
+
+ private String key;
+
+ private String value;
+
+ public XMLConfiguration() {
+ // default
+ }
+
+ public XMLConfiguration(String key, String value) {
+ super();
+ this.key = key;
+ this.value = value;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ return getKey() + "=" + getValue();
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((key == null) ? 0 : key.hashCode());
+ result = prime * result + ((value == null) ? 0 : value.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ XMLConfiguration other = (XMLConfiguration) obj;
+ if (key == null) {
+ if (other.key != null)
+ return false;
+ } else if (!key.equals(other.key))
+ return false;
+ if (value == null) {
+ if (other.value != null)
+ return false;
+ } else if (!value.equals(other.value))
+ return false;
+ return true;
+ }
+}
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ServersView.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ServersView.java 2012-06-14 11:40:41 UTC (rev 41964)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ServersView.java 2012-06-14 11:41:06 UTC (rev 41965)
@@ -1,5 +1,8 @@
package org.jboss.tools.ui.bot.ext.view;
+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;
@@ -8,10 +11,12 @@
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.ui.bot.ext.SWTBotFactory;
import org.jboss.tools.ui.bot.ext.SWTTestExt;
import org.jboss.tools.ui.bot.ext.Timing;
import org.jboss.tools.ui.bot.ext.condition.NonSystemJobRunsCondition;
import org.jboss.tools.ui.bot.ext.condition.TaskDuration;
+import org.jboss.tools.ui.bot.ext.entity.XMLConfiguration;
import org.jboss.tools.ui.bot.ext.gen.ActionItem.View.ServerServers;
import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
@@ -100,19 +105,19 @@
ContextMenuHelper.prepareTreeItemForContextMenu(tree, server);
new SWTBotMenu(ContextMenuHelper.getContextMenu(tree, "Restart", false)).click();
handleServerAlreadyRunning(bot);
-
+
bot.waitWhile(new NonSystemJobRunsCondition(), TaskDuration.VERY_LONG.getTimeout());
bot.waitUntil(new ICondition() {
-
+
@Override
public boolean test() throws Exception {
return "Started".equals(getServerStatus(serverName));
}
-
+
@Override
public void init(SWTBot bot) {
}
-
+
@Override
public String getFailureMessage() {
return "The server does not have status 'Started'";
@@ -179,10 +184,16 @@
}
return null;
}
-
+
+ public SWTBotTreeItem findServerByName(String name) {
+
+ SWTBot bot = show().bot();
+ return findServerByName(bot.tree(), name);
+ }
+
public boolean serverExists(String serverName){
SWTBot bot = show().bot();
-
+
try {
// if there are no servers the following text appears
bot.link("No servers available. Define a new server from the <a>new server wizard</a>...");
@@ -190,21 +201,57 @@
} catch (WidgetNotFoundException e){
// ok, there are some servers, let's check the name
}
-
+
SWTBotTreeItem server = findServerByName(bot.tree(), serverName);
return server != null;
}
-
+
public String getServerStatus(String serverName){
SWTBot bot = show().bot();
SWTBotTreeItem server = findServerByName(bot.tree(), serverName);
-
+
String label = server.getText();
int startIndex = label.indexOf('[') + 1;
int endIndex = label.indexOf(',');
return label.substring(startIndex, endIndex);
}
+ public String getServerPublishStatus(String serverName){
+ SWTBot bot = show().bot();
+ SWTBotTreeItem server = findServerByName(bot.tree(), serverName);
+
+ String label = server.getText();
+ int startIndex = label.indexOf(',') + 2;
+ int endIndex = label.indexOf(']');
+ return label.substring(startIndex, endIndex);
+ }
+
+ public boolean containsProject(String serverName, String project){
+ SWTBot bot = show().bot();
+ SWTBotTreeItem server = findServerByName(bot.tree(), serverName);
+ server.expand();
+
+ try {
+ getProjectNode(server, project);
+ return true;
+ } catch (WidgetNotFoundException e){
+ return false;
+ }
+ }
+
+ private SWTBotTreeItem getProjectNode(SWTBotTreeItem server, String projectName){
+ for (SWTBotTreeItem child : server.getItems()){
+ String name = child.getText();
+ if (name.contains("[")){
+ name = name.substring(0, name.indexOf("["));
+ }
+ if (name.trim().equals(projectName)){
+ return child;
+ }
+ }
+ throw new WidgetNotFoundException("Project " + projectName + " was not found within server");
+ }
+
/**
* removes project with given name from all servers
* @param projectName
@@ -249,4 +296,84 @@
}
+ public void addProjectToServer(String projectName, String serverName){
+ SWTBot bot = show().bot();
+ SWTBotTree serversTree = bot.tree();
+ SWTBotTreeItem server = findServerByName(serversTree, serverName);
+
+ ContextMenuHelper.prepareTreeItemForContextMenu(serversTree,server);
+ new SWTBotMenu(ContextMenuHelper.getContextMenu(serversTree, IDELabel.Menu.ADD_AND_REMOVE, false)).click();
+
+ SWTBot shellBot = bot.shell("Add and Remove...").bot();
+
+ shellBot.tree(0).getTreeItem(projectName).select();
+ shellBot.button("Add >").click();
+ shellBot.button("Finish").click();
+ shellBot.waitWhile(new NonSystemJobRunsCondition(), TaskDuration.VERY_LONG.getTimeout());
+ }
+
+ public void openServerEditor(String serverName){
+ SWTBot bot = show().bot();
+ SWTBotTreeItem server = findServerByName(bot.tree(), serverName);
+ server.doubleClick();
+ }
+
+ public void openWebPage(String serverName){
+ SWTBot bot = show().bot();
+ SWTBotTree serversTree = bot.tree();
+ SWTBotTreeItem server = findServerByName(serversTree, serverName);
+
+ server.contextMenu("Web Browser").click();
+ }
+
+ public void openWebPage(String serverName, String projectName){
+ SWTBot bot = show().bot();
+ SWTBotTree serversTree = bot.tree();
+ SWTBotTreeItem server = findServerByName(serversTree, serverName);
+ SWTBotTreeItem project = getProjectNode(server, projectName);
+ project.contextMenu("Web Browser").click();
+ }
+
+ public List<XMLConfiguration> getXMLConfiguration(String serverName, String categoryName){
+ SWTBotTreeItem server = findServerByName(serverName);
+ server.expand();
+ final SWTBotTreeItem category = server.expandNode("XML Configuration", categoryName);
+
+ String separator = " ";
+ SWTBotFactory.getBot().waitUntil(new TreeItemLabelDecorated(category.getNode(0), separator));
+
+ List<XMLConfiguration> configurations = new ArrayList<XMLConfiguration>();
+ for (final SWTBotTreeItem item : category.getItems()){
+ String[] columns = item.getText().split(separator);
+ configurations.add(new XMLConfiguration(columns[0].trim(), columns[1].trim()));
+ }
+ return configurations;
+ }
+
+ private static class TreeItemLabelDecorated implements ICondition {
+
+ private String separator;
+
+ private SWTBotTreeItem item;
+
+ public TreeItemLabelDecorated(SWTBotTreeItem item, String separator) {
+ super();
+ this.item = item;
+ this.separator = separator;
+ }
+
+ @Override
+ public void init(SWTBot bot) {
+ }
+
+ @Override
+ public boolean test() throws Exception {
+ return item.getText().contains(separator);
+ }
+
+ @Override
+ public String getFailureMessage() {
+ return "Expected the tree item to be decorated with separator '" + separator + "'";
+ }
+ }
}
More information about the jbosstools-commits
mailing list