Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2007-03-13 22:24:54 -0400
committerspingel2007-03-13 22:24:54 -0400
commit531fadc2d58a9404effa6d2a1083de6ec5058174 (patch)
tree905e10fa92408b82b90e18c871c3c4effae124f2 /org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/internal
parent045d25327f84fe213a65b7ab15d86ff5b8aea155 (diff)
downloadorg.eclipse.mylyn.tasks-531fadc2d58a9404effa6d2a1083de6ec5058174.tar.gz
org.eclipse.mylyn.tasks-531fadc2d58a9404effa6d2a1083de6ec5058174.tar.xz
org.eclipse.mylyn.tasks-531fadc2d58a9404effa6d2a1083de6ec5058174.zip
NEW - bug 176566: Hyperlinking support for Trac
https://bugs.eclipse.org/bugs/show_bug.cgi?id=176566
Diffstat (limited to 'org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/internal')
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/internal/trac/ui/TracHyperlinkDetectorTest.java53
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/internal/trac/ui/TracHyperlinkUtilTest.java163
2 files changed, 163 insertions, 53 deletions
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/internal/trac/ui/TracHyperlinkDetectorTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/internal/trac/ui/TracHyperlinkDetectorTest.java
deleted file mode 100644
index d255f96ae..000000000
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/internal/trac/ui/TracHyperlinkDetectorTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package org.eclipse.mylar.internal.trac.ui;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.text.hyperlink.IHyperlink;
-import org.eclipse.mylar.internal.trac.core.TracCorePlugin;
-import org.eclipse.mylar.tasks.core.TaskRepository;
-import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
-import org.eclipse.mylar.tasks.ui.WebHyperlink;
-
-public class TracHyperlinkDetectorTest extends TestCase {
-
- // private TaskHyperlinkDetector detector;
- private TaskRepository repository;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- repository = new TaskRepository(TracCorePlugin.REPOSITORY_KIND, "http://localhost");
- // detector = new TaskHyperlinkDetector();
- }
-
- public void testFindHyperlinks1() {
- IHyperlink[] links = TasksUiPlugin.getRepositoryUi(TracCorePlugin.REPOSITORY_KIND).findHyperlinks(repository,
- "#11", 0, 0);
- // IHyperlink[] links = detector.findHyperlinks(repository, "#11", 0,
- // 0);
- assertNotNull(links);
- assertEquals(1, links.length);
- assertTrue(links[0].getHyperlinkText().endsWith(" 11"));
- }
-
- // public void testFindHyperlinks2() {
- // IHyperlink[] links = detector.findHyperlinks(repository, "#11, #1", 0,
- // 0);
- // assertNotNull(links);
- // assertEquals(2, links.length);
- // assertTrue(links[0].getHyperlinkText().endsWith(" 11"));
- // assertTrue(links[0].getHyperlinkText().endsWith(" 1"));
- // }
-
- public void testFindWikiHyperlinks1() {
- IHyperlink[] links = TasksUiPlugin.getRepositoryUi(TracCorePlugin.REPOSITORY_KIND).findHyperlinks(repository,
- "[wiki:page]", 0, 0);
- // IHyperlink[] links = detector.findHyperlinks(repository,
- // "[wiki:page]", 0, 0);
- assertNotNull(links);
- assertEquals(1, links.length);
- assertEquals("http://localhost/wiki/page", ((WebHyperlink) links[0]).getURLString());
- }
-
-}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/internal/trac/ui/TracHyperlinkUtilTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/internal/trac/ui/TracHyperlinkUtilTest.java
new file mode 100644
index 000000000..dbc6ca874
--- /dev/null
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/internal/trac/ui/TracHyperlinkUtilTest.java
@@ -0,0 +1,163 @@
+package org.eclipse.mylar.internal.trac.ui;
+
+
+
+import junit.framework.TestCase;
+
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.hyperlink.IHyperlink;
+import org.eclipse.mylar.internal.trac.core.TracCorePlugin;
+import org.eclipse.mylar.tasks.core.TaskRepository;
+import org.eclipse.mylar.tasks.ui.TaskHyperlink;
+import org.eclipse.mylar.tasks.ui.WebHyperlink;
+
+public class TracHyperlinkUtilTest extends TestCase {
+
+ private TaskRepository repository;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ repository = new TaskRepository(TracCorePlugin.REPOSITORY_KIND, "http://localhost");
+ }
+
+ public void testFindHyperlinksTicket() {
+ IHyperlink[] links = TracHyperlinkUtil.findHyperlinks(repository, "#11", 0, 0);
+ assertNotNull(links);
+ assertEquals(1, links.length);
+ assertEquals(new Region(0, 3), links[0].getHyperlinkRegion());
+ assertEquals("11", ((TaskHyperlink)links[0]).getTaskId());
+
+ links = TracHyperlinkUtil.findHyperlinks(repository, "#11, #234", 6, 0);
+ assertNotNull(links);
+ assertEquals(1, links.length);
+ assertEquals("234", ((TaskHyperlink)links[0]).getTaskId());
+
+ links = TracHyperlinkUtil.findHyperlinks(repository, " ticket:123 ", 2, 0);
+ assertNotNull(links);
+ assertEquals(1, links.length);
+ assertEquals(new Region(2, 10), links[0].getHyperlinkRegion());
+ assertEquals("123", ((TaskHyperlink)links[0]).getTaskId());
+ }
+
+ public void testFindHyperlinksReport() {
+ IHyperlink[] links = TracHyperlinkUtil.findHyperlinks(repository, "report:123", 0, 0);
+ assertEquals(1, links.length);
+ assertEquals(new Region(0, 10), links[0].getHyperlinkRegion());
+ assertEquals("http://localhost/report/123", ((WebHyperlink) links[0]).getURLString());
+
+ links = TracHyperlinkUtil.findHyperlinks(repository, "{123}", 0, 0);
+ assertEquals(1, links.length);
+ assertEquals(new Region(0, 5), links[0].getHyperlinkRegion());
+ assertEquals("http://localhost/report/123", ((WebHyperlink) links[0]).getURLString());
+ }
+
+ public void testFindHyperlinksChangeset() {
+ IHyperlink[] links = TracHyperlinkUtil.findHyperlinks(repository, "r123", 0, 0);
+ assertEquals(1, links.length);
+ assertEquals(new Region(0, 4), links[0].getHyperlinkRegion());
+ assertEquals("http://localhost/changeset/123", ((WebHyperlink) links[0]).getURLString());
+
+ links = TracHyperlinkUtil.findHyperlinks(repository, "[123]", 0, 0);
+ assertEquals(1, links.length);
+ assertEquals(new Region(0, 5), links[0].getHyperlinkRegion());
+ assertEquals("http://localhost/changeset/123", ((WebHyperlink) links[0]).getURLString());
+
+ links = TracHyperlinkUtil.findHyperlinks(repository, "changeset:123", 0, 0);
+ assertEquals(1, links.length);
+ assertEquals(new Region(0, 13), links[0].getHyperlinkRegion());
+ assertEquals("http://localhost/changeset/123", ((WebHyperlink) links[0]).getURLString());
+
+ links = TracHyperlinkUtil.findHyperlinks(repository, "[123/trunk]", 0, 0);
+ assertEquals(1, links.length);
+ assertEquals(new Region(0, 11), links[0].getHyperlinkRegion());
+ assertEquals("http://localhost/changeset/123/trunk", ((WebHyperlink) links[0]).getURLString());
+
+ links = TracHyperlinkUtil.findHyperlinks(repository, "changeset:123/trunk", 0, 0);
+ assertEquals(1, links.length);
+ assertEquals(new Region(0, 19), links[0].getHyperlinkRegion());
+ assertEquals("http://localhost/changeset/123/trunk", ((WebHyperlink) links[0]).getURLString());
+ }
+
+ public void testFindHyperlinksRevisionLog() {
+ IHyperlink[] links = TracHyperlinkUtil.findHyperlinks(repository, "r123:456", 0, 0);
+ assertEquals(2, links.length);
+ assertEquals(new Region(0, 8), links[1].getHyperlinkRegion());
+ assertEquals("http://localhost/log/?rev=123&stop_rev=456", ((WebHyperlink) links[1]).getURLString());
+
+ links = TracHyperlinkUtil.findHyperlinks(repository, "[123:456]", 0, 0);
+ assertEquals(1, links.length);
+ assertEquals(new Region(0, 9), links[0].getHyperlinkRegion());
+ assertEquals("http://localhost/log/?rev=123&stop_rev=456", ((WebHyperlink) links[0]).getURLString());
+
+ links = TracHyperlinkUtil.findHyperlinks(repository, "log:@123:456", 0, 0);
+ assertEquals(1, links.length);
+ assertEquals(new Region(0, 12), links[0].getHyperlinkRegion());
+ assertEquals("http://localhost/log/?rev=123&stop_rev=456", ((WebHyperlink) links[0]).getURLString());
+
+ links = TracHyperlinkUtil.findHyperlinks(repository, "log:trunk@123:456", 0, 0);
+ assertEquals(1, links.length);
+ assertEquals(new Region(0, 17), links[0].getHyperlinkRegion());
+ assertEquals("http://localhost/log/trunk?rev=123&stop_rev=456", ((WebHyperlink) links[0]).getURLString());
+ }
+
+ public void testFindHyperlinksWiki() {
+ IHyperlink[] links = TracHyperlinkUtil.findHyperlinks(repository, "[wiki:page]", 1, 0);
+ assertNotNull(links);
+ assertEquals(1, links.length);
+ assertEquals("http://localhost/wiki/page", ((WebHyperlink) links[0]).getURLString());
+
+ links = TracHyperlinkUtil.findHyperlinks(repository, "wiki:page", 0, 0);
+ assertNotNull(links);
+ assertEquals(1, links.length);
+ assertEquals("http://localhost/wiki/page", ((WebHyperlink) links[0]).getURLString());
+
+ links = TracHyperlinkUtil.findHyperlinks(repository, "Page", 0, 0);
+ assertNull(links);
+
+ links = TracHyperlinkUtil.findHyperlinks(repository, "ab Page dc", 0, 0);
+ assertNull(links);
+
+ links = TracHyperlinkUtil.findHyperlinks(repository, "paGe", 0, 0);
+ assertNull(links);
+
+ links = TracHyperlinkUtil.findHyperlinks(repository, "WikiPage", 0, 0);
+ assertNotNull(links);
+ assertEquals(1, links.length);
+ assertEquals("http://localhost/wiki/WikiPage", ((WebHyperlink) links[0]).getURLString());
+ assertEquals(new Region(0, 8), links[0].getHyperlinkRegion());
+
+ }
+
+ public void testFindHyperlinksMilestone() {
+ IHyperlink[] links = TracHyperlinkUtil.findHyperlinks(repository, "milestone:1.0", 1, 0);
+ assertNotNull(links);
+ assertEquals(1, links.length);
+ assertEquals("http://localhost/milestone/1.0", ((WebHyperlink) links[0]).getURLString());
+ }
+
+ public void testFindHyperlinksAttachment() {
+ IHyperlink[] links = TracHyperlinkUtil.findHyperlinks(repository, "attachment:ticket:123:foo.bar", 1, 0);
+ assertNotNull(links);
+ assertEquals("123", ((TaskHyperlink)links[0]).getTaskId());
+ }
+
+ public void testFindHyperlinksFiles() {
+ IHyperlink[] links = TracHyperlinkUtil.findHyperlinks(repository, "source:trunk/foo", 1, 0);
+ assertNotNull(links);
+ assertEquals(1, links.length);
+ assertEquals("http://localhost/browser/trunk/foo", ((WebHyperlink) links[0]).getURLString());
+
+ links = TracHyperlinkUtil.findHyperlinks(repository, "source:trunk/foo@123", 1, 0);
+ assertNotNull(links);
+ assertEquals(1, links.length);
+ assertEquals("http://localhost/browser/trunk/foo?rev=123", ((WebHyperlink) links[0]).getURLString());
+
+ links = TracHyperlinkUtil.findHyperlinks(repository, "source:trunk/foo@123#L456", 1, 0);
+ assertNotNull(links);
+ assertEquals(1, links.length);
+ assertEquals("http://localhost/browser/trunk/foo?rev=123#L456", ((WebHyperlink) links[0]).getURLString());
+ }
+
+}

Back to the top