503109: create ManagedSuite for junit4

Change-Id: Ie3be756a125102931e88958cd026a37dacd34113
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=503109
Signed-off-by: Frank Becker <eclipse@frank-becker.de>
diff --git a/org.eclipse.mylyn.tests/src/org/eclipse/mylyn/tests/AllConnectorHeartbeatTests.java b/org.eclipse.mylyn.tests/src/org/eclipse/mylyn/tests/AllConnectorHeartbeatTests.java
index 8ad93be..3e196dc 100644
--- a/org.eclipse.mylyn.tests/src/org/eclipse/mylyn/tests/AllConnectorHeartbeatTests.java
+++ b/org.eclipse.mylyn.tests/src/org/eclipse/mylyn/tests/AllConnectorHeartbeatTests.java
@@ -11,12 +11,13 @@
 
 package org.eclipse.mylyn.tests;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
+import org.eclipse.mylyn.commons.sdk.util.ManagedSuite;
 import org.eclipse.mylyn.commons.sdk.util.ManagedTestSuite;
 import org.eclipse.mylyn.commons.sdk.util.TestConfiguration;
-import org.eclipse.mylyn.commons.sdk.util.TestConfiguration.TestKind;
+
+import junit.framework.JUnit4TestAdapter;
+import junit.framework.Test;
+import junit.framework.TestSuite;
 
 /**
  * @author Steffen Pingel
@@ -24,11 +25,16 @@
 public class AllConnectorHeartbeatTests {
 
 	public static Test suite() {
-		TestConfiguration configuration = new TestConfiguration(TestKind.INTEGRATION);
-		configuration.setDefaultOnly(true);
+
+		TestConfiguration configuration = ManagedSuite.getTestConfiguration();
+		if (configuration == null) {
+			configuration = new TestConfiguration();
+			configuration.setDefaultOnly(true);
+			ManagedSuite.setTestConfiguration(configuration);
+		}
 
 		TestSuite suite = new ManagedTestSuite(AllConnectorHeartbeatTests.class.getName());
-		AllConnectorTests.addTests(suite, configuration);
+		suite.addTest(new JUnit4TestAdapter(AllConnectorTests.class));
 		return suite;
 	}
 
diff --git a/org.eclipse.mylyn.tests/src/org/eclipse/mylyn/tests/AllConnectorTests.java b/org.eclipse.mylyn.tests/src/org/eclipse/mylyn/tests/AllConnectorTests.java
index 6b19e40..22897ba 100644
--- a/org.eclipse.mylyn.tests/src/org/eclipse/mylyn/tests/AllConnectorTests.java
+++ b/org.eclipse.mylyn.tests/src/org/eclipse/mylyn/tests/AllConnectorTests.java
@@ -13,39 +13,26 @@
 
 import org.eclipse.mylyn.bugzilla.rest.core.tests.AllBugzillaRestCoreTests;
 import org.eclipse.mylyn.bugzilla.tests.AllBugzillaTests;
-import org.eclipse.mylyn.commons.sdk.util.ManagedTestSuite;
-import org.eclipse.mylyn.commons.sdk.util.TestConfiguration;
-import org.eclipse.mylyn.commons.sdk.util.TestConfiguration.TestKind;
+import org.eclipse.mylyn.commons.sdk.util.ManagedSuite;
+import org.eclipse.mylyn.commons.sdk.util.ManagedSuite.TestConfigurationProperty;
 import org.eclipse.mylyn.gerrit.tests.AllGerritTests;
 import org.eclipse.mylyn.hudson.tests.AllHudsonTests;
 import org.eclipse.mylyn.tests.util.TestFixture;
 import org.eclipse.mylyn.trac.tests.AllTracTests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
 
 /**
  * @author Shawn Minto
  * @author Steffen Pingel
+ * @author Frank Becker
  */
