Author: lzoubek(a)redhat.com
Date: 2010-04-30 04:50:50 -0400 (Fri, 30 Apr 2010)
New Revision: 21821
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/TestConfigurator.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/ClearWorkspace.java
Log:
SWTBot extensions : do not run any test class, when configuration is incorrect
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-04-30
08:29:42 UTC (rev 21820)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/resources/SWTBotTest-default.properties 2010-04-30
08:50:50 UTC (rev 21821)
@@ -1,4 +1,5 @@
# SWTBotTest properties
+# all defined paths should exist
JAVA_HOME_15=/usr/java/jdk-1.5.0_12/jre
JAVA_HOME_16=/opt/sun-jdk-1.6.0.19/jre
# EAP|JBOSS_AS,<server version>,<jre version to run with>|default,<server
home>
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-04-30
08:29:42 UTC (rev 21820)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/RequirementAwareSuite.java 2010-04-30
08:50:50 UTC (rev 21821)
@@ -40,7 +40,7 @@
// adding ability to create screen shot (taken from SWTBotJunit4ClassRunner)
RunListener failureSpy = new ScreenshotCaptureListener();
notifier.removeListener(failureSpy);
- notifier.addListener(failureSpy);
+ notifier.addListener(failureSpy);
try {
super.run(notifier);
}
@@ -57,7 +57,7 @@
r.fulfill();
}
} catch (Exception e) {
- log.error("Fulfilling failed", e);
+ log.error("Fulfilling failed", e);
}
return super.withBeforeClasses(statement);
@@ -73,11 +73,15 @@
List<RequirementBase> reqs = TestConfigurator
.getClassRequirements(klass);
if (reqs != null) {
+ if (!TestConfigurator.checkConfig()) {
+ log.info("Skipping class '" + klass.getCanonicalName()+"' -
incorrect configuration");
+ return null;
+ }
log.info("Returning runner for test class "
+ klass.getCanonicalName());
- return new ReqAwareClassRunner(klass, reqs);
+ return new ReqAwareClassRunner(klass, reqs);
}
- log.info("Skipping test class " + klass.getCanonicalName());
+ log.info("Skipping class '" + klass.getCanonicalName() + "' -
annotations do not met configuration");
return null;
}
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-04-30
08:29:42 UTC (rev 21820)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/TestConfigurator.java 2010-04-30
08:50:50 UTC (rev 21821)
@@ -9,6 +9,8 @@
import java.util.Comparator;
import java.util.List;
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.SWTBotTestRequires;
@@ -18,7 +20,8 @@
import org.jboss.tools.ui.bot.ext.config.requirement.RequirementBase;
public class TestConfigurator {
-
+ private static final Logger log = Logger
+ .getLogger(TestConfigurator.class);
public class Keys {
public static final String SERVER = "SERVER";
public static final String SEAM = "SEAM";
@@ -41,9 +44,14 @@
// try to load from file first
String propFile = System.getProperty(SWTBOT_TEST_PROPERTIES_FILE,
null);
- if (propFile != null && new File(propFile).exists()) {
+ 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();
@@ -53,6 +61,7 @@
}
} else {
try {
+ log.info("Loading default configuration");
swtTestProperties.load(new FileInputStream(SWTTestExt.util
.getResourceFile(Activator.PLUGIN_ID,
"/SWTBotTest-default.properties")));
@@ -74,7 +83,29 @@
e.printStackTrace();
}
}
-
+/**
+ * check config values if they seem to be valid (existing dirs)
+ * @throws FileNotFoundException
+ */
+ public static boolean checkConfig() {
+ try {
+ checkDirExists(getProperty(Keys.JAVA_HOME_15));
+ checkDirExists(getProperty(Keys.JAVA_HOME_16));
+ checkDirExists(seam.seamHome);
+ checkDirExists(server.runtimeHome);
+ return true;
+ }
+ catch (Exception ex) {
+ log.error(ex.getMessage()+ " incorrect configuration, set your custom properties
file via 'swtbot.test.properties.file' java property");
+ 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
Modified:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/ClearWorkspace.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/ClearWorkspace.java 2010-04-30
08:29:42 UTC (rev 21820)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/requirement/ClearWorkspace.java 2010-04-30
08:50:50 UTC (rev 21821)
@@ -10,7 +10,7 @@
@Override
public boolean checkFulfilled() {
try {
- return SWTTestExt.bot.shells().length>=2 &&
SWTTestExt.bot.editors().isEmpty() &&
!SWTTestExt.configuredState.isWelcomeViewVisible();
+ return SWTTestExt.bot.shells().length==2 && SWTTestExt.bot.editors().isEmpty()
&& !SWTTestExt.configuredState.isWelcomeViewVisible();
}
catch (Exception ex) {
log.error("Cannot determine, if all editors and shells are closed", ex);
Show replies by date