[jbosstools-commits] JBoss Tools SVN: r22785 - in trunk/jst/tests/org.jboss.tools.ui.bot.ext: src/org/jboss/tools/ui/bot/ext and 3 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Mon Jun 14 08:41:39 EDT 2010


Author: lzoubek at redhat.com
Date: 2010-06-14 08:41:39 -0400 (Mon, 14 Jun 2010)
New Revision: 22785

Added:
   trunk/jst/tests/org.jboss.tools.ui.bot.ext/resources/SWTBotTest-default.multi.properties
   trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfiguration.java
Modified:
   trunk/jst/tests/org.jboss.tools.ui.bot.ext/resources/SWTBotTest-default.properties
   trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/RequirementAwareSuite.java
   trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/Annotations.java
   trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/ConfiguredState.java
   trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfigurator.java
   trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddESB.java
   trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddJava.java
   trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddSeam.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/view/ExplorerBase.java
Log:
SWTBot Extensions : added testsuite supporting multiple configurations at one run

Added: trunk/jst/tests/org.jboss.tools.ui.bot.ext/resources/SWTBotTest-default.multi.properties
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/resources/SWTBotTest-default.multi.properties	                        (rev 0)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/resources/SWTBotTest-default.multi.properties	2010-06-14 12:41:39 UTC (rev 22785)
@@ -0,0 +1,3 @@
+# multi-properties file, here can be defined multiple testing configurations similar to SWTTest-default.properties
+# <property name - configuration name>=<config properties file>
+EAP5=/data/lzoubek/workspace/eap5.properties
\ No newline at end of file


Property changes on: trunk/jst/tests/org.jboss.tools.ui.bot.ext/resources/SWTBotTest-default.multi.properties
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/resources/SWTBotTest-default.properties
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/resources/SWTBotTest-default.properties	2010-06-14 12:02:55 UTC (rev 22784)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/resources/SWTBotTest-default.properties	2010-06-14 12:41:39 UTC (rev 22785)
@@ -2,7 +2,8 @@
 # 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,<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>
+# 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
 #<seam version>,<seam runtime home>
 SEAM=2.2,/data/jboss/jboss-eap-5.0/seam

Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/RequirementAwareSuite.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/RequirementAwareSuite.java	2010-06-14 12:02:55 UTC (rev 22784)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/RequirementAwareSuite.java	2010-06-14 12:41:39 UTC (rev 22785)
@@ -3,18 +3,23 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+import java.util.Map.Entry;
 
 import org.apache.log4j.Logger;
 import org.eclipse.swtbot.swt.finder.junit.ScreenshotCaptureListener;
+import org.jboss.tools.ui.bot.ext.config.TestConfiguration;
 import org.jboss.tools.ui.bot.ext.config.TestConfigurator;
 import org.jboss.tools.ui.bot.ext.config.Annotations.SWTBotTestRequires;
 import org.jboss.tools.ui.bot.ext.config.requirement.RequirementBase;
 import org.junit.runner.Description;
 import org.junit.runner.Runner;
+import org.junit.runner.manipulation.Filter;
+import org.junit.runner.manipulation.NoTestsRemainException;
 import org.junit.runner.notification.RunListener;
 import org.junit.runner.notification.RunNotifier;
 import org.junit.runners.BlockJUnit4ClassRunner;
 import org.junit.runners.Suite;
+import org.junit.runners.model.FrameworkMethod;
 import org.junit.runners.model.InitializationError;
 import org.junit.runners.model.RunnerBuilder;
 import org.junit.runners.model.Statement;