+@RunWith(ManagedSuite.class)
+@Suite.SuiteClasses({ AllBugzillaRestCoreTests.class, AllBugzillaTests.class, AllHudsonTests.class,
+		AllGerritTests.class, AllTracTests.class })
+@TestConfigurationProperty()
 public class AllConnectorTests {
-
-	public static Test suite() {
+	static {
 		TestFixture.initializeTasksSettings();
-
-		TestConfiguration configuration = new TestConfiguration(TestKind.INTEGRATION);
-
-		TestSuite suite = new ManagedTestSuite(AllConnectorTests.class.getName());
-		addTests(suite, configuration);
-		return suite;
 	}
-
-	static void addTests(TestSuite suite, TestConfiguration configuration) {
-		suite.addTest(AllBugzillaTests.suite(configuration));
-		suite.addTest(AllTracTests.suite(configuration));
-		suite.addTest(AllHudsonTests.suite(configuration));
-		suite.addTest(AllGerritTests.suite(configuration));
-		suite.addTest(AllBugzillaRestCoreTests.suite(configuration));
-	}
-
 }
diff --git a/org.eclipse.mylyn.tests/src/org/eclipse/mylyn/tests/AllHeartbeatTests.java b/org.eclipse.mylyn.tests/src/org/eclipse/mylyn/tests/AllHeartbeatTests.java
index 16239f1..6548ac2 100644
--- a/org.eclipse.mylyn.tests/src/org/eclipse/mylyn/tests/AllHeartbeatTests.java
+++ b/org.eclipse.mylyn.tests/src/org/eclipse/mylyn/tests/AllHeartbeatTests.java
@@ -11,12 +11,11 @@
 
 package org.eclipse.mylyn.tests;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
 import org.eclipse.mylyn.commons.sdk.util.ManagedTestSuite;
 import org.eclipse.mylyn.commons.sdk.util.TestConfiguration;
-import org.eclipse.mylyn.commons.sdk.util.TestConfiguration.TestKind;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
 
 /**
  * @author Steffen Pingel
@@ -24,7 +23,7 @@
 public class AllHeartbeatTests {
 
 	public static Test suite() {
-		TestConfiguration configuration = new TestConfiguration(TestKind.INTEGRATION);
+		TestConfiguration configuration = new TestConfiguration();
 		configuration.setLocalOnly(true);
 
 		TestSuite suite = new ManagedTestSuite(AllHeartbeatTests.class.getName());
diff --git a/org.eclipse.mylyn.tests/src/org/eclipse/mylyn/tests/AllLocalTests.java b/org.eclipse.mylyn.tests/src/org/eclipse/mylyn/tests/AllLocalTests.java
index f7cf784..1a3d8c6 100644
--- a/org.eclipse.mylyn.tests/src/org/eclipse/mylyn/tests/AllLocalTests.java
+++ b/org.eclipse.mylyn.tests/src/org/eclipse/mylyn/tests/AllLocalTests.java
@@ -13,13 +13,14 @@
 
 import org.eclipse.mylyn.bugzilla.rest.core.tests.AllBugzillaRestCoreTests;
 import org.eclipse.mylyn.bugzilla.tests.AllBugzillaTests;
+import org.eclipse.mylyn.commons.sdk.util.ManagedSuite;
 import org.eclipse.mylyn.commons.sdk.util.ManagedTestSuite;
 import org.eclipse.mylyn.commons.sdk.util.TestConfiguration;
-import org.eclipse.mylyn.commons.sdk.util.TestConfiguration.TestKind;
 import org.eclipse.mylyn.gerrit.tests.AllGerritTests;
 import org.eclipse.mylyn.hudson.tests.AllHudsonTests;
 import org.eclipse.mylyn.trac.tests.AllTracTests;
 
+import junit.framework.JUnit4TestAdapter;
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
@@ -29,12 +30,16 @@
 public class AllLocalTests {
 
 	public static Test suite() {
-		TestConfiguration configuration = new TestConfiguration(TestKind.INTEGRATION);
-		configuration.setLocalOnly(true);
+		TestConfiguration testConfiguration = ManagedSuite.getTestConfiguration();
+		if (testConfiguration == null) {
+			TestConfiguration configuration = new TestConfiguration();
+			configuration.setLocalOnly(true);
+			ManagedSuite.setTestConfiguration(configuration);
+		}
 
 		TestSuite suite = new ManagedTestSuite(AllLocalTests.class.getName());
-		AllNonConnectorTests.addTests(suite, configuration);
-		addTests(suite, configuration);
+		AllNonConnectorTests.addTests(suite, testConfiguration);
+		addTests(suite, testConfiguration);
 		return suite;
 	}
 
@@ -43,7 +48,7 @@
 		suite.addTest(AllTracTests.suite(configuration));
 		suite.addTest(AllHudsonTests.suite(configuration));
 		suite.addTest(AllGerritTests.suite(configuration));
-		suite.addTest(AllBugzillaRestCoreTests.suite(configuration));
+		suite.addTest(new JUnit4TestAdapter(AllBugzillaRestCoreTests.class));
 	}
 
 }
diff --git a/org.eclipse.mylyn.tests/src/org/eclipse/mylyn/tests/AllTests.java b/org.eclipse.mylyn.tests/src/org/eclipse/mylyn/tests/AllTests.java
index f3aa180..a67face 100644
--- a/org.eclipse.mylyn.tests/src/org/eclipse/mylyn/tests/AllTests.java
+++ b/org.eclipse.mylyn.tests/src/org/eclipse/mylyn/tests/AllTests.java
@@ -11,12 +11,13 @@
 
 package org.eclipse.mylyn.tests;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
+import org.eclipse.mylyn.commons.sdk.util.ManagedSuite;
 import org.eclipse.mylyn.commons.sdk.util.ManagedTestSuite;
 import org.eclipse.mylyn.commons.sdk.util.TestConfiguration;
-import org.eclipse.mylyn.commons.sdk.util.TestConfiguration.TestKind;
+
+import junit.framework.JUnit4TestAdapter;
+import junit.framework.Test;
+import junit.framework.TestSuite;
 
 /**
  * @author Mik Kersten
@@ -24,11 +25,15 @@
 public class AllTests {
 
 	public static Test suite() {
-		TestConfiguration configuration = new TestConfiguration(TestKind.INTEGRATION);
+		TestConfiguration configuration = ManagedSuite.getTestConfiguration();
+		if (configuration == null) {
+			configuration = new TestConfiguration();
+			ManagedSuite.setTestConfiguration(configuration);
+		}
 
 		TestSuite suite = new ManagedTestSuite(AllTests.class.getName());
 		AllNonConnectorTests.addTests(suite, configuration);
-		AllConnectorTests.addTests(suite, configuration);
+		suite.addTest(new JUnit4TestAdapter(AllConnectorTests.class));
 		return suite;
 	}