Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkuppe2010-02-23 17:39:00 +0000
committermkuppe2010-02-23 17:39:00 +0000
commitea2bc65574203a8876d88b7b79bc634d6d78597c (patch)
tree62ff872c04911030cb1a59fc0887d68b9675c0ab /protocols
parent4c342f0ae518f89691b963a7f58787260aa10b93 (diff)
downloadorg.eclipse.ecf-ea2bc65574203a8876d88b7b79bc634d6d78597c.tar.gz
org.eclipse.ecf-ea2bc65574203a8876d88b7b79bc634d6d78597c.tar.xz
org.eclipse.ecf-ea2bc65574203a8876d88b7b79bc634d6d78597c.zip
Run tests outside of framework thread
Diffstat (limited to 'protocols')
-rw-r--r--protocols/bundles/ch.ethz.iks.slp/runtimeTests/src/main/java/ch/ethz/iks/slp/test/DistributedTestActivator.java7
-rw-r--r--protocols/bundles/ch.ethz.iks.slp/runtimeTests/src/main/java/ch/ethz/iks/slp/test/TestActivator.java98
2 files changed, 53 insertions, 52 deletions
diff --git a/protocols/bundles/ch.ethz.iks.slp/runtimeTests/src/main/java/ch/ethz/iks/slp/test/DistributedTestActivator.java b/protocols/bundles/ch.ethz.iks.slp/runtimeTests/src/main/java/ch/ethz/iks/slp/test/DistributedTestActivator.java
index 4f8875f85..12421e549 100644
--- a/protocols/bundles/ch.ethz.iks.slp/runtimeTests/src/main/java/ch/ethz/iks/slp/test/DistributedTestActivator.java
+++ b/protocols/bundles/ch.ethz.iks.slp/runtimeTests/src/main/java/ch/ethz/iks/slp/test/DistributedTestActivator.java
@@ -67,12 +67,7 @@ public class DistributedTestActivator extends TestActivator implements ServiceLi
}
if (advertiser != null && locator != null) {
- // do not call the tests from inside the framework thread
- new Thread(new Runnable() {
- public void run() {
- startTests();
- }
- }).start();
+ startTests();
}
}
diff --git a/protocols/bundles/ch.ethz.iks.slp/runtimeTests/src/main/java/ch/ethz/iks/slp/test/TestActivator.java b/protocols/bundles/ch.ethz.iks.slp/runtimeTests/src/main/java/ch/ethz/iks/slp/test/TestActivator.java
index c00982fc0..2d3bce230 100644
--- a/protocols/bundles/ch.ethz.iks.slp/runtimeTests/src/main/java/ch/ethz/iks/slp/test/TestActivator.java
+++ b/protocols/bundles/ch.ethz.iks.slp/runtimeTests/src/main/java/ch/ethz/iks/slp/test/TestActivator.java
@@ -50,55 +50,61 @@ public class TestActivator implements BundleActivator {
}
protected void startTests() {
- TestSuite suite = new TestSuite();
- Collection collection = new ArrayList();
-
- collection.add(SelfDiscoveryTest.class);
-
- for (Iterator iterator = collection.iterator(); iterator.hasNext();) {
- Class clazz = (Class) iterator.next();
- // run all methods starting with "test*"
- Method[] methods = clazz.getMethods();
- for (int i = 0; i < methods.length; i++) {
- if (methods[i].getName().startsWith("test")) {
- TestCase testCase;
- try {
- testCase = (TestCase) clazz.newInstance();
- testCase.setName(methods[i].getName());
- suite.addTest(testCase);
- } catch (InstantiationException e) {
- // may never happen
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- // may never happen
- e.printStackTrace();
+ new Thread(new Runnable() {
+ /* (non-Javadoc)
+ * @see java.lang.Runnable#run()
+ */
+ public void run() {
+ TestSuite suite = new TestSuite();
+ Collection collection = new ArrayList();
+
+ collection.add(SelfDiscoveryTest.class);
+
+ for (Iterator iterator = collection.iterator(); iterator.hasNext();) {
+ Class clazz = (Class) iterator.next();
+ // run all methods starting with "test*"
+ Method[] methods = clazz.getMethods();
+ for (int i = 0; i < methods.length; i++) {
+ if (methods[i].getName().startsWith("test")) {
+ TestCase testCase;
+ try {
+ testCase = (TestCase) clazz.newInstance();
+ testCase.setName(methods[i].getName());
+ suite.addTest(testCase);
+ } catch (InstantiationException e) {
+ // may never happen
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ // may never happen
+ e.printStackTrace();
+ }
+ }
}
}
+ TestResult result = TestRunner.run(suite);
+ if (result.wasSuccessful()) {
+ System.exit(0);
+ } else {
+ if (result.errorCount() > 0) {
+ System.err.println("Errors:");
+ for (Enumeration errors = result.errors(); errors
+ .hasMoreElements();) {
+ TestFailure error = (TestFailure) errors.nextElement();
+ System.err.println(error.trace());
+ }
+ }
+ if (result.failureCount() > 0) {
+ System.err.println("Failures:");
+ for (Enumeration failures = result.failures(); failures
+ .hasMoreElements();) {
+ TestFailure failure = (TestFailure) failures.nextElement();
+ System.err.println(failure.trace());
+ }
+ }
+ System.exit(1);
+ };
}
- }
- TestResult result = TestRunner.run(suite);
- if (result.wasSuccessful()) {
- System.exit(0);
- } else {
- if (result.errorCount() > 0) {
- System.err.println("Errors:");
- for (Enumeration errors = result.errors(); errors
- .hasMoreElements();) {
- TestFailure error = (TestFailure) errors.nextElement();
- System.err.println(error.trace());
- }
- }
- if (result.failureCount() > 0) {
- System.err.println("Failures:");
- for (Enumeration failures = result.failures(); failures
- .hasMoreElements();) {
- TestFailure failure = (TestFailure) failures.nextElement();
- System.err.println(failure.trace());
- }
- }
- System.exit(1);
- }
-
+ }).start();
}
public void stop(BundleContext context) throws Exception {

Back to the top