@@ -31,18 +36,22 @@
 	final static DoAfterAllTestsRunListener cleanUp = new DoAfterAllTestsRunListener();
 
 	class ReqAwareClassRunner extends BlockJUnit4ClassRunner {
+		private final TestConfiguration config;
 		private final List<RequirementBase> requirements;
 
 		public ReqAwareClassRunner(Class<?> klass,
-				List<RequirementBase> requirements) throws InitializationError {
+				List<RequirementBase> requirements, TestConfiguration config)
+				throws InitializationError {
 			super(klass);
 			this.requirements = requirements;
+			this.config = config;
 		}
 
 		@Override
 		public void run(RunNotifier notifier) {
-			// planned test counter must know about all tests (methods) within a class
-			cleanUp.incrPlanned(getChildren().size()-1);
+			// planned test counter must know about all tests (methods) within a
+			// class
+			cleanUp.incrPlanned(getChildren().size() - 1);
 			// ensure that we have exactly 1 cleanup listener registered
 			notifier.removeListener(cleanUp);
 			notifier.addListener(cleanUp);
@@ -57,8 +66,17 @@
 				notifier.removeListener(failureSpy);
 			}
 		}
+
 		@Override
+		protected String testName(FrameworkMethod method) {
+			return config.getPropName() + " - " + method.getName();
+		}
+
+		@Override
 		protected Statement withBeforeClasses(Statement statement) {
+			if (!this.config.equals(TestConfigurator.currentConfig)) {
+				TestConfigurator.currentConfig = this.config;
+			}
 			log.info("Fullfilling requirements before test "
 					+ getTestClass().getJavaClass());
 			try {
@@ -68,7 +86,6 @@
 			} catch (Exception e) {
 				log.error("Fulfilling failed", e);
 			}
-
 			return super.withBeforeClasses(statement);
 		}
 	}
