Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/TestFixture.java20
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracClientManager.java4
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracFixture.java24
3 files changed, 29 insertions, 19 deletions
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 4b2bb0252..e5c6f36cd 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
@@ -38,6 +38,7 @@ 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) {
@@ -53,6 +54,7 @@ public abstract class TestFixture {
getDefault().activate();
}
}
+
}
/**
@@ -95,13 +97,13 @@ public abstract class TestFixture {
private final String connectorKind;
- private String simpleInfo;
+ private String repositoryName;
protected final String repositoryUrl;
- private TestSuite suite;
+ private String simpleInfo;
- private String repositoryName;
+ private TestSuite suite;
public TestFixture(String connectorKind, String repositoryUrl) {
this.connectorKind = connectorKind;
@@ -110,13 +112,14 @@ public abstract class TestFixture {
protected abstract TestFixture activate();
- protected abstract TestFixture getDefault();
-
public void add(Class<? extends TestCase> clazz) {
Assert.isNotNull(suite, "Invoke createSuite() first");
suite.addTestSuite(clazz);
}
+ protected void configureRepository(TaskRepository repository) {
+ }
+
public AbstractRepositoryConnector connector() {
return connector;
}
@@ -138,6 +141,8 @@ public abstract class TestFixture {
return connectorKind;
}
+ protected abstract TestFixture getDefault();
+
public String getInfo() {
return repositoryName + " " + simpleInfo;
}
@@ -183,6 +188,9 @@ public abstract class TestFixture {
return repository;
}
+ protected void resetRepositories() {
+ }
+
protected void setInfo(String repositoryName, String version, String description) {
Assert.isNotNull(repositoryName);
Assert.isNotNull(version);
@@ -196,11 +204,13 @@ public abstract class TestFixture {
public TaskRepository singleRepository() {
TaskRepositoryManager manager = TasksUiPlugin.getRepositoryManager();
manager.clearRepositories();
+ resetRepositories();
TaskRepository repository = new TaskRepository(connectorKind, repositoryUrl);
Credentials credentials = TestUtil.readCredentials(PrivilegeLevel.USER);
repository.setCredentials(AuthenticationType.REPOSITORY, new AuthenticationCredentials(credentials.username,
credentials.password), false);
+ configureRepository(repository);
manager.addRepository(repository);
return repository;
}
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracClientManager.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracClientManager.java
index 8a0cb7a33..59d82052d 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracClientManager.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracClientManager.java
@@ -80,6 +80,10 @@ public class TracClientManager implements IRepositoryListener {
clientDataByUrl.remove(repository.getRepositoryUrl());
}
+ public void clearClients() {
+ clientByUrl.clear();
+ }
+
private void removeClient(TaskRepository repository) {
clientByUrl.remove(repository.getRepositoryUrl());
}
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 975e2aa0a..b06672ff0 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
@@ -13,12 +13,8 @@ package org.eclipse.mylyn.trac.tests.support;
import java.net.Proxy;
-import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
-import org.eclipse.mylyn.commons.net.AuthenticationType;
import org.eclipse.mylyn.commons.net.IProxyProvider;
import org.eclipse.mylyn.commons.net.WebLocation;
-import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryManager;
-import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.trac.core.TracClientFactory;
import org.eclipse.mylyn.internal.trac.core.TracCorePlugin;
import org.eclipse.mylyn.internal.trac.core.client.ITracClient;
@@ -202,21 +198,21 @@ public class TracFixture extends TestFixture {
@Override
public TaskRepository singleRepository() {
TracCorePlugin.getDefault().getConnector().getClientManager().writeCache();
- TaskRepositoryManager manager = TasksUiPlugin.getRepositoryManager();
- manager.clearRepositories();
+ TaskRepository repository = super.singleRepository();
+ TracCorePlugin.getDefault().getConnector().getClientManager().readCache();
+ return repository;
+ }
- Credentials credentials = TestUtil.readCredentials(PrivilegeLevel.USER);
- TaskRepository repository = new TaskRepository(TracCorePlugin.CONNECTOR_KIND, repositoryUrl);
- repository.setCredentials(AuthenticationType.REPOSITORY, new AuthenticationCredentials(credentials.username,
- credentials.password), false);
+ @Override
+ protected void configureRepository(TaskRepository repository) {
repository.setTimeZoneId(ITracClient.TIME_ZONE);
repository.setCharacterEncoding(ITracClient.CHARSET);
repository.setVersion(accessMode.name());
+ }
- manager.addRepository(repository);
- TracCorePlugin.getDefault().getConnector().getClientManager().readCache();
-
- return repository;
+ @Override
+ protected void resetRepositories() {
+ TracCorePlugin.getDefault().getConnector().getClientManager().clearClients();
}
// private static void initializeRepository(XmlRpcServer server) throws Exception {

Back to the top