Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2009-09-23 03:13:44 -0400
committerspingel2009-09-23 03:13:44 -0400
commit6659979febe99142ebe1c9bc9a7f828f6d10dac9 (patch)
tree08e84595d9680110fc1946383f722aa6a0ae3d8b
parent1e6cc032fd7e445ddc75eb35f51f6a13c304c8ba (diff)
downloadorg.eclipse.mylyn.tasks-6659979febe99142ebe1c9bc9a7f828f6d10dac9.tar.gz
org.eclipse.mylyn.tasks-6659979febe99142ebe1c9bc9a7f828f6d10dac9.tar.xz
org.eclipse.mylyn.tasks-6659979febe99142ebe1c9bc9a7f828f6d10dac9.zip
NEW - bug 290198: move test utilities to a separate plug-in
https://bugs.eclipse.org/bugs/show_bug.cgi?id=290198
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaHeadlessStandaloneTests.java8
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaFixture.java5
-rw-r--r--org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/TestFixture.java44
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AllTracHeadlessStandaloneTests.java14
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AllTracTests.java12
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracFixture.java7
6 files changed, 63 insertions, 27 deletions
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaHeadlessStandaloneTests.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaHeadlessStandaloneTests.java
index afa71866e..a5e2f6a40 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaHeadlessStandaloneTests.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaHeadlessStandaloneTests.java
@@ -31,12 +31,12 @@ public class AllBugzillaHeadlessStandaloneTests {
suite.addTestSuite(BugzillaConfigurationTest.class);
suite.addTestSuite(BugzillaVersionTest.class);
for (BugzillaFixture fixture : BugzillaFixture.ALL) {
- TestSuite fixtureSuite = fixture.createSuite();
- fixture.add(fixtureSuite, BugzillaClientTest.class);
+ fixture.createSuite(suite);
+ fixture.add(BugzillaClientTest.class);
// XXX: re-enable when webservice is used for retrieval of history
// fixture.add(fixtureSuite, BugzillaTaskHistoryTest.class);
- fixture.add(fixtureSuite, BugzillaRepositoryConnectorStandaloneTest.class);
- suite.addTest(fixtureSuite);
+ fixture.add(BugzillaRepositoryConnectorStandaloneTest.class);
+ fixture.done();
}
return suite;
}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaFixture.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaFixture.java
index 26c0c130a..3dd9e892b 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaFixture.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/support/BugzillaFixture.java
@@ -114,6 +114,11 @@ public class BugzillaFixture extends TestFixture {
return this;
}
+ @Override
+ protected TestFixture getDefault() {
+ return DEFAULT;
+ }
+
public String getVersion() {
return version;
}
diff --git a/org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/TestFixture.java b/org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/TestFixture.java
index f46bc10eb..bdb41c48b 100644
--- a/org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/TestFixture.java
+++ b/org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/TestFixture.java
@@ -16,6 +16,7 @@ import java.net.Proxy;
import junit.framework.TestCase;
import junit.framework.TestSuite;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.mylyn.commons.net.AbstractWebLocation;
import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
import org.eclipse.mylyn.commons.net.AuthenticationType;
@@ -36,6 +37,24 @@ import org.eclipse.mylyn.tests.util.TestUtil.PrivilegeLevel;
*/
public abstract class TestFixture {
+ private final class Activation extends TestCase {
+ private final boolean activate;
+
+ private Activation(String name, boolean activate) {
+ super(name);
+ this.activate = activate;
+ }
+
+ @Override
+ protected void runTest() throws Throwable {
+ if (activate) {
+ activate();
+ } else {
+ getDefault().activate();
+ }
+ }
+ }
+
/**
* Clears all tasks.
*/
@@ -80,6 +99,8 @@ public abstract class TestFixture {
protected final String repositoryUrl;
+ private TestSuite suite;
+
public TestFixture(String connectorKind, String repositoryUrl) {
this.connectorKind = connectorKind;
this.repositoryUrl = repositoryUrl;
@@ -87,7 +108,10 @@ public abstract class TestFixture {
protected abstract TestFixture activate();
- public void add(TestSuite suite, Class<? extends TestCase> clazz) {
+ protected abstract TestFixture getDefault();
+
+ public void add(Class<? extends TestCase> clazz) {
+ Assert.isNotNull(suite, "Invoke createSuite() first");
if (Boolean.parseBoolean(System.getProperty("mylyn.tests.annotate")) && getInfo() != null) {
suite.addTest(new TestSuite(clazz, clazz.getName() + " [" + getInfo() + "]"));
} else {
@@ -99,17 +123,19 @@ public abstract class TestFixture {
return connector;
}
- public TestSuite createSuite() {
- TestSuite suite = new TestSuite("Testing on " + getInfo());
- suite.addTest(new TestCase("activiating " + getRepositoryUrl()) {
- @Override
- protected void runTest() throws Throwable {
- activate();
- }
- });
+ public TestSuite createSuite(TestSuite parentSuite) {
+ suite = new TestSuite("Testing on " + getInfo());
+ parentSuite.addTest(suite);
+ suite.addTest(new Activation("repository: " + getRepositoryUrl() + " [" + getInfo() + "]", true));
return suite;
}
+ public void done() {
+ Assert.isNotNull(suite, "Invoke createSuite() first");
+ suite.addTest(new Activation("done", false));
+ suite = null;
+ }
+
public String getConnectorKind() {
return connectorKind;
}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AllTracHeadlessStandaloneTests.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AllTracHeadlessStandaloneTests.java
index f6097af8a..3ff73dc21 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AllTracHeadlessStandaloneTests.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AllTracHeadlessStandaloneTests.java
@@ -42,18 +42,18 @@ public class AllTracHeadlessStandaloneTests {
suite.addTestSuite(TracClientManagerTest.class);
// network tests
for (TracFixture fixture : TracFixture.ALL) {
- TestSuite fixtureSuite = fixture.createSuite();
- fixture.add(fixtureSuite, TracClientTest.class);
+ fixture.createSuite(suite);
+ fixture.add(TracClientTest.class);
if (fixture.getAccessMode() == Version.XML_RPC) {
- fixture.add(fixtureSuite, TracXmlRpcClientTest.class);
+ fixture.add(TracXmlRpcClientTest.class);
}
- suite.addTest(fixtureSuite);
+ fixture.done();
}
// validation tests
for (TracFixture fixture : TracFixture.MISC) {
- TestSuite fixtureSuite = fixture.createSuite();
- fixture.add(fixtureSuite, TracClientTest.class);
- suite.addTest(fixtureSuite);
+ fixture.createSuite(suite);
+ fixture.add(TracClientTest.class);
+ fixture.done();
}
return suite;
}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AllTracTests.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AllTracTests.java
index 8d54c46a2..e6104c62e 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AllTracTests.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AllTracTests.java
@@ -41,15 +41,15 @@ public class AllTracTests {
suite.addTestSuite(TracHyperlinkUtilTest.class);
// network tests
for (TracFixture fixture : TracFixture.ALL) {
- TestSuite fixtureSuite = fixture.createSuite();
- fixtureSuite.addTestSuite(TracRepositoryConnectorTest.class);
+ fixture.createSuite(suite);
+ fixture.add(TracRepositoryConnectorTest.class);
if (fixture.getAccessMode() == Version.XML_RPC) {
- fixtureSuite.addTestSuite(TracTaskDataHandlerXmlRpcTest.class);
- fixtureSuite.addTestSuite(TracAttachmentHandlerTest.class);
+ fixture.add(TracTaskDataHandlerXmlRpcTest.class);
+ fixture.add(TracAttachmentHandlerTest.class);
} else {
- fixtureSuite.addTestSuite(TracRepositoryConnectorWebTest.class);
+ fixture.add(TracRepositoryConnectorWebTest.class);
}
- suite.addTest(fixtureSuite);
+ fixture.done();
}
return suite;
}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracFixture.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracFixture.java
index 74934fa8a..e60340590 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracFixture.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracFixture.java
@@ -151,6 +151,11 @@ public class TracFixture extends TestFixture {
return this;
}
+ @Override
+ protected TestFixture getDefault() {
+ return DEFAULT;
+ }
+
public ITracClient connect() throws Exception {
return connect(repositoryUrl);
}
@@ -198,7 +203,7 @@ public class TracFixture extends TestFixture {
public TaskRepository singleRepository() {
TracCorePlugin.getDefault().getConnector().getClientManager().writeCache();
TaskRepositoryManager manager = TasksUiPlugin.getRepositoryManager();
- manager.clearRepositories(TasksUiPlugin.getDefault().getRepositoriesFilePath());
+ manager.clearRepositories();
Credentials credentials = TestUtil.readCredentials(PrivilegeLevel.USER);
TaskRepository repository = new TaskRepository(TracCorePlugin.CONNECTOR_KIND, repositoryUrl);

Back to the top