Author: lzoubek(a)redhat.com
Date: 2011-03-01 04:52:50 -0500 (Tue, 01 Mar 2011)
New Revision: 29403
Added:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/RemoteSystemBean.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddRemoteSystem.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/RemoveRemoteSystem.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/RemoteSystems.java
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/resources/SWTBotTest-default.properties
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/Annotations.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/ConfiguredState.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/ServerBean.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfiguration.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfigurator.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddServer.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/RequirementBase.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/StartServer.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/gen/ActionItem.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ServersView.java
Log:
swtbotext: added support for remote servers/deployment (can be now auto-configured and
forced by annotations)
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/resources/SWTBotTest-default.properties
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/resources/SWTBotTest-default.properties 2011-03-01
09:44:41 UTC (rev 29402)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/resources/SWTBotTest-default.properties 2011-03-01
09:52:50 UTC (rev 29403)
@@ -2,9 +2,12 @@
# all properties are optional, all defined paths should exist
# <java version>,<jre/jdk home>
JAVA=1.6,/opt/sun-jdk-1.6.0.19/jre
-#EAP|JBOSS_AS|EPP|SOA,<server version>,<jre version to run
with>|default,<server home>
+#EAP|JBOSS_AS|EPP|SOA,<server version>,<jre version to run
with>|default,<server home>,<optional remote system host>,<optional
remote home>
# note : when server is type of SOA, version is version of SOA (not the bundled EAP)
SERVER=EAP,5.0,1.6,/data/jboss/jboss-eap-5.0/jboss-as
+#SERVER=EAP,5.0,1.6,/data/jboss/jboss-eap-5.0/jboss-as,remote.example.com,/opt/jboss-eap-5.0/jboss-as
+# remote system= <user>,<host>,<private key>
+#RS=lzoubek,remote.example.com,/home/lzoubek/.ssh/id_rsa
#<seam version>,<seam runtime home>
SEAM=2.2,/data/jboss/jboss-eap-5.0/seam
#<esb versoin>,<esb runtime home>
@@ -19,4 +22,4 @@
#DB=hsqldb18,1.8,/home/username/lib/hsqldb/lib/hsqldb.jar,jdbc:hsqldb:hsql://localhost:8001/xdb,sa,,
#Connection profile named <db_type>_<version> will be created
#Annotation usage for TestCase db=@DB
-DB=hsqldb18,internal,driver,jdbc,user,,
\ No newline at end of file
+DB=hsqldb18,internal,driver,jdbc,user,,
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java 2011-03-01
09:44:41 UTC (rev 29402)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java 2011-03-01
09:52:50 UTC (rev 29403)
@@ -19,6 +19,7 @@
import static org.junit.Assert.fail;
import java.io.File;
+import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -33,6 +34,7 @@
import org.eclipse.swtbot.eclipse.finder.waits.Conditions;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
@@ -49,7 +51,11 @@
import org.jboss.tools.ui.bot.ext.entity.JavaClassEntity;
import org.jboss.tools.ui.bot.ext.entity.JavaProjectEntity;
import org.jboss.tools.ui.bot.ext.gen.ActionItem;
+import org.jboss.tools.ui.bot.ext.gen.ActionItem.NewObject;
import org.jboss.tools.ui.bot.ext.gen.ActionItem.NewObject.ServerServer;
+import org.jboss.tools.ui.bot.ext.gen.ActionItem.Preference;
+import org.jboss.tools.ui.bot.ext.gen.ActionItem.View;
+import org.jboss.tools.ui.bot.ext.gen.INewObject;
import org.jboss.tools.ui.bot.ext.gen.IServer;
import org.jboss.tools.ui.bot.ext.gen.IServerRuntime;
import org.jboss.tools.ui.bot.ext.types.EntityType;
@@ -58,6 +64,7 @@
import org.jboss.tools.ui.bot.ext.types.PerspectiveType;
import org.jboss.tools.ui.bot.ext.types.ViewType;
import org.jboss.tools.ui.bot.ext.view.ProjectExplorer;
+import org.jboss.tools.ui.bot.ext.view.RemoteSystems;
/**
* Provides Eclipse common operation based on SWTBot element operations
@@ -485,10 +492,28 @@
* @param serverName
*/
public void addServer(IServer server, String serverName) {
+ addServer(server, serverName, null,null);
+ }
+ /**
+ * adds server (Server runtime must be defined, the default selected runtime
+ * is used)
+ *
+ * @param server
+ * to add ( for example
+ * {@link ActionItem.Server.JBossCommunityJBossAS50#LABEL} class)
+ * @param serverName
+ */
+ public void addServer(IServer server, String serverName, String remoteSystem,String
remoteHome) {
log.info("Adding server: " + serverName);
SWTBot wiz = open.newObject(ActionItem.NewObject.ServerServer.LABEL);
open.selectTreeNode(server);
wiz.textWithLabel(ServerServer.TEXT_SERVER_NAME).setText(serverName);
+ wiz.button(IDELabel.Button.NEXT).click();
+ if (remoteSystem!=null && remoteHome!=null) {
+ wiz.comboBoxInGroup("Server Behaviour", 0).setSelection("Remote System
Deployment");
+ wiz.comboBoxWithLabel("Host").setSelection(remoteSystem);
+ wiz.textInGroup("Server Behaviour", 0).setText(remoteHome);
+ }
open.finish(wiz);
}
/**
@@ -680,8 +705,53 @@
props.put(IDELabel.JBossServerRuntimeDialog.NAME, name);
addServerRuntime(runtime, props, jreToUse);
}
-
/**
+ * adds remote system to RSE, does not verify hostname
+ * @param connectionName
+ * @param hostname
+ */
+ public void addRemoteSystem(String connectionName, String hostname) {
+ log.info(String.format("Adding remote system connection name=%s
hostname=%s",connectionName,hostname));
+ RemoteSystems remote = new RemoteSystems();
+ if (remote.existsConnection(connectionName)) {
+ log.warn(String.format("Connection called '%' already exits,
skipping",connectionName));
+ return;
+ }
+ SWTBot wiz = open.newObject(NewObject.create("Remote System
Explorer","Connection"));
+ open.selectTreeNode(ActionItem.create("General","SSH Only"));
+ wiz.button(IDELabel.Button.NEXT).click();
+ wiz.textWithLabel("Connection name:").setText(connectionName);
+ wiz.comboBoxWithLabel("Host name:").setText(hostname);
+ wiz.checkBox("Verify host name").deselect();
+ open.finish(wiz);
+ log.info("Connection was added");
+ }
+ /**
+ * adds path to private key into SSH2 Preference page
+ * @param pathToKey
+ */
+ public void setSSHKey(String pathToKey) {
+ SWTBot wiz = open.preferenceOpen(Preference.create("General","Network
Connections","SSH2"));
+ wiz.tabItem("General").activate();
+ wiz.textWithLabel("Private keys:").setText(pathToKey);
+ open.finish(wiz, IDELabel.Button.OK);
+ }
+ public void removeRemoteSystem(String connectionName) {
+ log.info(String.format("Removing remote system connection
name=%s",connectionName));
+ RemoteSystems remote = new RemoteSystems();
+ if (remote.existsConnection(connectionName)) {
+ log.warn(String.format("Connection called '%' does not
exist!",connectionName));
+ return;
+ }
+ remote.bot().tree().select(connectionName);
+ if (!remote.bot().tree().contextMenu(IDELabel.Menu.DELETE).isEnabled()) {
+ remote.bot().tree().contextMenu("Disconnect").click();
+ }
+ remote.bot().tree().contextMenu(IDELabel.Menu.DELETE).click();
+ open.finish(bot.shell("Delete Confirmation").bot(), true);
+ log.info("Connection was removed");
+ }
+ /**
* adds server runtime only if it's not specified yet
*
* @param runtime type of runtime
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/Annotations.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/Annotations.java 2011-03-01
09:44:41 UTC (rev 29402)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/Annotations.java 2011-03-01
09:52:50 UTC (rev 29403)
@@ -5,8 +5,10 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import org.jboss.tools.ui.bot.ext.SWTTestExt;
+
public class Annotations {
/**
* annotation which defines requirement of whole test Class
@@ -16,8 +18,12 @@
* <li>{@link SWTBotTestRequires#clearProjects()}</li>
* <li>{@link SWTBotTestRequires#clearWorkspace()}</li>
* <li>{@link SWTBotTestRequires#perspective()}</li>
+ * <li>{@link SWTBotTestRequires#runOnce()}</li>
* <li>{@link Server}</li>
* <li>{@link Seam}</li>
+ * <li>{@link ESB}</li>
+ * <li>{@link DB}</li>
+ * <li>{@link JBPM}</li>
* </ul>
* @author lzoubek
*
@@ -50,17 +56,17 @@
*/
String perspective() default "";
/**
- * my default workspace is cleaned before test (attempt to close all shells and
editors, closes 'Welcome' view),
+ * workspace is cleaned before test class is run (attempt to close all shells and
editors, closes 'Welcome' view),
* setting this to false will disable this feature
* @return
*/
+ boolean clearWorkspace() default true;
/**
* optionally require Database
* @return
*/
DB db() default @DB (required = false);
- boolean clearWorkspace() default true;
/**
* by default all projects are undeployed from pre-configured server & deleted
before test runs
* setting this to false will disable this feature
@@ -77,7 +83,9 @@
boolean runOnce() default false;
}
/**
- * Server requirement, by default matches all server types and versions
+ * Server requirement, by default matches all server types and versions,
+ * if you enable this requirement, you get server running before your test class
+ * runs. Server name,type and version can be retrieved via {@link
SWTTestExt#configuredState}
* @author lzoubek
*
*/
@@ -89,16 +97,21 @@
*/
boolean required() default true;
/**
- * state (default Running)
+ * state (default (default {@link ServerState#ALL}))
* @return
*/
ServerState state() default ServerState.Running;
/**
- * server type to match (Default ALL)
+ * server type to match (default {@link ServerType#ALL})
* @return
*/
ServerType type() default ServerType.ALL;
/**
+ * server location (derfault {@link ServerLocation#Any})
+ * @return
+ */
+ ServerLocation location() default ServerLocation.Any;
+ /**
* version of required server (use * for all versions) default *
* @return
*/
@@ -110,7 +123,8 @@
String operator() default "=";
}
/**
- *
+ * Seam runtime requirement, by default matches all versions, if enabled seam runtime
will
+ * be configured in workspace before test class runs. Runtime details can be referenced
from {@link SWTTestExt#configuredState}
* @author lzoubek(a)redhat.com
*
*/
@@ -196,7 +210,6 @@
*/
String operator() default "=";
}
-
public enum ServerState {
/**
* server is present, no matter if runs or not
@@ -215,6 +228,20 @@
*/
Disabled
}
+ public enum ServerLocation {
+ /**
+ * no matter where is server located (default)
+ */
+ Any,
+ /**
+ * server is required to be local
+ */
+ Local,
+ /**
+ * server is running on remote host
+ */
+ Remote,
+ }
public enum ServerType {
/**
* SOA platform (includes EAP)
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/ConfiguredState.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/ConfiguredState.java 2011-03-01
09:44:41 UTC (rev 29402)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/ConfiguredState.java 2011-03-01
09:52:50 UTC (rev 29403)
@@ -7,10 +7,8 @@
/**
* this class represents state of running test suite. Properties of this object
- * should be changed only by classed extending {@link RequirementBase} class.
- *
+ * should be changed only by classes extending {@link RequirementBase} class.
* @author lzoubek(a)redhat.com
- *
*/
public class ConfiguredState {
private List<String> jreList = new Vector<String>();
@@ -19,7 +17,8 @@
private ESB esb = new ESB();
private JBPM jbpm = new JBPM();
private DB db = new DB();
-
+ private RemoteSystem remoteSystem = new RemoteSystem();
+
private boolean viewsPrepared = false;
public boolean isViewsPrepared() {
@@ -79,7 +78,18 @@
public DB getDB() {
return db;
}
-
+ /**
+ * gets configured remote host
+ * @return
+ */
+ public RemoteSystem getRemoteSystem() {
+ return remoteSystem;
+ }
+ /**
+ * represents current server configuration
+ * @author lzoubek
+ *
+ */
public class Server {
/**
* is server runtime & server added?
@@ -110,7 +120,26 @@
* version of bundled ESB (applicable only for server type SOA)
*/
public String bundledESBVersion=null;
+ /**
+ * is server local? if no see {@link RemoteSystem}
+ */
+ public boolean isLocal = true;
+
}
+ public class RemoteSystem {
+ /**
+ * is configured?
+ */
+ public boolean isConfigured = false;
+ /**
+ * server's hostname
+ */
+ public String remoteHost = null;
+ /**
+ * server's remote username
+ */
+ public String remoteUser = null;
+ }
public class Seam {
/**
Added:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/RemoteSystemBean.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/RemoteSystemBean.java
(rev 0)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/RemoteSystemBean.java 2011-03-01
09:52:50 UTC (rev 29403)
@@ -0,0 +1,28 @@
+package org.jboss.tools.ui.bot.ext.config;
+
+public class RemoteSystemBean {
+ public String user;
+ public String host;
+ public String key;
+ public static RemoteSystemBean fromString(String propValue) throws Exception {
+ try {
+ if (propValue == null) {
+ return null;
+ }
+ String[] rsParams = propValue.split(",");
+ RemoteSystemBean bean = new RemoteSystemBean();
+ bean.user = rsParams[0];
+ bean.host = rsParams[1];
+ bean.key = rsParams[2];
+ return bean;
+ } catch (Exception ex) {
+ throw new Exception("Cannot parse RS property line="+propValue, ex);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return String.format("Remote System user=%s, host=%s, key=%s",
+ this.user, this.host, this.key);
+ }
+}
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/ServerBean.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/ServerBean.java 2011-03-01
09:44:41 UTC (rev 29402)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/ServerBean.java 2011-03-01
09:52:50 UTC (rev 29403)
@@ -1,5 +1,7 @@
package org.jboss.tools.ui.bot.ext.config;
+import java.util.Arrays;
+
/**
*
* @author lzoubek
@@ -11,8 +13,15 @@
public String runtimeHome;
public String withJavaVersion;
public String type;
-
/**
+ * name of remote system for this server, if null, server is local
+ */
+ public String remoteSystem;
+ /**
+ * home of app server located in remote system
+ */
+ public String remoteHome;
+ /**
* creates bean instance from property string
* @param propValue property value
* @return
@@ -29,6 +38,11 @@
bean.runtimeHome=serverParams[3];
bean.version=serverParams[1];
bean.type = serverParams[0];
+
+ if (serverParams.length>4) {
+ bean.remoteSystem=serverParams[4];
+ bean.remoteHome=serverParams[5];
+ }
return bean;
}
catch (Exception ex) {
@@ -37,7 +51,7 @@
}
@Override
public String toString() {
- return String.format("Server type=%s,version=%s,home=%s,withJava=%s",
this.type,this.version,this.runtimeHome,this.withJavaVersion);
+ return String.format("Server
type=%s,version=%s,home=%s,withJava=%s,remoteSystem=%s",
this.type,this.version,this.runtimeHome,this.withJavaVersion,this.remoteSystem);
}
/**
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfiguration.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfiguration.java 2011-03-01
09:44:41 UTC (rev 29402)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfiguration.java 2011-03-01
09:52:50 UTC (rev 29403)
@@ -8,7 +8,7 @@
import org.apache.log4j.Logger;
import org.jboss.tools.ui.bot.ext.Activator;
-import org.jboss.tools.ui.bot.ext.SWTTestExt;
+import org.jboss.tools.ui.bot.ext.SWTUtilExt;
import org.jboss.tools.ui.bot.ext.config.TestConfigurator.Keys;
import org.jboss.tools.ui.bot.ext.config.TestConfigurator.Values;
@@ -30,7 +30,8 @@
private JavaBean java;
private JBPMBean jbpm;
private DBBean db;
-
+ private RemoteSystemBean remoteSystem;
+
public TestConfiguration(String propName, String propFile) throws Exception {
this.propName = propName;
this.propFile = propFile;
@@ -44,15 +45,18 @@
} else {
log.info("Loading default configuration");
- swtTestProperties.load(new FileInputStream(SWTTestExt.util
+ swtTestProperties.load(new FileInputStream(SWTUtilExt
.getResourceFile(Activator.PLUGIN_ID,
"/SWTBotTest-default.properties")));
}
// properties got loaded
java = JavaBean.fromString(getProperty(Keys.JAVA));
printConfig(Keys.JAVA, java);
+ log.info(getProperty(Keys.SERVER));
server = ServerBean.fromString(getProperty(Keys.SERVER));
printConfig(Keys.SERVER, server);
+ remoteSystem = RemoteSystemBean.fromString(getProperty(Keys.RS));
+ printConfig(Keys.RS, remoteSystem);
seam = SeamBean.fromString(getProperty(Keys.SEAM));
printConfig(Keys.SEAM, seam);
esb = ESBBean.fromString(getProperty(Keys.ESB));
@@ -60,6 +64,7 @@
jbpm = JBPMBean.fromString(getProperty(Keys.JBPM));
printConfig(Keys.JBPM, jbpm);
db = DBBean.fromString(getProperty(Keys.DB));
+ printConfig(Keys.DB,db);
checkConfig();
}
@@ -111,8 +116,27 @@
+ java.version);
}
}
+
+ if (server!=null) {
+ if (server.remoteSystem!=null) {
+ if (remoteSystem!=null) {
+ if (!server.remoteSystem.equals(remoteSystem.host)) {
+ throw new Exception("Server is configured with remote system called "
+ + server.remoteSystem
+ +" but RS is configured as "
+ + remoteSystem.host
+ +" these names must be equal");
+ }
+ }
+ else {
+ throw new Exception(
+ "Server is configured to run with remote system "
+ + server.remoteSystem
+ + " but no RS is configured");
+ }
+ }
+ }
return true;
-
}
private static void checkDirExists(String dir) throws FileNotFoundException {
@@ -159,4 +183,7 @@
public DBBean getDB() {
return db;
}
+ public RemoteSystemBean getRemoteSystem() {
+ return remoteSystem;
+ }
}
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfigurator.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfigurator.java 2011-03-01
09:44:41 UTC (rev 29402)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfigurator.java 2011-03-01
09:52:50 UTC (rev 29403)
@@ -17,6 +17,7 @@
import org.jboss.tools.ui.bot.ext.config.Annotations.SWTBotTestRequires;
import org.jboss.tools.ui.bot.ext.config.Annotations.Seam;
import org.jboss.tools.ui.bot.ext.config.Annotations.Server;
+import org.jboss.tools.ui.bot.ext.config.Annotations.ServerLocation;
import org.jboss.tools.ui.bot.ext.config.Annotations.ServerState;
import org.jboss.tools.ui.bot.ext.config.Annotations.ServerType;
import org.jboss.tools.ui.bot.ext.config.requirement.RequirementBase;
@@ -31,6 +32,7 @@
public static final String ESB = "ESB";
public static final String JBPM = "JBPM";
public static final String DB = "DB";
+ public static final String RS = "RS";
}
public class Values {
@@ -165,22 +167,37 @@
return null;
}
}
+ if (s.location().equals(ServerLocation.Local) &&
currentConfig.getServer().remoteSystem!=null) {
+ return null;
+ }
+ if (s.location().equals(ServerLocation.Remote) &&
currentConfig.getServer().remoteSystem==null) {
+ return null;
+ }
if (!matches(currentConfig.getServer().version, s.operator(),
s.version())) {
return null;
}
- if (ServerState.Disabled.equals(s.state())) {
- RequirementBase removeServer = RequirementBase.createRemoveServer();
- removeServer.getDependsOn().add(RequirementBase.createStopServer());
- return removeServer;
- } else if (ServerState.NotRunning.equals(s.state())) {
- RequirementBase stopServer = RequirementBase.createStopServer();
- stopServer.getDependsOn().add(RequirementBase.createAddServer());
- return stopServer;
- } else if (ServerState.Present.equals(s.state())) {
- return RequirementBase.createAddServer();
- }
- return RequirementBase.createStartServer();
+ RequirementBase serverReq = null;
+ switch (s.state()) {
+ case Disabled: {
+ serverReq = RequirementBase.createRemoveServer();
+ serverReq.getDependsOn().add(RequirementBase.createStopServer());
+ break;
+ }
+ case NotRunning: {
+ serverReq = RequirementBase.createStopServer();
+ serverReq.getDependsOn().add(RequirementBase.createAddServer());
+ break;
+ }
+ case Present:{
+ serverReq = RequirementBase.createAddServer();
+ break;
+ }
+ default:
+ serverReq = RequirementBase.createStartServer();
+ break;
+ }
+ return serverReq;
}
/**
Added:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddRemoteSystem.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddRemoteSystem.java
(rev 0)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddRemoteSystem.java 2011-03-01
09:52:50 UTC (rev 29403)
@@ -0,0 +1,24 @@
+package org.jboss.tools.ui.bot.ext.config.requirement;
+
+import org.jboss.tools.ui.bot.ext.SWTTestExt;
+import org.jboss.tools.ui.bot.ext.config.TestConfigurator;
+
+public class AddRemoteSystem extends RequirementBase {
+
+ @Override
+ public boolean checkFulfilled() {
+ return SWTTestExt.configuredState.getRemoteSystem().isConfigured &&
+ SWTTestExt.configuredState.getRemoteSystem().remoteHost.equals(TestConfigurator.currentConfig.getServer().remoteSystem);
+ }
+
+ @Override
+ public void handle() {
+ SWTTestExt.eclipse.setSSHKey(TestConfigurator.currentConfig.getRemoteSystem().key);
+ String hostname = TestConfigurator.currentConfig.getRemoteSystem().host;
+ SWTTestExt.eclipse.addRemoteSystem(hostname, hostname);
+ SWTTestExt.configuredState.getRemoteSystem().isConfigured=true;
+ SWTTestExt.configuredState.getRemoteSystem().remoteHost=hostname;
+ SWTTestExt.configuredState.getRemoteSystem().remoteUser =
TestConfigurator.currentConfig.getRemoteSystem().user;
+ }
+
+}
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddServer.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddServer.java 2011-03-01
09:44:41 UTC (rev 29402)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddServer.java 2011-03-01
09:52:50 UTC (rev 29403)
@@ -33,6 +33,9 @@
getDependsOn().add(addJava);
javaName=addJava.getAddedAsName();
}
+ if (TestConfigurator.currentConfig.getServer().remoteSystem!=null) {
+ getDependsOn().add(createAddRemoteSystem());
+ }
}
@@ -53,7 +56,10 @@
String
runtimeName=TestConfigurator.currentConfig.getServer().type+"-"+TestConfigurator.currentConfig.getServer().version;
SWTTestExt.eclipse.addJbossServerRuntime(serverInfo.runtime,
runtimeHome, runtimeName, javaName);
- SWTTestExt.eclipse.addServer(serverInfo.server, runtimeName);
+ String remoteSystem = TestConfigurator.currentConfig.getServer().remoteSystem;
+ String remoteHome = TestConfigurator.currentConfig.getServer().remoteHome;
+ SWTTestExt.eclipse.addServer(serverInfo.server, runtimeName,remoteSystem,remoteHome);
+ SWTTestExt.configuredState.getServer().isLocal = remoteSystem==null;
SWTTestExt.configuredState.getServer().isConfigured=true;
SWTTestExt.configuredState.getServer().name=runtimeName;
SWTTestExt.configuredState.getServer().version=TestConfigurator.currentConfig.getServer().version;
Added:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/RemoveRemoteSystem.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/RemoveRemoteSystem.java
(rev 0)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/RemoveRemoteSystem.java 2011-03-01
09:52:50 UTC (rev 29403)
@@ -0,0 +1,20 @@
+package org.jboss.tools.ui.bot.ext.config.requirement;
+
+import org.jboss.tools.ui.bot.ext.SWTTestExt;
+import org.jboss.tools.ui.bot.ext.view.RemoteSystems;
+
+public class RemoveRemoteSystem extends RequirementBase {
+
+ @Override
+ public boolean checkFulfilled() {
+ return !SWTTestExt.configuredState.getRemoteSystem().isConfigured;
+ }
+
+ @Override
+ public void handle() {
+ String connection = SWTTestExt.configuredState.getRemoteSystem().remoteHost;
+ String user = SWTTestExt.configuredState.getRemoteSystem().remoteUser;
+ SWTTestExt.eclipse.removeRemoteSystem(connection);
+ }
+
+}
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/RequirementBase.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/RequirementBase.java 2011-03-01
09:44:41 UTC (rev 29402)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/RequirementBase.java 2011-03-01
09:52:50 UTC (rev 29403)
@@ -162,7 +162,15 @@
RequirementBase req = new RemoveServer();
return req;
}
-
+ public static RequirementBase createAddRemoteSystem() {
+ RequirementBase req = new AddRemoteSystem();
+ return req;
+ }
+
+ public static RequirementBase createRemoveRemoteSystem() {
+ RequirementBase req = new RemoveRemoteSystem();
+ return req;
+ }
public static RequirementBase prepareDB () {
RequirementBase req = new PrepareDB();
return req;
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/StartServer.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/StartServer.java 2011-03-01
09:44:41 UTC (rev 29402)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/StartServer.java 2011-03-01
09:52:50 UTC (rev 29403)
@@ -21,8 +21,10 @@
@Override
public void handle(){
if (!checkFulfilled()){
- SWTTestExt.servers.startServer(SWTTestExt.configuredState.getServer().name);
- SWTTestExt.configuredState.getServer().isRunning = true;
+ String server = SWTTestExt.configuredState.getServer().name;
+ String user = SWTTestExt.configuredState.getRemoteSystem().remoteUser;
+ SWTTestExt.servers.startServer(server,user,null);
+ SWTTestExt.configuredState.getServer().isRunning = true;
}
}
}
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/gen/ActionItem.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/gen/ActionItem.java 2011-03-01
09:44:41 UTC (rev 29402)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/gen/ActionItem.java 2011-03-01
09:52:50 UTC (rev 29403)
@@ -49,6 +49,34 @@
};
}
public static class View {
+ /**
+ * creates new action item instance from given path
+ * @param path
+ * @return
+ */
+ public static IView create(final String...path) {
+ if (path.length<1) {
+ throw new IllegalArgumentException("path must contain at least 1 item");
+ }
+ return new IView() {
+
+ @Override
+ public String getName() {
+ // TODO Auto-generated method stub
+ return path[path.length-1];
+ }
+
+ @Override
+ public List<String> getGroupPath() {
+ List<String> l = new Vector<String>();
+ for (int i=0; i<path.length-1;i++) {
+ l.add(path[i]);
+ }
+ return l;
+ }
+
+ };
+ }
public static class JavaBrowsingTypes {
/**
* represents item : Java Browsing->Types
@@ -2046,6 +2074,34 @@
}
public static class NewObject {
+ /**
+ * creates new action item instance from given path
+ * @param path
+ * @return
+ */
+ public static INewObject create(final String...path) {
+ if (path.length<1) {
+ throw new IllegalArgumentException("path must contain at least 1 item");
+ }
+ return new INewObject() {
+
+ @Override
+ public String getName() {
+ // TODO Auto-generated method stub
+ return path[path.length-1];
+ }
+
+ @Override
+ public List<String> getGroupPath() {
+ List<String> l = new Vector<String>();
+ for (int i=0; i<path.length-1;i++) {
+ l.add(path[i]);
+ }
+ return l;
+ }
+
+ };
+ }
public static class CVSProjectsfromCVS {
/**
* represents item : CVS->Projects from CVS
@@ -7394,6 +7450,34 @@
}
public static class Preference {
+ /**
+ * creates new action item instance from given path
+ * @param path
+ * @return
+ */
+ public static IPreference create(final String...path) {
+ if (path.length<1) {
+ throw new IllegalArgumentException("path must contain at least 1 item");
+ }
+ return new IPreference() {
+
+ @Override
+ public String getName() {
+ // TODO Auto-generated method stub
+ return path[path.length-1];
+ }
+
+ @Override
+ public List<String> getGroupPath() {
+ List<String> l = new Vector<String>();
+ for (int i=0; i<path.length-1;i++) {
+ l.add(path[i]);
+ }
+ return l;
+ }
+
+ };
+ }
public static class RunDebugViewManagement {
/**
* represents item : Run/Debug->View Management
Added:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/RemoteSystems.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/RemoteSystems.java
(rev 0)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/RemoteSystems.java 2011-03-01
09:52:50 UTC (rev 29403)
@@ -0,0 +1,52 @@
+package org.jboss.tools.ui.bot.ext.view;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.ui.bot.ext.gen.ActionItem.View;
+import org.jboss.tools.ui.bot.ext.types.IDELabel;
+
+public class RemoteSystems extends ViewBase {
+ Logger log = Logger.getLogger(RemoteSystems.class);
+
+ public RemoteSystems() {
+ viewObject = View.create("Remote Systems","Remote Systems");
+ }
+ public boolean existsConnection(String name) {
+ try {
+ bot().tree().getTreeItem(name);
+ return true;
+ }
+ catch (WidgetNotFoundException e) {
+ return false;
+ }
+ }
+ public List<String> getConnections() {
+ List<String> list = new ArrayList<String>();
+ for (SWTBotTreeItem item : bot().tree().getAllItems()) {
+ list.add(item.getText());
+ }
+ return list;
+ }
+ public void connect(String connection,String username, String password) {
+ bot().tree().getTreeItem(connection).select();
+ bot().tree().contextMenu("Connect").click();
+ SWTBot shell = bot.shell("Enter password").bot();
+ if (username!=null)
+ shell.textWithLabel("User ID:").setText(username);
+ if (password!=null)
+ shell.textWithLabel("Password (optional):").setText(password);
+ shell.button(IDELabel.Button.OK).click();
+ util.waitForNonIgnoredJobs();
+ }
+ public void disconnect(String connection) {
+
+ }
+ public void delete(String connection) {
+
+ }
+}
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 2011-03-01
09:44:41 UTC (rev 29402)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ServersView.java 2011-03-01
09:52:50 UTC (rev 29403)
@@ -90,6 +90,15 @@
* @param serverName
*/
public void startServer(String serverName) {
+ startServer(serverName, null, null);
+ }
+ /**
+ * start server with given name, username and password are used in case server is remote
type
+ * @param serverName
+ * @param username remote user, can be null (server is then treated as local)
+ * @param password should be null when SSH keys are properly set
+ */
+ public void startServer(String serverName, String username, String password) {
show();
SWTBot bot = show().bot();
SWTBotTree tree = bot.tree();
@@ -97,6 +106,18 @@
if (server!=null) {
ContextMenuHelper.prepareTreeItemForContextMenu(tree, server);
new SWTBotMenu(ContextMenuHelper.getContextMenu(tree, IDELabel.Menu.START,
false)).click();
+ if (username!=null) {
+ try {
+ SWTBot shell = bot.shell("Enter Password").bot();
+ shell.textWithLabel("User ID:").setText(username);
+ if (password!=null)
+ shell.textWithLabel("Password (optional):").setText(password);
+ shell.button(IDELabel.Button.OK).click();
+ }
+ catch (Exception ex){
+ log.error(ex);
+ }
+ }
util.waitForNonIgnoredJobs(Timing.time100S());
util.waitForAll(Timing.time3S());
}
@@ -105,7 +126,6 @@
"\nThis server is not defined within Servers view");
}
}
-
public SWTBotTreeItem findServerByName(SWTBotTree tree, String name) {
for (SWTBotTreeItem i : tree.getAllItems()) {