@@ -77,21 +94,25 @@
 			.getLogger(RequirementAwareSuite.class);
 
 	private class RequirementAwareRunnerBuilder extends RunnerBuilder {
+		private final TestConfiguration config;
+
+		public RequirementAwareRunnerBuilder(TestConfiguration config) {
+			this.config = config;
+		}
+
 		@Override
 		public Runner runnerForClass(Class<?> klass) throws Throwable {
-			List<RequirementBase> reqs = TestConfigurator
-					.getClassRequirements(klass);
-			if (reqs != null) {
-				if (!TestConfigurator.checkConfig()) {
-					log.info("Skipping class '" + klass.getCanonicalName()
-							+ "' - incorrect configuration");
-					return null;
-				}
+			if (!this.config.equals(TestConfigurator.currentConfig)) {
+				TestConfigurator.currentConfig = this.config;
+			}
+			List<RequirementBase> reqs = TestConfigurator.getClassRequirements(klass);
+			if (reqs != null) {				
 				log.info("Returning runner for class '"
-						+ klass.getCanonicalName()+"'");
-				// increment number of tests planned to run by 1 (class contains at least 1 test method)
+						+ klass.getCanonicalName() + "'");
+				// increment number of tests planned to run by 1 (class contains
+				// at least 1 test method)
 				cleanUp.incrPlanned();
-				return new ReqAwareClassRunner(klass, reqs);
+				return new ReqAwareClassRunner(klass, reqs, config);
 			}
 			log.info("Skipping class '" + klass.getCanonicalName()
 					+ "' - annotations do not met configuration");
@@ -108,14 +129,17 @@
 	 * 
 	 */
 	static class DoAfterAllTestsRunListener extends RunListener {
-		// As we can run more suites at once, we need to count tests which are planned to run
-		// and the ones which already passed (or failed), perform cleanups when the last one finishes
+		// As we can run more suites at once, we need to count tests which are
+		// planned to run
+		// and the ones which already passed (or failed), perform cleanups when
+		// the last one finishes
 		private int testsAboutToRun = 0;
 		private int testsFinished = 0;
 
 		public void incrPlanned() {
 			testsAboutToRun += 1;
 		}
+
 		public void incrPlanned(int amount) {
 			testsAboutToRun += amount;
 		}
@@ -130,14 +154,16 @@
 
 		public int getFinished() {
 			return testsFinished;
-		}		
+		}
+
 		@Override
 		public void testFinished(Description description) throws Exception {
 			incrFinished();
-			log.info("Finished test : "+description.getDisplayName());
-			log.info("Finished tests : "+getFinished()+"/"+getPlanned());
+			log.info("Finished test : " + description.getDisplayName());
+			log.info("Finished tests : " + getFinished() + "/" + getPlanned());
 			if (getFinished() >= getPlanned()) {
-				log.info("All tests finished, performing cleanup requirements ");
+				log
+						.info("All tests finished, performing cleanup requirements ");
 				try {
 					RequirementBase.createStopServer().fulfill();
 
@@ -165,11 +191,40 @@
 	 */
 	public RequirementAwareSuite(Class<?> klass) throws Throwable {
 		super(klass, Collections.<Runner> emptyList());
-		runners.add(new Suite(klass, new RequirementAwareRunnerBuilder()));
+		log.info("Loading test configurations");
+		for (Entry<Object, Object> entry : TestConfigurator.multiProperties
+				.entrySet()) {
+			try {
+				TestConfiguration config = new TestConfiguration(entry.getKey()
+						.toString(), entry.getValue().toString());
+				String suiteName = config.getPropName() + " - "
+						+ klass.getCanonicalName();
+				runners.add(new NamedSuite(klass,
+						new RequirementAwareRunnerBuilder(config), suiteName));
+			} catch (Exception ex) {
+				log.error("Error loading test configuration", ex);
+			}
+		}
 	}
 
 	@Override
 	protected List<Runner> getChildren() {
 		return runners;
 	}
+
+	public class NamedSuite extends Suite {
+		private final String suiteName;
+
+		public NamedSuite(Class<?> klass, RunnerBuilder builder, String name)
+				throws InitializationError {
+			super(klass, builder);
+			this.suiteName = name;
+		}
+
+		@Override
+		protected String getName() {
+			return suiteName;
+		}
+
+	}
 }

Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/Annotations.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/Annotations.java	2010-06-14 12:02:55 UTC (rev 22784)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/Annotations.java	2010-06-14 12:41:39 UTC (rev 22785)
@@ -154,6 +154,10 @@
 	}
 	public enum ServerType {
 		/**
+		 * SOA platform (includes EAP)
+		 */
+		SOA,
+		/**
 		 * EAP
 		 */
 		EAP, 

Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/ConfiguredState.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/ConfiguredState.java	2010-06-14 12:02:55 UTC (rev 22784)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/ConfiguredState.java	2010-06-14 12:41:39 UTC (rev 22785)
@@ -90,6 +90,10 @@
 		 * version of java configured to server (1.5 or 1.6)
 		 */
 		public String withJavaVersion = null;
+		/**
+		 * version of bundled ESB (applicable only for server type SOA)
+		 */
+		public String bundledESBVersion=null;
 	}
 
 	public class Seam {

Added: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfiguration.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfiguration.java	                        (rev 0)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfiguration.java	2010-06-14 12:41:39 UTC (rev 22785)
@@ -0,0 +1,135 @@
+package org.jboss.tools.ui.bot.ext.config;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Properties;
+
+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.config.TestConfigurator.Keys;
+import org.jboss.tools.ui.bot.ext.config.TestConfigurator.Values;
+
+public class TestConfiguration {
+	private static final Logger log = Logger.getLogger(TestConfiguration.class);
+
+	private Properties swtTestProperties = new Properties();
+
+	public String getProperty(String key) {
+		return swtTestProperties.getProperty(key);
+	}
+
+	private final String propName;
+	private final String propFile;
+
+	private ServerBean server;
+	private SeamBean seam;
+	private ESBBean esb;
+	private JavaBean java;
+
+	public TestConfiguration(String propName, String propFile) throws Exception {
+		this.propName = propName;
+		this.propFile = propFile;
+		if (propFile != null) {
+			if (new File(propFile).exists()) {
+				log.info("Loading configuration file '" + propFile + "'");
+				swtTestProperties.load(new FileInputStream(propFile));
+			} else {
+				throw new IOException(propName + " " + propFile + " does not exist!");
+			}
+
+		} else {
+			log.info("Loading default configuration");
+			swtTestProperties.load(new FileInputStream(SWTTestExt.util
+					.getResourceFile(Activator.PLUGIN_ID,
+							"/SWTBotTest-default.properties")));
+		}
+		// properties got loaded
+		java = JavaBean.fromString(getProperty(Keys.JAVA));
+		printConfig(Keys.JAVA, java);
+		server = ServerBean.fromString(getProperty(Keys.SERVER));
+		printConfig(Keys.SERVER, server);
+		seam = SeamBean.fromString(getProperty(Keys.SEAM));
+		printConfig(Keys.SEAM, seam);
+		esb = ESBBean.fromString(getProperty(Keys.ESB));
+		printConfig(Keys.ESB, esb);
+		
+		checkConfig();
+	}
+
+	private static void printConfig(String propName, Object bean) {
+		if (bean == null) {
+			log.info("Property " + propName + " not found, " + propName
+					+ " not configured");
+		} else {
+			log.info("Configured " + bean.toString());
+		}
+	}
+
+	private boolean checkConfig() throws Exception {
+			if (java != null)
+				checkDirExists(java.javaHome);
+			if (seam != null)
+				checkDirExists(seam.seamHome);
+			if (server != null)
+				checkDirExists(server.runtimeHome);
+			if (esb != null)
+				checkDirExists(esb.esbHome);
+			// special checks capturing dependency of server on java
+			if (java == null
+					&& server != null
+					&& !server.withJavaVersion
+							.equals(Values.SERVER_WITH_DEFAULT_JAVA)) {
+				throw new Exception(
+						"Server is configured to run with java version="
+								+ server.withJavaVersion
+								+ " but no JAVA is configured");
+			}
+			if (java != null) {
+				if (!java.version.equals(server.withJavaVersion)
+						&& !Values.SERVER_WITH_DEFAULT_JAVA
+								.equals(server.withJavaVersion)) {
+					throw new Exception(
+							"Server is configured to run with java version="
+									+ server.withJavaVersion
+									+ " but JAVA is configured with "
+									+ java.version);
+				}
+			}
+			return true;
+
+	}
+
+	private static void checkDirExists(String dir) throws FileNotFoundException {
+		if (!new File(dir).exists() || !new File(dir).isDirectory()) {
+			throw new FileNotFoundException("File '" + dir
+					+ "' does not exist or is not directory");
+		}
+	}
+
+	public ESBBean getEsb() {
+		return esb;
+	}
+
+	public SeamBean getSeam() {
+		return seam;
+	}
+
+	public ServerBean getServer() {
+		return server;
+	}
+
+	public JavaBean getJava() {
+		return java;
+	}
+
+	public String getPropFile() {
+		return propFile;
+	}
+
+	public String getPropName() {
+		return propName;
+	}
+}


Property changes on: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfiguration.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfigurator.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfigurator.java	2010-06-14 12:02:55 UTC (rev 22784)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfigurator.java	2010-06-14 12:41:39 UTC (rev 22785)
@@ -2,7 +2,6 @@
 
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -11,8 +10,6 @@
 import java.util.Properties;
 
 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.config.Annotations.ESB;
 import org.jboss.tools.ui.bot.ext.config.Annotations.SWTBotTestRequires;
 import org.jboss.tools.ui.bot.ext.config.Annotations.Seam;
@@ -34,120 +31,45 @@
 	public class Values {
 		public static final String SERVER_TYPE_EPP = "EPP";
 		public static final String SERVER_TYPE_EAP = "EAP";
+		public static final String SERVER_TYPE_SOA = "SOA";
 		public static final String SERVER_TYPE_JBOSSAS = "JBOSS_AS";
 		public static final String SERVER_WITH_DEFAULT_JAVA = "default";
 	}
 
 	public static final String SWTBOT_TEST_PROPERTIES_FILE = "swtbot.test.properties.file";
-	private static Properties swtTestProperties = new Properties();
-	public static ServerBean server;
-	public static SeamBean seam;
-	public static ESBBean esb;
-	public static JavaBean java;
+	public static final String SWTBOT_TEST_PROPERTIES_MULTI_FILE = "swtbot.test.properties.multi.file";
+	public static Properties multiProperties = new Properties();
+	public static TestConfiguration currentConfig;
 	static {
 		try {
 			// try to load from file first
 			String propFile = System.getProperty(SWTBOT_TEST_PROPERTIES_FILE,
 					null);
-			if (propFile != null) {
-				try {
-					if (new File(propFile).exists()) {
-						log
-								.info("Loading exeternaly provided configuration file '"
-										+ propFile + "'");
-						swtTestProperties.load(new FileInputStream(propFile));
-					} else {
-						throw new IOException(SWTBOT_TEST_PROPERTIES_FILE + " "
-								+ propFile + " does not exist!");
-					}
-				} catch (FileNotFoundException e) {
-					// TODO Auto-generated catch block
-					e.printStackTrace();
-				} catch (IOException e) {
-					// TODO Auto-generated catch block
-					e.printStackTrace();
+			String propMultiFile = System.getProperty(SWTBOT_TEST_PROPERTIES_MULTI_FILE,
+					null);
+			if (propMultiFile!=null) {
+				if (new File(propMultiFile).exists()) {
+					log
+					.info("Loading exeternaly provided multi-configuration file '"
+							+ propMultiFile + "'");
+					multiProperties.load(new FileInputStream(propMultiFile));
 				}
-			} else {
-				try {
-					log.info("Loading default configuration, override by pointing java system property '"+SWTBOT_TEST_PROPERTIES_FILE+"' to your custom property file");
-					swtTestProperties.load(new FileInputStream(SWTTestExt.util
-							.getResourceFile(Activator.PLUGIN_ID,
-									"/SWTBotTest-default.properties")));
-				} catch (IOException e1) {
-					// TODO Auto-generated catch block
-					e1.printStackTrace();
+				else {
+					throw new IOException(SWTBOT_TEST_PROPERTIES_MULTI_FILE + " "
+							+ propMultiFile + " does not exist!");
 				}
+			} else {				
+				multiProperties.put(SWTBOT_TEST_PROPERTIES_FILE, propFile);
+
 			}
+
 		} catch (Exception ex) {
 			ex.printStackTrace();
 		}
 
-		// properties got loaded
-		try {
-			java = JavaBean.fromString(getProperty(Keys.JAVA));
-			printConfig(Keys.JAVA, java);
-			server = ServerBean.fromString(getProperty(Keys.SERVER));
-			printConfig(Keys.SERVER, server);
-			seam = SeamBean.fromString(getProperty(Keys.SEAM));
-			printConfig(Keys.SEAM, seam);
-			esb = ESBBean.fromString(getProperty(Keys.ESB));
-			printConfig(Keys.ESB, esb);
-		} catch (Exception e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
-	}
 
-	private static void printConfig(String propName, Object bean) {
-		if (bean == null) {
-			log.info("Property " + propName
-					+ " not found, "+propName+" not configured");
-		} else {
-			log.info("Configured " + bean.toString());
-		}
 	}
-
 	/**
-	 * check config values if they seem to be valid (existing dirs)
-	 * 
-	 * @throws FileNotFoundException
-	 */
-	public static boolean checkConfig() {
-		try {
-			if (java != null)
-				checkDirExists(java.javaHome);
-			if (seam != null)
-				checkDirExists(seam.seamHome);
-			if (server != null)
-				checkDirExists(server.runtimeHome);
-			if (esb != null)
-				checkDirExists(esb.esbHome);
-			// special checks capturing dependency of server on java 
-			if (java==null && server!=null && !server.withJavaVersion.equals(Values.SERVER_WITH_DEFAULT_JAVA)) {
-				throw new Exception("Server is configured to run with java version="+server.withJavaVersion+" but no JAVA is configured");
-			}
-			if (java!=null && !java.version.equals(server.withJavaVersion)) {
-				throw new Exception("Server is configured to run with java version="+server.withJavaVersion+" but JAVA is configured with "+java.version);
-			}
-			return true;
-		} catch (Exception ex) {
-			log
-					.error("'"
-							+ ex.getMessage()
-							+ "' - incorrect configuration, update your configuraton");
-			return false;
-		}
-
-	}
-
-	private static void checkDirExists(String dir) throws FileNotFoundException {
-		if (!new File(dir).exists() || !new File(dir).isDirectory()) {
-			throw new FileNotFoundException("File '" + dir
-					+ "' does not exist or is not directory");
-		}
-	}
-
-	/**
 	 * returns null when given Server annotation does not match global test
 	 * configuration (e.g. Test wants Server type EAP but we are running on
 	 * JbossAS)
@@ -158,27 +80,31 @@
 	 */
 	private static RequirementBase getServerRequirement(Server s) {
 		// tests omitting server must run even when server not configured
-		if (ServerState.Disabled.equals(s.state()) && server == null) {
+		if (ServerState.Disabled.equals(s.state()) && currentConfig.getServer() == null) {
 			return RequirementBase.createRemoveServer();
 		}
-		if (!s.required() || server == null) {
+		if (!s.required() || currentConfig.getServer() == null) {
 			return null;
 		}
 		if (!s.type().equals(ServerType.ALL)) {
 			if (s.type().equals(ServerType.EAP)
-					&& !server.type.equals(Values.SERVER_TYPE_EAP)) {
+					&& !currentConfig.getServer().type.equals(Values.SERVER_TYPE_EAP)) {
 				return null;
 			}
 			if (s.type().equals(ServerType.JbossAS)
-					&& !server.type.equals(Values.SERVER_TYPE_JBOSSAS)) {
+					&& !currentConfig.getServer().type.equals(Values.SERVER_TYPE_JBOSSAS)) {
 				return null;
 			}
 			if (s.type().equals(ServerType.EPP)
-					&& !server.type.equals(Values.SERVER_TYPE_EPP)) {
+					&& !currentConfig.getServer().type.equals(Values.SERVER_TYPE_EPP)) {
 				return null;
 			}
+			if (s.type().equals(ServerType.SOA)
+					&& !currentConfig.getServer().type.equals(Values.SERVER_TYPE_SOA)) {
+				return null;
+			}
 		}
-		if (!matches(server.version, s.operator(), s.version())) {
+		if (!matches(currentConfig.getServer().version, s.operator(), s.version())) {
 			return null;
 		}
 		if (ServerState.Disabled.equals(s.state())) {
@@ -203,20 +129,20 @@
 	 * @return AddSeam requirement otherwise
 	 */
 	private static RequirementBase getSeamRequirement(Seam s) {
-		if (!s.required() || seam == null) {
+		if (!s.required() || currentConfig.getSeam() == null) {
 			return null;
 		}
-		if (!matches(seam.version, s.operator(), s.version())) {
+		if (!matches(currentConfig.getSeam().version, s.operator(), s.version())) {
 			return null;
 		}
 		return RequirementBase.createAddSeam();
 	}
 
 	private static RequirementBase getESBRequirement(ESB e) {
-		if (!e.required() || esb == null) {
+		if (!e.required() || currentConfig.getEsb() == null) {
 			return null;
 		}
-		if (!matches(esb.version, e.operator(), e.version())) {
+		if (!matches(currentConfig.getEsb().version, e.operator(), e.version())) {
 			return null;
 		}
 		return RequirementBase.createAddESB();
@@ -319,11 +245,19 @@
 	}
 
 	private static int versionToNumber(String version) {
-		return Integer.parseInt(version.replaceAll("\\.", ""));
+		version = version.replaceAll("\\.", "");
+		int addZeros = 4-version.length();
+		if (addZeros>0) {
+			while (addZeros>0) {
+				version+="0";
+				addZeros--;
+			}
+		}
+		return Integer.parseInt(version);
 	}
 
 	public static String getProperty(String key) {
-		return swtTestProperties.getProperty(key);
+		return currentConfig.getProperty(key);
 		// return SWTTestExt.util.getValue(swtTestProperties, key);
 	}
 }

Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddESB.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddESB.java	2010-06-14 12:02:55 UTC (rev 22784)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddESB.java	2010-06-14 12:41:39 UTC (rev 22785)
@@ -12,11 +12,11 @@
 
 	@Override
 	public void handle() {
-		String esbName = "ESB-"+TestConfigurator.esb.version;
-		SWTTestExt.eclipse.addESBRuntime(esbName,TestConfigurator.esb.version,TestConfigurator.esb.esbHome);
+		String esbName = "ESB-"+TestConfigurator.currentConfig.getEsb().version;
+		SWTTestExt.eclipse.addESBRuntime(esbName,TestConfigurator.currentConfig.getEsb().version,TestConfigurator.currentConfig.getEsb().esbHome);
 		SWTTestExt.configuredState.getEsb().isConfiured=true;
 		SWTTestExt.configuredState.getEsb().name=esbName;
-		SWTTestExt.configuredState.getEsb().version=TestConfigurator.esb.version;	
+		SWTTestExt.configuredState.getEsb().version=TestConfigurator.currentConfig.getEsb().version;	
 
 	}
 

Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddJava.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddJava.java	2010-06-14 12:02:55 UTC (rev 22784)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddJava.java	2010-06-14 12:41:39 UTC (rev 22785)
@@ -26,10 +26,10 @@
 		SWTTestExt.configuredState.getJreList().add(getAddedAsName());
 	}
 	public String getAddedAsName() {
-		return "JRE-"+TestConfigurator.java.version;
+		return "JRE-"+TestConfigurator.currentConfig.getJava().version;
 	}
 	private String getJavaHome() {
-		return TestConfigurator.java.javaHome;
+		return TestConfigurator.currentConfig.getJava().javaHome;
 	}
 
 }

Modified: trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddSeam.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddSeam.java	2010-06-14 12:02:55 UTC (rev 22784)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddSeam.java	2010-06-14 12:41:39 UTC (rev 22785)
@@ -12,11 +12,11 @@
 
 	@Override
 	public void handle() {
-		String seamName = "Seam-"+TestConfigurator.seam.version;
-		SWTTestExt.eclipse.addSeamRuntime(seamName, TestConfigurator.seam.version, TestConfigurator.seam.seamHome);
+		String seamName = "Seam-"+TestConfigurator.currentConfig.getSeam().version;
+		SWTTestExt.eclipse.addSeamRuntime(seamName, TestConfigurator.currentConfig.getSeam().version, TestConfigurator.currentConfig.getSeam().seamHome);
 		SWTTestExt.configuredState.getSeam().isConfiured=true;
 		SWTTestExt.configuredState.getSeam().name=seamName;
-		SWTTestExt.configuredState.getSeam().version=TestConfigurator.seam.version;		
+		SWTTestExt.configuredState.getSeam().version=TestConfigurator.currentConfig.getSeam().version;		
 	}
 
 }

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-14 12:02:55 UTC (rev 22784)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/AddServer.java	2010-06-14 12:41:39 UTC (rev 22785)
@@ -27,8 +27,8 @@
 
 	private String javaName=null;
 	public AddServer() {
-		String javaVer = getNeededJavaVersion(TestConfigurator.server.withJavaVersion);
-		if (javaVer!=null && TestConfigurator.java!=null &&javaVer.equals(TestConfigurator.java.version)) {
+		String javaVer = getNeededJavaVersion(TestConfigurator.currentConfig.getServer().withJavaVersion);
+		if (javaVer!=null && TestConfigurator.currentConfig.getJava()!=null &&javaVer.equals(TestConfigurator.currentConfig.getJava().version)) {
 			AddJava addJava = createAddJava();
 			getDependsOn().add(addJava);
 			javaName=addJava.getAddedAsName();
@@ -38,17 +38,26 @@
 
 	@Override
 	public void handle() {
-		ServerInfo serverInfo = getRuntime(TestConfigurator.server.type,TestConfigurator.server.version);
-		String runtimeHome=TestConfigurator.server.runtimeHome;
-		String runtimeName=TestConfigurator.server.type+"-"+TestConfigurator.server.version;
+		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;
 		SWTTestExt.eclipse.addJbossServerRuntime(serverInfo.runtime, 
 				runtimeHome, runtimeName, javaName);
 		SWTTestExt.eclipse.addServer(serverInfo.server, runtimeName);
 		SWTTestExt.configuredState.getServer().isConfigured=true;
 		SWTTestExt.configuredState.getServer().name=runtimeName;
-		SWTTestExt.configuredState.getServer().version=TestConfigurator.server.version;
-		SWTTestExt.configuredState.getServer().type=TestConfigurator.server.type;
-		SWTTestExt.configuredState.getServer().withJavaVersion = TestConfigurator.server.withJavaVersion;
+		SWTTestExt.configuredState.getServer().version=TestConfigurator.currentConfig.getServer().version;
+		SWTTestExt.configuredState.getServer().type=TestConfigurator.currentConfig.getServer().type;
+		SWTTestExt.configuredState.getServer().withJavaVersion = TestConfigurator.currentConfig.getServer().withJavaVersion;
+		// setup bundled ESB versions for SOA server type
+		if (TestConfigurator.currentConfig.getServer().type.equals(TestConfigurator.Values.SERVER_TYPE_SOA)) {
+			if ("4.3".equals(TestConfigurator.currentConfig.getServer().version)) {
+				SWTTestExt.configuredState.getServer().bundledESBVersion="4.4";			
+			}
+			if ("5.0".equals(TestConfigurator.currentConfig.getServer().version)) {
+				SWTTestExt.configuredState.getServer().bundledESBVersion="4.7";
+			}
+		} 
 	}
 
 	
@@ -79,7 +88,8 @@
 						JBossEnterpriseMiddlewareJBossEnterpriseApplicationPlatform50.LABEL);
 			}
 			
-		}if (TestConfigurator.Values.SERVER_TYPE_EPP.equals(serverType)) {
+		}
+		if (TestConfigurator.Values.SERVER_TYPE_EPP.equals(serverType)) {
 			if ("4.3".equals(version)) {
 				return new ServerInfo(JBossEnterpriseMiddlewareJBossEnterpriseApplicationPlatform43Runtime.LABEL,
 						JBossEnterpriseMiddlewareJBossEnterpriseApplicationPlatform43.LABEL
@@ -91,6 +101,18 @@
 			}
 			
 		}
+		if (TestConfigurator.Values.SERVER_TYPE_SOA.equals(serverType)) {
+			if ("4.3".equals(version)) {
+				return new ServerInfo(JBossEnterpriseMiddlewareJBossEnterpriseApplicationPlatform43Runtime.LABEL,
+						JBossEnterpriseMiddlewareJBossEnterpriseApplicationPlatform43.LABEL
+						);				
+			}
+			if ("5.0".equals(version)) {
+				return new ServerInfo(JBossEnterpriseMiddlewareJBossEnterpriseApplicationPlatform50Runtime.LABEL,
+						JBossEnterpriseMiddlewareJBossEnterpriseApplicationPlatform50.LABEL);
+			}
+			
+		}
 		else if (TestConfigurator.Values.SERVER_TYPE_JBOSSAS.equals(serverType)) {
 			if ("4.2".equals(version)) {
 				return new ServerInfo(JBossCommunityJBoss42Runtime.LABEL,JBossCommunityJBossAS42.LABEL);				

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-14 12:02:55 UTC (rev 22784)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/RemoveServer.java	2010-06-14 12:41:39 UTC (rev 22785)
@@ -23,6 +23,7 @@
 		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/view/ExplorerBase.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ExplorerBase.java	2010-06-14 12:02:55 UTC (rev 22784)
+++ trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ExplorerBase.java	2010-06-14 12:41:39 UTC (rev 22785)
@@ -142,6 +142,7 @@
 	public void runOnServer(String projectName) {
 		SWTBot viewBot = show().bot();
 		SWTBotTreeItem item = viewBot.tree().expandNode(projectName);
+		item.select();
 		ContextMenuHelper.prepareTreeItemForContextMenu(viewBot.tree(), item);
 		   final SWTBotMenu menuRunAs = viewBot.menu(IDELabel.Menu.RUN).menu(IDELabel.Menu.RUN_AS);
 		    final MenuItem menuItem = UIThreadRunnable
@@ -151,6 +152,7 @@
 		          MenuItem menuItem = null;
 		          final MenuItem[] menuItems = menuRunAs.widget.getMenu().getItems();
 		          while (menuItem == null && menuItemIndex < menuItems.length){
+		        	  log.info("Found item" +menuItems[menuItemIndex].getText());
 		            if (menuItems[menuItemIndex].getText().indexOf("Run on Server") > - 1){
 		              menuItem = menuItems[menuItemIndex];
 		            }



More information about the jbosstools-commits mailing list