Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Pingel2013-04-12 03:29:41 +0000
committerSteffen Pingel2013-04-12 21:36:18 +0000
commit9272712034cda71f10525c6fb0dec3a3be321adb (patch)
tree9ab65f35c34fed171e03e574d7c43fb82dea358e /org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn
parent0fc792d196e825bc409f6b7be6e8d883d792ba38 (diff)
downloadorg.eclipse.mylyn.tasks-9272712034cda71f10525c6fb0dec3a3be321adb.tar.gz
org.eclipse.mylyn.tasks-9272712034cda71f10525c6fb0dec3a3be321adb.tar.xz
org.eclipse.mylyn.tasks-9272712034cda71f10525c6fb0dec3a3be321adb.zip
400396: re-enable disabled Trac tests
Change-Id: I32852bb6266cc1709bd970643102f2fcd81ff016 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=400396
Diffstat (limited to 'org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn')
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/internal/trac/ui/TracHyperlinkUtilStandaloneTest.java65
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AllTracHeadlessStandaloneTests.java2
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AllTracTests.java17
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracClientProxyTest.java9
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracClientTest.java55
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracXmlRpcClientTest.java233
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracXmlRpcTest.java4
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracRepositoryQueryTest.java8
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracUtilTest.java3
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracFixture.java140
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracHarness.java17
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracTestCleanupUtil.java6
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracTestConstants.java39
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/XmlRpcServer.java43
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/ui/TracRepositorySettingsPageTest.java37
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/ui/TracTaskEditorTest.java59
16 files changed, 211 insertions, 526 deletions
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/internal/trac/ui/TracHyperlinkUtilStandaloneTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/internal/trac/ui/TracHyperlinkUtilStandaloneTest.java
deleted file mode 100644
index f6a8dd079..000000000
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/internal/trac/ui/TracHyperlinkUtilStandaloneTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2008 David Green 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:
- * David Green - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.mylyn.internal.trac.ui;
-
-import java.util.regex.Matcher;
-
-import junit.framework.TestCase;
-
-/**
- * @author David Green
- */
-public class TracHyperlinkUtilStandaloneTest extends TestCase {
-
- public void testWikiPattern2SinglePositiveMatch() {
- Matcher matcher = TracHyperlinkUtil.wikiPattern2.matcher("a HyperLink there");
- assertTrue(matcher.find());
- assertEquals(matcher.group(0), "HyperLink");
- assertFalse(matcher.find());
- }
-
- public void testWikiPattern2MultiplePositiveMatch() {
- Matcher matcher = TracHyperlinkUtil.wikiPattern2.matcher("a HyperLink there and ThereIsAnother");
- assertTrue(matcher.find());
- assertEquals(matcher.group(0), "HyperLink");
- assertTrue(matcher.find());
- assertEquals(matcher.group(0), "ThereIsAnother");
- assertFalse(matcher.find());
- }
-
- public void testWikiPattern2SingleNegativeMatch() {
- Matcher matcher = TracHyperlinkUtil.wikiPattern2.matcher("no !HyperLink there");
- assertFalse(matcher.find());
- }
-
- public void testWikiPattern2SinglePositiveMatchAtStartOfLine() {
- Matcher matcher = TracHyperlinkUtil.wikiPattern2.matcher("HyperLink there");
- assertTrue(matcher.find());
- assertEquals(matcher.group(0), "HyperLink");
- assertFalse(matcher.find());
- }
-
- public void testWikiPattern2SingleNegativeMatchAtStartOfLine() {
- Matcher matcher = TracHyperlinkUtil.wikiPattern2.matcher("!HyperLink there");
- assertFalse(matcher.find());
- }
-
- public void testWikiPattern2MixedPositiveNegativeMatch() {
- Matcher matcher = TracHyperlinkUtil.wikiPattern2.matcher("a HyperLink there and ThereIsAnother but !NotHere");
- assertTrue(matcher.find());
- assertEquals(matcher.group(0), "HyperLink");
- assertTrue(matcher.find());
- assertEquals(matcher.group(0), "ThereIsAnother");
- assertFalse(matcher.find());
- }
-
-}
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 610cbc8d7..6c70e5c2d 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
@@ -53,7 +53,7 @@ public class AllTracHeadlessStandaloneTests {
fixture.add(TracClientFactoryTest.class);
fixture.add(TracClientTest.class);
fixture.done();
- } else {
+ } else if (!fixture.hasTag(TracFixture.TAG_TEST)) {
addTests(suite, fixture);
}
}
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 54ce57d4a..62f7bd511 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
@@ -31,6 +31,7 @@ import org.eclipse.mylyn.trac.tests.core.TracUtilTest;
import org.eclipse.mylyn.trac.tests.support.TracFixture;
import org.eclipse.mylyn.trac.tests.support.TracTestCleanupUtil;
import org.eclipse.mylyn.trac.tests.ui.TracHyperlinkUtilTest;
+import org.eclipse.mylyn.trac.tests.ui.TracRepositorySettingsPageTest;
/**
* @author Mik Kersten
@@ -51,17 +52,13 @@ public class AllTracTests {
}
public static void addTests(TestSuite suite, TestConfiguration configuration) {
- // FIXME re-enable
- //suite.addTest(AllTracHeadlessStandaloneTests.suite(configuration));
+ suite.addTest(AllTracHeadlessStandaloneTests.suite(configuration));
suite.addTestSuite(TracUtilTest.class);
- // FIXME move test to tasks framework
- //suite.addTestSuite(TracTaskEditorTest.class);
suite.addTestSuite(TracHyperlinkUtilTest.class);
if (!configuration.isLocalOnly()) {
suite.addTestSuite(TracRepositoryQueryTest.class);
- // FIXME re-enable
- //suite.addTestSuite(TracRepositorySettingsPageTest.class);
+ suite.addTestSuite(TracRepositorySettingsPageTest.class);
// network tests
List<TracFixture> fixtures = configuration.discover(TracFixture.class, "trac");
for (TracFixture fixture : fixtures) {
@@ -74,6 +71,10 @@ public class AllTracTests {
protected static void addTests(TestSuite suite, TestConfiguration configuration, TracFixture fixture) {
fixture.createSuite(suite);
+ if (configuration.hasKind(TestKind.INTEGRATION) && !configuration.isLocalOnly()
+ && CommonTestUtil.hasCredentials(PrivilegeLevel.ADMIN)) {
+ fixture.add(TracTestCleanupUtil.class);
+ }
fixture.add(TracRepositoryConnectorTest.class);
if (fixture.getAccessMode() == Version.XML_RPC) {
fixture.add(TracTaskDataHandlerXmlRpcTest.class);
@@ -81,10 +82,6 @@ public class AllTracTests {
} else {
fixture.add(TracRepositoryConnectorWebTest.class);
}
- if (configuration.hasKind(TestKind.INTEGRATION) && !configuration.isLocalOnly()
- && CommonTestUtil.hasCredentials(PrivilegeLevel.ADMIN)) {
- suite.addTest(new TracTestCleanupUtil(fixture, fixture.getInfo()));
- }
fixture.done();
}
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 fd78177a7..03a69377c 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
@@ -25,7 +25,6 @@ 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.client.TracException;
import org.eclipse.mylyn.trac.tests.support.TestProxy;
-import org.eclipse.mylyn.trac.tests.support.TracTestConstants;
/**
* @author Steffen Pingel
@@ -60,22 +59,22 @@ public class TracClientProxyTest extends TestCase {
public void testConnectProxyWeb() throws Exception {
version = Version.TRAC_0_9;
- connectProxy(TracTestConstants.TEST_TRAC_010_URL, "GET");
+ connectProxy("http://mylyn.org/trac", "GET");
}
public void testConnectProxyXmlRpc() throws Exception {
version = Version.XML_RPC;
- connectProxy(TracTestConstants.TEST_TRAC_010_URL, "POST");
+ connectProxy("http://mylyn.org/trac", "POST");
}
public void testConnectProxySslWeb() throws Exception {
version = Version.TRAC_0_9;
- connectProxy(TracTestConstants.TEST_TRAC_010_SSL_URL, "CONNECT");
+ connectProxy("https://mylyn.org/trac", "CONNECT");
}
public void testConnectProxySslXmlRpc() throws Exception {
version = Version.XML_RPC;
- connectProxy(TracTestConstants.TEST_TRAC_010_SSL_URL, "CONNECT");
+ connectProxy("https://mylyn.org/trac", "CONNECT");
}
private void connectProxy(String url, String expectedMethod) throws Exception {
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracClientTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracClientTest.java
index 9389f0fe2..db64b287e 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracClientTest.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracClientTest.java
@@ -21,6 +21,7 @@ import java.util.List;
import junit.framework.TestCase;
+import org.apache.commons.lang.RandomStringUtils;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.mylyn.commons.repositories.core.auth.UserCredentials;
import org.eclipse.mylyn.commons.sdk.util.CommonTestUtil;
@@ -33,6 +34,8 @@ 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.TracRemoteException;
import org.eclipse.mylyn.internal.trac.core.model.TracSearch;
+import org.eclipse.mylyn.internal.trac.core.model.TracSearchFilter;
+import org.eclipse.mylyn.internal.trac.core.model.TracSearchFilter.CompareOperator;
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.model.TracTicketField;
@@ -40,8 +43,6 @@ import org.eclipse.mylyn.internal.trac.core.model.TracVersion;
import org.eclipse.mylyn.trac.tests.support.TracFixture;
import org.eclipse.mylyn.trac.tests.support.TracHarness;
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;
/**
* Test cases for classes that implement {@link ITracClient}.
@@ -52,12 +53,8 @@ public class TracClientTest extends TestCase {
private ITracClient client;
- private TestData data;
-
private TracFixture fixture;
- protected List<Ticket> tickets;
-
private TracHarness harness;
public TracClientTest() {
@@ -68,8 +65,6 @@ public class TracClientTest extends TestCase {
fixture = TracFixture.current();
harness = fixture.createHarness();
client = fixture.connect();
- data = TracFixture.init010();
- tickets = data.tickets;
}
@Override
@@ -79,7 +74,7 @@ public class TracClientTest extends TestCase {
public void testGetTicket() throws Exception {
TracTicket expectedTicket = harness.createTicket("getTicket");
- TracTicket ticket = client.getTicket(tickets.get(0).getId(), null);
+ TracTicket ticket = client.getTicket(expectedTicket.getId(), null);
TracTestUtil.assertTicketEquals(expectedTicket, ticket);
}
@@ -92,9 +87,12 @@ public class TracClientTest extends TestCase {
}
public void testGetTicketUmlaute() throws Exception {
- TracTicket ticket = client.getTicket(data.htmlEntitiesTicketId, null);
+ TracTicket ticket = harness.createTicket("test html entities: \u00E4\u00F6\u00FC");
assertEquals("test html entities: \u00E4\u00F6\u00FC", ticket.getValue(Key.SUMMARY));
if (client.getAccessMode() == Version.XML_RPC) {
+ ticket.putBuiltinValue(Key.DESCRIPTION, "\u00C4\u00D6\u00DC\n\nmulti\nline\n\n'''bold'''\n");
+ client.updateTicket(ticket, "", null);
+ ticket = client.getTicket(ticket.getId(), null);
assertEquals("\u00C4\u00D6\u00DC\n\nmulti\nline\n\n'''bold'''\n", ticket.getValue(Key.DESCRIPTION));
} else {
assertEquals(null, ticket.getValue(Key.DESCRIPTION));
@@ -128,23 +126,28 @@ public class TracClientTest extends TestCase {
}
public void testSearchExactMatch() throws Exception {
+ String uniqueTag = RandomStringUtils.randomAlphanumeric(6);
+ String summary = "searchExactMatch " + uniqueTag;
+ TracTicket ticket = harness.createTicketWithMilestone(summary, "milestone1");
+
TracSearch search = new TracSearch();
search.addFilter("milestone", "milestone1");
- search.addFilter("summary", "summary1");
+ search.addFilter("summary", summary);
List<TracTicket> result = new ArrayList<TracTicket>();
client.search(search, result, null);
assertEquals(1, result.size());
- TracTestUtil.assertTicketEquals(tickets.get(0), result.get(0));
+ TracTestUtil.assertTicketEquals(ticket, result.get(0));
assertEquals("milestone1", result.get(0).getValue(Key.MILESTONE));
- assertEquals("summary1", result.get(0).getValue(Key.SUMMARY));
+ assertEquals(summary, result.get(0).getValue(Key.SUMMARY));
}
public void testSearchMilestone1() throws Exception {
- TracTicket ticket = harness.createTicketWithMilestone("searchMilestone1", "milestone1");
- harness.createTicketWithMilestone("searchMilestone1", "milestone2");
+ String uniqueTag = RandomStringUtils.randomAlphanumeric(6);
+ TracTicket ticket = harness.createTicketWithMilestone("searchMilestone1" + uniqueTag, "milestone1");
+ harness.createTicketWithMilestone("searchMilestone1" + uniqueTag, "milestone2");
TracSearch search = new TracSearch();
- search.addFilter("summary", "searchMilestone1");
+ search.addFilter(new TracSearchFilter("summary", CompareOperator.CONTAINS, uniqueTag));
search.addFilter("milestone", "milestone1");
search.addFilter("milestone", "milestone1");
List<TracTicket> result = new ArrayList<TracTicket>();
@@ -154,11 +157,13 @@ public class TracClientTest extends TestCase {
}
public void testSearchMilestone2() throws Exception {
- TracTicket ticket1 = harness.createTicketWithMilestone("searchMilestone2", "milestone1");
- TracTicket ticket2 = harness.createTicketWithMilestone("searchMilestone2", "milestone1");
- TracTicket ticket3 = harness.createTicketWithMilestone("searchMilestone2", "milestone2");
+ String uniqueTag = RandomStringUtils.randomAlphanumeric(6);
+ TracTicket ticket1 = harness.createTicketWithMilestone("searchMilestone2 " + uniqueTag, "milestone1");
+ TracTicket ticket2 = harness.createTicketWithMilestone("searchMilestone2 " + uniqueTag, "milestone1");
+ TracTicket ticket3 = harness.createTicketWithMilestone("searchMilestone2 " + uniqueTag, "milestone2");
TracSearch search = new TracSearch();
+ search.addFilter(new TracSearchFilter("summary", CompareOperator.CONTAINS, uniqueTag));
search.addFilter("milestone", "milestone1");
search.addFilter("milestone", "milestone2");
search.setOrderBy("id");
@@ -171,6 +176,9 @@ public class TracClientTest extends TestCase {
}
public void testSearchMilestoneAmpersand() throws Exception {
+ harness.createMilestone("mile&stone");
+ TracTicket ticket = harness.createTicketWithMilestone("searchMilestoneAmpersand", "mile&stone");
+
TracSearch search = new TracSearch();
search.addFilter("milestone", "mile&stone");
search.setOrderBy("id");
@@ -178,7 +186,7 @@ public class TracClientTest extends TestCase {
try {
client.search(search, result, null);
assertEquals(1, result.size());
- TracTestUtil.assertTicketEquals(tickets.get(7), result.get(0));
+ TracTestUtil.assertTicketEquals(ticket, result.get(0));
} catch (TracRemoteException e) {
if ("'Query filter requires field and constraints separated by a \"=\"' while executing 'ticket.query()'".equals(e.getMessage())
&& (fixture.getVersion().equals("0.10") || fixture.getVersion().equals("0.11"))) {
@@ -190,7 +198,12 @@ public class TracClientTest extends TestCase {
}
public void testStatusClosed() throws Exception {
- TracTicket ticket = client.getTicket(data.offlineHandlerTicketId, null);
+ TracTicket ticket = harness.createTicket("statusClosed");
+ ticket.putBuiltinValue(Key.STATUS, "closed");
+ ticket.putBuiltinValue(Key.RESOLUTION, "fixed");
+ client.updateTicket(ticket, "", null);
+
+ ticket = client.getTicket(ticket.getId(), null);
assertEquals("closed", ticket.getValue(Key.STATUS));
assertEquals("fixed", ticket.getValue(Key.RESOLUTION));
}
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 af5273aba..670d483f7 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
@@ -20,14 +20,16 @@ import java.util.List;
import junit.framework.TestCase;
+import org.apache.commons.lang.RandomStringUtils;
import org.eclipse.core.runtime.NullProgressMonitor;
-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.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.model.TracAction;
import org.eclipse.mylyn.internal.trac.core.model.TracSearch;
+import org.eclipse.mylyn.internal.trac.core.model.TracSearchFilter;
+import org.eclipse.mylyn.internal.trac.core.model.TracSearchFilter.CompareOperator;
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.model.TracTicketField;
@@ -36,10 +38,7 @@ import org.eclipse.mylyn.internal.trac.core.model.TracWikiPage;
import org.eclipse.mylyn.internal.trac.core.model.TracWikiPageInfo;
import org.eclipse.mylyn.trac.tests.support.TracFixture;
import org.eclipse.mylyn.trac.tests.support.TracHarness;
-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;
-import org.eclipse.mylyn.trac.tests.support.XmlRpcServer.Ticket;
/**
* @author Steffen Pingel
@@ -47,11 +46,9 @@ import org.eclipse.mylyn.trac.tests.support.XmlRpcServer.Ticket;
*/
public class TracXmlRpcClientTest extends TestCase {
- protected List<Ticket> tickets;
+ private static final int VERY_HIGH_REVISION = 100000;
- private TestData data;
-
- private ITracClient client;
+ private TracXmlRpcClient client;
private TracHarness harness;
@@ -59,9 +56,7 @@ public class TracXmlRpcClientTest extends TestCase {
protected void setUp() throws Exception {
TracFixture fixture = TracFixture.current();
harness = fixture.createHarness();
- client = fixture.connect();
- data = TracFixture.init010();
- tickets = data.tickets;
+ client = (TracXmlRpcClient) fixture.connect();
}
@Override
@@ -70,17 +65,17 @@ public class TracXmlRpcClientTest extends TestCase {
}
public void testValidateFailNoAuth() throws Exception {
- client = TracFixture.current().connect(TracTestConstants.TEST_TRAC_010_URL, "", "");
+ client = (TracXmlRpcClient) TracFixture.current().connect(client.getUrl(), "", "");
try {
client.validate(new NullProgressMonitor());
- fail("Expected TracPermissiongDeniedException");
+ fail("Expected TracPermissionDeniedException");
} catch (TracPermissionDeniedException e) {
}
}
public void testMulticallExceptions() throws Exception {
try {
- ((TracXmlRpcClient) client).getTickets(new int[] { 1, Integer.MAX_VALUE }, null);
+ client.getTickets(new int[] { 1, Integer.MAX_VALUE }, null);
fail("Expected TracRemoteException");
} catch (TracRemoteException e) {
}
@@ -88,7 +83,7 @@ public class TracXmlRpcClientTest extends TestCase {
public void testSingleCallExceptions() throws Exception {
try {
- ((TracXmlRpcClient) client).getTicketLastChanged(Integer.MAX_VALUE, null);
+ client.getTicketLastChanged(Integer.MAX_VALUE, null);
fail("Expected TracRemoteException");
} catch (TracRemoteException e) {
}
@@ -113,79 +108,67 @@ public class TracXmlRpcClientTest extends TestCase {
}
public void testSearchValidateTicket() throws Exception {
+ String uniqueTag = RandomStringUtils.randomAlphanumeric(6);
+ TracTicket ticket = harness.createTicket("searchValidateTicket " + uniqueTag);
+ ticket.putBuiltinValue(Key.COMPONENT, "component1");
+ ticket.putBuiltinValue(Key.DESCRIPTION, "description1");
+ ticket.putBuiltinValue(Key.MILESTONE, "milestone1");
+ ticket.putBuiltinValue(Key.REPORTER, "anonymous");
+ client.updateTicket(ticket, "", null);
+
TracSearch search = new TracSearch();
- search.addFilter("summary", "summary1");
+ search.addFilter(new TracSearchFilter("summary", CompareOperator.CONTAINS, uniqueTag));
List<TracTicket> result = new ArrayList<TracTicket>();
client.search(search, result, null);
assertEquals(1, result.size());
- 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));
- assertEquals("anonymous", result.get(0).getValue(Key.REPORTER));
- assertEquals("summary1", result.get(0).getValue(Key.SUMMARY));
- // assertEquals("", result.get(0).getValue(Key.VERSION));
+ // work around missing value
+ ticket.putBuiltinValue(Key.OWNER, "somebody");
+ TracTestUtil.assertTicketEquals(ticket, result.get(0));
}
public void testGetTicketActions() throws Exception {
- 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());
- }
+ TracTicket ticket = harness.createTicket("getTicketActions");
+ 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());
+ }
+
+ public void testGetTicketActionsClosed() throws Exception {
+ TracTicket ticket = harness.createTicket("getTicketActionsClosed");
+ ticket.putBuiltinValue(Key.STATUS, "closed");
+ ticket.putBuiltinValue(Key.RESOLUTION, "fixed");
+ client.updateTicket(ticket, "", null);
+
+ ticket = client.getTicket(ticket.getId(), null);
+ TracAction[] actions = ticket.getActions();
+ assertNotNull(actions);
+ assertEquals(2, actions.length);
+ assertEquals("leave", actions[0].getId());
+ assertEquals("reopen", actions[1].getId());
}
public void testWikiToHtml() throws Exception {
String tracUrl = client.getUrl();
- String html = ((TracXmlRpcClient) client).wikiToHtml("", null);
+ if (tracUrl.endsWith("/")) {
+ tracUrl = tracUrl.substring(0, tracUrl.length() - 1);
+ }
+ String html = client.wikiToHtml("", null);
assertEquals("", html);
- html = ((TracXmlRpcClient) client).wikiToHtml("A simple line of text.", null);
+ html = client.wikiToHtml("A simple line of text.", null);
assertEquals("<p>\nA simple line of text.\n</p>\n", html);
String source = "= WikiFormattingTesting =\n" + " * '''bold''', '''!''' can be bold too''', and '''! '''\n"
@@ -204,23 +187,27 @@ public class TracXmlRpcClientTest extends TestCase {
+ tracUrl
+ "/wiki/WikiFormattingTesting\" rel=\"nofollow\">WikiFormattingTesting?</a></h1>\n<ul><li><strong>bold</strong>, <strong>\'\'\' can be bold too</strong>, and <strong>! </strong>\n</li><li><i>italic</i>\n</li><li><strong><i>bold italic</i></strong>\n</li><li><span class=\"underline\">underline</span>\n</li><li><tt>monospace</tt> or <tt>monospace</tt>\n</li><li><del>strike-through</del>\n</li><li><sup>superscript</sup> \n</li><li><sub>subscript</sub>\n</li></ul><h1 id=\"Heading\">Heading</h1>\n<h2 id=\"Subheading\">Subheading</h2>\n";
}
- html = ((TracXmlRpcClient) client).wikiToHtml(source, null);
+ html = client.wikiToHtml(source, null);
assertEquals(expectedHtml, html);
}
public void testValidateWikiAPI() throws Exception {
- ((TracXmlRpcClient) client).validateWikiRpcApi(null);
+ client.validateWikiRpcApi(null);
}
public void testGetAllWikiPageNames() throws Exception {
- String[] names = ((TracXmlRpcClient) client).getAllWikiPageNames(null);
+ String[] names = client.getAllWikiPageNames(null);
List<String> all = Arrays.asList(names);
assertTrue(all.contains("Test"));
}
public void testGetWikiPage() throws Exception {
- TracWikiPage page = ((TracXmlRpcClient) client).getWikiPage("TestGetPage", null);
- assertEquals("TestGetPage", page.getPageInfo().getPageName());
+ String pageName = "TestGetPage" + RandomStringUtils.randomAlphanumeric(6);
+ harness.createWikiPage(pageName, "Version 1");
+ harness.createWikiPage(pageName, "Version 2");
+
+ TracWikiPage page = client.getWikiPage(pageName, null);
+ assertEquals(pageName, page.getPageInfo().getPageName());
assertEquals("tests@mylyn.eclipse.org", page.getPageInfo().getAuthor());
assertEquals(2, page.getPageInfo().getVersion());
// XXX The Date returned from Wiki API seems to have a problem with the Time Zone
@@ -229,109 +216,121 @@ public class TracXmlRpcClientTest extends TestCase {
assertEquals("Version 2", page.getContent());
assertTrue(page.getPageHTML().startsWith("<html>"));
- page = ((TracXmlRpcClient) client).getWikiPage("TestGetPage", 1, null);
- assertEquals("TestGetPage", page.getPageInfo().getPageName());
- assertEquals("anonymous", page.getPageInfo().getAuthor());
+ page = client.getWikiPage(pageName, 1, null);
+ assertEquals(pageName, page.getPageInfo().getPageName());
+ assertEquals("tests@mylyn.eclipse.org", page.getPageInfo().getAuthor());
assertEquals(1, page.getPageInfo().getVersion());
assertEquals("Version 1", page.getContent());
assertTrue(page.getPageHTML().startsWith("<html>"));
}
- public void testGetWikiPageInvalid() throws Exception {
- // get info -- non-existing version
+ public void testGetWikiPageInfoInvalidRevision() throws Exception {
try {
- ((TracXmlRpcClient) client).getWikiPageInfo("Test", 10, null);
+ client.getWikiPageInfo("Test", VERY_HIGH_REVISION, null);
fail("Expected TracRemoteException");
} catch (TracRemoteException e) {
}
+ }
- // get info -- non-existing page name
+ public void testGetWikiPageInfoInvalidPage() throws Exception {
try {
- ((TracXmlRpcClient) client).getWikiPageInfo("NoSuchPage", null);
+ client.getWikiPageInfo("NoSuchPage", null);
fail("Expected TracRemoteException");
} catch (TracRemoteException e) {
}
+ }
- // get info -- null parameter
+ public void testGetWikiPageInfoNull() throws Exception {
try {
- ((TracXmlRpcClient) client).getWikiPageInfo(null, null);
+ client.getWikiPageInfo(null, null);
fail("Expected RuntimeException");
} catch (IllegalArgumentException e) {
}
+ }
- // get content -- non-existing version
+ public void testGetWikiPageContentInvalidRevision() throws Exception {
try {
- ((TracXmlRpcClient) client).getWikiPageContent("Test", 10, null);
+ client.getWikiPageContent("Test", VERY_HIGH_REVISION, null);
fail("Expected TracRemoteException");
} catch (TracRemoteException e) {
}
+ }
- // get content -- non-existing page name
+ public void testGetWikiPageContentInvalidPage() throws Exception {
try {
- ((TracXmlRpcClient) client).getWikiPageContent("NoSuchPage", null);
+ client.getWikiPageContent("NoSuchPage", null);
fail("Expected TracRemoteException");
} catch (TracRemoteException e) {
}
+ }
- // get content -- null parameter
+ public void testGetWikiPageContentContentNull() throws Exception {
try {
- ((TracXmlRpcClient) client).getWikiPageContent(null, null);
+ client.getWikiPageContent(null, null);
fail("Expected RuntimeException");
} catch (IllegalArgumentException e) {
}
+ }
- // get HTML -- non-existing version
+ public void testGetWikiPageHtmlInvalidRevision() throws Exception {
try {
- ((TracXmlRpcClient) client).getWikiPageHtml("Test", 10, null);
+ client.getWikiPageHtml("Test", VERY_HIGH_REVISION, null);
fail("Expected TracRemoteException");
} catch (TracRemoteException e) {
}
+ }
- // get HTML -- non-existing page name
+ public void testGetWikiPageHtmlInvalidPage() throws Exception {
try {
- ((TracXmlRpcClient) client).getWikiPageHtml("NoSuchPage", null);
+ client.getWikiPageHtml("NoSuchPage", null);
fail("Expected TracRemoteException");
} catch (TracRemoteException e) {
}
+ }
- // get HTML -- null parameter
+ public void testGetWikiPageHtmlNull() throws Exception {
try {
- ((TracXmlRpcClient) client).getWikiPageHtml(null, null);
+ client.getWikiPageHtml(null, null);
fail("Expected RuntimeException");
} catch (IllegalArgumentException e) {
}
+ }
- // get a page -- non-existing version
+ public void testGetWikiPageInvalidRevision() throws Exception {
try {
- ((TracXmlRpcClient) client).getWikiPage("Test", 10, null);
+ client.getWikiPage("Test", VERY_HIGH_REVISION, null);
fail("Expected TracRemoteException");
} catch (TracRemoteException e) {
}
+ }
- // get a page -- non-existing page name
+ public void testGetWikiPageInvalidPage() throws Exception {
try {
- ((TracXmlRpcClient) client).getWikiPage("NoSuchPage", null);
+ client.getWikiPage("NoSuchPage", null);
fail("Expected TracRemoteException");
} catch (TracRemoteException e) {
}
+ }
- // get a page -- null parameter
+ public void testGetWikiPageNull() throws Exception {
try {
- ((TracXmlRpcClient) client).getWikiPage(null, null);
+ client.getWikiPage(null, null);
fail("Expected RuntimeException");
} catch (IllegalArgumentException e) {
}
+ }
- // get all versions of a page -- non-existing page name
+ public void testGetWikiInfoAllVersionsInvalidPage() throws Exception {
try {
- ((TracXmlRpcClient) client).getWikiPageInfoAllVersions("NoSuchPage", null);
+ client.getWikiPageInfoAllVersions("NoSuchPage", null);
fail("Expected TracRemoteException");
} catch (TracRemoteException e) {
}
+ }
- // get all versions of a page -- null parameter
+ public void testGetWikiInfoAllVersionsInvalidPageNull() throws Exception {
try {
- ((TracXmlRpcClient) client).getWikiPageInfoAllVersions(null, null);
+ client.getWikiPageInfoAllVersions(null, null);
fail("Expected RuntimeException");
} catch (IllegalArgumentException e) {
}
@@ -339,8 +338,9 @@ public class TracXmlRpcClientTest extends TestCase {
public void testGetWikiPageInfoAllVersions() throws Exception {
String pageName = "Test";
+ harness.createWikiPage(pageName, "test content " + RandomStringUtils.randomAlphanumeric(6));
- TracWikiPageInfo[] versions = ((TracXmlRpcClient) client).getWikiPageInfoAllVersions(pageName, null);
+ TracWikiPageInfo[] versions = client.getWikiPageInfoAllVersions(pageName, null);
assertTrue(versions.length >= 1);
int counter = 1;
for (TracWikiPageInfo version : versions) {
@@ -350,7 +350,8 @@ public class TracXmlRpcClientTest extends TestCase {
}
public void testGetRecentWikiChanges() throws Exception {
- TracWikiPageInfo[] changes = ((TracXmlRpcClient) client).getRecentWikiChanges(new Date(0), null);
+ harness.createWikiPage("Test", "test content " + RandomStringUtils.randomAlphanumeric(6));
+ TracWikiPageInfo[] changes = client.getRecentWikiChanges(new Date(0), null);
TracWikiPageInfo testPage = null;
for (TracWikiPageInfo item : changes) {
assertTrue(item.getPageName() != null);
@@ -361,10 +362,6 @@ public class TracXmlRpcClientTest extends TestCase {
assertTrue(testPage != null);
}
- public void testPutWikiPage() throws Exception {
- // TODO testing wiki.putPage()
- }
-
public void testInvalidCharacters() throws Exception {
TracTicket ticket = harness.createTicket("invalid characters");
ticket.putBuiltinValue(Key.DESCRIPTION, "Control Character: \u0002");
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracXmlRpcTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracXmlRpcTest.java
index 8843c0c5b..fe6ea463c 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracXmlRpcTest.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracXmlRpcTest.java
@@ -30,7 +30,7 @@ import org.eclipse.mylyn.commons.repositories.core.auth.UserCredentials;
import org.eclipse.mylyn.commons.sdk.util.CommonTestUtil;
import org.eclipse.mylyn.commons.sdk.util.CommonTestUtil.PrivilegeLevel;
import org.eclipse.mylyn.internal.trac.core.util.TracHttpClientTransportFactory;
-import org.eclipse.mylyn.trac.tests.support.TracTestConstants;
+import org.eclipse.mylyn.trac.tests.support.TracFixture;
/**
* Test cases for <a href="http://trac-hacks.org/wiki/XmlRpcPlugin">Trac XML-RPC Plugin</a> (revision 1188 or higher is
@@ -62,7 +62,7 @@ public class TracXmlRpcTest extends TestCase {
random = new Random();
UserCredentials credentials = CommonTestUtil.getCredentials(PrivilegeLevel.ADMIN);
- createConnection(new URL(TracTestConstants.TEST_TRAC_010_URL + XMLRPC_URL), credentials.getUserName(),
+ createConnection(new URL(TracFixture.current().getRepositoryUrl() + XMLRPC_URL), credentials.getUserName(),
credentials.getPassword());
tickets = new ArrayList<Integer>();
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 41570ef54..523b20be2 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
@@ -17,14 +17,13 @@ import org.eclipse.core.runtime.NullProgressMonitor;
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.TracCorePlugin;
import org.eclipse.mylyn.internal.trac.core.client.ITracClient;
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;
/**
* @author Steffen Pingel
@@ -32,7 +31,7 @@ import org.eclipse.mylyn.trac.tests.support.TracTestConstants;
public class TracRepositoryQueryTest extends TestCase {
public void testChangeRepositoryUrl() throws Exception {
- TaskRepository repository = TracFixture.TRAC_0_12_XML_RPC.singleRepository();
+ TaskRepository repository = new TaskRepository(TracCorePlugin.CONNECTOR_KIND, "http://mylyn.org/trac-one");
TracSearch search = new TracSearch();
String queryUrl = repository.getRepositoryUrl() + ITracClient.QUERY_URL + search.toUrl();
@@ -46,7 +45,7 @@ public class TracRepositoryQueryTest extends TestCase {
TasksUiPlugin.getTaskList().addTask(task);
String oldUrl = repository.getRepositoryUrl();
- String newUrl = TracTestConstants.TEST_TRAC_010_URL;
+ String newUrl = "http://mylyn.org/trac-two";
new RefactorRepositoryUrlOperation(oldUrl, newUrl).run(new NullProgressMonitor());
repository.setRepositoryUrl(newUrl);
@@ -54,4 +53,5 @@ public class TracRepositoryQueryTest extends TestCase {
assertEquals(newUrl + ITracClient.QUERY_URL + search.toUrl(), query.getUrl());
assertEquals(newUrl + ITracClient.TICKET_URL + taskId, task.getUrl());
}
+
}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracUtilTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracUtilTest.java
index 0fe864049..ab622f91f 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracUtilTest.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracUtilTest.java
@@ -24,7 +24,6 @@ import org.eclipse.mylyn.internal.trac.core.util.TracUtil;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.TasksUi;
-import org.eclipse.mylyn.trac.tests.support.TracTestConstants;
/**
* @author Steffen Pingel
@@ -35,7 +34,7 @@ public class TracUtilTest extends TestCase {
@Override
protected void setUp() throws Exception {
- taskRepository = new TaskRepository(TracCorePlugin.CONNECTOR_KIND, TracTestConstants.TEST_TRAC_010_URL);
+ taskRepository = new TaskRepository(TracCorePlugin.CONNECTOR_KIND, "http://mylyn.org/trac");
}
public void testToTracSearch() {
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracFixture.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracFixture.java
index c8d4587c1..8d1eecf5e 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracFixture.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracFixture.java
@@ -23,6 +23,7 @@ import org.eclipse.mylyn.commons.repositories.core.auth.UserCredentials;
import org.eclipse.mylyn.commons.sdk.util.CommonTestUtil;
import org.eclipse.mylyn.commons.sdk.util.CommonTestUtil.PrivilegeLevel;
import org.eclipse.mylyn.commons.sdk.util.FixtureConfiguration;
+import org.eclipse.mylyn.commons.sdk.util.TestConfiguration;
import org.eclipse.mylyn.internal.trac.core.TracClientFactory;
import org.eclipse.mylyn.internal.trac.core.TracCorePlugin;
import org.eclipse.mylyn.internal.trac.core.TracRepositoryConnector;
@@ -42,81 +43,9 @@ public class TracFixture extends TestFixture {
public static String TAG_MISC = "misc";
- private static TracFixture current;
-
- public static XmlRpcServer.TestData data010;
-
- public static TracFixture TRAC_INVALID = new TracFixture(Version.TRAC_0_9, TracTestConstants.TEST_TRAC_INVALID_URL,
- "0.11", "Invalid URL");
-
-// 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 TRAC_0_12_WEB = new TracFixture(Version.TRAC_0_9, TracTestConstants.TEST_TRAC_012_URL,
- "0.12", "Web");
-
- public static TracFixture TRAC_0_12_XML_RPC = new TracFixture(Version.XML_RPC, TracTestConstants.TEST_TRAC_012_URL,
- "0.12", "XML-RPC");
-
- public static TracFixture TRAC_1_0_WEB = new TracFixture(Version.TRAC_0_9, TracTestConstants.TEST_TRAC_10_URL,
- "1.0", "Web");
-
- public static TracFixture TRAC_1_0_XML_RPC = new TracFixture(Version.XML_RPC, TracTestConstants.TEST_TRAC_10_URL,
- "1.0", "XML-RPC");
-
- public static TracFixture TRAC_TRUNK_WEB = new TracFixture(Version.TRAC_0_9, TracTestConstants.TEST_TRAC_TRUNK_URL,
- "0.12dev-r0", "Web");
-
- public static TracFixture TRAC_TRUNK_XML_RPC = new TracFixture(Version.XML_RPC,
- TracTestConstants.TEST_TRAC_TRUNK_URL, "0.13dev-r0", "XML-RPC");
+ public static final String TAG_TEST = "test";
- public static TracFixture DEFAULT = TRAC_1_0_XML_RPC;
-
- //public static TracFixture DEFAULT = TRAC_0_11_WEB;
-
- /**
- * Standard configurations for running all test against.
- */
- public static final TracFixture[] ALL = new TracFixture[] { TRAC_0_10_WEB, TRAC_0_11_WEB, TRAC_0_12_WEB,
- /*TRAC_TRUNK_WEB, */TRAC_0_10_XML_RPC, TRAC_0_11_XML_RPC, TRAC_0_12_XML_RPC, TRAC_1_0_WEB, TRAC_1_0_XML_RPC, /*TRAC_TRUNK_XML_RPC, TRAC_0_10_XML_RPC_SSL, */};
-
-// public static final TracFixture[] ALL = new TracFixture[] { TRAC_TRUNK_XML_RPC };
-
- /**
- * Misc configurations for running a limited number of test against.
- */
- public static final TracFixture[] MISC = new TracFixture[] { TRAC_0_10_XML_RPC_DIGEST_AUTH,
- TRAC_0_10_XML_RPC_FORM_AUTH, };
-
-// public static final TracFixture[] MISC = new TracFixture[] {};
-
- public static void cleanup010() throws Exception {
- if (data010 != null) {
- // data010.cleanup();
- data010 = null;
- }
- }
+ private static TracFixture current;
public static TracFixture current(TracFixture fixture) {
if (current == null) {
@@ -126,42 +55,7 @@ public class TracFixture extends TestFixture {
}
public static TracFixture current() {
- return current(DEFAULT);
- }
-
- public static XmlRpcServer.TestData init010() throws Exception {
- if (data010 == null) {
- UserCredentials credentials = CommonTestUtil.getCredentials(PrivilegeLevel.USER);
- XmlRpcServer server = new XmlRpcServer(TracTestConstants.TEST_TRAC_010_URL, credentials.getUserName(),
- credentials.getPassword());
-
- 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();
+ return current(TestConfiguration.getDefault().discoverDefault(TracFixture.class, "trac"));
}
private final Version accessMode;
@@ -197,7 +91,7 @@ public class TracFixture extends TestFixture {
@Override
protected TestFixture getDefault() {
- return DEFAULT;
+ return TestConfiguration.getDefault().discoverDefault(TracFixture.class, "trac");
}
public ITracClient connect() throws Exception {
@@ -295,28 +189,4 @@ public class TracFixture extends TestFixture {
return tags.contains(tag);
}
-// 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/TracHarness.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracHarness.java
index 93a9eb1c0..eb3dfcfc1 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracHarness.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracHarness.java
@@ -12,14 +12,15 @@
package org.eclipse.mylyn.trac.tests.support;
import java.io.ByteArrayInputStream;
+import java.util.Collections;
import org.eclipse.mylyn.commons.sdk.util.CommonTestUtil.PrivilegeLevel;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
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.internal.trac.core.client.InvalidTicketException;
import org.eclipse.mylyn.internal.trac.core.client.TracException;
+import org.eclipse.mylyn.internal.trac.core.client.TracXmlRpcClient;
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.ITask;
@@ -31,7 +32,7 @@ public class TracHarness {
private final TracFixture fixture;
- private ITracClient priviledgedClient;
+ private TracXmlRpcClient priviledgedClient;
private TaskRepository repository;
@@ -43,9 +44,9 @@ public class TracHarness {
return fixture;
}
- private ITracClient priviledgedClient() throws Exception {
+ private TracXmlRpcClient priviledgedClient() throws Exception {
if (priviledgedClient == null) {
- priviledgedClient = fixture.connectXmlRpc(PrivilegeLevel.USER);
+ priviledgedClient = (TracXmlRpcClient) fixture.connectXmlRpc(PrivilegeLevel.USER);
}
return priviledgedClient;
}
@@ -67,6 +68,10 @@ public class TracHarness {
return ticket;
}
+ public void createMilestone(String milestone) throws Exception {
+ new XmlRpcServer(priviledgedClient()).ticketMilestone(milestone).deleteAndCreate();
+ }
+
public TracTicket createTicketWithMilestone(String summary, String milestone) throws Exception {
TracTicket ticket = newTicket(summary);
ticket.putBuiltinValue(Key.MILESTONE, milestone);
@@ -119,4 +124,8 @@ public class TracHarness {
return Version.XML_RPC.name().equals(repository().getVersion());
}
+ public void createWikiPage(String pageName, String content) throws Exception {
+ priviledgedClient().putWikipage(pageName, content, Collections.<String, Object> emptyMap(), null);
+ }
+
}
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 c5fc4d344..39b9424dd 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
@@ -47,7 +47,13 @@ public class TracTestCleanupUtil extends TestCase {
return data;
}
+ public TracTestCleanupUtil(String name) {
+ super(name);
+ this.fixture = TracFixture.current();
+ }
+
public TracTestCleanupUtil(TracFixture fixture, String name) {
+ super(name);
this.fixture = fixture;
}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracTestConstants.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracTestConstants.java
deleted file mode 100644
index 8708e051b..000000000
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracTestConstants.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 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 org.eclipse.mylyn.commons.sdk.util.TestConfiguration;
-
-/**
- * @author Steffen Pingel
- */
-public class TracTestConstants {
-
- public static final String TEST_TRAC_010_URL = TestConfiguration.getRepositoryUrl("trac010");
-
- public static final String TEST_TRAC_010_SSL_URL = TestConfiguration.getRepositoryUrl("trac010", true);
-
- public static final String TEST_TRAC_010_DIGEST_AUTH_URL = TestConfiguration.getRepositoryUrl("trac010digest");
-
- public static final String TEST_TRAC_010_FORM_AUTH_URL = TestConfiguration.getRepositoryUrl("trac010formauth");
-
- public static final String TEST_TRAC_011_URL = TestConfiguration.getRepositoryUrl("trac-0.11.7");
-
- public static final String TEST_TRAC_012_URL = TestConfiguration.getRepositoryUrl("trac-0.12.5");
-
- public static final String TEST_TRAC_10_URL = TestConfiguration.getRepositoryUrl("trac-1.0");
-
- public static final String TEST_TRAC_TRUNK_URL = TestConfiguration.getRepositoryUrl("trac-trunk");
-
- public static final String TEST_TRAC_INVALID_URL = TestConfiguration.getRepositoryUrl("doesnotexist");
-
-}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/XmlRpcServer.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/XmlRpcServer.java
index 2bdc219e1..75a8fff26 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/XmlRpcServer.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/XmlRpcServer.java
@@ -12,7 +12,6 @@
package org.eclipse.mylyn.trac.tests.support;
import java.io.IOException;
-import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Hashtable;
@@ -22,8 +21,6 @@ import java.util.Vector;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
-import org.eclipse.mylyn.commons.net.WebLocation;
-import org.eclipse.mylyn.internal.trac.core.client.ITracClient.Version;
import org.eclipse.mylyn.internal.trac.core.client.TracXmlRpcClient;
/**
@@ -129,12 +126,6 @@ public class XmlRpcServer {
// all created tickets
public List<Ticket> tickets = new ArrayList<Ticket>();
- public int attachmentTicketId = 5;
-
- public int htmlEntitiesTicketId = 6;
-
- public int offlineHandlerTicketId = 7;
-
/**
* Undo all changes.
*/
@@ -276,23 +267,9 @@ public class XmlRpcServer {
private final TestData data;
- private final String password;
-
- private final TracXmlRpcClient repository;
-
- private final String url;
-
- private final String username;
-
- public XmlRpcServer(String url, String username, String password) throws Exception {
- this.url = url;
- this.username = username;
- this.password = password;
-
+ public XmlRpcServer(TracXmlRpcClient client) throws Exception {
+ this.client = client.getClient();
this.data = new TestData();
-
- this.repository = new TracXmlRpcClient(new WebLocation(url, username, password), Version.XML_RPC);
- this.client = repository.getClient();
}
private Object call(String method, Object... parameters) throws XmlRpcException, IOException {
@@ -312,22 +289,6 @@ public class XmlRpcServer {
return data;
}
- public String getPassword() {
- return password;
- }
-
- public TracXmlRpcClient getRepository() throws MalformedURLException {
- return repository;
- }
-
- public String getUrl() {
- return url;
- }
-
- public String getUsername() {
- return username;
- }
-
public Ticket ticket() throws Exception {
return new Ticket(null);
}
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 bad8bd479..701cf2609 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
@@ -20,6 +20,7 @@ import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.mylyn.commons.net.AuthenticationType;
+import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiExtensionReader;
import org.eclipse.mylyn.internal.tasks.ui.wizards.EditRepositoryWizard;
import org.eclipse.mylyn.internal.trac.core.TracRepositoryConnector;
import org.eclipse.mylyn.internal.trac.core.client.ITracClient;
@@ -65,6 +66,8 @@ public class TracRepositorySettingsPageTest extends TestCase {
private WizardDialog dialog;
+ private TracFixture fixture;
+
public TracRepositorySettingsPageTest() {
}
@@ -86,6 +89,8 @@ public class TracRepositorySettingsPageTest extends TestCase {
dialog.create();
// page.createControl(dialog.getShell());
// page.setVisible(true);
+
+ fixture = TracFixture.current();
}
@Override
@@ -107,32 +112,20 @@ public class TracRepositorySettingsPageTest extends TestCase {
validator = page.new TracValidator(page.createTaskRepository(), fixture.getAccessMode());
}
- public void testValidateXmlRpc() throws Exception {
- initialize(TracFixture.TRAC_0_10_XML_RPC);
-
- validator.run(new NullProgressMonitor());
- assertNull(validator.getResult());
- assertNull(validator.getStatus());
-
- page.applyValidatorResult(validator);
- assertEquals(Version.XML_RPC, page.getTracVersion());
- assertEquals("Authentication credentials are valid.", page.getMessage());
- }
-
- public void testValidateWeb() throws Exception {
- initialize(TracFixture.TRAC_0_10_WEB);
+ public void testValidate() throws Exception {
+ initialize(fixture);
validator.run(new NullProgressMonitor());
assertNull(validator.getResult());
assertNull(validator.getStatus());
page.applyValidatorResult(validator);
- assertEquals(Version.TRAC_0_9, page.getTracVersion());
+ assertEquals(fixture.getAccessMode(), page.getTracVersion());
assertEquals("Authentication credentials are valid.", page.getMessage());
}
public void testValidateAutomaticUser() throws Exception {
- initialize(TracFixture.TRAC_0_10_XML_RPC);
+ initialize(fixture);
page.setTracVersion(null);
validator = page.new TracValidator(page.createTaskRepository(), null);
@@ -147,7 +140,7 @@ public class TracRepositorySettingsPageTest extends TestCase {
}
public void testValidateAutomaticAnonymous() throws Exception {
- initialize(TracFixture.TRAC_0_10_XML_RPC);
+ initialize(fixture);
page.setUserId("");
page.setPassword("");
@@ -166,8 +159,9 @@ public class TracRepositorySettingsPageTest extends TestCase {
}
public void testValidateInvalid() throws Exception {
- initialize(TracFixture.TRAC_INVALID);
+ initialize(fixture);
+ page.setUrl("http://mylyn.org/doesnotexist");
page.setTracVersion(null);
validator = page.new TracValidator(page.createTaskRepository(), null);
@@ -197,11 +191,14 @@ public class TracRepositorySettingsPageTest extends TestCase {
}
public void testClientManagerChangeTaskRepositorySettings() throws Exception {
- TaskRepository repository = TracFixture.TRAC_0_10_WEB.singleRepository();
- TracRepositoryConnector connector = (TracRepositoryConnector) TracFixture.TRAC_0_10_WEB.connector();
+ TracRepositoryConnector connector = fixture.connector();
+ TaskRepository repository = fixture.singleRepository();
+ repository.setVersion(Version.TRAC_0_9.name());
ITracClient client = connector.getClientManager().getTracClient(repository);
assertEquals(Version.TRAC_0_9, client.getAccessMode());
+ TasksUiExtensionReader.initWorkbenchUiExtensions();
+
EditRepositoryWizard wizard = new EditRepositoryWizard(repository);
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
WizardDialog dialog = new WizardDialog(shell, wizard);
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
deleted file mode 100644
index bbe71a494..000000000
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/ui/TracTaskEditorTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * 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.ui;
-
-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.tasks.core.ITask;
-import org.eclipse.mylyn.tasks.core.TaskRepository;
-import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
-import org.eclipse.mylyn.trac.tests.support.TracFixture;
-import org.eclipse.mylyn.trac.tests.support.TracHarness;
-
-/**
- * @author Steffen Pingel
- */
-public class TracTaskEditorTest extends TestCase {
-
- private TracHarness harness;
-
- @Override
- protected void setUp() throws Exception {
- TracFixture fixture = TracFixture.current();
- harness = fixture.createHarness();
- }
-
- @Override
- protected void tearDown() throws Exception {
- harness.dispose();
- }
-
- public void testGetSelectedRepository() throws Exception {
- TaskRepository repository = harness.repository();
- ITask task = harness.createTask("testGetSelectedRepository");
- TasksUiPlugin.getTaskList().addTask(task);
- TasksUiUtil.openTask(task);
-
- TaskListView taskListView = TaskListView.getFromActivePerspective();
- // force refresh since automatic refresh is delayed
- taskListView.getViewer().refresh();
- taskListView.getViewer().expandAll();
- taskListView.getViewer().setSelection(new StructuredSelection(task));
-
- assertFalse(taskListView.getViewer().getSelection().isEmpty());
- assertEquals(repository, TasksUiUtil.getSelectedRepository(taskListView.getViewer()));
- }
-
-}

Back to the top