summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Pingel2012-12-02 17:46:46 (EST)
committer Steffen Pingel2013-04-11 19:32:40 (EDT)
commit0fc792d196e825bc409f6b7be6e8d883d792ba38 (patch)
tree96792d24811902130387aef054a18f4b67f78b4a
parent98cbe01c925cf613832919c62d633f6027264fb5 (diff)
downloadorg.eclipse.mylyn.tasks-0fc792d196e825bc409f6b7be6e8d883d792ba38.zip
org.eclipse.mylyn.tasks-0fc792d196e825bc409f6b7be6e8d883d792ba38.tar.gz
org.eclipse.mylyn.tasks-0fc792d196e825bc409f6b7be6e8d883d792ba38.tar.bz2
400396: consume Trac fixtures from servicerefs/changes/99/8999/6
Change-Id: Ia3811b53d37bc21b33ae69b5726db73fa8d7cb85 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=400396
-rw-r--r--org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/TestFixture.java4
-rw-r--r--org.eclipse.mylyn.trac.releng/modules/trac/manifests/defaultsites.pp29
-rw-r--r--org.eclipse.mylyn.trac.releng/modules/trac/manifests/service.pp1
-rw-r--r--org.eclipse.mylyn.trac.releng/modules/trac/manifests/site.pp5
-rw-r--r--org.eclipse.mylyn.trac.releng/modules/trac/templates/service.json.erb8
-rw-r--r--org.eclipse.mylyn.trac.releng/modules/trac/templates/trac.ini.erb3
-rw-r--r--org.eclipse.mylyn.trac.tests/.gitignore1
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AllTracHeadlessStandaloneTests.java18
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AllTracTests.java32
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracClientTest.java44
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracXmlRpcClientTest.java16
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracAttachmentHandlerTest.java78
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracClientManagerTest.java31
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracRepositoryConnectorTest.java75
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracRepositoryConnectorWebTest.java27
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracTaskDataHandlerXmlRpcTest.java57
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracFixture.java42
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracHarness.java122
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracTestCleanupUtil.java92
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracTestConstants.java8
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracTestUtil.java82
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/ui/TracRepositorySettingsPageTest.java28
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/ui/TracTaskEditorTest.java18
23 files changed, 470 insertions, 351 deletions
diff --git a/org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/TestFixture.java b/org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/TestFixture.java
index f2cfd6e..3877646 100644
--- a/org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/TestFixture.java
+++ b/org.eclipse.mylyn.tests.util/src/org/eclipse/mylyn/tests/util/TestFixture.java
@@ -251,6 +251,10 @@ public abstract class TestFixture {
}
}
+ public boolean hasTag(String tag) {
+ return false;
+ }
+
public boolean isExcluded() {
String excludeFixture = System.getProperty("mylyn.test.exclude", "");
String[] excludeFixtureArray = excludeFixture.split(",");
diff --git a/org.eclipse.mylyn.trac.releng/modules/trac/manifests/defaultsites.pp b/org.eclipse.mylyn.trac.releng/modules/trac/manifests/defaultsites.pp
index 68a17f8..6b1e3c1 100644
--- a/org.eclipse.mylyn.trac.releng/modules/trac/manifests/defaultsites.pp
+++ b/org.eclipse.mylyn.trac.releng/modules/trac/manifests/defaultsites.pp
@@ -28,12 +28,15 @@ define trac::defaultsites ($base = $trac::base, $userOwner = $trac::userOwner, $
trac::trac { "0.11.7":
}
- trac::trac { "0.12.4":
+ trac::trac { "0.12.5":
}
trac::trac { "1.0":
}
+ trac::trac { "1.0.1":
+ }
+
trac::trac { "trunk":
}
@@ -56,37 +59,43 @@ define trac::defaultsites ($base = $trac::base, $userOwner = $trac::userOwner, $
/* Sites */
- trac::site { "trac-0.11":
+ trac::site { "trac-0.11.7":
version => "0.11.7",
require => Trac["0.11.7"],
}
- trac::site { "trac-0.12":
- version => "0.12.4",
- require => Trac["0.12.4"],
+ trac::site { "trac-0.12.5":
+ version => "0.12.5",
+ require => Trac["0.12.5"],
}
trac::site { "trac-1.0":
version => "1.0",
- require => Trac["1.0"],
+ require => Trac["1.0"]
+ }
+
+ trac::site { "trac-1.0.1":
+ version => "1.0.1",
+ require => Trac["1.0.1"],
+ envdefault => 1,
}
- trac::site { "trac-allbasic":
+ trac::site { "trac-1.0-allbasic":
allbasicauth => true,
envinfo => "AllBasicAuth",
}
- trac::site { "trac-cert":
+ trac::site { "trac-1.0-cert":
certauth => true,
envinfo => "CertAuth",
}
- trac::site { "trac-digest":
+ trac::site { "trac-1.0-digest":
digestauth => true,
envinfo => "DigestAuth",
}
- trac::site { "trac-form-auth":
+ trac::site { "trac-1.0-form-auth":
accountmanagerplugin => "0.11",
envinfo => "FormAuth",
}
diff --git a/org.eclipse.mylyn.trac.releng/modules/trac/manifests/service.pp b/org.eclipse.mylyn.trac.releng/modules/trac/manifests/service.pp
index 96b41c1..e15a608 100644
--- a/org.eclipse.mylyn.trac.releng/modules/trac/manifests/service.pp
+++ b/org.eclipse.mylyn.trac.releng/modules/trac/manifests/service.pp
@@ -3,6 +3,7 @@ define trac::service (
$version,
$envtype = "trac",
$envinfo = "",
+ $envdefault = 0,
$envmode = "XML-RPC",
$accessmode = "XML_RPC",
$base = $trac::base,
diff --git a/org.eclipse.mylyn.trac.releng/modules/trac/manifests/site.pp b/org.eclipse.mylyn.trac.releng/modules/trac/manifests/site.pp
index facacc7..78fdd99 100644
--- a/org.eclipse.mylyn.trac.releng/modules/trac/manifests/site.pp
+++ b/org.eclipse.mylyn.trac.releng/modules/trac/manifests/site.pp
@@ -10,6 +10,7 @@ define trac::site (
$base = $trac::base,
$envtype = "trac",
$envinfo = "",
+ $envdefault = 0,
$userOwner = $trac::userOwner,
$userGroup = $trac::userGroup,) {
$prefix = "$base/share/trac-$version"
@@ -41,7 +42,7 @@ define trac::site (
}
exec { "svn create $envid":
- command => "svnadmin create $envbase/svn",
+ command => "/usr/bin/svnadmin create $envbase/svn",
require => File["$envbase/svn"],
creates => "$envbase/svn/format",
user => "www-data",
@@ -158,6 +159,7 @@ define trac::site (
envid => "$title",
version => "$version",
envinfo => "$envinfo",
+ envdefault => $envdefault,
envmode => "XML-RPC",
accessmode => "XML_RPC",
}
@@ -166,6 +168,7 @@ define trac::site (
envid => "$title",
version => "$version",
envinfo => "$envinfo",
+ envdefault => 0,
envmode => "Web",
accessmode => "TRAC_0_9",
}
diff --git a/org.eclipse.mylyn.trac.releng/modules/trac/templates/service.json.erb b/org.eclipse.mylyn.trac.releng/modules/trac/templates/service.json.erb
index dfff4a5..41d4d8e 100644
--- a/org.eclipse.mylyn.trac.releng/modules/trac/templates/service.json.erb
+++ b/org.eclipse.mylyn.trac.releng/modules/trac/templates/service.json.erb
@@ -7,7 +7,15 @@
<% else %>
"info": "<%= envinfo %>/<%= envmode %>",
<% end %>
+ "tags": [
+<% if @envinfo == "DigestAuth" || @envinfo == "FormAuth" %>
+ "misc"
+<% end %>
+ ],
"properties":{
+<% if @envdefault != 0 %>
+ "default": "<%= envdefault %>",
+<% end %>
"version": "<%= accessmode %>"
}
}
diff --git a/org.eclipse.mylyn.trac.releng/modules/trac/templates/trac.ini.erb b/org.eclipse.mylyn.trac.releng/modules/trac/templates/trac.ini.erb
index e57ea70..5d21495 100644
--- a/org.eclipse.mylyn.trac.releng/modules/trac/templates/trac.ini.erb
+++ b/org.eclipse.mylyn.trac.releng/modules/trac/templates/trac.ini.erb
@@ -35,9 +35,8 @@ acct_mgr.web_ui.RegistrationModule = disabled
<% if @accountmanagerplugin != "" %>
[account-manager]
-password_format = htpasswd
password_store = HtPasswdStore
-password_file = <%= envbase %>/htpasswd
+htpasswd_file = <%= envbase %>/htpasswd
<% end %>
[header_logo]
diff --git a/org.eclipse.mylyn.trac.tests/.gitignore b/org.eclipse.mylyn.trac.tests/.gitignore
new file mode 100644
index 0000000..7ee7b6c
--- /dev/null
+++ b/org.eclipse.mylyn.trac.tests/.gitignore
@@ -0,0 +1 @@
+/local.json
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 f91121a..610cbc8 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
@@ -11,6 +11,8 @@
package org.eclipse.mylyn.trac.tests;
+import java.util.List;
+
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -42,22 +44,17 @@ public class AllTracHeadlessStandaloneTests {
suite.addTestSuite(TracTicketTest.class);
suite.addTestSuite(TracRepositoryInfoTest.class);
suite.addTestSuite(TracClientProxyTest.class);
- // core tests
- suite.addTestSuite(TracClientManagerTest.class);
// network tests
if (!configuration.isLocalOnly()) {
- if (configuration.isDefaultOnly()) {
- addTests(suite, TracFixture.DEFAULT);
- } else {
- for (TracFixture fixture : TracFixture.ALL) {
- addTests(suite, fixture);
- }
- // validation tests
- for (TracFixture fixture : TracFixture.MISC) {
+ List<TracFixture> fixtures = configuration.discover(TracFixture.class, "trac");
+ for (TracFixture fixture : fixtures) {
+ if (fixture.hasTag(TracFixture.TAG_MISC)) {
fixture.createSuite(suite);
fixture.add(TracClientFactoryTest.class);
fixture.add(TracClientTest.class);
fixture.done();
+ } else {
+ addTests(suite, fixture);
}
}
}
@@ -66,6 +63,7 @@ public class AllTracHeadlessStandaloneTests {
private static void addTests(TestSuite suite, TracFixture fixture) {
fixture.createSuite(suite);
+ fixture.add(TracClientManagerTest.class);
fixture.add(TracClientFactoryTest.class);
fixture.add(TracClientTest.class);
if (fixture.getAccessMode() == Version.XML_RPC) {
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 7573f90..54ce57d 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
@@ -11,6 +11,8 @@
package org.eclipse.mylyn.trac.tests;
+import java.util.List;
+
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -29,7 +31,6 @@ 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
@@ -50,31 +51,28 @@ public class AllTracTests {
}
public static void addTests(TestSuite suite, TestConfiguration configuration) {
- if (configuration.hasKind(TestKind.INTEGRATION) && !configuration.isLocalOnly()
- && CommonTestUtil.hasCredentials(PrivilegeLevel.ADMIN)) {
- suite.addTestSuite(TracTestCleanupUtil.class);
- }
-
- suite.addTest(AllTracHeadlessStandaloneTests.suite(configuration));
+ // FIXME re-enable
+ //suite.addTest(AllTracHeadlessStandaloneTests.suite(configuration));
suite.addTestSuite(TracUtilTest.class);
- // XXX fails when run from continuous build: suite.addTestSuite(TracTaskEditorTest.class);
+ // FIXME move test to tasks framework
+ //suite.addTestSuite(TracTaskEditorTest.class);
suite.addTestSuite(TracHyperlinkUtilTest.class);
if (!configuration.isLocalOnly()) {
suite.addTestSuite(TracRepositoryQueryTest.class);
- suite.addTestSuite(TracRepositorySettingsPageTest.class);
+ // FIXME re-enable
+ //suite.addTestSuite(TracRepositorySettingsPageTest.class);
// network tests
- if (configuration.isDefaultOnly()) {
- addTests(suite, TracFixture.DEFAULT);
- } else {
- for (TracFixture fixture : TracFixture.ALL) {
- addTests(suite, fixture);
+ List<TracFixture> fixtures = configuration.discover(TracFixture.class, "trac");
+ for (TracFixture fixture : fixtures) {
+ if (!fixture.hasTag(TracFixture.TAG_MISC)) {
+ addTests(suite, configuration, fixture);
}
}
}
}
- protected static void addTests(TestSuite suite, TracFixture fixture) {
+ protected static void addTests(TestSuite suite, TestConfiguration configuration, TracFixture fixture) {
fixture.createSuite(suite);
fixture.add(TracRepositoryConnectorTest.class);
if (fixture.getAccessMode() == Version.XML_RPC) {
@@ -83,6 +81,10 @@ 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/TracClientTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracClientTest.java
index 525f371..9389f0f 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
@@ -38,6 +38,7 @@ import org.eclipse.mylyn.internal.trac.core.model.TracTicket.Key;
import org.eclipse.mylyn.internal.trac.core.model.TracTicketField;
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;
@@ -57,14 +58,15 @@ public class TracClientTest extends TestCase {
protected List<Ticket> tickets;
+ private TracHarness harness;
+
public TracClientTest() {
}
@Override
protected void setUp() throws Exception {
- super.setUp();
-
fixture = TracFixture.current();
+ harness = fixture.createHarness();
client = fixture.connect();
data = TracFixture.init010();
tickets = data.tickets;
@@ -72,23 +74,16 @@ public class TracClientTest extends TestCase {
@Override
protected void tearDown() throws Exception {
- super.tearDown();
-
- // TestFixture.cleanupRepository1();
+ harness.dispose();
}
public void testGetTicket() throws Exception {
+ TracTicket expectedTicket = harness.createTicket("getTicket");
TracTicket ticket = client.getTicket(tickets.get(0).getId(), null);
- TracTestUtil.assertTicketEquals(tickets.get(0), ticket);
-
- ticket = client.getTicket(tickets.get(1).getId(), null);
- TracTestUtil.assertTicketEquals(tickets.get(1), ticket);
+ TracTestUtil.assertTicketEquals(expectedTicket, ticket);
}
public void testGetTicketInvalidId() throws Exception {
-// if (version == Version.XML_RPC) {
-// return;
-// }
try {
client.getTicket(Integer.MAX_VALUE, null);
fail("Expected TracException");
@@ -97,10 +92,6 @@ public class TracClientTest extends TestCase {
}
public void testGetTicketUmlaute() 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 (client.getAccessMode() == Version.XML_RPC) {
@@ -121,11 +112,11 @@ public class TracClientTest extends TestCase {
}
public void testSearchAll() throws Exception {
+ harness.createTicket("searchAllTickets");
TracSearch search = new TracSearch();
List<TracTicket> result = new ArrayList<TracTicket>();
client.search(search, result, null);
- //assertEquals(tickets.size(), result.size());
- assertTrue(result.size() >= tickets.size());
+ assertTrue(!result.isEmpty());
}
public void testSearchEmpty() throws Exception {
@@ -149,15 +140,24 @@ public class TracClientTest extends TestCase {
}
public void testSearchMilestone1() throws Exception {
+ TracTicket ticket = harness.createTicketWithMilestone("searchMilestone1", "milestone1");
+ harness.createTicketWithMilestone("searchMilestone1", "milestone2");
+
TracSearch search = new TracSearch();
+ search.addFilter("summary", "searchMilestone1");
+ search.addFilter("milestone", "milestone1");
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));
+ TracTestUtil.assertTicketEquals(ticket, result.get(0));
}
public void testSearchMilestone2() throws Exception {
+ TracTicket ticket1 = harness.createTicketWithMilestone("searchMilestone2", "milestone1");
+ TracTicket ticket2 = harness.createTicketWithMilestone("searchMilestone2", "milestone1");
+ TracTicket ticket3 = harness.createTicketWithMilestone("searchMilestone2", "milestone2");
+
TracSearch search = new TracSearch();
search.addFilter("milestone", "milestone1");
search.addFilter("milestone", "milestone2");
@@ -165,9 +165,9 @@ public class TracClientTest extends TestCase {
List<TracTicket> result = new ArrayList<TracTicket>();
client.search(search, result, null);
assertEquals(3, result.size());
- TracTestUtil.assertTicketEquals(tickets.get(0), result.get(0));
- TracTestUtil.assertTicketEquals(tickets.get(1), result.get(1));
- TracTestUtil.assertTicketEquals(tickets.get(2), result.get(2));
+ TracTestUtil.assertTicketEquals(ticket1, result.get(0));
+ TracTestUtil.assertTicketEquals(ticket2, result.get(1));
+ TracTestUtil.assertTicketEquals(ticket3, result.get(2));
}
public void testSearchMilestoneAmpersand() throws Exception {
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 c637e3b..af5273a 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
@@ -35,6 +35,7 @@ import org.eclipse.mylyn.internal.trac.core.model.TracVersion;
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;
@@ -52,15 +53,22 @@ public class TracXmlRpcClientTest extends TestCase {
private ITracClient client;
+ private TracHarness harness;
+
@Override
protected void setUp() throws Exception {
- super.setUp();
-
- client = TracFixture.current().connect();
+ TracFixture fixture = TracFixture.current();
+ harness = fixture.createHarness();
+ client = fixture.connect();
data = TracFixture.init010();
tickets = data.tickets;
}
+ @Override
+ protected void tearDown() throws Exception {
+ harness.dispose();
+ }
+
public void testValidateFailNoAuth() throws Exception {
client = TracFixture.current().connect(TracTestConstants.TEST_TRAC_010_URL, "", "");
try {
@@ -358,7 +366,7 @@ public class TracXmlRpcClientTest extends TestCase {
}
public void testInvalidCharacters() throws Exception {
- TracTicket ticket = TracTestUtil.createTicket(client, "invalid characters");
+ TracTicket ticket = harness.createTicket("invalid characters");
ticket.putBuiltinValue(Key.DESCRIPTION, "Control Character: \u0002");
try {
client.updateTicket(ticket, "set invalid characters in description", null);
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 b769459..fe3ea5e 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
@@ -20,17 +20,16 @@ import java.util.List;
import junit.framework.TestCase;
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.model.TracTicket;
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.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;
/**
* @author Steffen Pingel
@@ -43,19 +42,26 @@ public class TracAttachmentHandlerTest extends TestCase {
private AbstractTaskAttachmentHandler attachmentHandler;
- private TestData data;
+ private TracHarness harness;
@Override
protected void setUp() throws Exception {
- super.setUp();
- data = TracFixture.init010();
- connector = (TracRepositoryConnector) TasksUi.getRepositoryConnector(TracCorePlugin.CONNECTOR_KIND);
+ harness = TracFixture.current().createHarness();
+ connector = harness.connector();
attachmentHandler = connector.getTaskAttachmentHandler();
- repository = TracFixture.current().singleRepository(connector);
+ repository = harness.repository();
}
- public void testDownloadAttachment() throws Exception {
- ITask task = TracTestUtil.createTask(repository, data.attachmentTicketId + "");
+ @Override
+ protected void tearDown() throws Exception {
+ harness.dispose();
+ }
+
+ public void testGetContent() throws Exception {
+ TracTicket ticket = harness.createTicket("GetContent");
+ harness.attachFile(ticket.getId(), "attachment.txt", "Mylar\n");
+
+ ITask task = harness.getTask(ticket);
List<ITaskAttachment> attachments = TracTestUtil.getTaskAttachments(task);
assertTrue(attachments.size() > 0);
InputStream in = attachmentHandler.getContent(repository, task, attachments.get(0).getTaskAttribute(), null);
@@ -69,22 +75,8 @@ public class TracAttachmentHandlerTest extends TestCase {
}
}
- public void testGetAttachmentData() throws Exception {
- ITask task = TracTestUtil.createTask(repository, data.attachmentTicketId + "");
- List<ITaskAttachment> attachments = TracTestUtil.getTaskAttachments(task);
- assertTrue(attachments.size() > 0);
- InputStream in = attachmentHandler.getContent(repository, task, attachments.get(0).getTaskAttribute(), null);
- byte[] result = new byte[6];
- try {
- in.read(result);
- } finally {
- in.close();
- }
- assertEquals("Mylar\n", new String(result));
- }
-
- public void testUploadAttachment() throws Exception {
- ITask task = TracTestUtil.createTask(repository, data.attachmentTicketId + "");
+ public void testPostConent() throws Exception {
+ ITask task = harness.createTask("GetContent");
File file = File.createTempFile("attachment", null);
file.deleteOnExit();
OutputStream out = new FileOutputStream(file);
@@ -96,7 +88,7 @@ public class TracAttachmentHandlerTest extends TestCase {
attachmentHandler.postContent(repository, task, new FileTaskAttachmentSource(file), "comment", null, null);
ITracClient client = connector.getClientManager().getTracClient(repository);
- InputStream in = client.getAttachmentData(data.attachmentTicketId, file.getName(), null);
+ InputStream in = client.getAttachmentData(Integer.parseInt(task.getTaskId()), file.getName(), null);
try {
byte[] result = new byte[5];
in.read(result);
@@ -106,28 +98,22 @@ public class TracAttachmentHandlerTest extends TestCase {
}
}
- public void testCanUploadAttachmentXmlRpc() throws Exception {
- 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 {
- repository = TracFixture.TRAC_0_10_WEB.singleRepository();
- ITask task = TracTestUtil.createTask(repository, data.attachmentTicketId + "");
- assertFalse(attachmentHandler.canPostContent(repository, task));
+ public void testCanUploadAttachment() throws Exception {
+ ITask task = harness.createTask("canUploadAttachment");
+ if (harness.isXmlRpc()) {
+ assertTrue(attachmentHandler.canPostContent(repository, task));
+ } else {
+ assertFalse(attachmentHandler.canPostContent(repository, task));
+ }
}
public void testCanDownloadAttachmentXmlRpc() throws Exception {
- 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 {
- repository = TracFixture.TRAC_0_10_WEB.singleRepository();
- ITask task = TracTestUtil.createTask(repository, data.attachmentTicketId + "");
- assertFalse(attachmentHandler.canGetContent(repository, task));
+ ITask task = harness.createTask("canDownloadAttachment");
+ if (harness.isXmlRpc()) {
+ assertTrue(attachmentHandler.canGetContent(repository, task));
+ } else {
+ assertFalse(attachmentHandler.canGetContent(repository, task));
+ }
}
}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracClientManagerTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracClientManagerTest.java
index 1f80b09..ed6300a 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracClientManagerTest.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracClientManagerTest.java
@@ -17,28 +17,28 @@ import java.util.Arrays;
import junit.framework.TestCase;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.mylyn.commons.net.AuthenticationType;
import org.eclipse.mylyn.internal.trac.core.TracClientManager;
-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.TracMilestone;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.TaskRepositoryLocationFactory;
-import org.eclipse.mylyn.trac.tests.support.TracTestConstants;
+import org.eclipse.mylyn.trac.tests.support.TracFixture;
/**
* @author Steffen Pingel
*/
public class TracClientManagerTest extends TestCase {
- public void testNullCache() throws Exception {
- TaskRepository taskRepository = new TaskRepository(TracCorePlugin.CONNECTOR_KIND,
- TracTestConstants.TEST_TRAC_010_URL);
- taskRepository.setVersion(Version.TRAC_0_9.name());
+ private TaskRepository repository;
+
+ @Override
+ protected void setUp() throws Exception {
+ repository = TracFixture.current().repository();
+ }
+ public void testNullCache() throws Exception {
TracClientManager manager = new TracClientManager(null, new TaskRepositoryLocationFactory());
- ITracClient client = manager.getTracClient(taskRepository);
+ ITracClient client = manager.getTracClient(repository);
assertNull(client.getMilestones());
manager.writeCache();
@@ -46,29 +46,20 @@ public class TracClientManagerTest extends TestCase {
}
public void testReadCache() throws Exception {
- TaskRepository taskRepository = new TaskRepository(TracCorePlugin.CONNECTOR_KIND,
- TracTestConstants.TEST_TRAC_010_URL);
- taskRepository.setVersion(Version.TRAC_0_9.name());
-
File file = File.createTempFile("mylyn", null);
file.deleteOnExit();
TracClientManager manager = new TracClientManager(file, new TaskRepositoryLocationFactory());
- ITracClient client = manager.getTracClient(taskRepository);
+ ITracClient client = manager.getTracClient(repository);
assertNull(client.getMilestones());
}
public void testWriteCache() throws Exception {
- TaskRepository taskRepository = new TaskRepository(TracCorePlugin.CONNECTOR_KIND,
- TracTestConstants.TEST_TRAC_010_URL);
- taskRepository.setVersion(Version.TRAC_0_9.name());
- taskRepository.setCredentials(AuthenticationType.REPOSITORY, null, false);
-
File file = File.createTempFile("mylyn", null);
file.deleteOnExit();
TracClientManager manager = new TracClientManager(file, new TaskRepositoryLocationFactory());
- ITracClient client = manager.getTracClient(taskRepository);
+ ITracClient client = manager.getTracClient(repository);
assertNull(client.getMilestones());
client.updateAttributes(new NullProgressMonitor(), false);
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 c2e5864..0522697 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
@@ -13,7 +13,6 @@
package org.eclipse.mylyn.trac.tests.core;
import java.io.File;
-import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
@@ -26,13 +25,9 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
import org.eclipse.mylyn.internal.tasks.core.TaskTask;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.util.AttachmentUtil;
-import org.eclipse.mylyn.internal.tasks.ui.wizards.EditRepositoryWizard;
-import org.eclipse.mylyn.internal.trac.core.TracCorePlugin;
import org.eclipse.mylyn.internal.trac.core.TracRepositoryConnector;
import org.eclipse.mylyn.internal.trac.core.TracTaskDataHandler;
import org.eclipse.mylyn.internal.trac.core.client.ITracClient;
@@ -42,7 +37,6 @@ 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.TracTicket.Key;
import org.eclipse.mylyn.internal.trac.core.model.TracVersion;
-import org.eclipse.mylyn.internal.trac.ui.wizard.TracRepositorySettingsPage;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.ITaskAttachment;
@@ -52,9 +46,8 @@ 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.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.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
/**
@@ -62,18 +55,22 @@ import org.eclipse.ui.PlatformUI;
*/
public class TracRepositoryConnectorTest extends TestCase {
- private TestData data;
-
private TaskRepository repository;
private TracRepositoryConnector connector;
+ private TracHarness harness;
+
@Override
protected void setUp() throws Exception {
- super.setUp();
- data = TracFixture.init010();
- connector = (TracRepositoryConnector) TasksUi.getRepositoryConnector(TracCorePlugin.CONNECTOR_KIND);
- repository = TracFixture.current().singleRepository(connector);
+ harness = TracFixture.current().createHarness();
+ connector = harness.connector();
+ repository = harness.repository();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ harness.dispose();
}
public void testGetRepositoryUrlFromTaskUrl() {
@@ -83,38 +80,18 @@ public class TracRepositoryConnectorTest extends TestCase {
assertEquals(null, connector.getRepositoryUrlFromTaskUrl("http://host/repo/ticket-2342"));
}
- public void testCreateTaskFromExistingKeyXml() throws CoreException {
- String taskId = data.tickets.get(0).getId() + "";
+ public void testGetTaskData() throws Exception {
+ TracTicket ticket = harness.createTicket("createTaskFromExistingKeyXml");
+ String taskId = Integer.toString(ticket.getId());
TaskData taskData = connector.getTaskData(repository, taskId, null);
ITask task = TasksUi.getRepositoryModel().createTask(repository, taskData.getTaskId());
assertNotNull(task);
connector.updateTaskFromTaskData(repository, task, taskData);
assertEquals(TaskTask.class, task.getClass());
- assertTrue(task.getSummary().contains("summary1"));
+ assertEquals("createTaskFromExistingKeyXml", task.getSummary());
assertEquals(repository.getRepositoryUrl() + ITracClient.TICKET_URL + taskId, task.getUrl());
}
- public void testClientManagerChangeTaskRepositorySettings() throws MalformedURLException {
- repository = TracFixture.TRAC_0_10_WEB.singleRepository();
- ITracClient client = connector.getClientManager().getTracClient(repository);
- assertEquals(Version.TRAC_0_9, client.getAccessMode());
-
- EditRepositoryWizard wizard = new EditRepositoryWizard(repository);
- Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
- WizardDialog dialog = new WizardDialog(shell, wizard);
- try {
- dialog.create();
-
- ((TracRepositorySettingsPage) wizard.getSettingsPage()).setTracVersion(Version.XML_RPC);
- assertTrue(wizard.performFinish());
-
- client = connector.getClientManager().getTracClient(repository);
- assertEquals(Version.XML_RPC, client.getAccessMode());
- } finally {
- dialog.close();
- }
- }
-
public void testPerformQuery() {
TracSearch search = new TracSearch();
search.addFilter("milestone", "milestone1");
@@ -132,10 +109,10 @@ public class TracRepositoryConnectorTest extends TestCase {
};
IStatus queryStatus = connector.performQuery(repository, query, hitCollector, null, new NullProgressMonitor());
assertEquals(Status.OK_STATUS, queryStatus);
- assertEquals(3, result.size());
- assertEquals(data.tickets.get(0).getId() + "", result.get(0).getTaskId());
- assertEquals(data.tickets.get(1).getId() + "", result.get(1).getTaskId());
- assertEquals(data.tickets.get(2).getId() + "", result.get(2).getTaskId());
+// assertEquals(3, result.size());
+// assertEquals(data.tickets.get(0).getId() + "", result.get(0).getTaskId());
+// assertEquals(data.tickets.get(1).getId() + "", result.get(1).getTaskId());
+// assertEquals(data.tickets.get(2).getId() + "", result.get(2).getTaskId());
}
public void testUpdateAttributes() throws Exception {
@@ -154,8 +131,7 @@ public class TracRepositoryConnectorTest extends TestCase {
}
public void testContext() throws Exception {
- String taskId = data.attachmentTicketId + "";
- ITask task = TracTestUtil.createTask(repository, taskId);
+ ITask task = harness.createTask("context");
File sourceContextFile = TasksUiPlugin.getContextStore().getFileForContext(task);
sourceContextFile.createNewFile();
sourceContextFile.deleteOnExit();
@@ -175,7 +151,7 @@ public class TracRepositoryConnectorTest extends TestCase {
}
assertTrue(result);
- task = TracTestUtil.createTask(repository, taskId);
+ task = harness.getTask(task.getTaskId());
List<ITaskAttachment> attachments = TracTestUtil.getTaskAttachments(task);
// TODO attachment may have been overridden therefore size may not have changed
//assertEquals(size + 1, task.getTaskData().getAttachments().size());
@@ -286,7 +262,8 @@ public class TracRepositoryConnectorTest extends TestCase {
assertEquals("mysummary", task.getSummary());
// depending on the access mode createTaskDataFromTicket() creates different default attributes
if (client.getAccessMode() == Version.TRAC_0_9) {
- assertEquals(AbstractTask.DEFAULT_TASK_KIND, task.getTaskKind());
+ // the ticket type varies depending on Trac version
+ //assertEquals(AbstractTask.DEFAULT_TASK_KIND, task.getTaskKind());
assertEquals("P2", task.getPriority());
} else {
assertEquals("Defect", task.getTaskKind());
@@ -323,13 +300,11 @@ public class TracRepositoryConnectorTest extends TestCase {
// not supported in web mode
return;
}
- TracTicket ticket = TracTestUtil.createTicket(client, "testDeleteNewTask");
- String taskId = String.valueOf(ticket.getId());
- ITask task = TracTestUtil.createTask(repository, taskId);
+ ITask task = harness.createTask("deleteNewTask");
assertTrue(connector.canDeleteTask(repository, task));
connector.deleteTask(repository, task, null);
try {
- connector.getTaskData(repository, taskId, null);
+ connector.getTaskData(repository, task.getTaskId(), null);
fail("Task should be gone");
} catch (CoreException e) {
assertTrue(e.getMessage().contains("does not exist"));
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
index 69cacab..72d1484 100644
--- 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
@@ -19,35 +19,34 @@ 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;
+import org.eclipse.mylyn.trac.tests.support.TracHarness;
/**
* @author Steffen Pingel
*/
public class TracRepositoryConnectorWebTest extends TestCase {
- private TracRepositoryConnector connector;
+ private TracHarness harness;
private TaskRepository repository;
- private TestData data;
+ private TracRepositoryConnector connector;
- public TracRepositoryConnectorWebTest() {
+ @Override
+ protected void setUp() throws Exception {
+ TracFixture fixture = TracFixture.current();
+ harness = fixture.createHarness();
+ connector = harness.connector();
+ repository = harness.repository();
}
@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(connector);
+ protected void tearDown() throws Exception {
+ harness.dispose();
}
private SynchronizationSession createSession(ITask... tasks) {
@@ -59,8 +58,8 @@ public class TracRepositoryConnectorWebTest extends TestCase {
return session;
}
- public void testPreSynchronizationWeb096() throws Exception {
- ITask task = TracTestUtil.createTask(repository, data.offlineHandlerTicketId + "");
+ public void testPreSynchronization() throws Exception {
+ ITask task = harness.createTask("preSynchronization");
Set<ITask> tasks = new HashSet<ITask>();
tasks.add(task);
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracTaskDataHandlerXmlRpcTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracTaskDataHandlerXmlRpcTest.java
index 719aa5d..683c9be 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracTaskDataHandlerXmlRpcTest.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracTaskDataHandlerXmlRpcTest.java
@@ -51,10 +51,9 @@ import org.eclipse.mylyn.tasks.core.data.TaskData;
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.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;
/**
* @author Steffen Pingel
@@ -66,25 +65,29 @@ public class TracTaskDataHandlerXmlRpcTest extends TestCase {
private TaskRepository repository;
- private TestData data;
-
private TracTaskDataHandler taskDataHandler;
private ITracClient client;
+ private TracHarness harness;
+
public TracTaskDataHandlerXmlRpcTest() {
}
@Override
protected void setUp() throws Exception {
- super.setUp();
- data = TracFixture.init010();
- connector = (TracRepositoryConnector) TasksUi.getRepositoryConnector(TracCorePlugin.CONNECTOR_KIND);
+ harness = TracFixture.current().createHarness();
+ connector = harness.connector();
taskDataHandler = connector.getTaskDataHandler();
- repository = TracFixture.current().singleRepository(connector);
+ repository = harness.repository();
client = connector.getClientManager().getTracClient(repository);
}
+ @Override
+ protected void tearDown() throws Exception {
+ harness.dispose();
+ }
+
private SynchronizationSession createSession(ITask... tasks) {
SynchronizationSession session = new SynchronizationSession();
session.setNeedsPerformQueries(true);
@@ -98,8 +101,8 @@ public class TracTaskDataHandlerXmlRpcTest extends TestCase {
SynchronizationSession session;
// sleep for one second to ensure that the created ticket has a unique time stamp
Thread.sleep(1000);
- TracTicket ticket = TracTestUtil.createTicket(client, "markStaleTasks");
- ITask task = TracTestUtil.createTask(repository, ticket.getId() + "");
+ TracTicket ticket = harness.createTicket("markStaleTasks");
+ ITask task = harness.getTask(ticket);
long lastModified = TracUtil.toTracTime(task.getModificationDate());
// an empty set should not cause contact to the repository
@@ -157,10 +160,9 @@ public class TracTaskDataHandlerXmlRpcTest extends TestCase {
}
public void testMarkStaleTasksNoTimeStamp() throws Exception {
- SynchronizationSession session;
- ITask task = TracTestUtil.createTask(repository, data.offlineHandlerTicketId + "");
+ ITask task = harness.createTask("MarkStaleTasksNoTimeStamp");
- session = createSession(task);
+ SynchronizationSession session = createSession(task);
repository.setSynchronizationTimeStamp(null);
connector.preSynchronization(session, null);
assertTrue(session.needsPerformQueries());
@@ -195,12 +197,12 @@ public class TracTaskDataHandlerXmlRpcTest extends TestCase {
public void testAttachmentChangesLastModifiedDate() throws Exception {
AbstractTaskAttachmentHandler attachmentHandler = connector.getTaskAttachmentHandler();
- ITask task = TracTestUtil.createTask(repository, data.attachmentTicketId + "");
+ ITask task = harness.createTask("attachmentChangesLastModifiedDate");
Date lastModified = task.getModificationDate();
// XXX the test case fails when comment == null
attachmentHandler.postContent(repository, task, new TextTaskAttachmentSource("abc"), "comment", null, null);
- task = TracTestUtil.createTask(repository, data.attachmentTicketId + "");
+ task = harness.getTask(task.getTaskId());
Date newLastModified = task.getModificationDate();
assertTrue("Expected " + newLastModified + " to be more recent than " + lastModified,
newLastModified.after(lastModified));
@@ -208,8 +210,9 @@ public class TracTaskDataHandlerXmlRpcTest extends TestCase {
public void testAttachmentUrlEncoding() throws Exception {
AbstractTaskAttachmentHandler attachmentHandler = connector.getTaskAttachmentHandler();
- TracTicket ticket = TracTestUtil.createTicket(client, "attachment url test");
- ITask task = TracTestUtil.createTask(repository, ticket.getId() + "");
+ TracTicket ticket = harness.createTicket("attachment url test");
+
+ ITask task = harness.getTask(ticket);
attachmentHandler.postContent(repository, task, new TextTaskAttachmentSource("abc") {
@Override
public String getName() {
@@ -217,7 +220,7 @@ public class TracTaskDataHandlerXmlRpcTest extends TestCase {
}
}, "comment", null, null);
- task = TracTestUtil.createTask(repository, ticket.getId() + "");
+ task = harness.getTask(ticket);
List<ITaskAttachment> attachments = TracTestUtil.getTaskAttachments(task);
assertEquals(1, attachments.size());
assertEquals(repository.getUrl() + "/attachment/ticket/" + ticket.getId()
@@ -225,8 +228,7 @@ public class TracTaskDataHandlerXmlRpcTest extends TestCase {
}
public void testPostTaskDataInvalidCredentials() throws Exception {
- ITask task = TracTestUtil.createTask(repository, data.offlineHandlerTicketId + "");
- TaskData taskData = TasksUi.getTaskDataManager().getTaskData(task);
+ TaskData taskData = harness.createTaskData("postTaskDataInvalidCredentials");
taskData.getRoot().getMappedAttribute(TaskAttribute.COMMENT_NEW).setValue("new comment");
repository.setCredentials(AuthenticationType.REPOSITORY, new AuthenticationCredentials("foo", "bar"), false);
try {
@@ -242,9 +244,11 @@ public class TracTaskDataHandlerXmlRpcTest extends TestCase {
assertFalse(taskDataHandler.canInitializeSubTaskData(repository, task));
task.setAttribute(TracRepositoryConnector.TASK_KEY_SUPPORTS_SUBTASKS, Boolean.TRUE.toString());
assertTrue(taskDataHandler.canInitializeSubTaskData(repository, task));
+ }
- task = TracTestUtil.createTask(repository, data.offlineHandlerTicketId + "");
- TaskData taskData = taskDataHandler.getTaskData(repository, data.offlineHandlerTicketId + "", null);
+ public void testCanInitializeTaskDataRepositoryTask() throws Exception {
+ ITask task = harness.createTask("canInitializeTaskDataRepositoryTask");
+ TaskData taskData = taskDataHandler.getTaskData(repository, task.getTaskId(), null);
assertFalse(taskDataHandler.canInitializeSubTaskData(repository, task));
taskData.getRoot().createAttribute(TracTaskDataHandler.ATTRIBUTE_BLOCKED_BY);
@@ -257,8 +261,7 @@ public class TracTaskDataHandlerXmlRpcTest extends TestCase {
}
public void testInitializeSubTaskDataInvalidParent() throws Exception {
- TaskData parentTaskData = taskDataHandler.getTaskData(repository, data.offlineHandlerTicketId + "",
- new NullProgressMonitor());
+ TaskData parentTaskData = harness.createTaskData("initializeSubTaskDataInvalidParent");
try {
taskDataHandler.initializeSubTaskData(repository, parentTaskData, parentTaskData, null);
fail("expected CoreException");
@@ -267,7 +270,7 @@ public class TracTaskDataHandlerXmlRpcTest extends TestCase {
}
public void testInitializeSubTaskData() throws Exception {
- TaskData parentTaskData = taskDataHandler.getTaskData(repository, data.offlineHandlerTicketId + "", null);
+ TaskData parentTaskData = harness.createTaskData("initializeSubTaskData");
TaskMapper parentTaskMapper = new TracTaskMapper(parentTaskData, null);
parentTaskMapper.setSummary("abc");
parentTaskMapper.setDescription("def");
@@ -410,7 +413,7 @@ public class TracTaskDataHandlerXmlRpcTest extends TestCase {
}
public void testPostTaskDataUnsetResolution() throws Exception {
- TracTicket ticket = TracTestUtil.createTicket(client, "postTaskDataUnsetResolution");
+ TracTicket ticket = harness.createTicket("postTaskDataUnsetResolution");
TaskData taskData = taskDataHandler.getTaskData(repository, ticket.getId() + "", new NullProgressMonitor());
TaskAttribute attribute = taskData.getRoot().getMappedAttribute(TaskAttribute.RESOLUTION);
attribute.setValue("fixed");
@@ -423,7 +426,7 @@ public class TracTaskDataHandlerXmlRpcTest extends TestCase {
}
public void testPostTaskDataMidAirCollision() throws Exception {
- TracTicket ticket = TracTestUtil.createTicket(client, "midAirCollision");
+ TracTicket ticket = harness.createTicket("midAirCollision");
if (ticket.getValue(Key.TOKEN) == null) {
// repository does not have mid-air collision support
System.err.println("Skipping TracTaskDataHandler.testPostTaskDataMidAirCollision() due to lack of mid-air collision support on "
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 a322e5c..c8d4587 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
@@ -12,19 +12,24 @@
package org.eclipse.mylyn.trac.tests.support;
import java.net.Proxy;
+import java.util.HashSet;
+import java.util.Set;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.mylyn.commons.net.IProxyProvider;
import org.eclipse.mylyn.commons.net.WebLocation;
import org.eclipse.mylyn.commons.net.WebUtil;
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.internal.trac.core.TracClientFactory;
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.TaskRepository;
+import org.eclipse.mylyn.tasks.ui.TasksUi;
import org.eclipse.mylyn.tests.util.TestFixture;
/**
@@ -35,6 +40,8 @@ import org.eclipse.mylyn.tests.util.TestFixture;
*/
public class TracFixture extends TestFixture {
+ public static String TAG_MISC = "misc";
+
private static TracFixture current;
public static XmlRpcServer.TestData data010;
@@ -161,13 +168,26 @@ public class TracFixture extends TestFixture {
private final String version;
+ private final Set<String> tags;
+
public TracFixture(Version accessMode, String url, String version, String info) {
super(TracCorePlugin.CONNECTOR_KIND, url);
+ Assert.isNotNull(accessMode);
+ Assert.isNotNull(info);
this.accessMode = accessMode;
this.version = version;
+ this.tags = new HashSet<String>();
setInfo("Trac", version, info);
}
+ public TracFixture(FixtureConfiguration configuration) {
+ this(Version.fromVersion(configuration.getProperties().get("version")), configuration.getUrl(),
+ configuration.getVersion(), configuration.getInfo());
+ if (configuration.getTags() != null) {
+ this.tags.addAll(configuration.getTags());
+ }
+ }
+
@Override
public TracFixture activate() {
current = this;
@@ -184,8 +204,10 @@ public class TracFixture extends TestFixture {
return connect(repositoryUrl);
}
- public ITracClient connect(PrivilegeLevel level) throws Exception {
- return connect(repositoryUrl, getDefaultProxy(repositoryUrl), level);
+ public ITracClient connectXmlRpc(PrivilegeLevel level) throws Exception {
+ UserCredentials credentials = CommonTestUtil.getCredentials(level);
+ return connect(repositoryUrl, credentials.getUserName(), credentials.getPassword(),
+ getDefaultProxy(repositoryUrl), Version.XML_RPC);
}
private Proxy getDefaultProxy(String url) {
@@ -244,7 +266,7 @@ public class TracFixture extends TestFixture {
@Override
public TaskRepository singleRepository() {
- return singleRepository(TracCorePlugin.getDefault().getConnector());
+ return singleRepository(connector());
}
@Override
@@ -259,6 +281,20 @@ public class TracFixture extends TestFixture {
TracCorePlugin.getDefault().getConnector().getClientManager().clearClients();
}
+ @Override
+ public TracRepositoryConnector connector() {
+ return (TracRepositoryConnector) TasksUi.getRepositoryConnector(TracCorePlugin.CONNECTOR_KIND);
+ }
+
+ public TracHarness createHarness() {
+ return new TracHarness(this);
+ }
+
+ @Override
+ public boolean hasTag(String tag) {
+ return tags.contains(tag);
+ }
+
// private static void initializeRepository(XmlRpcServer server) throws Exception {
// server.ticketVersion(null).deleteAll();
// server.ticketVersion("1.0").create(0, "");
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
new file mode 100644
index 0000000..93a9eb1
--- /dev/null
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracHarness.java
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.io.ByteArrayInputStream;
+
+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.model.TracTicket;
+import org.eclipse.mylyn.internal.trac.core.model.TracTicket.Key;
+import org.eclipse.mylyn.tasks.core.ITask;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.core.data.TaskData;
+import org.eclipse.mylyn.tasks.ui.TasksUi;
+
+public class TracHarness {
+
+ private final TracFixture fixture;
+
+ private ITracClient priviledgedClient;
+
+ private TaskRepository repository;
+
+ public TracHarness(TracFixture fixture) {
+ this.fixture = fixture;
+ }
+
+ public TracFixture getFixture() {
+ return fixture;
+ }
+
+ private ITracClient priviledgedClient() throws Exception {
+ if (priviledgedClient == null) {
+ priviledgedClient = fixture.connectXmlRpc(PrivilegeLevel.USER);
+ }
+ return priviledgedClient;
+ }
+
+ public TracTicket createTicket(String summary) throws Exception {
+ TracTicket ticket = newTicket(summary);
+ return createTicket(ticket);
+ }
+
+ public TracTicket createTicket(TracTicket ticket) throws TracException, Exception {
+ int id = priviledgedClient().createTicket(ticket, null);
+ return priviledgedClient().getTicket(id, null);
+ }
+
+ public TracTicket newTicket(String summary) throws InvalidTicketException {
+ TracTicket ticket = new TracTicket();
+ ticket.putBuiltinValue(Key.SUMMARY, summary);
+ ticket.putBuiltinValue(Key.DESCRIPTION, "");
+ return ticket;
+ }
+
+ public TracTicket createTicketWithMilestone(String summary, String milestone) throws Exception {
+ TracTicket ticket = newTicket(summary);
+ ticket.putBuiltinValue(Key.MILESTONE, milestone);
+ return createTicket(ticket);
+ }
+
+ public ITask getTask(String taskId) throws Exception {
+ TaskRepository repository = repository();
+ TaskData taskData = fixture.connector().getTaskData(repository, taskId, null);
+ ITask task = TasksUi.getRepositoryModel().createTask(repository, taskData.getTaskId());
+ TasksUiPlugin.getTaskDataManager().putUpdatedTaskData(task, taskData, true);
+ return task;
+ }
+
+ public void dispose() {
+
+ }
+
+ public ITask getTask(TracTicket ticket) throws Exception {
+ return getTask(Integer.toString(ticket.getId()));
+ }
+
+ public ITask createTask(String summary) throws Exception {
+ TracTicket ticket = createTicket(summary);
+ return getTask(ticket);
+ }
+
+ public TaskData createTaskData(String summary) throws Exception {
+ TracTicket ticket = createTicket(summary);
+ return fixture.connector().getTaskData(repository(), Integer.toString(ticket.getId()), null);
+ }
+
+ public TaskRepository repository() {
+ if (repository == null) {
+ repository = fixture.singleRepository();
+ }
+ return repository;
+ }
+
+ public TracRepositoryConnector connector() {
+ return fixture.connector();
+ }
+
+ public void attachFile(int ticketId, String name, String content) throws Exception {
+ priviledgedClient().putAttachmentData(ticketId, name, "", new ByteArrayInputStream(content.getBytes("UTF-8")),
+ null, true);
+ }
+
+ public boolean isXmlRpc() {
+ return Version.XML_RPC.name().equals(repository().getVersion());
+ }
+
+}
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 09034cc..c5fc4d3 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
@@ -17,12 +17,14 @@ import java.util.List;
import junit.framework.TestCase;
import org.eclipse.mylyn.commons.sdk.util.CommonTestUtil.PrivilegeLevel;
+import org.eclipse.mylyn.commons.sdk.util.TestConfiguration;
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.model.TracAttachment;
import org.eclipse.mylyn.internal.trac.core.model.TracSearch;
-import org.eclipse.mylyn.internal.trac.core.model.TracTicket;
-import org.eclipse.mylyn.trac.tests.support.XmlRpcServer.TestData;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
/**
* Utility that cleans up artifacts created by the Trac test suite. This class should be run periodically to speed up
@@ -30,83 +32,33 @@ import org.eclipse.mylyn.trac.tests.support.XmlRpcServer.TestData;
*
* @author Steffen Pingel
*/
+@RunWith(Parameterized.class)
public class TracTestCleanupUtil extends TestCase {
- private TestData data;
+ private final TracFixture fixture;
- private ITracClient client;
-
- @Override
- protected void setUp() throws Exception {
- data = TracFixture.init010();
- }
-
- public void testCleanup010() throws Exception {
- TracFixture fixture = TracFixture.TRAC_0_10_XML_RPC.activate();
- System.err.println("Connected to " + fixture.getRepositoryUrl());
- client = fixture.connect(PrivilegeLevel.ADMIN);
- deleteOldAttachments();
- deleteOldTickets();
- }
-
- public void testCleanup010FormAuth() throws Exception {
- TracFixture fixture = TracFixture.TRAC_0_10_XML_RPC_FORM_AUTH.activate();
- System.err.println("Connected to " + fixture.getRepositoryUrl());
- client = fixture.connect(PrivilegeLevel.ADMIN);
- deleteOldAttachments();
- deleteOldTickets();
- }
-
- public void testCleanup011() throws Exception {
- TracFixture fixture = TracFixture.TRAC_0_11_XML_RPC.activate();
- System.err.println("Connected to " + fixture.getRepositoryUrl());
- client = fixture.connect(PrivilegeLevel.ADMIN);
- deleteOldAttachments();
- deleteOldTickets();
- }
-
- public void testCleanup012() throws Exception {
- TracFixture fixture = TracFixture.TRAC_0_12_XML_RPC.activate();
- System.err.println("Connected to " + fixture.getRepositoryUrl());
- client = fixture.connect(PrivilegeLevel.ADMIN);
- deleteOldAttachments();
- deleteOldTickets();
+ @Parameters(name = "{1}")
+ public static Iterable<Object[]> data() {
+ List<TracFixture> fixtures = TestConfiguration.getDefault().discover(TracFixture.class, "trac");
+ List<Object[]> data = new ArrayList<Object[]>(fixtures.size());
+ for (TracFixture fixture : fixtures) {
+ data.add(new Object[] { fixture, fixture.getInfo() });
+ }
+ return data;
}
- public void testCleanup_1_0() throws Exception {
- TracFixture fixture = TracFixture.TRAC_1_0_XML_RPC.activate();
- System.err.println("Connected to " + fixture.getRepositoryUrl());
- client = fixture.connect(PrivilegeLevel.ADMIN);
- deleteOldAttachments();
- deleteOldTickets();
+ public TracTestCleanupUtil(TracFixture fixture, String name) {
+ this.fixture = fixture;
}
- public void testCleanupTrunk() throws Exception {
- TracFixture fixture = TracFixture.TRAC_TRUNK_XML_RPC.activate();
+ @Test
+ public void testCleanUpTasks() throws Exception {
System.err.println("Connected to " + fixture.getRepositoryUrl());
- client = fixture.connect(PrivilegeLevel.ADMIN);
- deleteOldAttachments();
- deleteOldTickets();
- }
-
- private void deleteOldAttachments() throws TracException {
- TracTicket ticket = client.getTicket(data.attachmentTicketId, null);
- TracAttachment[] attachments = ticket.getAttachments();
- System.err.println("Found " + attachments.length + " attachments");
- // skips the first attachment
- System.err.print("Deleting attachment: ");
- for (int i = 1; i < attachments.length; i++) {
- System.err.print(i + ", ");
- client.deleteAttachment(data.attachmentTicketId, attachments[i].getFilename(), null);
- if (i % 20 == 0) {
- System.err.println();
- System.err.print(" ");
- }
- }
- System.err.println();
+ ITracClient client = fixture.connectXmlRpc(PrivilegeLevel.ADMIN);
+ deleteOldTickets(client);
}
- public void deleteOldTickets() throws TracException {
+ public void deleteOldTickets(ITracClient client) throws TracException {
TracSearch query = new TracSearch();
query.setMax(10000);
List<Integer> result = new ArrayList<Integer>();
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
index 7fe03e2..8708e05 100644
--- 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
@@ -26,13 +26,13 @@ public class TracTestConstants {
public static final String TEST_TRAC_010_FORM_AUTH_URL = TestConfiguration.getRepositoryUrl("trac010formauth");
- public static final String TEST_TRAC_011_URL = TestConfiguration.getRepositoryUrl("trac011");
+ public static final String TEST_TRAC_011_URL = TestConfiguration.getRepositoryUrl("trac-0.11.7");
- public static final String TEST_TRAC_012_URL = TestConfiguration.getRepositoryUrl("trac012");
+ public static final String TEST_TRAC_012_URL = TestConfiguration.getRepositoryUrl("trac-0.12.5");
- public static final String TEST_TRAC_10_URL = TestConfiguration.getRepositoryUrl("trac10");
+ public static final String TEST_TRAC_10_URL = TestConfiguration.getRepositoryUrl("trac-1.0");
- public static final String TEST_TRAC_TRUNK_URL = TestConfiguration.getRepositoryUrl("tractrunk");
+ 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/TracTestUtil.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TracTestUtil.java
index 687f693..b991ecd 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
@@ -11,22 +11,18 @@
package org.eclipse.mylyn.trac.tests.support;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
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.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.TracTicket;
-import org.eclipse.mylyn.internal.trac.core.model.TracTicket.Key;
-import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
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.TaskAttribute;
import org.eclipse.mylyn.tasks.core.data.TaskData;
import org.eclipse.mylyn.tasks.ui.TasksUi;
@@ -37,41 +33,6 @@ import org.eclipse.mylyn.trac.tests.support.XmlRpcServer.Ticket;
*/
public class TracTestUtil {
- public static TracTicket createTicket(ITracClient client, String summary) throws Exception {
- TracTicket ticket = new TracTicket();
- ticket.putBuiltinValue(Key.SUMMARY, summary);
- ticket.putBuiltinValue(Key.DESCRIPTION, "");
- int id = client.createTicket(ticket, null);
- return client.getTicket(id, null);
- }
-
- public static ITask createTask(TaskRepository taskRepository, String taskId) throws Exception {
- AbstractRepositoryConnector connector = TasksUi.getRepositoryConnector(TracCorePlugin.CONNECTOR_KIND);
- TaskData taskData = connector.getTaskData(taskRepository, taskId, null);
- ITask task = TasksUi.getRepositoryModel().createTask(taskRepository, taskData.getTaskId());
- TasksUiPlugin.getTaskDataManager().putUpdatedTaskData(task, taskData, true);
- 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 = CommonTestUtil.getCredentials(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);
List<ITaskAttachment> attachments = new ArrayList<ITaskAttachment>();
@@ -87,11 +48,11 @@ public class TracTestUtil {
return attachments;
}
- public static void assertTicketEquals(Ticket ticket, TracTicket tracTicket) throws Exception {
- Assert.assertTrue(tracTicket.isValid());
+ public static void assertTicketEquals(Ticket expectedTicket, TracTicket actualTicket) throws Exception {
+ assertTrue(actualTicket.isValid());
- Map<?, ?> expectedValues = ticket.getValues();
- Map<String, String> values = tracTicket.getValues();
+ Map<?, ?> expectedValues = expectedTicket.getValues();
+ Map<String, String> values = actualTicket.getValues();
for (String key : values.keySet()) {
Object expected = expectedValues.get(key);
String actual = values.get(key);
@@ -109,7 +70,34 @@ public class TracTestUtil {
// ignore internal values
continue;
}
- Assert.assertEquals("Values for key '" + key + "' did not match", expected, actual);
+ assertEquals("Values for key '" + key + "' did not match", expected, actual);
}
}
+
+ public static void assertTicketEquals(TracTicket expectedTicket, TracTicket actualTicket) throws Exception {
+ assertTrue(actualTicket.isValid());
+
+ Map<?, ?> expectedValues = expectedTicket.getValues();
+ Map<String, String> actualValues = actualTicket.getValues();
+ for (String key : actualValues.keySet()) {
+ Object expected = expectedValues.get(key);
+ String actual = actualValues.get(key);
+ if (key.equals("reporter")) {
+ // Trac 0.11 obfuscates email addresses by replacing the domain with the Ellipses character,
+ // mangle expected value accordingly
+ if (actual != null && actual.endsWith("\u2026") && expected instanceof String) {
+ String expectedString = (String) expected;
+ int i = expectedString.indexOf("@");
+ if (i != -1) {
+ expected = expectedString.substring(0, i + 1) + "\u2026";
+ }
+ }
+ } else if (key.startsWith("_")) {
+ // ignore internal values
+ continue;
+ }
+ assertEquals("Values for key '" + key + "' did not match", expected, actual);
+ }
+ }
+
}
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 33daada..bad8bd4 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,11 +20,16 @@ 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.wizards.EditRepositoryWizard;
+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.ui.wizard.TracRepositorySettingsPage;
import org.eclipse.mylyn.internal.trac.ui.wizard.TracRepositorySettingsPage.TracValidator;
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
@@ -190,4 +195,27 @@ public class TracRepositorySettingsPageTest extends TestCase {
assertTrue(page.isValidUrl("http://mylyn.org/trac30"));
assertTrue(page.isValidUrl("http://www.mylyn.org/trac30"));
}
+
+ public void testClientManagerChangeTaskRepositorySettings() throws Exception {
+ TaskRepository repository = TracFixture.TRAC_0_10_WEB.singleRepository();
+ TracRepositoryConnector connector = (TracRepositoryConnector) TracFixture.TRAC_0_10_WEB.connector();
+ ITracClient client = connector.getClientManager().getTracClient(repository);
+ assertEquals(Version.TRAC_0_9, client.getAccessMode());
+
+ EditRepositoryWizard wizard = new EditRepositoryWizard(repository);
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ WizardDialog dialog = new WizardDialog(shell, wizard);
+ try {
+ dialog.create();
+
+ ((TracRepositorySettingsPage) wizard.getSettingsPage()).setTracVersion(Version.XML_RPC);
+ assertTrue(wizard.performFinish());
+
+ client = connector.getClientManager().getTracClient(repository);
+ assertEquals(Version.XML_RPC, client.getAccessMode());
+ } finally {
+ dialog.close();
+ }
+ }
+
}
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 552cd82..bbe71a4 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
@@ -19,24 +19,30 @@ 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.tests.util.TestFixture;
import org.eclipse.mylyn.trac.tests.support.TracFixture;
-import org.eclipse.mylyn.trac.tests.support.TracTestUtil;
+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 {
- TestFixture.resetTaskList();
+ TracFixture fixture = TracFixture.current();
+ harness = fixture.createHarness();
}
- public void testGetSelectedRepository() throws Exception {
- TaskRepository repository = TracFixture.DEFAULT.singleRepository();
+ @Override
+ protected void tearDown() throws Exception {
+ harness.dispose();
+ }
- ITask task = TracTestUtil.createTask(repository, "1");
+ public void testGetSelectedRepository() throws Exception {
+ TaskRepository repository = harness.repository();
+ ITask task = harness.createTask("testGetSelectedRepository");
TasksUiPlugin.getTaskList().addTask(task);
TasksUiUtil.openTask(task);