diff options
author | spingel | 2010-03-31 18:46:46 +0000 |
---|---|---|
committer | spingel | 2010-03-31 18:46:46 +0000 |
commit | b87b4ebbfa8073a207f4bb74ab3cdfc1c3c40432 (patch) | |
tree | 4b121b9c46aeb830db7b0acc83c1ee577b23a9a2 /org.eclipse.mylyn.discovery.tests | |
parent | 8913ed18b0def4ccc91836675f31ffb3b9adb3d9 (diff) | |
download | org.eclipse.mylyn.commons-b87b4ebbfa8073a207f4bb74ab3cdfc1c3c40432.tar.gz org.eclipse.mylyn.commons-b87b4ebbfa8073a207f4bb74ab3cdfc1c3c40432.tar.xz org.eclipse.mylyn.commons-b87b4ebbfa8073a207f4bb74ab3cdfc1c3c40432.zip |
RESOLVED - bug 307452: [discovery] directories should support relative path names
https://bugs.eclipse.org/bugs/show_bug.cgi?id=307452
Diffstat (limited to 'org.eclipse.mylyn.discovery.tests')
-rw-r--r-- | org.eclipse.mylyn.discovery.tests/src/org/eclipse/mylyn/discovery/tests/core/DirectoryParserTest.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.discovery.tests/src/org/eclipse/mylyn/discovery/tests/core/DirectoryParserTest.java b/org.eclipse.mylyn.discovery.tests/src/org/eclipse/mylyn/discovery/tests/core/DirectoryParserTest.java index 84ad539e..c9edc0e5 100644 --- a/org.eclipse.mylyn.discovery.tests/src/org/eclipse/mylyn/discovery/tests/core/DirectoryParserTest.java +++ b/org.eclipse.mylyn.discovery.tests/src/org/eclipse/mylyn/discovery/tests/core/DirectoryParserTest.java @@ -13,6 +13,8 @@ package org.eclipse.mylyn.discovery.tests.core; import java.io.IOException; import java.io.StringReader; +import java.net.URI; +import java.net.URISyntaxException; import junit.framework.TestCase; @@ -115,4 +117,34 @@ public class DirectoryParserTest extends TestCase { assertEquals(1, directory.getEntries().size()); assertEquals(false, directory.getEntries().get(0).isPermitCategories()); } + + public void testParseBaseRelativeUrl() throws IOException, URISyntaxException { + parser.setBaseUri(new URI("http://base.uri/location/directory.xml")); + Directory directory = parser.parse(new StringReader( + "<directory xmlns=\"http://www.eclipse.org/mylyn/discovery/directory/\"><entry url=\"parent/baz.jar\"/><entry url=\"http://absolute/bar.jar\"/></directory>")); + assertNotNull(directory); + assertEquals(2, directory.getEntries().size()); + assertEquals("http://base.uri/location/parent/baz.jar", directory.getEntries().get(0).getLocation()); + assertEquals("http://absolute/bar.jar", directory.getEntries().get(1).getLocation()); + } + + public void testParseRootUrl() throws IOException, URISyntaxException { + parser.setBaseUri(new URI("http://base.uri/location/directory.xml")); + Directory directory = parser.parse(new StringReader( + "<directory xmlns=\"http://www.eclipse.org/mylyn/discovery/directory/\"><entry url=\"/baz.jar\"/></directory>")); + assertNotNull(directory); + assertEquals(1, directory.getEntries().size()); + assertEquals("http://base.uri/baz.jar", directory.getEntries().get(0).getLocation()); + } + + public void testParseBaseInvalidRelativeUrl() throws IOException, URISyntaxException { + parser.setBaseUri(new URI("http://base.uri/location/directory.xml")); + Directory directory = parser.parse(new StringReader( + "<directory xmlns=\"http://www.eclipse.org/mylyn/discovery/directory/\"><entry url=\":/baz.jar\"/><entry url=\"http://absolute/bar.jar\"/></directory>")); + assertNotNull(directory); + assertEquals(2, directory.getEntries().size()); + assertEquals(":/baz.jar", directory.getEntries().get(0).getLocation()); + assertEquals("http://absolute/bar.jar", directory.getEntries().get(1).getLocation()); + } + } |