Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2009-08-29 06:28:52 +0000
committerspingel2009-08-29 06:28:52 +0000
commit7e356e2c6a7bdf8e92457c62f68ed019fbdfc3a1 (patch)
treeba06583f1915c670c3330c1268ebbe6859b78669 /org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac
parent73b181c9568fe77a1be2122afed7ee8553d77218 (diff)
downloadorg.eclipse.mylyn.tasks-7e356e2c6a7bdf8e92457c62f68ed019fbdfc3a1.tar.gz
org.eclipse.mylyn.tasks-7e356e2c6a7bdf8e92457c62f68ed019fbdfc3a1.tar.xz
org.eclipse.mylyn.tasks-7e356e2c6a7bdf8e92457c62f68ed019fbdfc3a1.zip
NEW - bug 287225: implement test suite driver for multiple repositories
https://bugs.eclipse.org/bugs/show_bug.cgi?id=287225
Diffstat (limited to 'org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac')
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AllTracHeadlessStandaloneTests.java23
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AllTracTests.java22
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/AbstractTracClientTest.java126
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracClientProxyTest.java23
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracClientTest.java (renamed from org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/AbstractTracClientRepositoryTest.java)344
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracWebClientTest.java115
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracXmlRpcClientTest.java254
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/RepositorySearchTest.java90
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracAttachmentHandlerTest.java52
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracRepositoryConnectorTest.java145
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracRepositoryConnectorWebTest.java84
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracRepositoryQueryTest.java5
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracTaskDataHandlerXmlRpcTest.java (renamed from org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracTaskDataHandlerTest.java)141
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TestFixture.java120
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracFixture.java240
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracTestCleanupUtil.java21
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracTestUtil.java57
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/ui/TracRepositorySettingsPageTest.java56
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/ui/TracTaskEditorTest.java5
19 files changed, 784 insertions, 1139 deletions
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 e3f80dd5e..6e14bcc55 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
@@ -14,34 +14,41 @@ package org.eclipse.mylyn.trac.tests;
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.eclipse.mylyn.internal.trac.core.client.ITracClient.Version;
import org.eclipse.mylyn.trac.tests.client.TracClientFactoryTest;
import org.eclipse.mylyn.trac.tests.client.TracClientProxyTest;
+import org.eclipse.mylyn.trac.tests.client.TracClientTest;
import org.eclipse.mylyn.trac.tests.client.TracRepositoryInfoTest;
import org.eclipse.mylyn.trac.tests.client.TracSearchTest;
import org.eclipse.mylyn.trac.tests.client.TracTicketTest;
-import org.eclipse.mylyn.trac.tests.client.TracWebClientTest;
import org.eclipse.mylyn.trac.tests.client.TracXmlRpcClientTest;
import org.eclipse.mylyn.trac.tests.core.TracClientManagerTest;
+import org.eclipse.mylyn.trac.tests.support.TracFixture;
/**
- * @author Mik Kersten
* @author Steffen Pingel
*/
public class AllTracHeadlessStandaloneTests {
public static Test suite() {
TestSuite suite = new TestSuite("Headless Standalone Tests for org.eclipse.mylyn.trac.tests");
- // other
- suite.addTestSuite(TracClientManagerTest.class);
- // client
+ // client tests
suite.addTestSuite(TracSearchTest.class);
suite.addTestSuite(TracTicketTest.class);
suite.addTestSuite(TracRepositoryInfoTest.class);
- suite.addTestSuite(TracXmlRpcClientTest.class);
- suite.addTestSuite(TracWebClientTest.class);
suite.addTestSuite(TracClientFactoryTest.class);
suite.addTestSuite(TracClientProxyTest.class);
+ // core tests
+ suite.addTestSuite(TracClientManagerTest.class);
+ // network tests
+ for (TracFixture fixture : TracFixture.ALL) {
+ TestSuite fixtureSuite = fixture.createSuite();
+ fixtureSuite.addTestSuite(TracClientTest.class);
+ if (fixture.getAccessMode() == Version.XML_RPC) {
+ fixtureSuite.addTestSuite(TracXmlRpcClientTest.class);
+ }
+ suite.addTest(fixtureSuite);
+ }
return suite;
}
-
} \ No newline at end of file
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 8961d99f6..8d54c46a2 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
@@ -14,12 +14,14 @@ package org.eclipse.mylyn.trac.tests;
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.eclipse.mylyn.trac.tests.core.RepositorySearchTest;
+import org.eclipse.mylyn.internal.trac.core.client.ITracClient.Version;
import org.eclipse.mylyn.trac.tests.core.TracAttachmentHandlerTest;
import org.eclipse.mylyn.trac.tests.core.TracRepositoryConnectorTest;
+import org.eclipse.mylyn.trac.tests.core.TracRepositoryConnectorWebTest;
import org.eclipse.mylyn.trac.tests.core.TracRepositoryQueryTest;
-import org.eclipse.mylyn.trac.tests.core.TracTaskDataHandlerTest;
+import org.eclipse.mylyn.trac.tests.core.TracTaskDataHandlerXmlRpcTest;
import org.eclipse.mylyn.trac.tests.core.TracUtilTest;
+import org.eclipse.mylyn.trac.tests.support.TracFixture;
import org.eclipse.mylyn.trac.tests.ui.TracHyperlinkUtilTest;
import org.eclipse.mylyn.trac.tests.ui.TracRepositorySettingsPageTest;
@@ -32,15 +34,23 @@ public class AllTracTests {
public static Test suite() {
TestSuite suite = new TestSuite("Tests for org.eclipse.mylyn.trac.tests");
suite.addTest(AllTracHeadlessStandaloneTests.suite());
- suite.addTestSuite(TracRepositoryConnectorTest.class);
suite.addTestSuite(TracUtilTest.class);
suite.addTestSuite(TracRepositoryQueryTest.class);
- suite.addTestSuite(TracAttachmentHandlerTest.class);
- suite.addTestSuite(RepositorySearchTest.class);
- suite.addTestSuite(TracTaskDataHandlerTest.class);
// XXX fails when run from continuous build: suite.addTestSuite(TracTaskEditorTest.class);
suite.addTestSuite(TracRepositorySettingsPageTest.class);
suite.addTestSuite(TracHyperlinkUtilTest.class);
+ // network tests
+ for (TracFixture fixture : TracFixture.ALL) {
+ TestSuite fixtureSuite = fixture.createSuite();
+ fixtureSuite.addTestSuite(TracRepositoryConnectorTest.class);
+ if (fixture.getAccessMode() == Version.XML_RPC) {
+ fixtureSuite.addTestSuite(TracTaskDataHandlerXmlRpcTest.class);
+ fixtureSuite.addTestSuite(TracAttachmentHandlerTest.class);
+ } else {
+ fixtureSuite.addTestSuite(TracRepositoryConnectorWebTest.class);
+ }
+ suite.addTest(fixtureSuite);
+ }
return suite;
}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/AbstractTracClientTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/AbstractTracClientTest.java
deleted file mode 100644
index 3c73f2374..000000000
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/AbstractTracClientTest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Steffen Pingel and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Steffen Pingel - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.mylyn.trac.tests.client;
-
-import java.net.Proxy;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.mylyn.commons.net.IProxyProvider;
-import org.eclipse.mylyn.commons.net.WebLocation;
-import org.eclipse.mylyn.context.tests.support.TestUtil;
-import org.eclipse.mylyn.context.tests.support.TestUtil.Credentials;
-import org.eclipse.mylyn.context.tests.support.TestUtil.PrivilegeLevel;
-import org.eclipse.mylyn.internal.trac.core.TracClientFactory;
-import org.eclipse.mylyn.internal.trac.core.client.ITracClient;
-import org.eclipse.mylyn.internal.trac.core.client.ITracClient.Version;
-import org.eclipse.mylyn.internal.trac.core.model.TracTicket;
-import org.eclipse.mylyn.trac.tests.support.TracTestConstants;
-import org.eclipse.mylyn.trac.tests.support.XmlRpcServer.Ticket;
-
-/**
- * Provides a base implementation for test cases that access trac repositories.
- *
- * @author Steffen Pingel
- */
-public abstract class AbstractTracClientTest extends TestCase {
-
- public String repositoryUrl;
-
- public ITracClient client;
-
- public String username;
-
- public String password;
-
- public Version version;
-
- private final PrivilegeLevel level;
-
- final IProgressMonitor callback = new NullProgressMonitor();
-
- public AbstractTracClientTest(Version version, PrivilegeLevel level) {
- this.version = version;
- this.level = level;
- }
-
- public AbstractTracClientTest(Version version) {
- this(version, PrivilegeLevel.USER);
- }
-
- public AbstractTracClientTest() {
- this(null, PrivilegeLevel.USER);
- }
-
- public ITracClient connect096() throws Exception {
- return connect(TracTestConstants.TEST_TRAC_096_URL);
- }
-
- public ITracClient connect010() throws Exception {
- return connect(TracTestConstants.TEST_TRAC_010_URL);
- }
-
- public ITracClient connect010DigestAuth() throws Exception {
- return connect(TracTestConstants.TEST_TRAC_010_DIGEST_AUTH_URL);
- }
-
- public ITracClient connect011() throws Exception {
- return connect(TracTestConstants.TEST_TRAC_011_URL);
- }
-
- public ITracClient connect(String url) throws Exception {
- return connect(url, Proxy.NO_PROXY);
- }
-
- public ITracClient connect(String url, Proxy proxy) throws Exception {
- Credentials credentials = TestUtil.readCredentials(level);
- return connect(url, credentials.username, credentials.password, proxy);
- }
-
- public ITracClient connect(String url, String username, String password) throws Exception {
- return connect(url, username, password, Proxy.NO_PROXY);
- }
-
- public ITracClient connect(String url, String username, String password, Proxy proxy) throws Exception {
- return connect(url, username, password, proxy, version);
- }
-
- public ITracClient connect(String url, String username, String password, final Proxy proxy, Version version)
- throws Exception {
- this.repositoryUrl = url;
- this.username = username;
- this.password = password;
-
- WebLocation location = new WebLocation(url, username, password, new IProxyProvider() {
- public Proxy getProxyForHost(String host, String proxyType) {
- return proxy;
- }
- });
- this.client = TracClientFactory.createClient(location, version);
-
- return this.client;
- }
-
- protected void assertTicketEquals(Ticket ticket, TracTicket tracTicket) throws Exception {
- assertTrue(tracTicket.isValid());
-
- Map<?, ?> expectedValues = ticket.getValues();
- Map<String, String> values = tracTicket.getValues();
- for (String key : values.keySet()) {
- assertEquals("Values for key '" + key + "' did not match", expectedValues.get(key), values.get(key));
- }
- }
-
-}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracClientProxyTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracClientProxyTest.java
index 3f3c1dfe9..c2db49dba 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracClientProxyTest.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracClientProxyTest.java
@@ -15,13 +15,22 @@ import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.Proxy.Type;
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.mylyn.commons.net.IProxyProvider;
+import org.eclipse.mylyn.commons.net.WebLocation;
+import org.eclipse.mylyn.internal.trac.core.TracClientFactory;
import org.eclipse.mylyn.internal.trac.core.client.ITracClient;
import org.eclipse.mylyn.internal.trac.core.client.TracException;
import org.eclipse.mylyn.internal.trac.core.client.ITracClient.Version;
import org.eclipse.mylyn.trac.tests.support.TestProxy;
import org.eclipse.mylyn.trac.tests.support.TracTestConstants;
-public class TracClientProxyTest extends AbstractTracClientTest {
+/**
+ * @author Steffen Pingel
+ */
+public class TracClientProxyTest extends TestCase {
private TestProxy testProxy;
@@ -29,6 +38,8 @@ public class TracClientProxyTest extends AbstractTracClientTest {
private int proxyPort;
+ private Version version;
+
public TracClientProxyTest() {
}
@@ -70,12 +81,16 @@ public class TracClientProxyTest extends AbstractTracClientTest {
private void connectProxy(String url, String expectedMethod) throws Exception {
testProxy.setResponse(TestProxy.NOT_FOUND);
proxy = new Proxy(Type.HTTP, new InetSocketAddress("localhost", proxyPort));
- ITracClient client = connect(url, proxy);
+ WebLocation location = new WebLocation(url, "", "", new IProxyProvider() {
+ public Proxy getProxyForHost(String host, String proxyType) {
+ return proxy;
+ }
+ });
+ ITracClient client = TracClientFactory.createClient(location, version);
try {
- client.validate(callback);
+ client.validate(new NullProgressMonitor());
} catch (TracException e) {
}
-
assertEquals(expectedMethod, testProxy.getRequest().getMethod());
}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/AbstractTracClientRepositoryTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracClientTest.java
index 93bd7029b..53d7edce2 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/AbstractTracClientRepositoryTest.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracClientTest.java
@@ -15,20 +15,27 @@ import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.Proxy.Type;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
import java.util.List;
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.mylyn.context.tests.support.TestUtil;
import org.eclipse.mylyn.context.tests.support.TestUtil.Credentials;
import org.eclipse.mylyn.context.tests.support.TestUtil.PrivilegeLevel;
import org.eclipse.mylyn.internal.trac.core.client.ITracClient;
import org.eclipse.mylyn.internal.trac.core.client.TracException;
import org.eclipse.mylyn.internal.trac.core.client.TracLoginException;
+import org.eclipse.mylyn.internal.trac.core.client.TracPermissionDeniedException;
import org.eclipse.mylyn.internal.trac.core.client.ITracClient.Version;
import org.eclipse.mylyn.internal.trac.core.model.TracSearch;
import org.eclipse.mylyn.internal.trac.core.model.TracTicket;
+import org.eclipse.mylyn.internal.trac.core.model.TracVersion;
import org.eclipse.mylyn.internal.trac.core.model.TracTicket.Key;
-import org.eclipse.mylyn.trac.tests.support.TestFixture;
-import org.eclipse.mylyn.trac.tests.support.TracTestConstants;
+import org.eclipse.mylyn.trac.tests.support.TracFixture;
+import org.eclipse.mylyn.trac.tests.support.TracTestUtil;
import org.eclipse.mylyn.trac.tests.support.XmlRpcServer.TestData;
import org.eclipse.mylyn.trac.tests.support.XmlRpcServer.Ticket;
@@ -37,21 +44,26 @@ import org.eclipse.mylyn.trac.tests.support.XmlRpcServer.Ticket;
*
* @author Steffen Pingel
*/
-public class AbstractTracClientRepositoryTest extends AbstractTracClientTest {
+public class TracClientTest extends TestCase {
- protected List<Ticket> tickets;
+ private ITracClient client;
private TestData data;
- public AbstractTracClientRepositoryTest(Version version) {
- super(version);
+ private TracFixture fixture;
+
+ protected List<Ticket> tickets;
+
+ public TracClientTest() {
}
@Override
protected void setUp() throws Exception {
super.setUp();
- data = TestFixture.init010();
+ fixture = TracFixture.current();
+ client = fixture.connect();
+ data = TracFixture.init010();
tickets = data.tickets;
}
@@ -62,116 +74,18 @@ public class AbstractTracClientRepositoryTest extends AbstractTracClientTest {
// TestFixture.cleanupRepository1();
}
- public void testValidate010() throws Exception {
- validate(TracTestConstants.TEST_TRAC_010_URL);
- }
-
- public void testValidate010DigestAuth() throws Exception {
- validate(TracTestConstants.TEST_TRAC_010_DIGEST_AUTH_URL);
- }
-
- public void testValidate011() throws Exception {
- validate(TracTestConstants.TEST_TRAC_011_URL);
- }
-
- public void testValidate010FormAuth() throws Exception {
- validate(TracTestConstants.TEST_TRAC_010_FORM_AUTH_URL);
- }
-
- protected void validate(String url) throws Exception {
- Credentials credentials = TestUtil.readCredentials(PrivilegeLevel.USER);
-
- // standard connect
- connect(url);
- client.validate(callback);
-
- // invalid url
- connect("http://non.existant/repository");
- try {
- client.validate(callback);
- fail("Expected TracException");
- } catch (TracException e) {
- }
-
- // invalid password
- connect(url, credentials.username, "wrongpassword");
- try {
- client.validate(callback);
- fail("Expected TracLoginException");
- } catch (TracLoginException e) {
- }
-
- // invalid username
- connect(url, "wrongusername", credentials.password);
- try {
- client.validate(callback);
- fail("Expected TracLoginException");
- } catch (TracLoginException e) {
- }
- }
-
- public void testProxy() throws Exception {
- connect(TracTestConstants.TEST_TRAC_010_URL, "", "", new Proxy(Type.HTTP, new InetSocketAddress(
- "invalidhostname", 8080)));
- try {
- client.validate(callback);
- fail("Expected IOException");
- } catch (TracException e) {
- }
- }
-
- public void testGetTicket096() throws Exception {
- if (version == Version.XML_RPC) {
- return;
- }
-
- connect096();
- getTicket();
- }
-
- public void testGetTicket010() throws Exception {
- connect010();
- getTicket();
- }
-
- public void testGetTicket011() throws Exception {
- if (version == Version.TRAC_0_9) {
- // XXX web mode is broken for Trac 0.11: need to fix bug 175211
- return;
- }
-
- connect011();
- getTicket();
- }
-
- private void getTicket() throws Exception {
+ public void testGetTicket() throws Exception {
TracTicket ticket = client.getTicket(tickets.get(0).getId(), null);
- assertTicketEquals(tickets.get(0), ticket);
+ TracTestUtil.assertTicketEquals(tickets.get(0), ticket);
ticket = client.getTicket(tickets.get(1).getId(), null);
- assertTicketEquals(tickets.get(1), ticket);
+ TracTestUtil.assertTicketEquals(tickets.get(1), ticket);
}
- public void testGetTicketInvalidId096() throws Exception {
- if (version == Version.XML_RPC) {
- return;
- }
-
- connect096();
- getTicketInvalidId();
- }
-
- public void testGetTicketInvalidId010() throws Exception {
- connect010();
- getTicketInvalidId();
- }
-
- public void testGetTicketInvalidId011() throws Exception {
- connect011();
- getTicketInvalidId();
- }
-
- private void getTicketInvalidId() throws Exception {
+ public void testGetTicketInvalidId() throws Exception {
+// if (version == Version.XML_RPC) {
+// return;
+// }
try {
client.getTicket(Integer.MAX_VALUE, null);
fail("Expected TracException");
@@ -180,41 +94,30 @@ public class AbstractTracClientRepositoryTest extends AbstractTracClientTest {
}
public void testGetTicketUmlaute010() throws Exception {
- connect010();
- getTicketUmlaute();
- }
-
- public void testGetTicketUmlaute011() throws Exception {
- if (version == Version.TRAC_0_9) {
- // XXX need to fix bug 175211
- return;
- }
-
- connect011();
- getTicketUmlaute();
- }
-
- private void getTicketUmlaute() throws Exception {
+// if (version == Version.TRAC_0_9) {
+// // XXX need to fix bug 175211
+// return;
+// }
TracTicket ticket = client.getTicket(data.htmlEntitiesTicketId, null);
assertEquals("test html entities: \u00E4\u00F6\u00FC", ticket.getValue(Key.SUMMARY));
- if (version == Version.XML_RPC) {
+ if (client.getAccessMode() == Version.XML_RPC) {
assertEquals("\u00C4\u00D6\u00DC\n\nmulti\nline\n\n'''bold'''\n", ticket.getValue(Key.DESCRIPTION));
} else {
assertEquals(null, ticket.getValue(Key.DESCRIPTION));
}
}
- public void testSearchAll010() throws Exception {
- connect010();
- searchAll();
- }
-
- public void testSearchAll011() throws Exception {
- connect011();
- searchAll();
+ public void testProxy() throws Exception {
+ client = fixture.connect(fixture.getRepositoryUrl(), "", "", new Proxy(Type.HTTP, new InetSocketAddress(
+ "invalidhostname", 8080)));
+ try {
+ client.validate(new NullProgressMonitor());
+ fail("Expected IOException");
+ } catch (TracException e) {
+ }
}
- private void searchAll() throws Exception {
+ public void testSearchAll() throws Exception {
TracSearch search = new TracSearch();
List<TracTicket> result = new ArrayList<TracTicket>();
client.search(search, result, null);
@@ -222,17 +125,7 @@ public class AbstractTracClientRepositoryTest extends AbstractTracClientTest {
assertTrue(result.size() >= tickets.size());
}
- public void testSearchEmpty010() throws Exception {
- connect010();
- searchEmpty();
- }
-
- public void testSearchEmpty011() throws Exception {
- connect011();
- searchEmpty();
- }
-
- private void searchEmpty() throws Exception {
+ public void testSearchEmpty() throws Exception {
TracSearch search = new TracSearch();
search.addFilter("milestone", "does not exist");
List<TracTicket> result = new ArrayList<TracTicket>();
@@ -240,36 +133,28 @@ public class AbstractTracClientRepositoryTest extends AbstractTracClientTest {
assertEquals(0, result.size());
}
- public void testSearchMilestone1_010() throws Exception {
- connect010();
- searchMilestone1();
- }
-
- public void testSearchMilestone1_011() throws Exception {
- connect011();
- searchMilestone1();
- }
-
- private void searchMilestone1() throws Exception {
+ public void testSearchExactMatch010() throws Exception {
TracSearch search = new TracSearch();
search.addFilter("milestone", "milestone1");
+ search.addFilter("summary", "summary1");
List<TracTicket> result = new ArrayList<TracTicket>();
client.search(search, result, null);
assertEquals(1, result.size());
- assertTicketEquals(tickets.get(0), result.get(0));
- }
-
- public void testSearchMilestone2_0_10() throws Exception {
- connect010();
- searchMilestone2();
+ TracTestUtil.assertTicketEquals(tickets.get(0), result.get(0));
+ assertEquals("milestone1", result.get(0).getValue(Key.MILESTONE));
+ assertEquals("summary1", result.get(0).getValue(Key.SUMMARY));
}
- public void testSearchMilestone2_0_11() throws Exception {
- connect011();
- searchMilestone2();
+ public void testSearchMilestone1() throws Exception {
+ TracSearch search = new TracSearch();
+ search.addFilter("milestone", "milestone1");
+ List<TracTicket> result = new ArrayList<TracTicket>();
+ client.search(search, result, null);
+ assertEquals(1, result.size());
+ TracTestUtil.assertTicketEquals(tickets.get(0), result.get(0));
}
- private void searchMilestone2() throws Exception {
+ public void testSearchMilestone2() throws Exception {
TracSearch search = new TracSearch();
search.addFilter("milestone", "milestone1");
search.addFilter("milestone", "milestone2");
@@ -277,47 +162,110 @@ public class AbstractTracClientRepositoryTest extends AbstractTracClientTest {
List<TracTicket> result = new ArrayList<TracTicket>();
client.search(search, result, null);
assertEquals(3, result.size());
- assertTicketEquals(tickets.get(0), result.get(0));
- assertTicketEquals(tickets.get(1), result.get(1));
- assertTicketEquals(tickets.get(2), result.get(2));
- }
-
- public void testSearchExactMatch010() throws Exception {
- connect010();
- searchExactMatch();
- }
-
- public void testSearchExactMatch011() throws Exception {
- connect011();
- searchExactMatch();
+ TracTestUtil.assertTicketEquals(tickets.get(0), result.get(0));
+ TracTestUtil.assertTicketEquals(tickets.get(1), result.get(1));
+ TracTestUtil.assertTicketEquals(tickets.get(2), result.get(2));
}
- private void searchExactMatch() throws Exception {
+ public void testSearchMilestoneAmpersand() throws Exception {
+ // XXX re-enable for XML-RPC when bug 162094 is resolved
+ if (client.getAccessMode() == Version.XML_RPC) {
+ return;
+ }
TracSearch search = new TracSearch();
- search.addFilter("milestone", "milestone1");
- search.addFilter("summary", "summary1");
+ search.addFilter("milestone", "mile&stone");
+ search.setOrderBy("id");
List<TracTicket> result = new ArrayList<TracTicket>();
client.search(search, result, null);
assertEquals(1, result.size());
- assertTicketEquals(tickets.get(0), result.get(0));
- assertEquals("milestone1", result.get(0).getValue(Key.MILESTONE));
- assertEquals("summary1", result.get(0).getValue(Key.SUMMARY));
+ TracTestUtil.assertTicketEquals(tickets.get(7), result.get(0));
+ }
+
+ public void testStatusClosed() throws Exception {
+ TracTicket ticket = client.getTicket(data.offlineHandlerTicketId, null);
+ assertEquals("closed", ticket.getValue(Key.STATUS));
+ assertEquals("fixed", ticket.getValue(Key.RESOLUTION));
}
- public void testStatusClosed010() throws Exception {
- connect010();
- statusClosed();
+ public void testUpdateAttributesAnonymous() throws Exception {
+ client = fixture.connect(fixture.getRepositoryUrl(), "", "");
+ assertNull(client.getMilestones());
+ try {
+ client.updateAttributes(new NullProgressMonitor(), true);
+ if (fixture.getAccessMode() == Version.XML_RPC) {
+ fail("Expected anonymous access to be denied");
+ }
+ } catch (TracPermissionDeniedException e) {
+ if (fixture.getAccessMode() == Version.XML_RPC) {
+ return; // expected exception, done here
+ }
+ throw e;
+ }
+ TracVersion[] versions = client.getVersions();
+ assertEquals(2, versions.length);
+ Arrays.sort(versions, new Comparator<TracVersion>() {
+ public int compare(TracVersion o1, TracVersion o2) {
+ return o1.getName().compareTo(o2.getName());
+ }
+ });
+ assertEquals("1.0", versions[0].getName());
+ assertEquals("2.0", versions[1].getName());
+ }
+
+ public void testValidate() throws Exception {
+ Credentials credentials = TestUtil.readCredentials(PrivilegeLevel.USER);
+
+ // standard connect
+ client.validate(new NullProgressMonitor());
+
+ // invalid url
+ client = TracFixture.current().connect("http://non.existant/repository");
+ try {
+ client.validate(new NullProgressMonitor());
+ fail("Expected TracException");
+ } catch (TracException e) {
+ }
+
+ String url = TracFixture.current().getRepositoryUrl();
+
+ // invalid password
+ client = TracFixture.current().connect(url, credentials.username, "wrongpassword");
+ try {
+ client.validate(new NullProgressMonitor());
+ fail("Expected TracLoginException");
+ } catch (TracLoginException e) {
+ }
+
+ // invalid username
+ client = TracFixture.current().connect(url, "wrongusername", credentials.password);
+ try {
+ client.validate(new NullProgressMonitor());
+ fail("Expected TracLoginException");
+ } catch (TracLoginException e) {
+ }
}
- public void testStatusClosed011() throws Exception {
- connect011();
- statusClosed();
+ public void testValidateAnonymousLogin() throws Exception {
+ client = fixture.connect(fixture.getRepositoryUrl(), "", "");
+ try {
+ client.validate(new NullProgressMonitor());
+ if (fixture.getAccessMode() == Version.XML_RPC) {
+ fail("Expected anonymous access to be denied");
+ }
+ } catch (TracPermissionDeniedException e) {
+ if (fixture.getAccessMode() == Version.TRAC_0_9) {
+ fail("Expected anonymous access to be allowed");
+ }
+ }
}
- protected void statusClosed() throws Exception {
- TracTicket ticket = client.getTicket(data.offlineHandlerTicketId, null);
- assertEquals("closed", ticket.getValue(Key.STATUS));
- assertEquals("fixed", ticket.getValue(Key.RESOLUTION));
+ public void testValidateAnyPage() throws Exception {
+ client = fixture.connect("http://mylyn.eclipse.org/");
+ try {
+ client.validate(new NullProgressMonitor());
+ fail("Expected TracException");
+ } catch (TracException e) {
+ }
}
}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracWebClientTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracWebClientTest.java
deleted file mode 100644
index 23990ace4..000000000
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracWebClientTest.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Steffen Pingel and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Steffen Pingel - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.mylyn.trac.tests.client;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.List;
-
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.mylyn.internal.trac.core.client.TracException;
-import org.eclipse.mylyn.internal.trac.core.client.ITracClient.Version;
-import org.eclipse.mylyn.internal.trac.core.model.TracSearch;
-import org.eclipse.mylyn.internal.trac.core.model.TracTicket;
-import org.eclipse.mylyn.internal.trac.core.model.TracVersion;
-import org.eclipse.mylyn.trac.tests.support.TracTestConstants;
-
-/**
- * @author Steffen Pingel
- */
-public class TracWebClientTest extends AbstractTracClientRepositoryTest {
-
- public TracWebClientTest() {
- super(Version.TRAC_0_9);
- }
-
- public void testValidate096() throws Exception {
- validate(TracTestConstants.TEST_TRAC_096_URL);
- }
-
- @Override
- public void testValidate011() throws Exception {
- try {
- validate(TracTestConstants.TEST_TRAC_011_URL);
- } catch (TracException e) {
- }
- }
-
- public void testValidateAnyPage() throws Exception {
- connect("http://mylyn.eclipse.org/");
- try {
- client.validate(callback);
- fail("Expected TracException");
- } catch (TracException e) {
- }
- }
-
- public void testValidateAnonymousLogin() throws Exception {
- connect(TracTestConstants.TEST_TRAC_010_URL, "", "");
- client.validate(callback);
-
- connect(TracTestConstants.TEST_TRAC_096_URL, "", "");
- client.validate(callback);
- }
-
- public void testUpdateAttributesAnonymous096() throws Exception {
- connect(TracTestConstants.TEST_TRAC_096_URL, "", "");
- updateAttributes();
- }
-
- public void testUpdateAttributesAnonymous010() throws Exception {
- connect(TracTestConstants.TEST_TRAC_010_URL, "", "");
- updateAttributes();
- }
-
- private void updateAttributes() throws TracException {
- assertNull(client.getMilestones());
- client.updateAttributes(new NullProgressMonitor(), true);
- TracVersion[] versions = client.getVersions();
- assertEquals(2, versions.length);
- Arrays.sort(versions, new Comparator<TracVersion>() {
- public int compare(TracVersion o1, TracVersion o2) {
- return o1.getName().compareTo(o2.getName());
- }
- });
- assertEquals("1.0", versions[0].getName());
- assertEquals("2.0", versions[1].getName());
- }
-
- // TODO move this test to AbstracTracClientTest when bug 162094 is resolved
- public void testSearchMilestoneAmpersand010() throws Exception {
- connect010();
- searchMilestoneAmpersand();
- }
-
- public void testSearchMilestoneAmpersand011() throws Exception {
- connect011();
- searchMilestoneAmpersand();
- }
-
- private void searchMilestoneAmpersand() throws Exception {
- TracSearch search = new TracSearch();
- search.addFilter("milestone", "mile&stone");
- search.setOrderBy("id");
- List<TracTicket> result = new ArrayList<TracTicket>();
- client.search(search, result, null);
- assertEquals(1, result.size());
- assertTicketEquals(tickets.get(7), result.get(0));
- }
-
- public void testStatusClosed096() throws Exception {
- connect096();
- statusClosed();
- }
-
-}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracXmlRpcClientTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracXmlRpcClientTest.java
index 0fc8da47d..8ff51c784 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracXmlRpcClientTest.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracXmlRpcClientTest.java
@@ -18,11 +18,13 @@ import java.util.Comparator;
import java.util.Date;
import java.util.List;
+import junit.framework.TestCase;
+
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.mylyn.internal.trac.core.client.ITracClient;
import org.eclipse.mylyn.internal.trac.core.client.TracPermissionDeniedException;
import org.eclipse.mylyn.internal.trac.core.client.TracRemoteException;
import org.eclipse.mylyn.internal.trac.core.client.TracXmlRpcClient;
-import org.eclipse.mylyn.internal.trac.core.client.ITracClient.Version;
import org.eclipse.mylyn.internal.trac.core.model.TracAction;
import org.eclipse.mylyn.internal.trac.core.model.TracSearch;
import org.eclipse.mylyn.internal.trac.core.model.TracTicket;
@@ -32,33 +34,42 @@ import org.eclipse.mylyn.internal.trac.core.model.TracWikiPage;
import org.eclipse.mylyn.internal.trac.core.model.TracWikiPageInfo;
import org.eclipse.mylyn.internal.trac.core.model.TracTicket.Key;
import org.eclipse.mylyn.trac.tests.support.TracTestConstants;
+import org.eclipse.mylyn.trac.tests.support.TracFixture;
+import org.eclipse.mylyn.trac.tests.support.TracTestUtil;
+import org.eclipse.mylyn.trac.tests.support.XmlRpcServer.TestData;
+import org.eclipse.mylyn.trac.tests.support.XmlRpcServer.Ticket;
/**
* @author Steffen Pingel
* @author Xiaoyang Guan
*/
-public class TracXmlRpcClientTest extends AbstractTracClientRepositoryTest {
+public class TracXmlRpcClientTest extends TestCase {
- public TracXmlRpcClientTest() {
- super(Version.XML_RPC);
- }
+ protected List<Ticket> tickets;
+
+ private TestData data;
+
+ private ITracClient client;
@Override
- public void testValidate011() throws Exception {
- validate(TracTestConstants.TEST_TRAC_011_URL);
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ client = TracFixture.current().connect();
+ data = TracFixture.init010();
+ tickets = data.tickets;
}
public void testValidateFailNoAuth() throws Exception {
- connect(TracTestConstants.TEST_TRAC_010_URL, "", "");
+ client = TracFixture.current().connect(TracTestConstants.TEST_TRAC_010_URL, "", "");
try {
- client.validate(callback);
+ client.validate(new NullProgressMonitor());
fail("Expected TracPermissiongDeniedException");
} catch (TracPermissionDeniedException e) {
}
}
public void testMulticallExceptions() throws Exception {
- connect010();
try {
((TracXmlRpcClient) client).getTickets(new int[] { 1, Integer.MAX_VALUE }, null);
fail("Expected TracRemoteException");
@@ -66,17 +77,7 @@ public class TracXmlRpcClientTest extends AbstractTracClientRepositoryTest {
}
}
- public void testUpdateAttributes010() throws Exception {
- connect010();
- updateAttributes();
- }
-
- public void testUpdateAttributes011() throws Exception {
- connect011();
- updateAttributes();
- }
-
- public void updateAttributes() throws Exception {
+ public void testUpdateAttributes() throws Exception {
assertNull(client.getMilestones());
client.updateAttributes(new NullProgressMonitor(), true);
TracVersion[] versions = client.getVersions();
@@ -94,23 +95,13 @@ public class TracXmlRpcClientTest extends AbstractTracClientRepositoryTest {
assertEquals(new Date(0), versions[1].getTime());
}
- public void testSearchValidateTicket010() throws Exception {
- connect010();
- searchValidateTicket();
- }
-
- public void testSearchValidateTicket011() throws Exception {
- connect011();
- searchValidateTicket();
- }
-
- public void searchValidateTicket() throws Exception {
+ public void testSearchValidateTicket() throws Exception {
TracSearch search = new TracSearch();
search.addFilter("summary", "summary1");
List<TracTicket> result = new ArrayList<TracTicket>();
client.search(search, result, null);
assertEquals(1, result.size());
- assertTicketEquals(tickets.get(0), result.get(0));
+ TracTestUtil.assertTicketEquals(tickets.get(0), result.get(0));
assertEquals("component1", result.get(0).getValue(Key.COMPONENT));
assertEquals("description1", result.get(0).getValue(Key.DESCRIPTION));
assertEquals("milestone1", result.get(0).getValue(Key.MILESTONE));
@@ -120,73 +111,60 @@ public class TracXmlRpcClientTest extends AbstractTracClientRepositoryTest {
}
public void testGetTicketActions010() throws Exception {
- connect010();
-
- TracTicket ticket = client.getTicket(tickets.get(0).getId(), null);
- TracAction[] actions = ticket.getActions();
- assertNotNull(actions);
- assertEquals(4, actions.length);
- assertEquals("leave", actions[0].getId());
- assertNull(actions[0].getLabel());
- assertEquals(0, actions[0].getFields().size());
- assertEquals("resolve", actions[1].getId());
- assertNull(actions[1].getLabel());
- assertEquals(0, actions[1].getFields().size());
- assertEquals("reassign", actions[2].getId());
- assertNull(actions[2].getLabel());
- assertEquals(0, actions[2].getFields().size());
- assertEquals("accept", actions[3].getId());
- assertNull(actions[3].getLabel());
- assertEquals(0, actions[3].getFields().size());
-
- ticket = client.getTicket(tickets.get(1).getId(), null);
- actions = ticket.getActions();
- assertNotNull(actions);
- assertEquals(2, actions.length);
- assertEquals("leave", actions[0].getId());
- assertEquals("reopen", actions[1].getId());
- }
-
- public void testGetTicketActions011() throws Exception {
- connect011();
-
- TracTicket ticket = client.getTicket(tickets.get(0).getId(), null);
- TracAction[] actions = ticket.getActions();
- assertNotNull(actions);
- assertEquals(4, actions.length);
- assertEquals("leave", actions[0].getId());
- assertEquals("resolve", actions[1].getId());
- assertEquals("resolve", actions[1].getLabel());
- assertNotNull(actions[1].getHint());
- List<TracTicketField> fields = actions[1].getFields();
- assertEquals(1, fields.size());
- assertEquals(5, fields.get(0).getOptions().length);
- assertEquals("fixed", fields.get(0).getOptions()[0]);
- assertEquals("reassign", actions[2].getId());
- fields = actions[2].getFields();
- assertEquals(1, fields.size());
- assertNull(fields.get(0).getOptions());
- assertEquals("accept", actions[3].getId());
-
- ticket = client.getTicket(tickets.get(1).getId(), null);
- actions = ticket.getActions();
- assertNotNull(actions);
- assertEquals(2, actions.length);
- assertEquals("leave", actions[0].getId());
- assertEquals("reopen", actions[1].getId());
- }
-
- public void testWikiToHtml010() throws Exception {
- connect010();
- wikiToHtml(TracTestConstants.TEST_TRAC_010_URL);
- }
-
- public void testWikiToHtml011() throws Exception {
- connect011();
- wikiToHtml("http://mylyn.eclipse.org/trac011");
+ if (client.getUrl().equals(TracTestConstants.TEST_TRAC_010_URL)) {
+ TracTicket ticket = client.getTicket(tickets.get(0).getId(), null);
+ TracAction[] actions = ticket.getActions();
+ assertNotNull(actions);
+ assertEquals(4, actions.length);
+ assertEquals("leave", actions[0].getId());
+ assertNull(actions[0].getLabel());
+ assertEquals(0, actions[0].getFields().size());
+ assertEquals("resolve", actions[1].getId());
+ assertNull(actions[1].getLabel());
+ assertEquals(0, actions[1].getFields().size());
+ assertEquals("reassign", actions[2].getId());
+ assertNull(actions[2].getLabel());
+ assertEquals(0, actions[2].getFields().size());
+ assertEquals("accept", actions[3].getId());
+ assertNull(actions[3].getLabel());
+ assertEquals(0, actions[3].getFields().size());
+
+ ticket = client.getTicket(tickets.get(1).getId(), null);
+ actions = ticket.getActions();
+ assertNotNull(actions);
+ assertEquals(2, actions.length);
+ assertEquals("leave", actions[0].getId());
+ assertEquals("reopen", actions[1].getId());
+ } else {
+ TracTicket ticket = client.getTicket(tickets.get(0).getId(), null);
+ TracAction[] actions = ticket.getActions();
+ assertNotNull(actions);
+ assertEquals(4, actions.length);
+ assertEquals("leave", actions[0].getId());
+ assertEquals("resolve", actions[1].getId());
+ assertEquals("resolve", actions[1].getLabel());
+ assertNotNull(actions[1].getHint());
+ List<TracTicketField> fields = actions[1].getFields();
+ assertEquals(1, fields.size());
+ assertEquals(5, fields.get(0).getOptions().length);
+ assertEquals("fixed", fields.get(0).getOptions()[0]);
+ assertEquals("reassign", actions[2].getId());
+ fields = actions[2].getFields();
+ assertEquals(1, fields.size());
+ assertNull(fields.get(0).getOptions());
+ assertEquals("accept", actions[3].getId());
+
+ ticket = client.getTicket(tickets.get(1).getId(), null);
+ actions = ticket.getActions();
+ assertNotNull(actions);
+ assertEquals(2, actions.length);
+ assertEquals("leave", actions[0].getId());
+ assertEquals("reopen", actions[1].getId());
+ }
}
- public void wikiToHtml(String tracUrl) throws Exception {
+ public void testWikiToHtml() throws Exception {
+ String tracUrl = client.getUrl();
String html = ((TracXmlRpcClient) client).wikiToHtml("", null);
assertEquals("", html);
@@ -206,43 +184,17 @@ public class TracXmlRpcClientTest extends AbstractTracClientRepositoryTest {
assertEquals(expectedHtml, html);
}
- public void testValidateWikiAPI010() throws Exception {
- connect010();
- ((TracXmlRpcClient) client).validateWikiRpcApi(null);
- }
-
- public void testValidateWikiAPI011() throws Exception {
- connect011();
+ public void testValidateWikiAPI() throws Exception {
((TracXmlRpcClient) client).validateWikiRpcApi(null);
}
- public void testGetAllWikiPageNames010() throws Exception {
- connect010();
- getAllWikiPageNames();
- }
-
- public void testGetAllWikiPageNames011() throws Exception {
- connect011();
- getAllWikiPageNames();
- }
-
- private void getAllWikiPageNames() throws Exception {
+ public void testGetAllWikiPageNames() throws Exception {
String[] names = ((TracXmlRpcClient) client).getAllWikiPageNames(null);
List<String> all = Arrays.asList(names);
assertTrue(all.contains("Test"));
}
- public void testGetWikiPage010() throws Exception {
- connect010();
- getWikiPage();
- }
-
- public void testGetWikiPage011() throws Exception {
- connect011();
- getWikiPage();
- }
-
- private void getWikiPage() throws Exception {
+ public void testGetWikiPage() throws Exception {
TracWikiPage page = ((TracXmlRpcClient) client).getWikiPage("TestGetPage", null);
assertEquals("TestGetPage", page.getPageInfo().getPageName());
assertEquals("tests@mylyn.eclipse.org", page.getPageInfo().getAuthor());
@@ -261,17 +213,7 @@ public class TracXmlRpcClientTest extends AbstractTracClientRepositoryTest {
assertTrue(page.getPageHTML().startsWith("<html>"));
}
- public void testGetWikiPageInvalid010() throws Exception {
- connect010();
- getWikiPageInvalid();
- }
-
- public void testGetWikiPageInvalid011() throws Exception {
- connect011();
- getWikiPageInvalid();
- }
-
- private void getWikiPageInvalid() throws Exception {
+ public void testGetWikiPageInvalid() throws Exception {
// get info -- non-existing version
try {
((TracXmlRpcClient) client).getWikiPageInfo("Test", 10, null);
@@ -371,17 +313,7 @@ public class TracXmlRpcClientTest extends AbstractTracClientRepositoryTest {
}
}
- public void testGetWikiPageInfoAllVersions010() throws Exception {
- connect010();
- getWikiPageInfoAllVersions();
- }
-
- public void testGetWikiPageInfoAllVersions011() throws Exception {
- connect011();
- getWikiPageInfoAllVersions();
- }
-
- private void getWikiPageInfoAllVersions() throws Exception {
+ public void testGetWikiPageInfoAllVersions() throws Exception {
String pageName = "Test";
TracWikiPageInfo[] versions = ((TracXmlRpcClient) client).getWikiPageInfoAllVersions(pageName, null);
@@ -393,17 +325,7 @@ public class TracXmlRpcClientTest extends AbstractTracClientRepositoryTest {
}
}
- public void testGetRecentWikiChanges010() throws Exception {
- connect010();
- getRecentWikiChanges();
- }
-
- public void testGetRecentWikiChanges011() throws Exception {
- connect011();
- getRecentWikiChanges();
- }
-
- private void getRecentWikiChanges() throws Exception {
+ public void testGetRecentWikiChanges() throws Exception {
TracWikiPageInfo[] changes = ((TracXmlRpcClient) client).getRecentWikiChanges(new Date(0), null);
TracWikiPageInfo testPage = null;
for (TracWikiPageInfo item : changes) {
@@ -415,17 +337,7 @@ public class TracXmlRpcClientTest extends AbstractTracClientRepositoryTest {
assertTrue(testPage != null);
}
- public void testPutWikiPage010() throws Exception {
- connect010();
- putWikiPage();
- }
-
- public void testPutWikiPage011() throws Exception {
- connect011();
- putWikiPage();
- }
-
- private void putWikiPage() throws Exception {
+ public void testPutWikiPage() throws Exception {
// TODO testing wiki.putPage()
}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/RepositorySearchTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/RepositorySearchTest.java
deleted file mode 100644
index 45fe504b2..000000000
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/RepositorySearchTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Steffen Pingel and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Steffen Pingel - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.mylyn.trac.tests.core;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
-import org.eclipse.mylyn.commons.net.AuthenticationType;
-import org.eclipse.mylyn.context.tests.support.TestUtil;
-import org.eclipse.mylyn.context.tests.support.TestUtil.Credentials;
-import org.eclipse.mylyn.context.tests.support.TestUtil.PrivilegeLevel;
-import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryManager;
-import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
-import org.eclipse.mylyn.internal.tasks.ui.search.RepositorySearchResult;
-import org.eclipse.mylyn.internal.tasks.ui.search.SearchHitCollector;
-import org.eclipse.mylyn.internal.trac.core.TracCorePlugin;
-import org.eclipse.mylyn.internal.trac.core.client.ITracClient;
-import org.eclipse.mylyn.internal.trac.core.client.ITracClient.Version;
-import org.eclipse.mylyn.internal.trac.core.model.TracSearch;
-import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
-import org.eclipse.mylyn.tasks.core.ITask;
-import org.eclipse.mylyn.tasks.core.TaskRepository;
-import org.eclipse.mylyn.tasks.ui.TasksUi;
-import org.eclipse.mylyn.trac.tests.support.TestFixture;
-import org.eclipse.mylyn.trac.tests.support.TracTestConstants;
-import org.eclipse.mylyn.trac.tests.support.XmlRpcServer.TestData;
-
-/**
- * @author Steffen Pingel
- */
-public class RepositorySearchTest extends TestCase {
-
- private TestData data;
-
- private TaskRepositoryManager manager;
-
- private TaskRepository repository;
-
- public RepositorySearchTest() {
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- data = TestFixture.init010();
- manager = TasksUiPlugin.getRepositoryManager();
- manager.clearRepositories(TasksUiPlugin.getDefault().getRepositoriesFilePath());
- }
-
- protected void init(String url, Version version) {
- Credentials credentials = TestUtil.readCredentials(PrivilegeLevel.USER);
-
- repository = new TaskRepository(TracCorePlugin.CONNECTOR_KIND, url);
- repository.setCredentials(AuthenticationType.REPOSITORY, new AuthenticationCredentials(credentials.username,
- credentials.password), false);
- repository.setTimeZoneId(ITracClient.TIME_ZONE);
- repository.setCharacterEncoding(ITracClient.CHARSET);
- repository.setVersion(version.name());
-
- manager.addRepository(repository);
- }
-
- public void testSearch() {
- init(TracTestConstants.TEST_TRAC_096_URL, Version.TRAC_0_9);
-
- TracSearch search = new TracSearch();
- String queryUrl = repository.getRepositoryUrl() + ITracClient.QUERY_URL + search.toUrl();
- IRepositoryQuery query = TasksUi.getRepositoryModel().createRepositoryQuery(repository);
- query.setUrl(queryUrl);
- SearchHitCollector collector = new SearchHitCollector(TasksUiPlugin.getTaskList(), repository, query);
- collector.run(new NullProgressMonitor());
- RepositorySearchResult searchResult = (RepositorySearchResult) collector.getSearchResult();
- assertEquals(data.tickets.size(), searchResult.getMatchCount());
- for (Object match : searchResult.getElements()) {
- ITask task = (ITask) match;
- assertEquals(TracTestConstants.TEST_TRAC_096_URL, task.getRepositoryUrl());
- }
- }
-}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracAttachmentHandlerTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracAttachmentHandlerTest.java
index d714aae4f..30c490c1e 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracAttachmentHandlerTest.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracAttachmentHandlerTest.java
@@ -23,14 +23,12 @@ import org.eclipse.mylyn.internal.tasks.core.data.FileTaskAttachmentSource;
import org.eclipse.mylyn.internal.trac.core.TracCorePlugin;
import org.eclipse.mylyn.internal.trac.core.TracRepositoryConnector;
import org.eclipse.mylyn.internal.trac.core.client.ITracClient;
-import org.eclipse.mylyn.internal.trac.core.client.ITracClient.Version;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.ITaskAttachment;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.data.AbstractTaskAttachmentHandler;
import org.eclipse.mylyn.tasks.ui.TasksUi;
-import org.eclipse.mylyn.trac.tests.support.TestFixture;
-import org.eclipse.mylyn.trac.tests.support.TracTestConstants;
+import org.eclipse.mylyn.trac.tests.support.TracFixture;
import org.eclipse.mylyn.trac.tests.support.TracTestUtil;
import org.eclipse.mylyn.trac.tests.support.XmlRpcServer.TestData;
@@ -50,25 +48,13 @@ public class TracAttachmentHandlerTest extends TestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- data = TestFixture.init010();
+ data = TracFixture.init010();
connector = (TracRepositoryConnector) TasksUi.getRepositoryConnector(TracCorePlugin.CONNECTOR_KIND);
attachmentHandler = connector.getTaskAttachmentHandler();
+ repository = TracFixture.current().singleRepository();
}
- protected void init(String url, Version version) {
- repository = TracTestUtil.init(url, version);
- }
-
- public void testDownloadAttachmentXmlRpc010() throws Exception {
- downloadAttachmentXmlRpc(TracTestConstants.TEST_TRAC_010_URL);
- }
-
- public void testDownloadAttachmentXmlRpc011() throws Exception {
- downloadAttachmentXmlRpc(TracTestConstants.TEST_TRAC_011_URL);
- }
-
- private void downloadAttachmentXmlRpc(String url) throws Exception {
- init(url, Version.XML_RPC);
+ public void testDownloadAttachment() throws Exception {
ITask task = TracTestUtil.createTask(repository, data.attachmentTicketId + "");
List<ITaskAttachment> attachments = TracTestUtil.getTaskAttachments(task);
assertTrue(attachments.size() > 0);
@@ -83,16 +69,7 @@ public class TracAttachmentHandlerTest extends TestCase {
}
}
- public void testGetAttachmentDataXmlRpc010() throws Exception {
- getAttachmentDataXmlRpc(TracTestConstants.TEST_TRAC_010_URL);
- }
-
- public void testGetAttachmentDataXmlRpc011() throws Exception {
- getAttachmentDataXmlRpc(TracTestConstants.TEST_TRAC_011_URL);
- }
-
- private void getAttachmentDataXmlRpc(String url) throws Exception {
- init(url, Version.XML_RPC);
+ public void testGetAttachmentData() throws Exception {
ITask task = TracTestUtil.createTask(repository, data.attachmentTicketId + "");
List<ITaskAttachment> attachments = TracTestUtil.getTaskAttachments(task);
assertTrue(attachments.size() > 0);
@@ -106,16 +83,7 @@ public class TracAttachmentHandlerTest extends TestCase {
assertEquals("Mylar\n", new String(result));
}
- public void testUploadAttachmentXmlRpc010() throws Exception {
- uploadAttachmentXmlRpc(TracTestConstants.TEST_TRAC_010_URL);
- }
-
- public void testUploadAttachmentXmlRpc011() throws Exception {
- uploadAttachmentXmlRpc(TracTestConstants.TEST_TRAC_011_URL);
- }
-
- private void uploadAttachmentXmlRpc(String url) throws Exception {
- init(url, Version.XML_RPC);
+ public void testUploadAttachment() throws Exception {
ITask task = TracTestUtil.createTask(repository, data.attachmentTicketId + "");
File file = File.createTempFile("attachment", null);
file.deleteOnExit();
@@ -139,25 +107,25 @@ public class TracAttachmentHandlerTest extends TestCase {
}
public void testCanUploadAttachmentXmlRpc() throws Exception {
- init(TracTestConstants.TEST_TRAC_010_URL, Version.XML_RPC);
+ repository = TracFixture.TRAC_0_10_XML_RPC.singleRepository();
ITask task = TracTestUtil.createTask(repository, data.attachmentTicketId + "");
assertTrue(attachmentHandler.canPostContent(repository, task));
}
public void testCanUploadAttachmentWeb() throws Exception {
- init(TracTestConstants.TEST_TRAC_010_URL, Version.TRAC_0_9);
+ repository = TracFixture.TRAC_0_10_WEB.singleRepository();
ITask task = TracTestUtil.createTask(repository, data.attachmentTicketId + "");
assertFalse(attachmentHandler.canPostContent(repository, task));
}
public void testCanDownloadAttachmentXmlRpc() throws Exception {
- init(TracTestConstants.TEST_TRAC_010_URL, Version.XML_RPC);
+ repository = TracFixture.TRAC_0_10_XML_RPC.singleRepository();
ITask task = TracTestUtil.createTask(repository, data.attachmentTicketId + "");
assertTrue(attachmentHandler.canGetContent(repository, task));
}
public void testCanDownloadAttachmentWeb() throws Exception {
- init(TracTestConstants.TEST_TRAC_010_URL, Version.TRAC_0_9);
+ repository = TracFixture.TRAC_0_10_WEB.singleRepository();
ITask task = TracTestUtil.createTask(repository, data.attachmentTicketId + "");
assertFalse(attachmentHandler.canGetContent(repository, task));
}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracRepositoryConnectorTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracRepositoryConnectorTest.java
index f896109f4..84880df9a 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracRepositoryConnectorTest.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracRepositoryConnectorTest.java
@@ -49,8 +49,7 @@ import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.data.TaskData;
import org.eclipse.mylyn.tasks.core.data.TaskDataCollector;
import org.eclipse.mylyn.tasks.ui.TasksUi;
-import org.eclipse.mylyn.trac.tests.support.TestFixture;
-import org.eclipse.mylyn.trac.tests.support.TracTestConstants;
+import org.eclipse.mylyn.trac.tests.support.TracFixture;
import org.eclipse.mylyn.trac.tests.support.TracTestUtil;
import org.eclipse.mylyn.trac.tests.support.XmlRpcServer.TestData;
import org.eclipse.swt.widgets.Shell;
@@ -70,12 +69,9 @@ public class TracRepositoryConnectorTest extends TestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- data = TestFixture.init010();
+ data = TracFixture.init010();
connector = (TracRepositoryConnector) TasksUi.getRepositoryConnector(TracCorePlugin.CONNECTOR_KIND);
- }
-
- protected void init(String url, Version version) {
- repository = TracTestUtil.init(url, version);
+ repository = TracFixture.current().singleRepository();
}
public void testGetRepositoryUrlFromTaskUrl() {
@@ -85,32 +81,7 @@ public class TracRepositoryConnectorTest extends TestCase {
assertEquals(null, connector.getRepositoryUrlFromTaskUrl("http://host/repo/ticket-2342"));
}
- public void testCreateTaskFromExistingKeyXmlRpc011() throws CoreException {
- init(TracTestConstants.TEST_TRAC_010_URL, Version.XML_RPC);
- createTaskFromExistingKey();
- }
-
- public void testCreateTaskFromExistingKeyXmlRpc010() throws CoreException {
- init(TracTestConstants.TEST_TRAC_010_URL, Version.XML_RPC);
- createTaskFromExistingKey();
- }
-
- public void testCreateTaskFromExistingKeyTracWeb011() throws CoreException {
- init(TracTestConstants.TEST_TRAC_010_URL, Version.TRAC_0_9);
- createTaskFromExistingKey();
- }
-
- public void testCreateTaskFromExistingKeyTracWeb010() throws CoreException {
- init(TracTestConstants.TEST_TRAC_010_URL, Version.TRAC_0_9);
- createTaskFromExistingKey();
- }
-
- public void testCreateTaskFromExistingKeyTracWeb096() throws CoreException {
- init(TracTestConstants.TEST_TRAC_096_URL, Version.TRAC_0_9);
- createTaskFromExistingKey();
- }
-
- protected void createTaskFromExistingKey() throws CoreException {
+ public void testCreateTaskFromExistingKeyXml() throws CoreException {
String taskId = data.tickets.get(0).getId() + "";
TaskData taskData = connector.getTaskData(repository, taskId, null);
ITask task = TasksUi.getRepositoryModel().createTask(repository, taskData.getTaskId());
@@ -122,9 +93,9 @@ public class TracRepositoryConnectorTest extends TestCase {
}
public void testClientManagerChangeTaskRepositorySettings() throws MalformedURLException {
- init(TracTestConstants.TEST_TRAC_010_URL, Version.TRAC_0_9);
+ repository = TracFixture.TRAC_0_10_WEB.singleRepository();
ITracClient client = connector.getClientManager().getTracClient(repository);
- assertEquals(Version.TRAC_0_9, client.getVersion());
+ assertEquals(Version.TRAC_0_9, client.getAccessMode());
EditRepositoryWizard wizard = new EditRepositoryWizard(repository);
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
@@ -136,41 +107,19 @@ public class TracRepositoryConnectorTest extends TestCase {
assertTrue(wizard.performFinish());
client = connector.getClientManager().getTracClient(repository);
- assertEquals(Version.XML_RPC, client.getVersion());
+ assertEquals(Version.XML_RPC, client.getAccessMode());
} finally {
dialog.close();
}
}
- public void testPerformQueryXmlRpc011() {
- performQuery(TracTestConstants.TEST_TRAC_011_URL, Version.XML_RPC);
- }
-
- public void testPerformQueryXmlRpc010() {
- performQuery(TracTestConstants.TEST_TRAC_010_URL, Version.XML_RPC);
- }
-
- public void testPerformQueryWeb011() {
- performQuery(TracTestConstants.TEST_TRAC_010_URL, Version.TRAC_0_9);
- }
-
- public void testPerformQueryWeb010() {
- performQuery(TracTestConstants.TEST_TRAC_010_URL, Version.TRAC_0_9);
- }
-
- public void testPerformQueryWeb096() {
- performQuery(TracTestConstants.TEST_TRAC_096_URL, Version.TRAC_0_9);
- }
-
- protected void performQuery(String url, Version version) {
- init(url, version);
-
+ public void testPerformQuery() {
TracSearch search = new TracSearch();
search.addFilter("milestone", "milestone1");
search.addFilter("milestone", "milestone2");
search.setOrderBy("id");
IRepositoryQuery query = TasksUi.getRepositoryModel().createRepositoryQuery(repository);
- query.setUrl(url + ITracClient.QUERY_URL + search.toUrl());
+ query.setUrl(repository.getUrl() + ITracClient.QUERY_URL + search.toUrl());
final List<TaskData> result = new ArrayList<TaskData>();
TaskDataCollector hitCollector = new TaskDataCollector() {
@@ -187,32 +136,7 @@ public class TracRepositoryConnectorTest extends TestCase {
assertEquals(data.tickets.get(2).getId() + "", result.get(2).getTaskId());
}
- public void testUpdateAttributesWeb011() throws Exception {
- init(TracTestConstants.TEST_TRAC_011_URL, Version.TRAC_0_9);
- updateAttributes();
- }
-
- public void testUpdateAttributesWeb010() throws Exception {
- init(TracTestConstants.TEST_TRAC_010_URL, Version.TRAC_0_9);
- updateAttributes();
- }
-
- public void testUpdateAttributesWeb096() throws Exception {
- init(TracTestConstants.TEST_TRAC_096_URL, Version.TRAC_0_9);
- updateAttributes();
- }
-
- public void testUpdateAttributesXmlRpc011() throws Exception {
- init(TracTestConstants.TEST_TRAC_011_URL, Version.XML_RPC);
- updateAttributes();
- }
-
- public void testUpdateAttributesXmlRpc010() throws Exception {
- init(TracTestConstants.TEST_TRAC_010_URL, Version.XML_RPC);
- updateAttributes();
- }
-
- protected void updateAttributes() throws Exception {
+ public void testUpdateAttributes() throws Exception {
connector.updateRepositoryConfiguration(repository, new NullProgressMonitor());
ITracClient server = connector.getClientManager().getTracClient(repository);
@@ -227,17 +151,28 @@ public class TracRepositoryConnectorTest extends TestCase {
assertEquals("2.0", versions[1].getName());
}
- public void testContextXmlRpc010() throws Exception {
- init(TracTestConstants.TEST_TRAC_010_URL, Version.XML_RPC);
+ public void testContext() throws Exception {
String taskId = data.attachmentTicketId + "";
ITask task = TracTestUtil.createTask(repository, taskId);
File sourceContextFile = ContextCorePlugin.getContextStore().getFileForContext(task.getHandleIdentifier());
sourceContextFile.createNewFile();
sourceContextFile.deleteOnExit();
- boolean result = AttachmentUtil.postContext(connector, repository, task, "", null, null);
- assertTrue(result);
+ boolean result;
+ try {
+ result = AttachmentUtil.postContext(connector, repository, task, "", null, null);
+ if (repository.getVersion().equals(Version.TRAC_0_9.name())) {
+ fail("expected CoreException"); // operation should not be supported
+ }
+ } catch (CoreException e) {
+ if (repository.getVersion().equals(Version.TRAC_0_9.name())) {
+ // done
+ return;
+ }
+ throw e;
+ }
+ assertTrue(result);
task = TracTestUtil.createTask(repository, taskId);
List<ITaskAttachment> attachments = TracTestUtil.getTaskAttachments(task);
// TODO attachment may have been overridden therefore size may not have changed
@@ -248,21 +183,6 @@ public class TracRepositoryConnectorTest extends TestCase {
assertTrue(task.isActive());
}
- public void testContextWeb096() throws Exception {
- init(TracTestConstants.TEST_TRAC_096_URL, Version.TRAC_0_9);
- String taskId = data.attachmentTicketId + "";
- ITask task = TracTestUtil.createTask(repository, taskId);
- File sourceContextFile = ContextCorePlugin.getContextStore().getFileForContext(task.getHandleIdentifier());
- sourceContextFile.createNewFile();
- sourceContextFile.deleteOnExit();
-
- try {
- AttachmentUtil.postContext(connector, repository, task, "", null, null);
- fail("expected CoreException"); // operation should not be supported
- } catch (CoreException e) {
- }
- }
-
public void testIsCompleted() {
assertTrue(TracRepositoryConnector.isCompleted("closed"));
assertFalse(TracRepositoryConnector.isCompleted("Closed"));
@@ -318,8 +238,6 @@ public class TracRepositoryConnectorTest extends TestCase {
}
public void testUpdateTaskFromTaskData() throws Exception {
- init(TracTestConstants.TEST_TRAC_010_URL, Version.TRAC_0_9);
-
TracTicket ticket = new TracTicket(123);
ticket.putBuiltinValue(Key.DESCRIPTION, "mydescription");
ticket.putBuiltinValue(Key.PRIORITY, "mypriority");
@@ -332,7 +250,7 @@ public class TracRepositoryConnectorTest extends TestCase {
ITask task = TasksUi.getRepositoryModel().createTask(repository, taskData.getTaskId());
connector.updateTaskFromTaskData(repository, task, taskData);
- assertEquals(TracTestConstants.TEST_TRAC_010_URL + ITracClient.TICKET_URL + "123", task.getUrl());
+ assertEquals(repository.getRepositoryUrl() + ITracClient.TICKET_URL + "123", task.getUrl());
assertEquals("123", task.getTaskKey());
assertEquals("mysummary", task.getSummary());
assertEquals("P3", task.getPriority());
@@ -340,8 +258,6 @@ public class TracRepositoryConnectorTest extends TestCase {
}
public void testUpdateTaskFromTaskDataSummaryOnly() throws Exception {
- init(TracTestConstants.TEST_TRAC_010_URL, Version.TRAC_0_9);
-
TracTicket ticket = new TracTicket(456);
ticket.putBuiltinValue(Key.SUMMARY, "mysummary");
@@ -351,15 +267,18 @@ public class TracRepositoryConnectorTest extends TestCase {
ITask task = TasksUi.getRepositoryModel().createTask(repository, taskData.getTaskId());
connector.updateTaskFromTaskData(repository, task, taskData);
- assertEquals(TracTestConstants.TEST_TRAC_010_URL + ITracClient.TICKET_URL + "456", task.getUrl());
+ assertEquals(repository.getRepositoryUrl() + ITracClient.TICKET_URL + "456", task.getUrl());
assertEquals("456", task.getTaskKey());
assertEquals("mysummary", task.getSummary());
assertEquals("P3", task.getPriority());
- assertEquals(AbstractTask.DEFAULT_TASK_KIND, task.getTaskKind());
+ if (client.getAccessMode() == Version.TRAC_0_9) {
+ assertEquals(AbstractTask.DEFAULT_TASK_KIND, task.getTaskKind());
+ } else {
+ assertEquals("Defect", task.getTaskKind());
+ }
}
public void testUpdateTaskFromTaskDataClosed() throws Exception {
- init(TracTestConstants.TEST_TRAC_010_URL, Version.TRAC_0_9);
TracTaskDataHandler taskDataHandler = connector.getTaskDataHandler();
ITracClient client = connector.getClientManager().getTracClient(repository);
ITask task = TasksUi.getRepositoryModel().createTask(repository, "1");
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracRepositoryConnectorWebTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracRepositoryConnectorWebTest.java
new file mode 100644
index 000000000..c773f85cd
--- /dev/null
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracRepositoryConnectorWebTest.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 Steffen Pingel and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Steffen Pingel - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.trac.tests.core;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.eclipse.mylyn.internal.tasks.core.sync.SynchronizationSession;
+import org.eclipse.mylyn.internal.trac.core.TracCorePlugin;
+import org.eclipse.mylyn.internal.trac.core.TracRepositoryConnector;
+import org.eclipse.mylyn.tasks.core.ITask;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.ui.TasksUi;
+import org.eclipse.mylyn.trac.tests.support.TracFixture;
+import org.eclipse.mylyn.trac.tests.support.TracTestUtil;
+import org.eclipse.mylyn.trac.tests.support.XmlRpcServer.TestData;
+
+/**
+ * @author Steffen Pingel
+ */
+public class TracRepositoryConnectorWebTest extends TestCase {
+
+ private TracRepositoryConnector connector;
+
+ private TaskRepository repository;
+
+ private TestData data;
+
+ public TracRepositoryConnectorWebTest() {
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ data = TracFixture.init010();
+ connector = (TracRepositoryConnector) TasksUi.getRepositoryConnector(TracCorePlugin.CONNECTOR_KIND);
+ repository = TracFixture.current(TracFixture.TRAC_0_10_WEB).singleRepository();
+ }
+
+ private SynchronizationSession createSession(ITask... tasks) {
+ SynchronizationSession session = new SynchronizationSession();
+ session.setNeedsPerformQueries(true);
+ session.setTaskRepository(repository);
+ session.setFullSynchronization(true);
+ session.setTasks(new HashSet<ITask>(Arrays.asList(tasks)));
+ return session;
+ }
+
+ public void testPreSynchronizationWeb096() throws Exception {
+ ITask task = TracTestUtil.createTask(repository, data.offlineHandlerTicketId + "");
+
+ Set<ITask> tasks = new HashSet<ITask>();
+ tasks.add(task);
+ SynchronizationSession session = createSession();
+ session.setTasks(tasks);
+
+ assertEquals(null, repository.getSynchronizationTimeStamp());
+ connector.preSynchronization(session, null);
+ assertTrue(session.needsPerformQueries());
+ assertEquals(null, repository.getSynchronizationTimeStamp());
+ // bug 238043: assertEquals(Collections.emptySet(), session.getStaleTasks());
+ assertEquals(null, session.getStaleTasks());
+
+ int time = (int) (System.currentTimeMillis() / 1000) + 1;
+ repository.setSynchronizationTimeStamp(time + "");
+ connector.preSynchronization(session, null);
+ assertTrue(session.needsPerformQueries());
+ // bug 238043: assertEquals(Collections.emptySet(), session.getStaleTasks());
+ assertEquals(null, session.getStaleTasks());
+ }
+
+}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracRepositoryQueryTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracRepositoryQueryTest.java
index 19e6e7be4..dd122ef42 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracRepositoryQueryTest.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracRepositoryQueryTest.java
@@ -18,14 +18,13 @@ import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
import org.eclipse.mylyn.internal.tasks.ui.RefactorRepositoryUrlOperation;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.trac.core.client.ITracClient;
-import org.eclipse.mylyn.internal.trac.core.client.ITracClient.Version;
import org.eclipse.mylyn.internal.trac.core.model.TracSearch;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.TasksUi;
+import org.eclipse.mylyn.trac.tests.support.TracFixture;
import org.eclipse.mylyn.trac.tests.support.TracTestConstants;
-import org.eclipse.mylyn.trac.tests.support.TracTestUtil;
/**
* @author Steffen Pingel
@@ -33,7 +32,7 @@ import org.eclipse.mylyn.trac.tests.support.TracTestUtil;
public class TracRepositoryQueryTest extends TestCase {
public void testChangeRepositoryUrl() throws Exception {
- TaskRepository repository = TracTestUtil.init(TracTestConstants.TEST_TRAC_096_URL, Version.XML_RPC);
+ TaskRepository repository = TracFixture.DEFAULT.singleRepository();
TracSearch search = new TracSearch();
String queryUrl = repository.getRepositoryUrl() + ITracClient.QUERY_URL + search.toUrl();
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracTaskDataHandlerTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracTaskDataHandlerXmlRpcTest.java
index 578def8c7..d670d690f 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracTaskDataHandlerTest.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracTaskDataHandlerXmlRpcTest.java
@@ -18,7 +18,6 @@ import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
-import java.util.Set;
import junit.framework.TestCase;
@@ -36,7 +35,6 @@ import org.eclipse.mylyn.internal.trac.core.TracRepositoryConnector;
import org.eclipse.mylyn.internal.trac.core.TracTaskDataHandler;
import org.eclipse.mylyn.internal.trac.core.TracTaskMapper;
import org.eclipse.mylyn.internal.trac.core.client.ITracClient;
-import org.eclipse.mylyn.internal.trac.core.client.ITracClient.Version;
import org.eclipse.mylyn.internal.trac.core.model.TracTicket;
import org.eclipse.mylyn.internal.trac.core.model.TracTicket.Key;
import org.eclipse.mylyn.internal.trac.core.util.TracUtil;
@@ -52,7 +50,7 @@ import org.eclipse.mylyn.tasks.core.data.TaskMapper;
import org.eclipse.mylyn.tasks.core.data.TaskOperation;
import org.eclipse.mylyn.tasks.core.data.TaskRelation;
import org.eclipse.mylyn.tasks.ui.TasksUi;
-import org.eclipse.mylyn.trac.tests.support.TestFixture;
+import org.eclipse.mylyn.trac.tests.support.TracFixture;
import org.eclipse.mylyn.trac.tests.support.TracTestConstants;
import org.eclipse.mylyn.trac.tests.support.TracTestUtil;
import org.eclipse.mylyn.trac.tests.support.XmlRpcServer.TestData;
@@ -60,7 +58,7 @@ import org.eclipse.mylyn.trac.tests.support.XmlRpcServer.TestData;
/**
* @author Steffen Pingel
*/
-public class TracTaskDataHandlerTest extends TestCase {
+public class TracTaskDataHandlerXmlRpcTest extends TestCase {
private TracRepositoryConnector connector;
@@ -72,19 +70,16 @@ public class TracTaskDataHandlerTest extends TestCase {
private ITracClient client;
- public TracTaskDataHandlerTest() {
+ public TracTaskDataHandlerXmlRpcTest() {
}
@Override
protected void setUp() throws Exception {
super.setUp();
- data = TestFixture.init010();
+ data = TracFixture.init010();
connector = (TracRepositoryConnector) TasksUi.getRepositoryConnector(TracCorePlugin.CONNECTOR_KIND);
taskDataHandler = connector.getTaskDataHandler();
- }
-
- protected void init(String url, Version version) {
- repository = TracTestUtil.init(url, version);
+ repository = TracFixture.current().singleRepository();
client = connector.getClientManager().getTracClient(repository);
}
@@ -97,41 +92,7 @@ public class TracTaskDataHandlerTest extends TestCase {
return session;
}
- public void testPreSynchronizationWeb096() throws Exception {
- init(TracTestConstants.TEST_TRAC_096_URL, Version.TRAC_0_9);
- ITask task = TracTestUtil.createTask(repository, data.offlineHandlerTicketId + "");
-
- Set<ITask> tasks = new HashSet<ITask>();
- tasks.add(task);
- SynchronizationSession session = createSession();
- session.setTasks(tasks);
-
- assertEquals(null, repository.getSynchronizationTimeStamp());
- connector.preSynchronization(session, null);
- assertTrue(session.needsPerformQueries());
- assertEquals(null, repository.getSynchronizationTimeStamp());
- // bug 238043: assertEquals(Collections.emptySet(), session.getStaleTasks());
- assertEquals(null, session.getStaleTasks());
-
- int time = (int) (System.currentTimeMillis() / 1000) + 1;
- repository.setSynchronizationTimeStamp(time + "");
- connector.preSynchronization(session, null);
- assertTrue(session.needsPerformQueries());
- // bug 238043: assertEquals(Collections.emptySet(), session.getStaleTasks());
- assertEquals(null, session.getStaleTasks());
- }
-
- public void testMarkStaleTasksXmlRpc010() throws Exception {
- init(TracTestConstants.TEST_TRAC_010_URL, Version.XML_RPC);
- markStaleTasks();
- }
-
- public void testMarkStaleTasksXmlRpc011() throws Exception {
- init(TracTestConstants.TEST_TRAC_011_URL, Version.XML_RPC);
- markStaleTasks();
- }
-
- private void markStaleTasks() throws Exception {
+ public void testMarkStaleTasks() throws Exception {
SynchronizationSession session;
TracTicket ticket = TracTestUtil.createTicket(client, "markStaleTasks");
ITask task = TracTestUtil.createTask(repository, ticket.getId() + "");
@@ -179,17 +140,7 @@ public class TracTaskDataHandlerTest extends TestCase {
assertEquals(Collections.singleton(task), session.getStaleTasks());
}
- public void testMarkStaleTasksNoTimeStampXmlRpc010() throws Exception {
- init(TracTestConstants.TEST_TRAC_010_URL, Version.XML_RPC);
- markStaleTasksNoTimeStamp();
- }
-
- public void testMarkStaleTasksNoTimeStampXmlRpc011() throws Exception {
- init(TracTestConstants.TEST_TRAC_011_URL, Version.XML_RPC);
- markStaleTasksNoTimeStamp();
- }
-
- private void markStaleTasksNoTimeStamp() throws Exception {
+ public void testMarkStaleTasksNoTimeStamp() throws Exception {
SynchronizationSession session;
ITask task = TracTestUtil.createTask(repository, data.offlineHandlerTicketId + "");
@@ -226,17 +177,7 @@ public class TracTaskDataHandlerTest extends TestCase {
}
}
- public void testAttachmentChangesLastModifiedDate010() throws Exception {
- init(TracTestConstants.TEST_TRAC_010_URL, Version.XML_RPC);
- attachmentChangesLastModifiedDate();
- }
-
- public void testAttachmentChangesLastModifiedDate011() throws Exception {
- init(TracTestConstants.TEST_TRAC_011_URL, Version.XML_RPC);
- attachmentChangesLastModifiedDate();
- }
-
- private void attachmentChangesLastModifiedDate() throws Exception {
+ public void testAttachmentChangesLastModifiedDate() throws Exception {
AbstractTaskAttachmentHandler attachmentHandler = connector.getTaskAttachmentHandler();
ITask task = TracTestUtil.createTask(repository, data.attachmentTicketId + "");
Date lastModified = task.getModificationDate();
@@ -249,17 +190,7 @@ public class TracTaskDataHandlerTest extends TestCase {
newLastModified.after(lastModified));
}
- public void testAttachmentUrlEncoding010() throws Exception {
- init(TracTestConstants.TEST_TRAC_010_URL, Version.XML_RPC);
- attachmentUrlEncoding();
- }
-
- public void testAttachmentUrlEncoding011() throws Exception {
- init(TracTestConstants.TEST_TRAC_011_URL, Version.XML_RPC);
- attachmentUrlEncoding();
- }
-
- private void attachmentUrlEncoding() throws Exception {
+ public void testAttachmentUrlEncoding() throws Exception {
AbstractTaskAttachmentHandler attachmentHandler = connector.getTaskAttachmentHandler();
TracTicket ticket = TracTestUtil.createTicket(client, "attachment url test");
ITask task = TracTestUtil.createTask(repository, ticket.getId() + "");
@@ -277,17 +208,7 @@ public class TracTaskDataHandlerTest extends TestCase {
+ "/https%253A%252F%252Fbugs.eclipse.org%252Fbugs.xml.zip", attachments.get(0).getUrl());
}
- public void testPostTaskDataInvalidCredentials010() throws Exception {
- init(TracTestConstants.TEST_TRAC_010_URL, Version.XML_RPC);
- postTaskDataInvalidCredentials();
- }
-
- public void testPostTaskDataInvalidCredentials011() throws Exception {
- init(TracTestConstants.TEST_TRAC_011_URL, Version.XML_RPC);
- postTaskDataInvalidCredentials();
- }
-
- private void postTaskDataInvalidCredentials() throws Exception {
+ public void testPostTaskDataInvalidCredentials() throws Exception {
ITask task = TracTestUtil.createTask(repository, data.offlineHandlerTicketId + "");
TaskData taskData = TasksUi.getTaskDataManager().getTaskData(task);
taskData.getRoot().getMappedAttribute(TaskAttribute.COMMENT_NEW).setValue("new comment");
@@ -301,8 +222,6 @@ public class TracTaskDataHandlerTest extends TestCase {
}
public void testCanInitializeTaskData() throws Exception {
- init(TracTestConstants.TEST_TRAC_010_URL, Version.XML_RPC);
-
ITask task = new TaskTask(TracCorePlugin.CONNECTOR_KIND, "", "");
assertFalse(taskDataHandler.canInitializeSubTaskData(repository, task));
task.setAttribute(TracRepositoryConnector.TASK_KEY_SUPPORTS_SUBTASKS, Boolean.TRUE.toString());
@@ -322,7 +241,6 @@ public class TracTaskDataHandlerTest extends TestCase {
}
public void testInitializeSubTaskDataInvalidParent() throws Exception {
- init(TracTestConstants.TEST_TRAC_010_URL, Version.XML_RPC);
TaskData parentTaskData = taskDataHandler.getTaskData(repository, data.offlineHandlerTicketId + "",
new NullProgressMonitor());
try {
@@ -333,7 +251,6 @@ public class TracTaskDataHandlerTest extends TestCase {
}
public void testInitializeSubTaskData() throws Exception {
- init(TracTestConstants.TEST_TRAC_010_URL, Version.XML_RPC);
TaskData parentTaskData = taskDataHandler.getTaskData(repository, data.offlineHandlerTicketId + "", null);
TaskMapper parentTaskMapper = new TracTaskMapper(parentTaskData, null);
parentTaskMapper.setSummary("abc");
@@ -358,7 +275,6 @@ public class TracTaskDataHandlerTest extends TestCase {
}
public void testGetSubTaskIds() throws Exception {
- init(TracTestConstants.TEST_TRAC_010_URL, Version.XML_RPC);
TaskData taskData = new TaskData(new TracAttributeMapper(new TaskRepository("", ""), client),
TracCorePlugin.CONNECTOR_KIND, "", "");
TaskAttribute blockedBy = taskData.getRoot().createAttribute(TracTaskDataHandler.ATTRIBUTE_BLOCKED_BY);
@@ -405,17 +321,7 @@ public class TracTaskDataHandlerTest extends TestCase {
return subTaskIds;
}
- public void testInitializeTaskData_0_10() throws Exception {
- init(TracTestConstants.TEST_TRAC_010_URL, Version.XML_RPC);
- initializeTaskData();
- }
-
- public void testInitializeTaskData_0_11() throws Exception {
- init(TracTestConstants.TEST_TRAC_011_URL, Version.XML_RPC);
- initializeTaskData();
- }
-
- private void initializeTaskData() throws Exception {
+ public void testInitializeTaskData() throws Exception {
TaskData taskData = new TaskData(taskDataHandler.getAttributeMapper(repository), TracCorePlugin.CONNECTOR_KIND,
"", "");
TaskMapping mapping = new TaskMapping() {
@@ -441,17 +347,9 @@ public class TracTaskDataHandlerTest extends TestCase {
assertNull(taskData.getRoot().getAttribute(TracAttribute.SEVERITY.getTracKey()));
}
- public void testOperations_XmlRpc_0_10() throws Exception {
- init(TracTestConstants.TEST_TRAC_010_URL, Version.XML_RPC);
- operations(false);
- }
-
- public void testOperations_XmlRpc_0_11() throws Exception {
- init(TracTestConstants.TEST_TRAC_011_URL, Version.XML_RPC);
- operations(true);
- }
+ public void testOperations() throws Exception {
+ boolean hasReassign = TracTestConstants.TEST_TRAC_011_URL.equals(repository.getRepositoryUrl());
- protected void operations(boolean hasReassign) throws Exception {
TaskData taskData = taskDataHandler.getTaskData(repository, "1", new NullProgressMonitor());
List<TaskAttribute> operations = taskData.getAttributeMapper().getAttributesByType(taskData,
TaskAttribute.TYPE_OPERATION);
@@ -486,17 +384,7 @@ public class TracTaskDataHandlerTest extends TestCase {
}
}
- public void testPostTaskDataUnsetResolutionXmlRpc010() throws Exception {
- init(TracTestConstants.TEST_TRAC_010_URL, Version.XML_RPC);
- postTaskDataUnsetResolution();
- }
-
- public void testPostTaskDataUnsetResolutionXmlRpc011() throws Exception {
- init(TracTestConstants.TEST_TRAC_011_URL, Version.XML_RPC);
- postTaskDataUnsetResolution();
- }
-
- private void postTaskDataUnsetResolution() throws Exception {
+ public void testPostTaskDataUnsetResolution() throws Exception {
TracTicket ticket = TracTestUtil.createTicket(client, "postTaskDataUnsetResolution");
TaskData taskData = taskDataHandler.getTaskData(repository, ticket.getId() + "", new NullProgressMonitor());
TaskAttribute attribute = taskData.getRoot().getMappedAttribute(TaskAttribute.RESOLUTION);
@@ -508,4 +396,5 @@ public class TracTaskDataHandlerTest extends TestCase {
attribute = taskData.getRoot().getMappedAttribute(TaskAttribute.RESOLUTION);
assertEquals("", attribute.getValue());
}
+
}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TestFixture.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TestFixture.java
index f52b11bfe..dec79ff9c 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TestFixture.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TestFixture.java
@@ -11,84 +11,68 @@
package org.eclipse.mylyn.trac.tests.support;
+import java.net.Proxy;
+
+import org.eclipse.mylyn.commons.net.AbstractWebLocation;
+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.context.tests.support.TestUtil;
import org.eclipse.mylyn.context.tests.support.TestUtil.Credentials;
import org.eclipse.mylyn.context.tests.support.TestUtil.PrivilegeLevel;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
-/**
- * Initializes Trac repositories to a defined state. This is done once per test run, since cleaning and initializing the
- * repository for each test method would take too long.
- *
- * @author Steffen Pingel
- */
public class TestFixture {
- public static XmlRpcServer.TestData data010;
-
- /**
- * Adds the existing repository content to the test data of <code>server</code>.
- */
- private static void initializeTestData(XmlRpcServer server) throws Exception {
- server.ticketMilestone("milestone1").itemCreated();
- server.ticketMilestone("milestone2").itemCreated();
- server.ticketMilestone("milestone3").itemCreated();
- server.ticketMilestone("milestone4").itemCreated();
- server.ticketMilestone("mile&stone").itemCreated();
-
- server.ticketVersion("1.0").itemCreated();
- server.ticketVersion("2.0").itemCreated();
-
- server.ticket(1).itemCreated();
- server.ticket(2).itemCreated();
- server.ticket(3).itemCreated();
- server.ticket(4).itemCreated();
- server.ticket(5).itemCreated();
- server.ticket(6).itemCreated();
- server.ticket(7).itemCreated();
- server.ticket(8).itemCreated();
+ protected final String repositoryUrl;
+
+ private final String connectorKind;
+
+ public TestFixture(String connectorKind, String repositoryUrl) {
+ this.connectorKind = connectorKind;
+ this.repositoryUrl = repositoryUrl;
+ }
+
+ public String getConnectorKind() {
+ return connectorKind;
+ }
+
+ public String getRepositoryUrl() {
+ return repositoryUrl;
+ }
+
+ public TaskRepository repository() {
+ TaskRepository repository = new TaskRepository(connectorKind, repositoryUrl);
+ Credentials credentials = TestUtil.readCredentials(PrivilegeLevel.USER);
+ repository.setCredentials(AuthenticationType.REPOSITORY, new AuthenticationCredentials(credentials.username,
+ credentials.password), false);
+ return repository;
+ }
+
+ public AbstractWebLocation location() throws Exception {
+ return location(PrivilegeLevel.USER);
+ }
+
+ public AbstractWebLocation location(PrivilegeLevel level) throws Exception {
+ return location(level, Proxy.NO_PROXY);
+ }
+
+ public AbstractWebLocation location(PrivilegeLevel level, Proxy proxy) throws Exception {
+ Credentials credentials = TestUtil.readCredentials(level);
+ return location(credentials.username, credentials.password, proxy);
}
-// private static void initializeRepository(XmlRpcServer server) throws Exception {
-// server.ticketVersion(null).deleteAll();
-// server.ticketVersion("1.0").create(0, "");
-// server.ticketVersion("2.0").create(0, "");
-//
-// server.ticketMilestone(null).deleteAll();
-// server.ticketMilestone("milestone1").create();
-// server.ticketMilestone("milestone2").create();
-// server.ticketMilestone("milestone3").create();
-// server.ticketMilestone("milestone4").create();
-//
-// server.ticket().deleteAll();
-// Ticket ticket = server.ticket().create("summary1", "description1");
-// ticket.update("comment", "milestone", "milestone1");
-// ticket = server.ticket().create("summary2", "description2");
-// ticket.update("comment", "milestone", "milestone2");
-// ticket = server.ticket().create("summary3", "description3");
-// ticket.update("comment", "milestone", "milestone2");
-// ticket = server.ticket().create("summary4", "description4");
-//
-// ticket = server.ticket().create("test html entities: ���", "���\n\nmulti\nline\n\n'''bold'''\n");
-// ticket = server.ticket().create("offline handler test", "");
-// }
-
- public static XmlRpcServer.TestData init010() throws Exception {
- if (data010 == null) {
- Credentials credentials = TestUtil.readCredentials(PrivilegeLevel.USER);
- XmlRpcServer server = new XmlRpcServer(TracTestConstants.TEST_TRAC_010_URL, credentials.username,
- credentials.password);
-
- initializeTestData(server);
- data010 = server.getData();
- }
- return data010;
+ public AbstractWebLocation location(String username, String password) throws Exception {
+ return location(username, password, Proxy.NO_PROXY);
}
- public static void cleanup010() throws Exception {
- if (data010 != null) {
- // data010.cleanup();
- data010 = null;
- }
+ public AbstractWebLocation location(String username, String password, final Proxy proxy) throws Exception {
+ return new WebLocation(repositoryUrl, username, password, new IProxyProvider() {
+ public Proxy getProxyForHost(String host, String proxyType) {
+ return proxy;
+ }
+ });
}
}
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
new file mode 100644
index 000000000..4adf4f0b7
--- /dev/null
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracFixture.java
@@ -0,0 +1,240 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Steffen Pingel and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Steffen Pingel - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.trac.tests.support;
+
+import java.net.Proxy;
+
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+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.context.tests.support.TestUtil;
+import org.eclipse.mylyn.context.tests.support.TestUtil.Credentials;
+import org.eclipse.mylyn.context.tests.support.TestUtil.PrivilegeLevel;
+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;
+import org.eclipse.mylyn.internal.trac.core.client.ITracClient.Version;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+
+/**
+ * Initializes Trac repositories to a defined state. This is done once per test run, since cleaning and initializing the
+ * repository for each test method would take too long.
+ *
+ * @author Steffen Pingel
+ */
+public class TracFixture extends TestFixture {
+
+ private static TracFixture current;
+
+ public static XmlRpcServer.TestData data010;
+
+ public static TracFixture TRAC_0_9_WEB = new TracFixture(Version.TRAC_0_9, TracTestConstants.TEST_TRAC_096_URL,
+ "0.9/Web");
+
+ public static TracFixture TRAC_0_10_WEB = new TracFixture(Version.TRAC_0_9, TracTestConstants.TEST_TRAC_010_URL,
+ "0.10/Web");
+
+ public static TracFixture TRAC_0_10_XML_RPC = new TracFixture(Version.XML_RPC, TracTestConstants.TEST_TRAC_010_URL,
+ "0.10/XML-RPC");
+
+ public static TracFixture TRAC_0_10_XML_RPC_DIGEST_AUTH = new TracFixture(Version.XML_RPC,
+ TracTestConstants.TEST_TRAC_010_DIGEST_AUTH_URL, "0.10/XML-RPC/DigestAuth");
+
+ public static TracFixture TRAC_0_10_XML_RPC_FORM_AUTH = new TracFixture(Version.XML_RPC,
+ TracTestConstants.TEST_TRAC_010_FORM_AUTH_URL, "0.10/XML-RPC/FormAuth");
+
+ public static TracFixture TRAC_0_10_XML_RPC_SSL = new TracFixture(Version.XML_RPC,
+ TracTestConstants.TEST_TRAC_010_SSL_URL, "0.10/XML-RPC/SSL");
+
+ public static TracFixture TRAC_0_11_WEB = new TracFixture(Version.TRAC_0_9, TracTestConstants.TEST_TRAC_011_URL,
+ "0.11/Web");
+
+ public static TracFixture TRAC_0_11_XML_RPC = new TracFixture(Version.XML_RPC, TracTestConstants.TEST_TRAC_011_URL,
+ "0.11/XML-RPC");
+
+ public static TracFixture DEFAULT = TRAC_0_11_XML_RPC;
+
+ public static final TracFixture[] ALL = new TracFixture[] { TRAC_0_9_WEB, TRAC_0_10_WEB, TRAC_0_11_WEB,
+ TRAC_0_10_XML_RPC, TRAC_0_11_XML_RPC, };
+
+ public static void cleanup010() throws Exception {
+ if (data010 != null) {
+ // data010.cleanup();
+ data010 = null;
+ }
+ }
+
+ public static TracFixture current(TracFixture fixture) {
+ if (current == null) {
+ current = fixture;
+ }
+ return current;
+ }
+
+ public static TracFixture current() {
+ return current(DEFAULT);
+ }
+
+ public static XmlRpcServer.TestData init010() throws Exception {
+ if (data010 == null) {
+ Credentials credentials = TestUtil.readCredentials(PrivilegeLevel.USER);
+ XmlRpcServer server = new XmlRpcServer(TracTestConstants.TEST_TRAC_010_URL, credentials.username,
+ credentials.password);
+
+ initializeTestData(server);
+ data010 = server.getData();
+ }
+ return data010;
+ }
+
+ /**
+ * Adds the existing repository content to the test data of <code>server</code>.
+ */
+ protected static void initializeTestData(XmlRpcServer server) throws Exception {
+ server.ticketMilestone("milestone1").itemCreated();
+ server.ticketMilestone("milestone2").itemCreated();
+ server.ticketMilestone("milestone3").itemCreated();
+ server.ticketMilestone("milestone4").itemCreated();
+ server.ticketMilestone("mile&stone").itemCreated();
+
+ server.ticketVersion("1.0").itemCreated();
+ server.ticketVersion("2.0").itemCreated();
+
+ server.ticket(1).itemCreated();
+ server.ticket(2).itemCreated();
+ server.ticket(3).itemCreated();
+ server.ticket(4).itemCreated();
+ server.ticket(5).itemCreated();
+ server.ticket(6).itemCreated();
+ server.ticket(7).itemCreated();
+ server.ticket(8).itemCreated();
+ }
+
+ private final Version accessMode;
+
+ private final String version;
+
+ public TracFixture(Version accessMode, String url, String version) {
+ super(TracCorePlugin.CONNECTOR_KIND, url);
+ this.accessMode = accessMode;
+ this.version = version;
+ }
+
+ public TracFixture activate() {
+ current = this;
+ return this;
+ }
+
+ public ITracClient connect() throws Exception {
+ return connect(repositoryUrl);
+ }
+
+ public ITracClient connect(PrivilegeLevel level) throws Exception {
+ return connect(repositoryUrl, Proxy.NO_PROXY, level);
+ }
+
+ public ITracClient connect(String url) throws Exception {
+ return connect(url, Proxy.NO_PROXY, PrivilegeLevel.USER);
+ }
+
+ public ITracClient connect(String url, Proxy proxy, PrivilegeLevel level) throws Exception {
+ Credentials credentials = TestUtil.readCredentials(level);
+ return connect(url, credentials.username, credentials.password, proxy);
+ }
+
+ public ITracClient connect(String url, String username, String password) throws Exception {
+ return connect(url, username, password, Proxy.NO_PROXY);
+ }
+
+ public ITracClient connect(String url, String username, String password, Proxy proxy) throws Exception {
+ return connect(url, username, password, proxy, accessMode);
+ }
+
+ public ITracClient connect(String url, String username, String password, final Proxy proxy, Version version)
+ throws Exception {
+ WebLocation location = new WebLocation(url, username, password, new IProxyProvider() {
+ public Proxy getProxyForHost(String host, String proxyType) {
+ return proxy;
+ }
+ });
+ return TracClientFactory.createClient(location, version);
+ }
+
+ public TestSuite createSuite() {
+ TestSuite suite = new TestSuite("Testing on Trac " + getVersion());
+ suite.addTest(new TestCase("activiating " + getRepositoryUrl()) {
+ @Override
+ protected void runTest() throws Throwable {
+ TracFixture.this.activate();
+ }
+ });
+ return suite;
+ }
+
+ public Version getAccessMode() {
+ return accessMode;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public TaskRepository singleRepository() {
+ TracCorePlugin.getDefault().getConnector().getClientManager().writeCache();
+ TaskRepositoryManager manager = TasksUiPlugin.getRepositoryManager();
+ manager.clearRepositories(TasksUiPlugin.getDefault().getRepositoriesFilePath());
+
+ 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);
+ repository.setTimeZoneId(ITracClient.TIME_ZONE);
+ repository.setCharacterEncoding(ITracClient.CHARSET);
+ repository.setVersion(accessMode.name());
+
+ manager.addRepository(repository);
+ TracCorePlugin.getDefault().getConnector().getClientManager().readCache();
+
+ return repository;
+ }
+
+// private static void initializeRepository(XmlRpcServer server) throws Exception {
+// server.ticketVersion(null).deleteAll();
+// server.ticketVersion("1.0").create(0, "");
+// server.ticketVersion("2.0").create(0, "");
+//
+// server.ticketMilestone(null).deleteAll();
+// server.ticketMilestone("milestone1").create();
+// server.ticketMilestone("milestone2").create();
+// server.ticketMilestone("milestone3").create();
+// server.ticketMilestone("milestone4").create();
+//
+// server.ticket().deleteAll();
+// Ticket ticket = server.ticket().create("summary1", "description1");
+// ticket.update("comment", "milestone", "milestone1");
+// ticket = server.ticket().create("summary2", "description2");
+// ticket.update("comment", "milestone", "milestone2");
+// ticket = server.ticket().create("summary3", "description3");
+// ticket.update("comment", "milestone", "milestone2");
+// ticket = server.ticket().create("summary4", "description4");
+//
+// ticket = server.ticket().create("test html entities: ���", "���\n\nmulti\nline\n\n'''bold'''\n");
+// ticket = server.ticket().create("offline handler test", "");
+//}
+
+}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracTestCleanupUtil.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracTestCleanupUtil.java
index bf59614b1..48438445c 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracTestCleanupUtil.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracTestCleanupUtil.java
@@ -11,12 +11,13 @@
package org.eclipse.mylyn.trac.tests.support;
+import junit.framework.TestCase;
+
import org.eclipse.mylyn.context.tests.support.TestUtil.PrivilegeLevel;
+import org.eclipse.mylyn.internal.trac.core.client.ITracClient;
import org.eclipse.mylyn.internal.trac.core.client.TracException;
-import org.eclipse.mylyn.internal.trac.core.client.ITracClient.Version;
import org.eclipse.mylyn.internal.trac.core.model.TracAttachment;
import org.eclipse.mylyn.internal.trac.core.model.TracTicket;
-import org.eclipse.mylyn.trac.tests.client.AbstractTracClientTest;
import org.eclipse.mylyn.trac.tests.support.XmlRpcServer.TestData;
/**
@@ -25,28 +26,26 @@ import org.eclipse.mylyn.trac.tests.support.XmlRpcServer.TestData;
*
* @author Steffen Pingel
*/
-public class TracTestCleanupUtil extends AbstractTracClientTest {
+public class TracTestCleanupUtil extends TestCase {
private TestData data;
- public TracTestCleanupUtil() {
- super(Version.XML_RPC, PrivilegeLevel.ADMIN);
- }
+ private ITracClient client;
@Override
protected void setUp() throws Exception {
- super.setUp();
-
- data = TestFixture.init010();
+ data = TracFixture.init010();
}
public void testCleanup010() throws Exception {
- connect010();
+ TracFixture fixture = TracFixture.TRAC_0_10_XML_RPC.activate();
+ client = fixture.connect(PrivilegeLevel.ADMIN);
cleanup();
}
public void testCleanup011() throws Exception {
- connect011();
+ TracFixture fixture = TracFixture.TRAC_0_11_XML_RPC.activate();
+ client = fixture.connect(PrivilegeLevel.ADMIN);
cleanup();
}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracTestUtil.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracTestUtil.java
index 7a439753a..8e2904535 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracTestUtil.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracTestUtil.java
@@ -13,18 +13,14 @@ package org.eclipse.mylyn.trac.tests.support;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
+
+import junit.framework.Assert;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
-import org.eclipse.mylyn.commons.net.AuthenticationType;
-import org.eclipse.mylyn.context.tests.support.TestUtil;
-import org.eclipse.mylyn.context.tests.support.TestUtil.Credentials;
-import org.eclipse.mylyn.context.tests.support.TestUtil.PrivilegeLevel;
-import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryManager;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.trac.core.TracCorePlugin;
import org.eclipse.mylyn.internal.trac.core.client.ITracClient;
-import org.eclipse.mylyn.internal.trac.core.client.ITracClient.Version;
import org.eclipse.mylyn.internal.trac.core.model.TracTicket;
import org.eclipse.mylyn.internal.trac.core.model.TracTicket.Key;
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
@@ -34,6 +30,7 @@ import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.mylyn.tasks.core.data.TaskData;
import org.eclipse.mylyn.tasks.ui.TasksUi;
+import org.eclipse.mylyn.trac.tests.support.XmlRpcServer.Ticket;
/**
* @author Steffen Pingel
@@ -56,24 +53,24 @@ public class TracTestUtil {
return task;
}
- public static TaskRepository init(String repositoryUrl, Version version) {
- TracCorePlugin.getDefault().getConnector().getClientManager().writeCache();
- TaskRepositoryManager manager = TasksUiPlugin.getRepositoryManager();
- manager.clearRepositories(TasksUiPlugin.getDefault().getRepositoriesFilePath());
-
- 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);
- repository.setTimeZoneId(ITracClient.TIME_ZONE);
- repository.setCharacterEncoding(ITracClient.CHARSET);
- repository.setVersion(version.name());
-
- manager.addRepository(repository);
- TracCorePlugin.getDefault().getConnector().getClientManager().readCache();
-
- return repository;
- }
+// public static TaskRepository init(String repositoryUrl, Version version) {
+// TracCorePlugin.getDefault().getConnector().getClientManager().writeCache();
+// TaskRepositoryManager manager = TasksUiPlugin.getRepositoryManager();
+// manager.clearRepositories(TasksUiPlugin.getDefault().getRepositoriesFilePath());
+//
+// 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);
+// repository.setTimeZoneId(ITracClient.TIME_ZONE);
+// repository.setCharacterEncoding(ITracClient.CHARSET);
+// repository.setVersion(version.name());
+//
+// manager.addRepository(repository);
+// TracCorePlugin.getDefault().getConnector().getClientManager().readCache();
+//
+// return repository;
+// }
public static List<ITaskAttachment> getTaskAttachments(ITask task) throws CoreException {
TaskData taskData = TasksUi.getTaskDataManager().getTaskData(task);
@@ -90,4 +87,14 @@ public class TracTestUtil {
return attachments;
}
+ public static void assertTicketEquals(Ticket ticket, TracTicket tracTicket) throws Exception {
+ Assert.assertTrue(tracTicket.isValid());
+
+ Map<?, ?> expectedValues = ticket.getValues();
+ Map<String, String> values = tracTicket.getValues();
+ for (String key : values.keySet()) {
+ Assert.assertEquals("Values for key '" + key + "' did not match", expectedValues.get(key), values.get(key));
+ }
+ }
+
}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/ui/TracRepositorySettingsPageTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/ui/TracRepositorySettingsPageTest.java
index 631d38c77..c07f01851 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/ui/TracRepositorySettingsPageTest.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/ui/TracRepositorySettingsPageTest.java
@@ -11,29 +11,28 @@
package org.eclipse.mylyn.trac.tests.ui;
-import java.net.Proxy;
+import junit.framework.TestCase;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.mylyn.internal.trac.core.client.ITracClient;
+import org.eclipse.mylyn.commons.net.AuthenticationType;
import org.eclipse.mylyn.internal.trac.core.client.ITracClient.Version;
import org.eclipse.mylyn.internal.trac.ui.wizard.TracRepositorySettingsPage;
import org.eclipse.mylyn.internal.trac.ui.wizard.TracRepositorySettingsPage.TracValidator;
-import org.eclipse.mylyn.trac.tests.client.AbstractTracClientTest;
-import org.eclipse.mylyn.trac.tests.support.TracTestConstants;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.trac.tests.support.TracFixture;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
/**
* @author Steffen Pingel
*/
-public class TracRepositorySettingsPageTest extends AbstractTracClientTest {
+public class TracRepositorySettingsPageTest extends TestCase {
private TracRepositorySettingsPage page;
private TracValidator validator;
public TracRepositorySettingsPageTest() {
- super(null);
}
@Override
@@ -47,28 +46,20 @@ public class TracRepositorySettingsPageTest extends AbstractTracClientTest {
page.setVisible(true);
}
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
-
- // TestFixture.cleanupRepository1();
- }
-
- @Override
- public ITracClient connect(String url, String username, String password, Proxy proxy, Version version)
- throws Exception {
+ protected void initialize(TracFixture fixture) throws Exception {
+ // initialize page from test fixture
+ TaskRepository repository = fixture.repository();
page.setAnonymous(false);
- page.setUrl(url);
- page.setUserId(username);
- page.setPassword(password);
- page.setTracVersion(version);
- validator = page.new TracValidator(page.createTaskRepository(), version);
- return null;
+ page.setUrl(repository.getRepositoryUrl());
+ page.setUserId(repository.getCredentials(AuthenticationType.REPOSITORY).getUserName());
+ page.setPassword(repository.getCredentials(AuthenticationType.REPOSITORY).getPassword());
+ page.setTracVersion(fixture.getAccessMode());
+
+ validator = page.new TracValidator(page.createTaskRepository(), fixture.getAccessMode());
}
public void testValidateXmlRpc() throws Exception {
- version = Version.XML_RPC;
- connect010();
+ initialize(TracFixture.TRAC_0_10_XML_RPC);
validator.run(new NullProgressMonitor());
assertNull(validator.getResult());
@@ -76,8 +67,7 @@ public class TracRepositorySettingsPageTest extends AbstractTracClientTest {
}
public void testValidateWeb() throws Exception {
- version = Version.TRAC_0_9;
- connect010();
+ initialize(TracFixture.TRAC_0_10_WEB);
validator.run(new NullProgressMonitor());
assertNull(validator.getResult());
@@ -85,8 +75,10 @@ public class TracRepositorySettingsPageTest extends AbstractTracClientTest {
}
public void testValidateAutomaticUser() throws Exception {
- version = null;
- connect010();
+ initialize(TracFixture.TRAC_0_10_XML_RPC);
+
+ page.setTracVersion(null);
+ validator = page.new TracValidator(page.createTaskRepository(), null);
validator.run(new NullProgressMonitor());
assertEquals(Version.XML_RPC, validator.getResult());
@@ -94,8 +86,12 @@ public class TracRepositorySettingsPageTest extends AbstractTracClientTest {
}
public void testValidateAutomaticAnonymous() throws Exception {
- version = null;
- connect(TracTestConstants.TEST_TRAC_010_URL, "", "");
+ initialize(TracFixture.TRAC_0_10_XML_RPC);
+
+ page.setUserId("");
+ page.setPassword("");
+ page.setTracVersion(null);
+ validator = page.new TracValidator(page.createTaskRepository(), null);
validator.run(new NullProgressMonitor());
assertEquals(Version.TRAC_0_9, validator.getResult());
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/ui/TracTaskEditorTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/ui/TracTaskEditorTest.java
index 32e90a2ca..49b5d6760 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/ui/TracTaskEditorTest.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/ui/TracTaskEditorTest.java
@@ -16,12 +16,11 @@ import junit.framework.TestCase;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.views.TaskListView;
-import org.eclipse.mylyn.internal.trac.core.client.ITracClient.Version;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.tests.TaskTestUtil;
import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
-import org.eclipse.mylyn.trac.tests.support.TracTestConstants;
+import org.eclipse.mylyn.trac.tests.support.TracFixture;
import org.eclipse.mylyn.trac.tests.support.TracTestUtil;
/**
@@ -35,7 +34,7 @@ public class TracTaskEditorTest extends TestCase {
}
public void testGetSelectedRepository() throws Exception {
- TaskRepository repository = TracTestUtil.init(TracTestConstants.TEST_TRAC_010_URL, Version.XML_RPC);
+ TaskRepository repository = TracFixture.DEFAULT.singleRepository();
ITask task = TracTestUtil.createTask(repository, "1");
TasksUiPlugin.getTaskList().addTask(task);

Back to the top