diff options
author | spingel | 2009-07-01 22:32:16 +0000 |
---|---|---|
committer | spingel | 2009-07-01 22:32:16 +0000 |
commit | 0e5c669e62a91d6f259075d2c2db05210c8da96f (patch) | |
tree | 6580c04371f755119a6000d9946b00f77234eb53 /org.eclipse.mylyn.trac.tests | |
parent | 6469a635436028a73c6e5a15a3b43b3413847bcb (diff) | |
download | org.eclipse.mylyn.tasks-0e5c669e62a91d6f259075d2c2db05210c8da96f.tar.gz org.eclipse.mylyn.tasks-0e5c669e62a91d6f259075d2c2db05210c8da96f.tar.xz org.eclipse.mylyn.tasks-0e5c669e62a91d6f259075d2c2db05210c8da96f.zip |
NEW - bug 281590: [regression] cannot set resolution for reopened tasks
https://bugs.eclipse.org/bugs/show_bug.cgi?id=281590
Diffstat (limited to 'org.eclipse.mylyn.trac.tests')
11 files changed, 502 insertions, 429 deletions
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AllTracHeadlessStandaloneTests.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AllTracHeadlessStandaloneTests.java index feb77b6a3..8c1fce9a9 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 @@ -16,11 +16,10 @@ import junit.framework.TestSuite; import org.eclipse.mylyn.trac.tests.client.TracClientFactoryTest; import org.eclipse.mylyn.trac.tests.client.TracClientProxyTest; +import org.eclipse.mylyn.trac.tests.client.TracRepositoryInfoTest; import org.eclipse.mylyn.trac.tests.client.TracSearchTest; import org.eclipse.mylyn.trac.tests.client.TracTicketTest; -import org.eclipse.mylyn.trac.tests.client.TracWebClientSearchTest; import org.eclipse.mylyn.trac.tests.client.TracWebClientTest; -import org.eclipse.mylyn.trac.tests.client.TracXmlRpcClientSearchTest; import org.eclipse.mylyn.trac.tests.client.TracXmlRpcClientTest; import org.eclipse.mylyn.trac.tests.core.TracClientManagerTest; @@ -37,10 +36,9 @@ public class AllTracHeadlessStandaloneTests { // client suite.addTestSuite(TracSearchTest.class); suite.addTestSuite(TracTicketTest.class); + suite.addTestSuite(TracRepositoryInfoTest.class); suite.addTestSuite(TracXmlRpcClientTest.class); - suite.addTestSuite(TracXmlRpcClientSearchTest.class); suite.addTestSuite(TracWebClientTest.class); - suite.addTestSuite(TracWebClientSearchTest.class); suite.addTestSuite(TracClientFactoryTest.class); suite.addTestSuite(TracClientProxyTest.class); return suite; diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/AbstractTracClientRepositoryTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/AbstractTracClientRepositoryTest.java index e90fdee4d..2ae6b2bc6 100644 --- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/AbstractTracClientRepositoryTest.java +++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/AbstractTracClientRepositoryTest.java @@ -14,6 +14,8 @@ package org.eclipse.mylyn.trac.tests.client; import java.net.InetSocketAddress; import java.net.Proxy; import java.net.Proxy.Type; +import java.util.ArrayList; +import java.util.List; import org.eclipse.mylyn.context.tests.support.TestUtil; import org.eclipse.mylyn.context.tests.support.TestUtil.Credentials; @@ -22,7 +24,13 @@ import org.eclipse.mylyn.internal.trac.core.client.ITracClient; import org.eclipse.mylyn.internal.trac.core.client.TracException; import org.eclipse.mylyn.internal.trac.core.client.TracLoginException; import org.eclipse.mylyn.internal.trac.core.client.ITracClient.Version; +import org.eclipse.mylyn.internal.trac.core.model.TracSearch; +import org.eclipse.mylyn.internal.trac.core.model.TracTicket; +import org.eclipse.mylyn.internal.trac.core.model.TracTicket.Key; +import org.eclipse.mylyn.trac.tests.support.TestFixture; import org.eclipse.mylyn.trac.tests.support.TracTestConstants; +import org.eclipse.mylyn.trac.tests.support.XmlRpcServer.TestData; +import org.eclipse.mylyn.trac.tests.support.XmlRpcServer.Ticket; /** * Test cases for classes that implement {@link ITracClient}. @@ -31,10 +39,29 @@ import org.eclipse.mylyn.trac.tests.support.TracTestConstants; */ public class AbstractTracClientRepositoryTest extends AbstractTracClientTest { + protected List<Ticket> tickets; + + private TestData data; + public AbstractTracClientRepositoryTest(Version version) { super(version); } + @Override + protected void setUp() throws Exception { + super.setUp(); + + data = TestFixture.init010(); + tickets = data.tickets; + } + + @Override + protected void tearDown() throws Exception { + super.tearDown(); + + // TestFixture.cleanupRepository1(); + } + public void testValidate010() throws Exception { validate(TracTestConstants.TEST_TRAC_010_URL); } @@ -56,12 +83,12 @@ public class AbstractTracClientRepositoryTest extends AbstractTracClientTest { // standard connect connect(url); - repository.validate(callback); + client.validate(callback); // invalid url connect("http://non.existant/repository"); try { - repository.validate(callback); + client.validate(callback); fail("Expected TracException"); } catch (TracException e) { } @@ -69,7 +96,7 @@ public class AbstractTracClientRepositoryTest extends AbstractTracClientTest { // invalid password connect(url, credentials.username, "wrongpassword"); try { - repository.validate(callback); + client.validate(callback); fail("Expected TracLoginException"); } catch (TracLoginException e) { } @@ -77,7 +104,7 @@ public class AbstractTracClientRepositoryTest extends AbstractTracClientTest { // invalid username connect(url, "wrongusername", credentials.password); try { - repository.validate(callback); + client.validate(callback); fail("Expected TracLoginException"); } catch (TracLoginException e) { } @@ -87,10 +114,210 @@ public class AbstractTracClientRepositoryTest extends AbstractTracClientTest { connect(TracTestConstants.TEST_TRAC_010_URL, "", "", new Proxy(Type.HTTP, new InetSocketAddress( "invalidhostname", 8080))); try { - repository.validate(callback); + client.validate(callback); fail("Expected IOException"); } catch (TracException e) { } } + public void testGetTicket096() throws Exception { + if (version == Version.XML_RPC) { + return; + } + + connect096(); + getTicket(); + } + + public void testGetTicket010() throws Exception { + connect010(); + getTicket(); + } + + public void testGetTicket011() throws Exception { + if (version == Version.TRAC_0_9) { + // XXX web mode is broken for Trac 0.11: need to fix bug 175211 + return; + } + + connect011(); + getTicket(); + } + + private void getTicket() throws Exception { + TracTicket ticket = client.getTicket(tickets.get(0).getId(), null); + assertTicketEquals(tickets.get(0), ticket); + + ticket = client.getTicket(tickets.get(1).getId(), null); + assertTicketEquals(tickets.get(1), ticket); + } + + public void testGetTicketInvalidId096() throws Exception { + if (version == Version.XML_RPC) { + return; + } + + connect096(); + getTicketInvalidId(); + } + + public void testGetTicketInvalidId010() throws Exception { + connect010(); + getTicketInvalidId(); + } + + public void testGetTicketInvalidId011() throws Exception { + connect011(); + getTicketInvalidId(); + } + + private void getTicketInvalidId() throws Exception { + try { + client.getTicket(Integer.MAX_VALUE, null); + fail("Expected TracException"); + } catch (TracException e) { + } + } + + public void testGetTicketUmlaute010() throws Exception { + connect010(); + getTicketUmlaute(); + } + + public void testGetTicketUmlaute011() throws Exception { + if (version == Version.TRAC_0_9) { + // XXX need to fix bug 175211 + return; + } + + connect011(); + getTicketUmlaute(); + } + + private void getTicketUmlaute() throws Exception { + TracTicket ticket = client.getTicket(data.htmlEntitiesTicketId, null); + assertEquals("test html entities: \u00E4\u00F6\u00FC", ticket.getValue(Key.SUMMARY)); + if (version == Version.XML_RPC) { + assertEquals("\u00C4\u00D6\u00DC\n\nmulti\nline\n\n'''bold'''\n", ticket.getValue(Key.DESCRIPTION)); + } else { + assertEquals(null, ticket.getValue(Key.DESCRIPTION)); + } + } + + public void testSearchAll010() throws Exception { + connect010(); + searchAll(); + } + + public void testSearchAll011() throws Exception { + connect011(); + searchAll(); + } + + private void searchAll() throws Exception { + 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()); + } + + public void testSearchEmpty010() throws Exception { + connect010(); + searchEmpty(); + } + + public void testSearchEmpty011() throws Exception { + connect011(); + searchEmpty(); + } + + private void searchEmpty() throws Exception { + TracSearch search = new TracSearch(); + search.addFilter("milestone", "does not exist"); + List<TracTicket> result = new ArrayList<TracTicket>(); + client.search(search, result, null); + assertEquals(0, result.size()); + } + + public void testSearchMilestone1_010() throws Exception { + connect010(); + searchMilestone1(); + } + + public void testSearchMilestone1_011() throws Exception { + connect011(); + searchMilestone1(); + } + + private void searchMilestone1() throws Exception { + TracSearch search = new TracSearch(); + search.addFilter("milestone", "milestone1"); + List<TracTicket> result = new ArrayList<TracTicket>(); + client.search(search, result, null); + assertEquals(1, result.size()); + assertTicketEquals(tickets.get(0), result.get(0)); + } + + public void testSearchMilestone2_0_10() throws Exception { + connect010(); + searchMilestone2(); + } + + public void testSearchMilestone2_0_11() throws Exception { + connect011(); + searchMilestone2(); + } + + private void searchMilestone2() throws Exception { + TracSearch search = new TracSearch(); + search.addFilter("milestone", "milestone1"); + search.addFilter("milestone", "milestone2"); + search.setOrderBy("id"); + List<TracTicket> result = new ArrayList<TracTicket>(); + client.search(search, result, null); + assertEquals(3, result.size()); + assertTicketEquals(tickets.get(0), result.get(0)); + assertTicketEquals(tickets.get(1), result.get(1)); + assertTicketEquals(tickets.get(2), result.get(2)); + } + + public void testSearchExactMatch010() throws Exception { + connect010(); + searchExactMatch(); + } + + public void testSearchExactMatch011() throws Exception { + connect011(); + searchExactMatch(); + } + + private void searchExactMatch() throws Exception { + TracSearch search = new TracSearch(); + search.addFilter("milestone", "milestone1"); + search.addFilter("summary", "summary1"); + List<TracTicket> result = new ArrayList<TracTicket>(); + client.search(search, result, null); + assertEquals(1, result.size()); + assertTicketEquals(tickets.get(0), result.get(0)); + assertEquals("milestone1", result.get(0).getValue(Key.MILESTONE)); + assertEquals("summary1", result.get(0).getValue(Key.SUMMARY)); + } + + public void testStatusClosed010() throws Exception { + connect010(); + statusClosed(); + } + + public void testStatusClosed011() throws Exception { + connect011(); + statusClosed(); + } + + protected void statusClosed() throws Exception { + TracTicket ticket = client.getTicket(data.offlineHandlerTicketId, 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/AbstractTracClientSearchTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/AbstractTracClientSearchTest.java deleted file mode 100644 index 27f6e21c1..000000000 --- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/AbstractTracClientSearchTest.java +++ /dev/null @@ -1,268 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 Steffen Pingel and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Tasktop Technologies - initial API and implementation - *******************************************************************************/ - -package org.eclipse.mylyn.trac.tests.client; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.eclipse.mylyn.internal.trac.core.client.ITracClient; -import org.eclipse.mylyn.internal.trac.core.client.TracException; -import org.eclipse.mylyn.internal.trac.core.client.ITracClient.Version; -import org.eclipse.mylyn.internal.trac.core.model.TracSearch; -import org.eclipse.mylyn.internal.trac.core.model.TracTicket; -import org.eclipse.mylyn.internal.trac.core.model.TracTicket.Key; -import org.eclipse.mylyn.trac.tests.support.TestFixture; -import org.eclipse.mylyn.trac.tests.support.XmlRpcServer.TestData; -import org.eclipse.mylyn.trac.tests.support.XmlRpcServer.Ticket; - -/** - * Test cases that validate search results for classes that implement {@link ITracClient}. - * - * @author Steffen Pingel - */ -public abstract class AbstractTracClientSearchTest extends AbstractTracClientTest { - - protected List<Ticket> tickets; - - private TestData data; - - public AbstractTracClientSearchTest(Version version) { - super(version); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - - data = TestFixture.init010(); - tickets = data.tickets; - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - - // TestFixture.cleanupRepository1(); - } - - protected void assertTicketEquals(Ticket ticket, TracTicket tracTicket) throws Exception { - assertTrue(tracTicket.isValid()); - - Map<?, ?> expectedValues = ticket.getValues(); - Map<String, String> values = tracTicket.getValues(); - for (String key : values.keySet()) { - assertEquals("Values for key '" + key + "' did not match", expectedValues.get(key), values.get(key)); - } - } - - public void testGetTicket096() throws Exception { - if (version == Version.XML_RPC) { - return; - } - - connect096(); - getTicket(); - } - - public void testGetTicket010() throws Exception { - connect010(); - getTicket(); - } - - public void testGetTicket011() throws Exception { - if (version == Version.TRAC_0_9) { - // XXX web mode is broken for Trac 0.11: need to fix bug 175211 - return; - } - - connect011(); - getTicket(); - } - - private void getTicket() throws Exception { - TracTicket ticket = repository.getTicket(tickets.get(0).getId(), null); - assertTicketEquals(tickets.get(0), ticket); - - ticket = repository.getTicket(tickets.get(1).getId(), null); - assertTicketEquals(tickets.get(1), ticket); - } - - public void testGetTicketInvalidId096() throws Exception { - if (version == Version.XML_RPC) { - return; - } - - connect096(); - getTicketInvalidId(); - } - - public void testGetTicketInvalidId010() throws Exception { - connect010(); - getTicketInvalidId(); - } - - public void testGetTicketInvalidId011() throws Exception { - connect011(); - getTicketInvalidId(); - } - - private void getTicketInvalidId() throws Exception { - try { - repository.getTicket(Integer.MAX_VALUE, null); - fail("Expected TracException"); - } catch (TracException e) { - } - } - - public void testGetTicketUmlaute010() throws Exception { - connect010(); - getTicketUmlaute(); - } - - public void testGetTicketUmlaute011() throws Exception { - if (version == Version.TRAC_0_9) { - // XXX need to fix bug 175211 - return; - } - - connect011(); - getTicketUmlaute(); - } - - private void getTicketUmlaute() throws Exception { - TracTicket ticket = repository.getTicket(data.htmlEntitiesTicketId, null); - assertEquals("test html entities: \u00E4\u00F6\u00FC", ticket.getValue(Key.SUMMARY)); - if (version == Version.XML_RPC) { - assertEquals("\u00C4\u00D6\u00DC\n\nmulti\nline\n\n'''bold'''\n", ticket.getValue(Key.DESCRIPTION)); - } else { - assertEquals(null, ticket.getValue(Key.DESCRIPTION)); - } - } - - public void testSearchAll010() throws Exception { - connect010(); - searchAll(); - } - - public void testSearchAll011() throws Exception { - connect011(); - searchAll(); - } - - private void searchAll() throws Exception { - TracSearch search = new TracSearch(); - List<TracTicket> result = new ArrayList<TracTicket>(); - repository.search(search, result, null); - //assertEquals(tickets.size(), result.size()); - assertTrue(result.size() >= tickets.size()); - } - - public void testSearchEmpty010() throws Exception { - connect010(); - searchEmpty(); - } - - public void testSearchEmpty011() throws Exception { - connect011(); - searchEmpty(); - } - - private void searchEmpty() throws Exception { - TracSearch search = new TracSearch(); - search.addFilter("milestone", "does not exist"); - List<TracTicket> result = new ArrayList<TracTicket>(); - repository.search(search, result, null); - assertEquals(0, result.size()); - } - - public void testSearchMilestone1_010() throws Exception { - connect010(); - searchMilestone1(); - } - - public void testSearchMilestone1_011() throws Exception { - connect011(); - searchMilestone1(); - } - - private void searchMilestone1() throws Exception { - TracSearch search = new TracSearch(); - search.addFilter("milestone", "milestone1"); - List<TracTicket> result = new ArrayList<TracTicket>(); - repository.search(search, result, null); - assertEquals(1, result.size()); - assertTicketEquals(tickets.get(0), result.get(0)); - } - - public void testSearchMilestone2_0_10() throws Exception { - connect010(); - searchMilestone2(); - } - - public void testSearchMilestone2_0_11() throws Exception { - connect011(); - searchMilestone2(); - } - - private void searchMilestone2() throws Exception { - TracSearch search = new TracSearch(); - search.addFilter("milestone", "milestone1"); - search.addFilter("milestone", "milestone2"); - search.setOrderBy("id"); - List<TracTicket> result = new ArrayList<TracTicket>(); - repository.search(search, result, null); - assertEquals(3, result.size()); - assertTicketEquals(tickets.get(0), result.get(0)); - assertTicketEquals(tickets.get(1), result.get(1)); - assertTicketEquals(tickets.get(2), result.get(2)); - } - - public void testSearchExactMatch010() throws Exception { - connect010(); - searchExactMatch(); - } - - public void testSearchExactMatch011() throws Exception { - connect011(); - searchExactMatch(); - } - - private void searchExactMatch() throws Exception { - TracSearch search = new TracSearch(); - search.addFilter("milestone", "milestone1"); - search.addFilter("summary", "summary1"); - List<TracTicket> result = new ArrayList<TracTicket>(); - repository.search(search, result, null); - assertEquals(1, result.size()); - assertTicketEquals(tickets.get(0), result.get(0)); - assertEquals("milestone1", result.get(0).getValue(Key.MILESTONE)); - assertEquals("summary1", result.get(0).getValue(Key.SUMMARY)); - } - - public void testStatusClosed010() throws Exception { - connect010(); - statusClosed(); - } - - public void testStatusClosed011() throws Exception { - connect011(); - statusClosed(); - } - - protected void statusClosed() throws Exception { - TracTicket ticket = repository.getTicket(data.offlineHandlerTicketId, 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/AbstractTracClientTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/AbstractTracClientTest.java index 0d3a526fa..f4418bc6e 100644 --- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/AbstractTracClientTest.java +++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/AbstractTracClientTest.java @@ -12,6 +12,7 @@ package org.eclipse.mylyn.trac.tests.client; import java.net.Proxy; +import java.util.Map; import junit.framework.TestCase; @@ -25,7 +26,9 @@ import org.eclipse.mylyn.context.tests.support.TestUtil.PrivilegeLevel; import org.eclipse.mylyn.internal.trac.core.TracClientFactory; import org.eclipse.mylyn.internal.trac.core.client.ITracClient; import org.eclipse.mylyn.internal.trac.core.client.ITracClient.Version; +import org.eclipse.mylyn.internal.trac.core.model.TracTicket; import org.eclipse.mylyn.trac.tests.support.TracTestConstants; +import org.eclipse.mylyn.trac.tests.support.XmlRpcServer.Ticket; /** * Provides a base implementation for test cases that access trac repositories. @@ -36,7 +39,7 @@ public abstract class AbstractTracClientTest extends TestCase { public String repositoryUrl; - public ITracClient repository; + public ITracClient client; public String username; @@ -105,9 +108,19 @@ public abstract class AbstractTracClientTest extends TestCase { return proxy; } }); - this.repository = TracClientFactory.createClient(location, version); + this.client = TracClientFactory.createClient(location, version); - return this.repository; + return this.client; + } + + protected void assertTicketEquals(Ticket ticket, TracTicket tracTicket) throws Exception { + assertTrue(tracTicket.isValid()); + + Map<?, ?> expectedValues = ticket.getValues(); + Map<String, String> values = tracTicket.getValues(); + for (String key : values.keySet()) { + assertEquals("Values for key '" + key + "' did not match", expectedValues.get(key), values.get(key)); + } } } diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracRepositoryInfoTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracRepositoryInfoTest.java new file mode 100644 index 000000000..4071786e3 --- /dev/null +++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracRepositoryInfoTest.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2009 Steffen Pingel and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Steffen Pingel - initial API and implementation + *******************************************************************************/ + +package org.eclipse.mylyn.trac.tests.client; + +import junit.framework.TestCase; + +import org.eclipse.mylyn.internal.trac.core.model.TracRepositoryInfo; + +/** + * @author Steffen Pingel + */ +public class TracRepositoryInfoTest extends TestCase { + + public void testIsApiVersion() { + TracRepositoryInfo info = new TracRepositoryInfo(1, 1, 1); + assertTrue(info.isApiVersion(1, 1, 1)); + assertFalse(info.isApiVersion(1, 1, 0)); + assertFalse(info.isApiVersion(1, 0, 1)); + assertFalse(info.isApiVersion(0, 1, 1)); + assertFalse(info.isApiVersion(-1, -1, -1)); + } + + public void testIsApiVersionOrHigher() { + TracRepositoryInfo info = new TracRepositoryInfo(1, 2, 3); + assertTrue(info.isApiVersionOrHigher(1, 2, 3)); + assertTrue(info.isApiVersionOrHigher(0, 1, 3)); + assertTrue(info.isApiVersionOrHigher(1, 2, -3)); + assertFalse(info.isApiVersionOrHigher(1, 2, 4)); + assertFalse(info.isApiVersionOrHigher(2, 3, 2)); + } + + public void testIsApiVersionOrSmaller() { + TracRepositoryInfo info = new TracRepositoryInfo(1, 2, 3); + assertTrue(info.isApiVersionOrSmaller(1, 2, 3)); + assertTrue(info.isApiVersionOrSmaller(2, 1, 3)); + assertTrue(info.isApiVersionOrSmaller(1, 3, -3)); + assertFalse(info.isApiVersionOrSmaller(1, 2, 2)); + assertFalse(info.isApiVersionOrSmaller(0, 3, 2)); + } + +} diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracWebClientSearchTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracWebClientSearchTest.java deleted file mode 100644 index 5cb7a4627..000000000 --- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracWebClientSearchTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 Steffen Pingel and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Tasktop Technologies - initial API and implementation - *******************************************************************************/ - -package org.eclipse.mylyn.trac.tests.client; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.mylyn.internal.trac.core.client.ITracClient.Version; -import org.eclipse.mylyn.internal.trac.core.model.TracSearch; -import org.eclipse.mylyn.internal.trac.core.model.TracTicket; - -/** - * @author Steffen Pingel - */ -public class TracWebClientSearchTest extends AbstractTracClientSearchTest { - - public TracWebClientSearchTest() { - super(Version.TRAC_0_9); - } - - // TODO move this test to AbstracTracClientTest when bug 162094 is resolved - public void testSearchMilestoneAmpersand010() throws Exception { - connect010(); - searchMilestoneAmpersand(); - } - - public void testSearchMilestoneAmpersand011() throws Exception { - connect011(); - searchMilestoneAmpersand(); - } - - private void searchMilestoneAmpersand() throws Exception { - TracSearch search = new TracSearch(); - search.addFilter("milestone", "mile&stone"); - search.setOrderBy("id"); - List<TracTicket> result = new ArrayList<TracTicket>(); - repository.search(search, result, null); - assertEquals(1, result.size()); - assertTicketEquals(tickets.get(7), result.get(0)); - } - - public void testStatusClosed096() throws Exception { - connect096(); - statusClosed(); - } - -} diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracWebClientTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracWebClientTest.java index c5784c49a..c85a9746b 100644 --- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracWebClientTest.java +++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracWebClientTest.java @@ -11,12 +11,16 @@ package org.eclipse.mylyn.trac.tests.client; +import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; +import java.util.List; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.mylyn.internal.trac.core.client.TracException; import org.eclipse.mylyn.internal.trac.core.client.ITracClient.Version; +import org.eclipse.mylyn.internal.trac.core.model.TracSearch; +import org.eclipse.mylyn.internal.trac.core.model.TracTicket; import org.eclipse.mylyn.internal.trac.core.model.TracVersion; import org.eclipse.mylyn.trac.tests.support.TracTestConstants; @@ -44,7 +48,7 @@ public class TracWebClientTest extends AbstractTracClientRepositoryTest { public void testValidateAnyPage() throws Exception { connect("http://mylyn.eclipse.org/"); try { - repository.validate(callback); + client.validate(callback); fail("Expected TracException"); } catch (TracException e) { } @@ -52,10 +56,10 @@ public class TracWebClientTest extends AbstractTracClientRepositoryTest { public void testValidateAnonymousLogin() throws Exception { connect(TracTestConstants.TEST_TRAC_010_URL, "", ""); - repository.validate(callback); + client.validate(callback); connect(TracTestConstants.TEST_TRAC_096_URL, "", ""); - repository.validate(callback); + client.validate(callback); } public void testUpdateAttributesAnonymous096() throws Exception { @@ -69,9 +73,9 @@ public class TracWebClientTest extends AbstractTracClientRepositoryTest { } private void updateAttributes() throws TracException { - assertNull(repository.getMilestones()); - repository.updateAttributes(new NullProgressMonitor(), true); - TracVersion[] versions = repository.getVersions(); + assertNull(client.getMilestones()); + client.updateAttributes(new NullProgressMonitor(), true); + TracVersion[] versions = client.getVersions(); assertEquals(2, versions.length); Arrays.sort(versions, new Comparator<TracVersion>() { public int compare(TracVersion o1, TracVersion o2) { @@ -82,4 +86,30 @@ public class TracWebClientTest extends AbstractTracClientRepositoryTest { assertEquals("2.0", versions[1].getName()); } + // TODO move this test to AbstracTracClientTest when bug 162094 is resolved + public void testSearchMilestoneAmpersand010() throws Exception { + connect010(); + searchMilestoneAmpersand(); + } + + public void testSearchMilestoneAmpersand011() throws Exception { + connect011(); + searchMilestoneAmpersand(); + } + + private void searchMilestoneAmpersand() throws Exception { + TracSearch search = new TracSearch(); + search.addFilter("milestone", "mile&stone"); + search.setOrderBy("id"); + List<TracTicket> result = new ArrayList<TracTicket>(); + client.search(search, result, null); + assertEquals(1, result.size()); + assertTicketEquals(tickets.get(7), result.get(0)); + } + + public void testStatusClosed096() throws Exception { + connect096(); + statusClosed(); + } + } diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracXmlRpcClientSearchTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracXmlRpcClientSearchTest.java deleted file mode 100644 index 904d8f077..000000000 --- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/client/TracXmlRpcClientSearchTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 Steffen Pingel and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Tasktop Technologies - initial API and implementation - *******************************************************************************/ - -package org.eclipse.mylyn.trac.tests.client; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.mylyn.internal.trac.core.client.ITracClient.Version; -import org.eclipse.mylyn.internal.trac.core.model.TracSearch; -import org.eclipse.mylyn.internal.trac.core.model.TracTicket; -import org.eclipse.mylyn.internal.trac.core.model.TracTicket.Key; - -/** - * @author Steffen Pingel - */ -public class TracXmlRpcClientSearchTest extends AbstractTracClientSearchTest { - - public TracXmlRpcClientSearchTest() { - super(Version.XML_RPC); - } - - public void testSearchValidateTicket010() throws Exception { - connect010(); - searchValidateTicket(); - } - - public void testSearchValidateTicket011() throws Exception { - connect011(); - searchValidateTicket(); - } - - public void searchValidateTicket() throws Exception { - TracSearch search = new TracSearch(); - search.addFilter("summary", "summary1"); - List<TracTicket> result = new ArrayList<TracTicket>(); - repository.search(search, result, null); - assertEquals(1, result.size()); - 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)); - } - -} 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 0933f7e52..f26d47101 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 @@ -12,6 +12,7 @@ package org.eclipse.mylyn.trac.tests.client; +import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.Date; @@ -22,9 +23,14 @@ import org.eclipse.mylyn.internal.trac.core.client.TracPermissionDeniedException import org.eclipse.mylyn.internal.trac.core.client.TracRemoteException; import org.eclipse.mylyn.internal.trac.core.client.TracXmlRpcClient; import org.eclipse.mylyn.internal.trac.core.client.ITracClient.Version; +import org.eclipse.mylyn.internal.trac.core.model.TracAction; +import org.eclipse.mylyn.internal.trac.core.model.TracSearch; +import org.eclipse.mylyn.internal.trac.core.model.TracTicket; +import org.eclipse.mylyn.internal.trac.core.model.TracTicketField; 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.internal.trac.core.model.TracTicket.Key; import org.eclipse.mylyn.trac.tests.support.TracTestConstants; /** @@ -45,7 +51,7 @@ public class TracXmlRpcClientTest extends AbstractTracClientRepositoryTest { public void testValidateFailNoAuth() throws Exception { connect(TracTestConstants.TEST_TRAC_010_URL, "", ""); try { - repository.validate(callback); + client.validate(callback); fail("Expected TracPermissiongDeniedException"); } catch (TracPermissionDeniedException e) { } @@ -54,7 +60,7 @@ public class TracXmlRpcClientTest extends AbstractTracClientRepositoryTest { public void testMulticallExceptions() throws Exception { connect010(); try { - ((TracXmlRpcClient) repository).getTickets(new int[] { 1, Integer.MAX_VALUE }, null); + ((TracXmlRpcClient) client).getTickets(new int[] { 1, Integer.MAX_VALUE }, null); fail("Expected TracRemoteException"); } catch (TracRemoteException e) { } @@ -71,9 +77,9 @@ public class TracXmlRpcClientTest extends AbstractTracClientRepositoryTest { } public void updateAttributes() throws Exception { - assertNull(repository.getMilestones()); - repository.updateAttributes(new NullProgressMonitor(), true); - TracVersion[] versions = repository.getVersions(); + assertNull(client.getMilestones()); + client.updateAttributes(new NullProgressMonitor(), true); + TracVersion[] versions = client.getVersions(); assertEquals(2, versions.length); Arrays.sort(versions, new Comparator<TracVersion>() { public int compare(TracVersion o1, TracVersion o2) { @@ -88,6 +94,88 @@ public class TracXmlRpcClientTest extends AbstractTracClientRepositoryTest { assertEquals(new Date(0), versions[1].getTime()); } + public void testSearchValidateTicket010() throws Exception { + connect010(); + searchValidateTicket(); + } + + public void testSearchValidateTicket011() throws Exception { + connect011(); + searchValidateTicket(); + } + + public void searchValidateTicket() throws Exception { + TracSearch search = new TracSearch(); + search.addFilter("summary", "summary1"); + List<TracTicket> result = new ArrayList<TracTicket>(); + client.search(search, result, null); + assertEquals(1, result.size()); + assertTicketEquals(tickets.get(0), result.get(0)); + 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)); + } + + public void testGetTicketActions010() throws Exception { + connect010(); + + TracTicket ticket = client.getTicket(tickets.get(0).getId(), null); + TracAction[] actions = ticket.getActions(); + assertNotNull(actions); + assertEquals(4, actions.length); + assertEquals("leave", actions[0].getId()); + assertNull(actions[0].getLabel()); + assertEquals(0, actions[0].getFields().size()); + assertEquals("resolve", actions[1].getId()); + assertNull(actions[1].getLabel()); + assertEquals(0, actions[1].getFields().size()); + assertEquals("reassign", actions[2].getId()); + assertNull(actions[2].getLabel()); + assertEquals(0, actions[2].getFields().size()); + assertEquals("accept", actions[3].getId()); + assertNull(actions[3].getLabel()); + assertEquals(0, actions[3].getFields().size()); + + ticket = client.getTicket(tickets.get(1).getId(), null); + actions = ticket.getActions(); + assertNotNull(actions); + assertEquals(2, actions.length); + assertEquals("leave", actions[0].getId()); + assertEquals("reopen", actions[1].getId()); + } + + public void testGetTicketActions011() throws Exception { + connect011(); + + TracTicket ticket = client.getTicket(tickets.get(0).getId(), null); + TracAction[] actions = ticket.getActions(); + assertNotNull(actions); + assertEquals(4, actions.length); + assertEquals("leave", actions[0].getId()); + assertEquals("resolve", actions[1].getId()); + assertEquals("resolve", actions[1].getLabel()); + assertNotNull(actions[1].getHint()); + List<TracTicketField> fields = actions[1].getFields(); + assertEquals(1, fields.size()); + assertEquals(5, fields.get(0).getOptions().length); + assertEquals("fixed", fields.get(0).getOptions()[0]); + assertEquals("reassign", actions[2].getId()); + fields = actions[2].getFields(); + assertEquals(1, fields.size()); + assertNull(fields.get(0).getOptions()); + assertEquals("accept", actions[3].getId()); + + ticket = client.getTicket(tickets.get(1).getId(), null); + actions = ticket.getActions(); + assertNotNull(actions); + assertEquals(2, actions.length); + assertEquals("leave", actions[0].getId()); + assertEquals("reopen", actions[1].getId()); + } + public void testWikiToHtml010() throws Exception { connect010(); wikiToHtml(TracTestConstants.TEST_TRAC_010_URL); @@ -99,10 +187,10 @@ public class TracXmlRpcClientTest extends AbstractTracClientRepositoryTest { } public void wikiToHtml(String tracUrl) throws Exception { - String html = ((TracXmlRpcClient) repository).wikiToHtml("", null); + String html = ((TracXmlRpcClient) client).wikiToHtml("", null); assertEquals("", html); - html = ((TracXmlRpcClient) repository).wikiToHtml("A simple line of text.", null); + html = ((TracXmlRpcClient) 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" @@ -114,18 +202,18 @@ public class TracXmlRpcClientTest extends AbstractTracClientRepositoryTest { + 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) repository).wikiToHtml(source, null); + html = ((TracXmlRpcClient) client).wikiToHtml(source, null); assertEquals(expectedHtml, html); } public void testValidateWikiAPI010() throws Exception { connect010(); - ((TracXmlRpcClient) repository).validateWikiRpcApi(null); + ((TracXmlRpcClient) client).validateWikiRpcApi(null); } public void testValidateWikiAPI011() throws Exception { connect011(); - ((TracXmlRpcClient) repository).validateWikiRpcApi(null); + ((TracXmlRpcClient) client).validateWikiRpcApi(null); } public void testGetAllWikiPageNames010() throws Exception { @@ -139,7 +227,7 @@ public class TracXmlRpcClientTest extends AbstractTracClientRepositoryTest { } private void getAllWikiPageNames() throws Exception { - String[] names = ((TracXmlRpcClient) repository).getAllWikiPageNames(null); + String[] names = ((TracXmlRpcClient) client).getAllWikiPageNames(null); List<String> all = Arrays.asList(names); assertTrue(all.contains("Test")); } @@ -155,7 +243,7 @@ public class TracXmlRpcClientTest extends AbstractTracClientRepositoryTest { } private void getWikiPage() throws Exception { - TracWikiPage page = ((TracXmlRpcClient) repository).getWikiPage("TestGetPage", null); + TracWikiPage page = ((TracXmlRpcClient) client).getWikiPage("TestGetPage", null); assertEquals("TestGetPage", page.getPageInfo().getPageName()); assertEquals("tests@mylyn.eclipse.org", page.getPageInfo().getAuthor()); assertEquals(2, page.getPageInfo().getVersion()); @@ -165,7 +253,7 @@ public class TracXmlRpcClientTest extends AbstractTracClientRepositoryTest { assertEquals("Version 2", page.getContent()); assertTrue(page.getPageHTML().startsWith("<html>")); - page = ((TracXmlRpcClient) repository).getWikiPage("TestGetPage", 1, null); + page = ((TracXmlRpcClient) client).getWikiPage("TestGetPage", 1, null); assertEquals("TestGetPage", page.getPageInfo().getPageName()); assertEquals("anonymous", page.getPageInfo().getAuthor()); assertEquals(1, page.getPageInfo().getVersion()); @@ -186,98 +274,98 @@ public class TracXmlRpcClientTest extends AbstractTracClientRepositoryTest { private void getWikiPageInvalid() throws Exception { // get info -- non-existing version try { - ((TracXmlRpcClient) repository).getWikiPageInfo("Test", 10, null); + ((TracXmlRpcClient) client).getWikiPageInfo("Test", 10, null); fail("Expected TracRemoteException"); } catch (TracRemoteException e) { } // get info -- non-existing page name try { - ((TracXmlRpcClient) repository).getWikiPageInfo("NoSuchPage", null); + ((TracXmlRpcClient) client).getWikiPageInfo("NoSuchPage", null); fail("Expected TracRemoteException"); } catch (TracRemoteException e) { } // get info -- null parameter try { - ((TracXmlRpcClient) repository).getWikiPageInfo(null, null); + ((TracXmlRpcClient) client).getWikiPageInfo(null, null); fail("Expected RuntimeException"); } catch (IllegalArgumentException e) { } // get content -- non-existing version try { - ((TracXmlRpcClient) repository).getWikiPageContent("Test", 10, null); + ((TracXmlRpcClient) client).getWikiPageContent("Test", 10, null); fail("Expected TracRemoteException"); } catch (TracRemoteException e) { } // get content -- non-existing page name try { - ((TracXmlRpcClient) repository).getWikiPageContent("NoSuchPage", null); + ((TracXmlRpcClient) client).getWikiPageContent("NoSuchPage", null); fail("Expected TracRemoteException"); } catch (TracRemoteException e) { } // get content -- null parameter try { - ((TracXmlRpcClient) repository).getWikiPageContent(null, null); + ((TracXmlRpcClient) client).getWikiPageContent(null, null); fail("Expected RuntimeException"); } catch (IllegalArgumentException e) { } // get HTML -- non-existing version try { - ((TracXmlRpcClient) repository).getWikiPageHtml("Test", 10, null); + ((TracXmlRpcClient) client).getWikiPageHtml("Test", 10, null); fail("Expected TracRemoteException"); } catch (TracRemoteException e) { } // get HTML -- non-existing page name try { - ((TracXmlRpcClient) repository).getWikiPageHtml("NoSuchPage", null); + ((TracXmlRpcClient) client).getWikiPageHtml("NoSuchPage", null); fail("Expected TracRemoteException"); } catch (TracRemoteException e) { } // get HTML -- null parameter try { - ((TracXmlRpcClient) repository).getWikiPageHtml(null, null); + ((TracXmlRpcClient) client).getWikiPageHtml(null, null); fail("Expected RuntimeException"); } catch (IllegalArgumentException e) { } // get a page -- non-existing version try { - ((TracXmlRpcClient) repository).getWikiPage("Test", 10, null); + ((TracXmlRpcClient) client).getWikiPage("Test", 10, null); fail("Expected TracRemoteException"); } catch (TracRemoteException e) { } // get a page -- non-existing page name try { - ((TracXmlRpcClient) repository).getWikiPage("NoSuchPage", null); + ((TracXmlRpcClient) client).getWikiPage("NoSuchPage", null); fail("Expected TracRemoteException"); } catch (TracRemoteException e) { } // get a page -- null parameter try { - ((TracXmlRpcClient) repository).getWikiPage(null, null); + ((TracXmlRpcClient) client).getWikiPage(null, null); fail("Expected RuntimeException"); } catch (IllegalArgumentException e) { } // get all versions of a page -- non-existing page name try { - ((TracXmlRpcClient) repository).getWikiPageInfoAllVersions("NoSuchPage", null); + ((TracXmlRpcClient) client).getWikiPageInfoAllVersions("NoSuchPage", null); fail("Expected TracRemoteException"); } catch (TracRemoteException e) { } // get all versions of a page -- null parameter try { - ((TracXmlRpcClient) repository).getWikiPageInfoAllVersions(null, null); + ((TracXmlRpcClient) client).getWikiPageInfoAllVersions(null, null); fail("Expected RuntimeException"); } catch (IllegalArgumentException e) { } @@ -296,7 +384,7 @@ public class TracXmlRpcClientTest extends AbstractTracClientRepositoryTest { private void getWikiPageInfoAllVersions() throws Exception { String pageName = "Test"; - TracWikiPageInfo[] versions = ((TracXmlRpcClient) repository).getWikiPageInfoAllVersions(pageName, null); + TracWikiPageInfo[] versions = ((TracXmlRpcClient) client).getWikiPageInfoAllVersions(pageName, null); assertTrue(versions.length >= 1); int counter = 1; for (TracWikiPageInfo version : versions) { @@ -316,7 +404,7 @@ public class TracXmlRpcClientTest extends AbstractTracClientRepositoryTest { } private void getRecentWikiChanges() throws Exception { - TracWikiPageInfo[] changes = ((TracXmlRpcClient) repository).getRecentWikiChanges(new Date(0), null); + TracWikiPageInfo[] changes = ((TracXmlRpcClient) client).getRecentWikiChanges(new Date(0), null); TracWikiPageInfo testPage = null; for (TracWikiPageInfo item : changes) { assertTrue(item.getPageName() != null); @@ -340,4 +428,5 @@ public class TracXmlRpcClientTest extends AbstractTracClientRepositoryTest { private void putWikiPage() throws Exception { // TODO testing wiki.putPage() } + } diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracTaskDataHandlerTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracTaskDataHandlerTest.java index 4c2e6bcb0..67dbd65d4 100644 --- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracTaskDataHandlerTest.java +++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracTaskDataHandlerTest.java @@ -49,6 +49,7 @@ import org.eclipse.mylyn.tasks.core.data.AbstractTaskAttachmentHandler; import org.eclipse.mylyn.tasks.core.data.TaskAttribute; 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.TestFixture; @@ -441,4 +442,49 @@ public class TracTaskDataHandlerTest extends TestCase { assertNull(taskData.getRoot().getAttribute(TracAttribute.SEVERITY.getTracKey())); } + public void testOperations_XmlRpc_0_10() throws Exception { + init(TracTestConstants.TEST_TRAC_010_URL, Version.XML_RPC); + operations(false); + } + + public void testOperations_XmlRpc_0_11() throws Exception { + init(TracTestConstants.TEST_TRAC_011_URL, Version.XML_RPC); + operations(true); + } + + protected void operations(boolean hasReassign) throws Exception { + TaskData taskData = taskDataHandler.getTaskData(repository, "1", new NullProgressMonitor()); + List<TaskAttribute> operations = taskData.getAttributeMapper().getAttributesByType(taskData, + TaskAttribute.TYPE_OPERATION); + assertEquals((hasReassign ? 5 : 4), operations.size()); + + TaskOperation operation = taskData.getAttributeMapper().getTaskOperation(operations.get(0)); + assertEquals(TaskAttribute.OPERATION, operation.getTaskAttribute().getId()); + + operation = taskData.getAttributeMapper().getTaskOperation(operations.get(1)); + assertEquals("leave", operation.getOperationId()); + assertNotNull(operation.getLabel()); + + operation = taskData.getAttributeMapper().getTaskOperation(operations.get(2)); + assertEquals("resolve", operation.getOperationId()); + assertNotNull(operation.getLabel()); + String associatedId = operation.getTaskAttribute().getMetaData().getValue( + TaskAttribute.META_ASSOCIATED_ATTRIBUTE_ID); + assertNotNull(associatedId); + + if (hasReassign) { + operation = taskData.getAttributeMapper().getTaskOperation(operations.get(3)); + assertEquals("reassign", operation.getOperationId()); + assertNotNull(operation.getLabel()); + + operation = taskData.getAttributeMapper().getTaskOperation(operations.get(4)); + assertEquals("accept", operation.getOperationId()); + assertNotNull(operation.getLabel()); + } else { + operation = taskData.getAttributeMapper().getTaskOperation(operations.get(3)); + assertEquals("accept", operation.getOperationId()); + assertNotNull(operation.getLabel()); + } + } + } 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 de8a4c90e..2322fa09d 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 @@ -51,11 +51,11 @@ public class TracTestCleanupUtil extends AbstractTracClientTest { } private void cleanup() throws TracException { - TracTicket ticket = repository.getTicket(data.attachmentTicketId, null); + TracTicket ticket = client.getTicket(data.attachmentTicketId, null); TracAttachment[] attachments = ticket.getAttachments(); // skips the first attachment for (int i = 1; i < attachments.length; i++) { - repository.deleteAttachment(data.attachmentTicketId, attachments[i].getFilename(), null); + client.deleteAttachment(data.attachmentTicketId, attachments[i].getFilename(), null); } } |