Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2006-09-15 17:30:53 -0400
committerspingel2006-09-15 17:30:53 -0400
commit8f8666de01e095036e768d89fb98ca59d2c98c7f (patch)
tree034b2b203bb9f4ec508b2c2c3b17e55ed0006f33 /org.eclipse.mylyn.trac.tests
parente18c75178950c307fa10d35f4cc10371f28d3682 (diff)
downloadorg.eclipse.mylyn.tasks-8f8666de01e095036e768d89fb98ca59d2c98c7f.tar.gz
org.eclipse.mylyn.tasks-8f8666de01e095036e768d89fb98ca59d2c98c7f.tar.xz
org.eclipse.mylyn.tasks-8f8666de01e095036e768d89fb98ca59d2c98c7f.zip
Progress on: 147779: improve the way that context is stored on disk
https://bugs.eclipse.org/bugs/show_bug.cgi?id=147779
Diffstat (limited to 'org.eclipse.mylyn.trac.tests')
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracRepositoryConnectorTest.java13
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracXmlRpcTest.java55
2 files changed, 49 insertions, 19 deletions
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracRepositoryConnectorTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracRepositoryConnectorTest.java
index 982615fff..78b830d04 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracRepositoryConnectorTest.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracRepositoryConnectorTest.java
@@ -42,11 +42,10 @@ import org.eclipse.mylar.internal.trac.core.model.TracVersion;
import org.eclipse.mylar.internal.trac.core.model.TracTicket.Key;
import org.eclipse.mylar.internal.trac.ui.wizard.TracRepositorySettingsPage;
import org.eclipse.mylar.tasks.core.AbstractQueryHit;
-import org.eclipse.mylar.tasks.core.QueryHitCollector;
import org.eclipse.mylar.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylar.tasks.core.AbstractRepositoryTask;
import org.eclipse.mylar.tasks.core.ITask;
-import org.eclipse.mylar.tasks.core.RepositoryAttachment;
+import org.eclipse.mylar.tasks.core.QueryHitCollector;
import org.eclipse.mylar.tasks.core.TaskList;
import org.eclipse.mylar.tasks.core.TaskRepository;
import org.eclipse.mylar.tasks.core.TaskRepositoryManager;
@@ -278,20 +277,20 @@ public class TracRepositoryConnectorTest extends TestCase {
TracTask task = (TracTask) connector.createTaskFromExistingKey(repository, data.attachmentTicketId + "", null);
TasksUiPlugin.getSynchronizationManager().synchronize(connector, task, true, null);
- int size = task.getTaskData().getAttachments().size();
+ //int size = task.getTaskData().getAttachments().size();
File sourceContextFile = ContextCorePlugin.getContextManager().getFileForContext(task.getHandleIdentifier());
- //System.err.println(">>> " + sourceContextFile.exists() + " " + sourceContextFile.length());
sourceContextFile.createNewFile();
sourceContextFile.deleteOnExit();
assertTrue(connector.attachContext(repository, task, "", TasksUiPlugin.getDefault().getProxySettings()));
TasksUiPlugin.getSynchronizationManager().synchronize(connector, task, true, null);
- assertEquals(size + 1, task.getTaskData().getAttachments().size());
+ // TODO attachment may have been overridden therefore size may not have changed
+ //assertEquals(size + 1, task.getTaskData().getAttachments().size());
- RepositoryAttachment attachment = task.getTaskData().getAttachments().get(size);
- assertTrue(connector.retrieveContext(repository, task, attachment, TasksUiPlugin.getDefault().getProxySettings(), TasksUiPlugin.getDefault().getDataDirectory()));
+ //RepositoryAttachment attachment = task.getTaskData().getAttachments().get(size);
+ //assertTrue(connector.retrieveContext(repository, task, attachment, TasksUiPlugin.getDefault().getProxySettings(), TasksUiPlugin.getDefault().getDataDirectory()));
}
public void testContext096() throws Exception {
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracXmlRpcTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracXmlRpcTest.java
index c8d2cf8c9..1b4001a83 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracXmlRpcTest.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracXmlRpcTest.java
@@ -32,7 +32,7 @@ import org.eclipse.mylar.internal.trac.core.util.TracHttpClientTransportFactory;
/**
* Test cases for <a href="http://trac-hacks.org/wiki/XmlRpcPlugin">Trac XML-RPC
- * Plugin</a> API. Revision 1070 or higher is required.
+ * Plugin</a> API. Revision 1188 or higher is required.
*
* <p>
* This class does not depend on any Mylar (connector) classes except for
@@ -356,41 +356,54 @@ public class TracXmlRpcTest extends TestCase {
public void testAttachment() throws XmlRpcException, IOException {
int id = createTicket("summary", "description", new Hashtable());
- String filename = (String) call("ticket.putAttachment", id, "attach.txt", "data".getBytes(), true);
+ String filename = (String) call("ticket.putAttachment", id, "attach.txt", "description", "data".getBytes(), true);
// the returned filename may differ, since another ticket may have an
// attachment named "attach.txt"
// assertEquals("attach.txt", filename);
Object[] ret = (Object[]) call("ticket.listAttachments", id);
assertEquals(1, ret.length);
- assertHasValue(ret, filename);
-
+ Object[] attachment = (Object[]) ret[0];
+ assertEquals("attach.txt", attachment[0]);
+ assertEquals("description", attachment[1]);
+ assertEquals(4, attachment[2]);
+ // date
+ assertEquals(username, attachment[4]);
+
byte[] bytes = (byte[]) call("ticket.getAttachment", id, filename);
String data = new String(bytes);
assertEquals("data", data);
- String filename2 = (String) call("ticket.putAttachment", id, filename, "data".getBytes(), true);
+ // test override
+
+ String filename2 = (String) call("ticket.putAttachment", id, filename, "newdescription", "newdata".getBytes(), true);
assertEquals(filename, filename2);
ret = (Object[]) call("ticket.listAttachments", id);
assertEquals(1, ret.length);
- assertHasValue(ret, filename);
-
- String filename3 = (String) call("ticket.putAttachment", id, "attach.txt", "data".getBytes(), false);
+ attachment = (Object[]) ret[0];
+ assertEquals("attach.txt", attachment[0]);
+ assertEquals("newdescription", attachment[1]);
+ assertEquals(7, attachment[2]);
+ // date
+ assertEquals(username, attachment[4]);
+ bytes = (byte[]) call("ticket.getAttachment", id, filename);
+ data = new String(bytes);
+ assertEquals("newdata", data);
+
+
+ String filename3 = (String) call("ticket.putAttachment", id, "attach.txt", "description", "data".getBytes(), false);
assertFalse("attach.txt".equals(filename3));
ret = (Object[]) call("ticket.listAttachments", id);
assertEquals(2, ret.length);
- assertHasValue(ret, filename);
- assertHasValue(ret, filename3);
}
public void testDeleteAttachment() throws XmlRpcException, IOException {
int id = createTicket("summary", "description", new Hashtable());
- String filename = (String) call("ticket.putAttachment", id, "attach.txt", "data".getBytes(), true);
+ String filename = (String) call("ticket.putAttachment", id, "attach.txt", "description", "data".getBytes(), true);
Object[] ret = (Object[]) call("ticket.listAttachments", id);
assertEquals(1, ret.length);
- assertHasValue(ret, filename);
call("ticket.deleteAttachment", id, filename);
@@ -398,6 +411,24 @@ public class TracXmlRpcTest extends TestCase {
assertEquals(0, ret.length);
}
+ public void testDuplicateAttachment() throws XmlRpcException, IOException {
+ int id1 = createTicket("summary", "description", new Hashtable());
+ int id2 = createTicket("summary", "description", new Hashtable());
+
+ String filename1 = (String) call("ticket.putAttachment", id1, "attach.txt", "description", "data".getBytes(), true);
+ String filename2 = (String) call("ticket.putAttachment", id2, "attach.txt", "description", "data2".getBytes(), true);
+ assertEquals("attach.txt", filename1);
+ assertEquals(filename1, filename2);
+
+ byte[] bytes = (byte[]) call("ticket.getAttachment", id1, "attach.txt");
+ String data = new String(bytes);
+ assertEquals("data", data);
+
+ bytes = (byte[]) call("ticket.getAttachment", id2, "attach.txt");
+ data = new String(bytes);
+ assertEquals("data2", data);
+ }
+
public void testQuery() throws XmlRpcException, IOException {
Object[] ret = (Object[]) call("ticket.query", "summary~=foo|bar|baz");
for (Object id : ret) {

Back to the top