[jbosstools-commits] JBoss Tools SVN: r22806 - in trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext: config/requirement and 1 other directory.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Tue Jun 15 08:05:29 EDT 2010


Author: lzoubek at redhat.com
Date: 2010-06-15 08:05:29 -0400 (Tue, 15 Jun 2010)
New Revision: 22806

Modified:
   trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java
   trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddServer.java
   trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/RemoveServer.java
   trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/StartServer.java
Log:
SWTBot extensions : fixes when server configuration changes

Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java	2010-06-15 11:40:37 UTC (rev 22805)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java	2010-06-15 12:05:29 UTC (rev 22806)
@@ -492,22 +492,63 @@
 	}
 	public void addESBRuntime(String name, String version, String runtimeHome ) {
 		SWTBot wiz = open.preferenceOpen(ActionItem.Preference.JBossToolsJBossESBRuntimes.LABEL);
-		wiz.button("Add").click();
-		bot.shell(IDELabel.Shell.NEW_ESB_RUNTIME).activate();
-		bot.text(0).setText(name);
-		bot.text(1).setText(runtimeHome);
-		String[] versions = bot.comboBox().items();
-		int myIndex =0;
-		for (int index=0;index<versions.length;index++) {
-			if (version.equals(versions[index])) {
-				myIndex=index;
-				break;
+		
+		boolean createRuntime = true;
+		// first check if Environment doesn't exist
+		SWTBotTable tbRuntimeEnvironments = bot.table();
+		int numRows = tbRuntimeEnvironments.rowCount();
+		if (numRows > 0) {
+			int currentRow = 0;
+			while (createRuntime && currentRow < numRows) {
+				if (tbRuntimeEnvironments.cell(currentRow, 1).equalsIgnoreCase(
+						name)) {
+					createRuntime = false;
+				} else {
+					currentRow++;
+				}
 			}
 		}
-		bot.comboBox().setSelection(myIndex);
-		open.finish(bot.activeShell().bot());
+		if (createRuntime) {
+			wiz.button("Add").click();
+			bot.shell(IDELabel.Shell.NEW_ESB_RUNTIME).activate();
+			bot.text(0).setText(name);
+			bot.text(1).setText(runtimeHome);
+			String[] versions = bot.comboBox().items();
+			int myIndex =0;
+			for (int index=0;index<versions.length;index++) {
+				if (version.equals(versions[index])) {
+					myIndex=index;
+					break;
+				}
+			}
+			bot.comboBox().setSelection(myIndex);
+			open.finish(bot.activeShell().bot());
+		}
 		open.finish(wiz, IDELabel.Button.OK);
 	}
+	public void removeESBRuntime(String name) {
+		SWTBot wiz = open.preferenceOpen(ActionItem.Preference.JBossToolsJBossESBRuntimes.LABEL);
+		SWTBotTable tbRuntimeEnvironments = bot.table();
+		int numRows = tbRuntimeEnvironments.rowCount();
+		if (numRows > 0) {
+			int currentRow = 0;
+			while (currentRow < numRows) {
+				if (tbRuntimeEnvironments.cell(currentRow, 1).equalsIgnoreCase(
+						name)) {
+					tbRuntimeEnvironments.click(currentRow, 1);
+					wiz.button(IDELabel.Button.REMOVE).click();
+					SWTBotShell shell = bot.shell("Confirm Runtime Delete");
+					shell.activate();
+					shell.bot().button(IDELabel.Button.OK).click();
+					log.info("ESB Runtime '" + name +"' removed.");
+					break;
+				} else {
+					currentRow++;
+				}
+			}
+		}
+		open.finish(wiz,IDELabel.Button.OK);
+	}
 	/**
 	 * adds jboss server runtime only if it's not specified yet
 	 * 

Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddServer.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddServer.java	2010-06-15 11:40:37 UTC (rev 22805)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddServer.java	2010-06-15 12:05:29 UTC (rev 22806)
@@ -38,6 +38,16 @@
 
 	@Override
 	public void handle() {
+		
+		// handle state when server is already configured, but configuration changed and another 
+		if (SWTTestExt.configuredState.getServer().isConfigured) {
+			if (SWTTestExt.configuredState.getServer().type!=TestConfigurator.currentConfig.getServer().type
+					||SWTTestExt.configuredState.getServer().version!=TestConfigurator.currentConfig.getServer().version) {
+				createStopServer().handle();
+				createRemoveServer().handle();
+			}
+		}
+		
 		ServerInfo serverInfo = getRuntime(TestConfigurator.currentConfig.getServer().type,TestConfigurator.currentConfig.getServer().version);
 		String runtimeHome=TestConfigurator.currentConfig.getServer().runtimeHome;
 		String runtimeName=TestConfigurator.currentConfig.getServer().type+"-"+TestConfigurator.currentConfig.getServer().version;
@@ -135,7 +145,9 @@
 	}
 	@Override
 	public boolean checkFulfilled() {
-		return SWTTestExt.configuredState.getServer().isConfigured;
+		return SWTTestExt.configuredState.getServer().isConfigured 
+		&& SWTTestExt.configuredState.getServer().type.equals(TestConfigurator.currentConfig.getServer().type)
+		&& SWTTestExt.configuredState.getServer().version.equals(TestConfigurator.currentConfig.getServer().version);
 	}
 
 }

Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/RemoveServer.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/RemoveServer.java	2010-06-15 11:40:37 UTC (rev 22805)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/RemoveServer.java	2010-06-15 12:05:29 UTC (rev 22806)
@@ -16,14 +16,15 @@
 
 	@Override
 	public void handle() {
-		SWTTestExt.servers.deleteServer(SWTTestExt.configuredState.getServer().name);
-		SWTTestExt.eclipse.removeServerRuntime(SWTTestExt.configuredState.getServer().name);
-		SWTTestExt.configuredState.getServer().isConfigured=false;
-		SWTTestExt.configuredState.getServer().name=null;
-		SWTTestExt.configuredState.getServer().version=null;
-		SWTTestExt.configuredState.getServer().type=null;
-		SWTTestExt.configuredState.getServer().withJavaVersion=null;
-		SWTTestExt.configuredState.getServer().bundledESBVersion=null;
+		if (!checkFulfilled()) {
+			SWTTestExt.servers.deleteServer(SWTTestExt.configuredState.getServer().name);
+			SWTTestExt.eclipse.removeServerRuntime(SWTTestExt.configuredState.getServer().name);
+			SWTTestExt.configuredState.getServer().isConfigured=false;
+			SWTTestExt.configuredState.getServer().name=null;
+			SWTTestExt.configuredState.getServer().version=null;
+			SWTTestExt.configuredState.getServer().type=null;
+			SWTTestExt.configuredState.getServer().withJavaVersion=null;
+			SWTTestExt.configuredState.getServer().bundledESBVersion=null;
+		}
 	}
-
 }

Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/StartServer.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/StartServer.java	2010-06-15 11:40:37 UTC (rev 22805)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/StartServer.java	2010-06-15 12:05:29 UTC (rev 22806)
@@ -9,7 +9,7 @@
 public class StartServer extends RequirementBase {
 
 	public StartServer() {
-		// define dependency
+		// define dependency				
 		getDependsOn().add(createAddServer());
 	}
 	
@@ -20,7 +20,7 @@
 
 	@Override
 	public void handle(){
-	  if (!SWTTestExt.configuredState.getServer().isRunning){
+	  if (!checkFulfilled()){
 	    SWTTestExt.servers.startServer(SWTTestExt.configuredState.getServer().name);
 	    SWTTestExt.configuredState.getServer().isRunning = true;
 	  }



More information about the jbosstools-commits mailing list