Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten2006-06-21 03:40:36 +0000
committermkersten2006-06-21 03:40:36 +0000
commit9f89ae63642d902b398c51592c2e4b677a9ccc2a (patch)
tree7899811224fddbcfa1e8625cc7f3f7cdaf265927 /org.eclipse.mylyn.trac.tests
parent7835063ee03b994b1b68aa552ec418ef25c64152 (diff)
downloadorg.eclipse.mylyn.tasks-9f89ae63642d902b398c51592c2e4b677a9ccc2a.tar.gz
org.eclipse.mylyn.tasks-9f89ae63642d902b398c51592c2e4b677a9ccc2a.tar.xz
org.eclipse.mylyn.tasks-9f89ae63642d902b398c51592c2e4b677a9ccc2a.zip
Progress on: 147816: Trac connector: implement core and model
https://bugs.eclipse.org/bugs/show_bug.cgi?id=147816
Diffstat (limited to 'org.eclipse.mylyn.trac.tests')
-rw-r--r--org.eclipse.mylyn.trac.tests/.classpath6
-rw-r--r--org.eclipse.mylyn.trac.tests/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AllTracTests.java3
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracSearchTest.java133
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracTicketTest.java73
5 files changed, 212 insertions, 6 deletions
diff --git a/org.eclipse.mylyn.trac.tests/.classpath b/org.eclipse.mylyn.trac.tests/.classpath
index 1c64a6d3f..751c8f2e5 100644
--- a/org.eclipse.mylyn.trac.tests/.classpath
+++ b/org.eclipse.mylyn.trac.tests/.classpath
@@ -1,11 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
- <accessrules>
- <accessrule kind="nonaccessible" pattern="com/sun/**"/>
- </accessrules>
- </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/org.eclipse.mylyn.trac.tests/META-INF/MANIFEST.MF b/org.eclipse.mylyn.trac.tests/META-INF/MANIFEST.MF
index fa97ad28f..a0170f9ad 100644
--- a/org.eclipse.mylyn.trac.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.trac.tests/META-INF/MANIFEST.MF
@@ -5,5 +5,6 @@ Bundle-SymbolicName: org.eclipse.mylar.trac.tests
Bundle-Version: 0.0.0
Bundle-Localization: plugin
Require-Bundle: org.junit,
- org.apache.xmlrpc
+ org.apache.xmlrpc,
+ org.eclipse.mylar.trac
Export-Package: org.eclipse.mylar.trac.tests
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 4e193f669..ddd9fbbda 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
@@ -16,6 +16,7 @@ import junit.framework.TestSuite;
/**
* @author Mik Kersten
+ * @author Steffen Pingel
*/
public class AllTracTests {
@@ -23,6 +24,8 @@ public class AllTracTests {
TestSuite suite = new TestSuite("Test for org.eclipse.mylar.trac.tests");
//$JUnit-BEGIN$
suite.addTestSuite(TracXmlRpcTest.class);
+ suite.addTestSuite(TracSearchTest.class);
+ suite.addTestSuite(TracTicketTest.class);
//$JUnit-END$
return suite;
}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracSearchTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracSearchTest.java
new file mode 100644
index 000000000..19562c955
--- /dev/null
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracSearchTest.java
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * 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 junit.framework.TestCase;
+
+import org.eclipse.mylar.internal.trac.model.TracSearch;
+
+/**
+ * @author Steffen Pingel
+ */
+public class TracSearchTest extends TestCase {
+
+ private static final String QUERY1 = "&status=new|assigned|reopened&milestone~=0.1";
+
+ private static final String URL1 = "&status=new&status=assigned&status=reopened&milestone=%7E0.1";
+
+ private TracSearch search1;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ search1 = new TracSearch();
+ search1.addFilter("status", "new");
+ search1.addFilter("status", "assigned");
+ search1.addFilter("status", "reopened");
+ search1.addFilter("milestone", "~0.1");
+ }
+
+ public void testToQuery() {
+ assertEquals(QUERY1, search1.toQuery());
+ }
+
+ public void testToQueryEmpty() {
+ assertEquals("", new TracSearch().toQuery());
+ }
+
+ public void testToQueryOperators1() {
+ TracSearch search = new TracSearch();
+ search.addFilter("is", "a");
+ search.addFilter("contains", "~b");
+ search.addFilter("starts", "^c");
+ search.addFilter("ends", "$d");
+ search.addFilter("nis", "!e");
+ search.addFilter("ncontains", "!~f");
+ search.addFilter("nstarts", "!^g");
+ search.addFilter("nends", "!$h");
+
+ assertEquals("&is=a&contains~=b&starts^=c&ends$=d&nis!=e&ncontains!~=f&nstarts!^=g&nends!$=h", search.toQuery());
+ }
+
+ public void testToQueryOperators2() {
+ TracSearch search = new TracSearch();
+ search.addFilter("nstarts", "!^g");
+ search.addFilter("nis", "!e");
+ search.addFilter("is", "a");
+
+ assertEquals("&nstarts!^=g&nis!=e&is=a", search.toQuery());
+ }
+
+ public void testToQuerySortOrder() {
+ search1.setOrderBy("id");
+ assertEquals("&order=id" + QUERY1, search1.toQuery());
+
+ search1.setAscending(false);
+ assertEquals("&order=id&desc=1" + QUERY1, search1.toQuery());
+
+ search1.setOrderBy("summary");
+ search1.setAscending(true);
+ assertEquals("&order=summary" + QUERY1, search1.toQuery());
+ }
+
+ public void testToUrl() {
+ assertEquals(URL1, search1.toUrl());
+ }
+
+ public void testToUrlEmpty() {
+ assertEquals("", new TracSearch().toUrl());
+ }
+
+ public void testToUrlEncoding() {
+ search1.addFilter("encoded", "&");
+ assertEquals(URL1 + "&encoded=%26", search1.toUrl());
+ }
+
+ public void testToUrlOperators1() {
+ TracSearch search = new TracSearch();
+ search.addFilter("is", "a");
+ search.addFilter("contains", "~b");
+ search.addFilter("starts", "^c");
+ search.addFilter("ends", "$d");
+ search.addFilter("nis", "!e");
+ search.addFilter("ncontains", "!~f");
+ search.addFilter("nstarts", "!^g");
+ search.addFilter("nends", "!$h");
+
+ assertEquals(
+ "&is=a&contains=%7Eb&starts=%5Ec&ends=%24d&nis=%21e&ncontains=%21%7Ef&nstarts=%21%5Eg&nends=%21%24h",
+ search.toUrl());
+ }
+
+ public void testToUrlOperators2() {
+ TracSearch search = new TracSearch();
+ search.addFilter("nstarts", "!^g");
+ search.addFilter("nis", "!e");
+ search.addFilter("is", "a");
+
+ assertEquals("&nstarts=%21%5Eg&nis=%21e&is=a", search.toUrl());
+ }
+
+ public void testToUrlSortOrder() {
+ search1.setOrderBy("id");
+ assertEquals("&order=id" + QUERY1, search1.toQuery());
+
+ search1.setAscending(false);
+ assertEquals("&order=id&desc=1" + QUERY1, search1.toQuery());
+
+ search1.setOrderBy("summary");
+ search1.setAscending(true);
+ assertEquals("&order=summary" + QUERY1, search1.toQuery());
+ }
+
+}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracTicketTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracTicketTest.java
new file mode 100644
index 000000000..395d81c6a
--- /dev/null
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracTicketTest.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * 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.util.Calendar;
+import java.util.Date;
+import java.util.TimeZone;
+
+import org.eclipse.mylar.internal.trac.core.InvalidTicketException;
+import org.eclipse.mylar.internal.trac.model.TracTicket;
+import org.eclipse.mylar.internal.trac.model.TracTicket.Key;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Steffen Pingel
+ */
+public class TracTicketTest extends TestCase {
+
+ public void testValid() {
+ TracTicket ticket = new TracTicket();
+ assertFalse(ticket.isValid());
+
+ ticket.setId(1);
+ assertTrue(ticket.isValid());
+ }
+
+ public void testPutTracValue() throws InvalidTicketException {
+ TracTicket ticket = new TracTicket(1);
+ ticket.putTracValue("summary", "a");
+ assertEquals("a", ticket.getValue(Key.SUMMARY));
+ assertEquals(null, ticket.getCustomValue("summary"));
+ assertEquals(null, ticket.getCustomValue("a"));
+
+ ticket.putTracValue("summary", "b");
+ ticket.putTracValue("custom", "c");
+ assertEquals("b", ticket.getValue(Key.SUMMARY));
+ assertEquals(null, ticket.getCustomValue("summary"));
+ assertEquals("c", ticket.getCustomValue("custom"));
+ }
+
+ public void testPutTracValueId() throws InvalidTicketException {
+ TracTicket ticket = new TracTicket();
+ try {
+ ticket.putTracValue("id", "1");
+ fail("Expected RuntimeException");
+ } catch (RuntimeException e) {
+ }
+ }
+
+ public void testSetCreated() throws InvalidTicketException {
+ TracTicket ticket = new TracTicket(1);
+ ticket.setCreated(0);
+ assertEquals(TimeZone.getTimeZone("GMT").getOffset(0) * 1000, ticket.getCreated().getTime());
+
+ Date date = new Date();
+ Calendar utc = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+ utc.setTime(date);
+ ticket.setCreated((int) (utc.getTimeInMillis() / 1000));
+
+ assertEquals(date.getTime() / 1000, ticket.getCreated().getTime() / 1000);
+ }
+
+}

Back to the top