Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten2006-06-16 12:37:19 -0400
committermkersten2006-06-16 12:37:19 -0400
commitca958a4987445d6437ef5bb309efe538cf7a1856 (patch)
tree6bc5b531541cbfc7a608a77d933ac9e068b63ab8
parentc6828f51bb8a67ff3087d11f99641db0f82f24b5 (diff)
downloadorg.eclipse.mylyn.tasks-ca958a4987445d6437ef5bb309efe538cf7a1856.tar.gz
org.eclipse.mylyn.tasks-ca958a4987445d6437ef5bb309efe538cf7a1856.tar.xz
org.eclipse.mylyn.tasks-ca958a4987445d6437ef5bb309efe538cf7a1856.zip
Progress on: 145794: make test case for retrieving Trac report
https://bugs.eclipse.org/bugs/show_bug.cgi?id=145794
-rw-r--r--org.eclipse.mylyn.trac.tests/.settings/org.eclipse.jdt.ui.prefs4
-rw-r--r--org.eclipse.mylyn.trac.tests/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.mylyn.trac.tests/src/empty.txt0
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/Constants.java28
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracXmlRpcTest.java405
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TrustAll.java36
6 files changed, 473 insertions, 3 deletions
diff --git a/org.eclipse.mylyn.trac.tests/.settings/org.eclipse.jdt.ui.prefs b/org.eclipse.mylyn.trac.tests/.settings/org.eclipse.jdt.ui.prefs
index b91473576..86dbfc675 100644
--- a/org.eclipse.mylyn.trac.tests/.settings/org.eclipse.jdt.ui.prefs
+++ b/org.eclipse.mylyn.trac.tests/.settings/org.eclipse.jdt.ui.prefs
@@ -1,5 +1,5 @@
-#Fri Feb 10 11:16:20 PST 2006
+#Fri Jun 16 09:36:17 PDT 2006
eclipse.preferences.version=1
formatter_profile=_Mylar based on Eclipse [built-in]
formatter_settings_version=9
-org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\r\n * @return the ${bare_field_name}\r\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\r\n * @param ${param} the ${bare_field_name} to set\r\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/**\r\n * \r\n */</template><template autoinsert\="true" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\r\n * @author ${user}\r\n *\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\r\n * \r\n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\r\n * ${see_to_overridden}\r\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\r\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\r\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\r\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\r\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\r\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\r\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\r\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\r\n * @return the ${bare_field_name}\r\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\r\n * @param ${param} the ${bare_field_name} to set\r\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/**\r\n * \r\n */</template><template autoinsert\="true" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\r\n * @author ${user}\r\n *\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\r\n * \r\n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\r\n * ${see_to_overridden}\r\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\r\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\r\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\r\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\r\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\r\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\r\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\r\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\r\n * ${tags}\r\n * ${see_to_target}\r\n */</template></templates>
diff --git a/org.eclipse.mylyn.trac.tests/META-INF/MANIFEST.MF b/org.eclipse.mylyn.trac.tests/META-INF/MANIFEST.MF
index 6acd17324..fa97ad28f 100644
--- a/org.eclipse.mylyn.trac.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.trac.tests/META-INF/MANIFEST.MF
@@ -4,5 +4,6 @@ Bundle-Name: Mylar Trac Tests Plug-in
Bundle-SymbolicName: org.eclipse.mylar.trac.tests
Bundle-Version: 0.0.0
Bundle-Localization: plugin
-Require-Bundle: org.junit
+Require-Bundle: org.junit,
+ org.apache.xmlrpc
Export-Package: org.eclipse.mylar.trac.tests
diff --git a/org.eclipse.mylyn.trac.tests/src/empty.txt b/org.eclipse.mylyn.trac.tests/src/empty.txt
deleted file mode 100644
index e69de29bb..000000000
--- a/org.eclipse.mylyn.trac.tests/src/empty.txt
+++ /dev/null
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/Constants.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/Constants.java
new file mode 100644
index 000000000..395ccf0a4
--- /dev/null
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/Constants.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2006 - 2006 Mylar eclipse.org project 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:
+ * Mylar project committers - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylar.trac.tests;
+
+public class Constants {
+
+ public static final String TEST_REPOSITORY1_URL = "http://trac.steffenpingel.de/mylar-test";
+
+ public static final String TEST_REPOSITORY1_SSL_URL = "https://trac.steffenpingel.de/mylar-test";
+
+ public static final String TEST_REPOSITORY1_ADMIN_USERNAME = "trac-ticket-admin";
+
+ public static final String TEST_REPOSITORY1_ADMIN_PASSWORD = "trac-ticket-admin";
+
+ public static final String TEST_REPOSITORY1_USERNAME = "trac-test";
+
+ public static final String TEST_REPOSITORY1_PASSWORD = "trac-test";
+
+}
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
new file mode 100644
index 000000000..0fb473390
--- /dev/null
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracXmlRpcTest.java
@@ -0,0 +1,405 @@
+/*******************************************************************************
+ * Copyright (c) 2006 - 2006 Mylar eclipse.org project 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:
+ * Mylar project committers - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylar.trac.tests;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Date;
+import java.util.Hashtable;
+import java.util.Random;
+import java.util.Vector;
+
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLContext;
+
+import junit.framework.TestCase;
+
+import org.apache.xmlrpc.DefaultXmlRpcTransportFactory;
+import org.apache.xmlrpc.XmlRpc;
+import org.apache.xmlrpc.XmlRpcClient;
+import org.apache.xmlrpc.XmlRpcException;
+import org.eclipse.mylar.trac.tests.support.TrustAll;
+
+/**
+ * Test cases for Trac XML-RPC Plugin API. This class does not depend on any of
+ * the Mylar connector classes.
+ */
+public class TracXmlRpcTest extends TestCase {
+
+ public static final String XMLRPC_URL = "/login/xmlrpc";
+
+ private XmlRpcClient xmlrpc;
+
+ private String username;
+
+// private String password;
+
+ private Random random;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ random = new Random();
+
+ XmlRpc.setDefaultInputEncoding("UTF-8");
+
+ createConnection(new URL(Constants.TEST_REPOSITORY1_URL + XMLRPC_URL),
+ Constants.TEST_REPOSITORY1_ADMIN_USERNAME, Constants.TEST_REPOSITORY1_ADMIN_PASSWORD);
+ }
+
+ @SuppressWarnings("deprecation")
+ private void createConnection(URL url, String username, String password) throws Exception {
+ if (url.toString().startsWith("https")) {
+ DefaultXmlRpcTransportFactory transport = new DefaultXmlRpcTransportFactory(url);
+ transport.setBasicAuthentication(username, password);
+
+ SSLContext ctx = SSLContext.getInstance("TLS");
+
+ javax.net.ssl.TrustManager[] tm = new javax.net.ssl.TrustManager[] { new TrustAll() };
+ ctx.init(null, tm, null);
+ HttpsURLConnection.setDefaultSSLSocketFactory(ctx.getSocketFactory());
+
+ xmlrpc = new XmlRpcClient(url, transport);
+ } else {
+ xmlrpc = new XmlRpcClient(url);
+
+ // the XML-RPC library is kind of broken: setting authentication
+ // credentials for
+ // http connections is only possible through a deprecated method
+ xmlrpc.setBasicAuthentication(username, password);
+ }
+
+ this.username = username;
+// this.password = password;
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ private Object call(String method, Object... parameters) throws XmlRpcException, IOException {
+ Vector<Object> params = new Vector<Object>();
+ for (Object parameter : parameters) {
+ params.add(parameter);
+ }
+
+ Object result = xmlrpc.execute(method, params);
+ if (result instanceof XmlRpcException) {
+ throw (XmlRpcException) result;
+ }
+ return result;
+ }
+
+ public Hashtable<String, Object> createMultiCall(String methodName, Object... parameters) throws XmlRpcException,
+ IOException {
+ Hashtable<String, Object> table = new Hashtable<String, Object>();
+ table.put("methodName", methodName);
+ table.put("params", parameters);
+ return table;
+ }
+
+ private void internalTestCrud(String module) throws XmlRpcException, IOException {
+ try {
+ call(module + ".delete", "foo");
+ } catch (XmlRpcException e) {
+ }
+
+ call(module + ".create", "foo", "bar");
+
+ assertHasValue(((Vector) call(module + ".getAll")).toArray(), "foo");
+ assertEquals("bar", (String) (call(module + ".get", "foo")));
+
+ call(module + ".update", "foo", "baz");
+ assertEquals("baz", (String) (call(module + ".get", "foo")));
+
+ call(module + ".delete", "foo");
+ }
+
+ private Object createValue(Object fieldName, Object clazz) {
+ if (clazz == String.class) {
+ return fieldName.toString() + random.nextInt();
+ } else if (clazz == Date.class) {
+ return new Date();
+ } else if (clazz == Boolean.class) {
+ return random.nextBoolean();
+ } else if (clazz == Double.class) {
+ return random.nextDouble();
+ } else if (clazz == Integer.class) {
+ return random.nextInt();
+ }
+
+ throw new RuntimeException("Invalid test data: " + fieldName + ", " + clazz);
+ }
+
+ private void internalTestComponent(String module, Object... fields) throws XmlRpcException, IOException {
+ try {
+ call(module + ".delete", "foo");
+ } catch (XmlRpcException e) {
+ }
+
+ Hashtable<String, Object> attributes = new Hashtable<String, Object>();
+ for (int i = 0; i < fields.length; i += 2) {
+ attributes.put((String) fields[i], createValue(fields[i], fields[i + 1]));
+ }
+
+ call(module + ".create", "foo", attributes);
+
+ assertHasValue(((Vector) call(module + ".getAll")).toArray(), "foo");
+ Hashtable values = (Hashtable) call(module + ".get", "foo");
+ for (String attribute : attributes.keySet()) {
+ assertEquals(attributes.get(attribute), values.get(attribute));
+ }
+
+ for (int i = 0; i < fields.length; i += 2) {
+ attributes.put((String) fields[i], createValue(fields[i], fields[i + 1]));
+ }
+
+ call(module + ".update", "foo", attributes);
+ values = (Hashtable) call(module + ".get", "foo");
+ for (String attribute : attributes.keySet()) {
+ assertEquals(attributes.get(attribute), values.get(attribute));
+ }
+
+ call(module + ".delete", "foo");
+ }
+
+ public void testMilestoneDate() throws XmlRpcException, IOException {
+ try {
+ call("ticket.milestone.delete", "foo");
+ } catch (XmlRpcException e) {
+ }
+
+ int due = (int) (System.currentTimeMillis() / 1000) + 1000;
+ int completed = (int) (System.currentTimeMillis() / 1000);
+
+ Hashtable<String, Object> attributes = new Hashtable<String, Object>();
+ attributes.put("description", "description");
+ attributes.put("due", due);
+ attributes.put("completed", completed);
+
+ call("ticket.milestone.create", "foo", attributes);
+
+ Hashtable values = (Hashtable) call("ticket.milestone.get", "foo");
+ assertEquals(new Integer(due), (Integer) values.get("due"));
+ assertEquals(new Integer(completed), (Integer) values.get("completed"));
+
+ call("ticket.milestone.delete", "foo");
+ }
+
+ private void assertHasValue(Object[] items, Object value) {
+ for (Object item : items) {
+ if (item.equals(value)) {
+ return;
+ }
+ }
+ fail("Could not find expected value: " + value);
+ }
+
+ public void testGetTicket() throws XmlRpcException, IOException {
+ Hashtable<String, Object> attributes = new Hashtable<String, Object>();
+ attributes.put("type", "task");
+ attributes.put("status", "closed");
+ int id = (Integer) call("ticket.create", "summary", "description", attributes);
+
+ attributes.put("summary", "summary");
+ attributes.put("description", "description");
+
+ Vector ticket = (Vector) call("ticket.get", id);
+ assertEquals(id, ticket.get(0));
+ assertTrue(ticket.get(1) instanceof Integer); // time created
+ assertEquals(ticket.get(1), ticket.get(2)); // time changed
+ Hashtable values = (Hashtable) ticket.get(3);
+ for (String attribute : attributes.keySet()) {
+ assertEquals(attributes.get(attribute), values.get(attribute));
+ }
+
+ call("ticket.delete", id);
+ }
+
+ public void testGetTicketUmlaute() throws XmlRpcException, IOException {
+ Hashtable<String, Object> attributes = new Hashtable<String, Object>();
+ int id = (Integer) call("ticket.create", "summaryńÍ▄", "▀▀▀", attributes);
+
+ attributes.put("summary", "summaryńÍ▄");
+ attributes.put("description", "▀▀▀");
+
+ Vector ticket = (Vector) call("ticket.get", id);
+ assertEquals(id, ticket.get(0));
+ assertTrue(ticket.get(1) instanceof Integer); // time created
+ assertEquals(ticket.get(1), ticket.get(2)); // time changed
+ Hashtable values = (Hashtable) ticket.get(3);
+ for (String attribute : attributes.keySet()) {
+ assertEquals(attributes.get(attribute), values.get(attribute));
+ }
+
+ call("ticket.delete", id);
+ }
+
+ public void testUpdateTicket() throws XmlRpcException, IOException {
+ int id = (Integer) call("ticket.create", "summary", "description", new Hashtable());
+
+ Hashtable<String, Object> attributes = new Hashtable<String, Object>();
+ attributes.put("summary", "changed");
+ call("ticket.update", id, "my comment", attributes);
+
+ attributes.put("description", "description");
+
+ Vector ticket = (Vector) call("ticket.get", id);
+ Hashtable values = (Hashtable) ticket.get(3);
+ for (String attribute : attributes.keySet()) {
+ assertEquals(attributes.get(attribute), values.get(attribute));
+ }
+
+ call("ticket.delete", id);
+ }
+
+ public void testGetChangeLog() throws XmlRpcException, IOException {
+ int id = (Integer) call("ticket.create", "summary", "description", new Hashtable());
+
+ Hashtable<String, Object> attributes = new Hashtable<String, Object>();
+ attributes.put("summary", "changed");
+ call("ticket.update", id, "my comment", attributes);
+
+ Vector log = (Vector) call("ticket.changeLog", id, 0);
+ Vector entry = (Vector) log.get(0);
+ assertTrue(entry.get(0) instanceof Integer); // time
+ assertEquals(username, entry.get(1)); // author
+ assertEquals("summary", entry.get(2)); // field
+ assertEquals("summary", entry.get(3)); // old value
+ assertEquals("changed", entry.get(4)); // new value
+
+ call("ticket.delete", id);
+ }
+
+ public void testMultiGetTicket() throws XmlRpcException, IOException {
+ Object[] calls = new Object[] { createMultiCall("ticket.get", 1), createMultiCall("ticket.get", 2), };
+
+ Vector ret = (Vector) call("system.multicall", new Object[] { calls });
+
+ Vector ticket = (Vector) ret.get(0);
+ assertEquals(1, ticket.get(0));
+
+ ticket = (Vector) ret.get(1);
+ assertEquals(2, ticket.get(0));
+ }
+
+ public void testAttachment() throws XmlRpcException, IOException {
+ int id = (Integer) call("ticket.create", "summary", "description", new Hashtable());
+
+ String filename = (String) call("ticket.putAttachment", id, "attach.txt", "data".getBytes(), true);
+ // the returned filename may differ, since another ticket may have an
+ // attachment named "attach.txt"
+ // assertEquals("attach.txt", filename);
+
+ Vector ret = (Vector) call("ticket.listAttachments", id);
+ assertEquals(1, ret.size());
+ assertHasValue(ret.toArray(), filename);
+
+ 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);
+ assertEquals(filename, filename2);
+ ret = (Vector) call("ticket.listAttachments", id);
+ assertEquals(1, ret.size());
+ assertHasValue(ret.toArray(), filename);
+
+ String filename3 = (String) call("ticket.putAttachment", id, "attach.txt", "data".getBytes(), false);
+ assertFalse("attach.txt".equals(filename3));
+ ret = (Vector) call("ticket.listAttachments", id);
+ assertEquals(2, ret.size());
+ assertHasValue(ret.toArray(), filename);
+ assertHasValue(ret.toArray(), filename3);
+
+ call("ticket.delete", id);
+ }
+
+ public void testDeleteAttachment() throws XmlRpcException, IOException {
+ int id = (Integer) call("ticket.create", "summary", "description", new Hashtable());
+
+ String filename = (String) call("ticket.putAttachment", id, "attach.txt", "data".getBytes(), true);
+
+ Vector ret = (Vector) call("ticket.listAttachments", id);
+ assertEquals(1, ret.size());
+ assertHasValue(ret.toArray(), filename);
+
+ call("ticket.deleteAttachment", id, filename);
+
+ ret = (Vector) call("ticket.listAttachments", id);
+ assertEquals(0, ret.size());
+
+ call("ticket.delete", id);
+ }
+
+ public void testQuery() throws XmlRpcException, IOException {
+ Vector ret = (Vector) call("ticket.query", "summary=foobarsummary1|foobaz summary2");
+ for (Object id : ret) {
+ call("ticket.delete", (Integer) id);
+ }
+
+ int id1 = (Integer) call("ticket.create", "foobarsummary1", "description", new Hashtable());
+ int id2 = (Integer) call("ticket.create", "foobaz summary2", "description", new Hashtable());
+
+ ret = (Vector) call("ticket.query", "summary=foobarsummary1|foobaz summary2");
+ assertEquals(2, ret.size());
+ assertEquals(ret.get(0), id1);
+ assertEquals(ret.get(1), id2);
+
+ call("ticket.delete", id1);
+ call("ticket.delete", id2);
+ }
+
+ public void testQueryAll() throws XmlRpcException, IOException {
+ int id = (Integer) call("ticket.create", "foo", "description", new Hashtable());
+
+ Vector ret = (Vector) call("ticket.query", "order=id");
+ assertTrue(ret.size() > 0);
+ assertHasValue(ret.toArray(), id);
+
+ call("ticket.delete", id);
+ }
+
+ public void testPriorities() throws XmlRpcException, IOException {
+ internalTestCrud("ticket.priority");
+ }
+
+ public void testSeverities() throws XmlRpcException, IOException {
+ internalTestCrud("ticket.severity");
+ }
+
+ public void testType() throws XmlRpcException, IOException {
+ internalTestCrud("ticket.type");
+ }
+
+ public void testStatus() throws XmlRpcException, IOException {
+ internalTestCrud("ticket.status");
+ }
+
+ public void testResolutions() throws XmlRpcException, IOException {
+ internalTestCrud("ticket.resolution");
+ }
+
+ public void testVersions() throws XmlRpcException, IOException {
+ internalTestComponent("ticket.version", "time", Integer.class, "description", String.class);
+ }
+
+ public void testComponents() throws XmlRpcException, IOException {
+ internalTestComponent("ticket.component", "owner", String.class, "description", String.class);
+ }
+
+ public void testMilestones() throws XmlRpcException, IOException {
+ internalTestComponent("ticket.milestone", "due", Integer.class, "completed", Integer.class, "description",
+ String.class);
+ }
+
+}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TrustAll.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TrustAll.java
new file mode 100644
index 000000000..a9d792c7d
--- /dev/null
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/support/TrustAll.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2006 - 2006 Mylar eclipse.org project 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:
+ * Mylar project committers - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylar.trac.tests.support;
+
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+import javax.net.ssl.X509TrustManager;
+
+/**
+ * A trust store that accepts all certificates.
+ */
+public class TrustAll implements X509TrustManager {
+
+ public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {
+ // ignore
+ }
+
+ public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {
+ // ignore
+ }
+
+ public X509Certificate[] getAcceptedIssuers() {
+ return null;
+ }
+
+}

Back to the top