Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDJ Houghton2008-11-14 21:38:29 +0000
committerDJ Houghton2008-11-14 21:38:29 +0000
commiteadc09b9944e2d8ec06e3515d8f94151abc42de4 (patch)
treeb56d902327f360a60d4ae1ab7ed0665cd92440d3 /bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core
parente429e9ce3f880556c43cdf21c4949f46e9a778b5 (diff)
downloadrt.equinox.p2-eadc09b9944e2d8ec06e3515d8f94151abc42de4.tar.gz
rt.equinox.p2-eadc09b9944e2d8ec06e3515d8f94151abc42de4.tar.xz
rt.equinox.p2-eadc09b9944e2d8ec06e3515d8f94151abc42de4.zip
Bug 255407 - Need to create helper methods for URI relativization/absolution
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core')
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/URIUtilTest.java61
1 files changed, 61 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/URIUtilTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/URIUtilTest.java
index f7fa3d27f..322d40e3b 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/URIUtilTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/URIUtilTest.java
@@ -170,4 +170,65 @@ public class URIUtilTest extends AbstractProvisioningTest {
assertEquals(correctURI, URIUtil.removeFileExtension(testFileWithExtension.toURI()));
assertEquals(correctURI, URIUtil.removeFileExtension(testFileWithOutExtension.toURI()));
}
+
+ public void testMakeAbsolute() throws URISyntaxException {
+ URI[][] data = new URI[][] {
+ // simple path
+ /*
+ new URI[] {new URI("b"), new URI("file:/c:/a/"), new URI("file:/c:/a/b")}, //
+ new URI[] {new URI("b"), new URI("file:/c:/a"), new URI("file:/c:/a/b")},
+ // common root
+ new URI[] {new URI("plugins/foo.jar"), new URI("file:/c:/eclipse/"), new URI("file:/c:/eclipse/plugins/foo.jar")},
+ // different drives
+ new URI[] {new URI("file:/c:/a/b"), new URI("file:/d:/a/x"), new URI("file:/c:/a/b")}, //
+ new URI[] {new URI("file:/c:/eclipse/plugins/foo.jar"), new URI("file:/d:/eclipse/"), new URI("file:/c:/eclipse/plugins/foo.jar")},
+ // non-local
+ new URI[] {new URI("http:/c:/a/b"), new URI("file:/c:/a/x"), new URI("http:/c:/a/b")}, //
+ new URI[] {new URI("file:/c:/a/b"), new URI("http:/c:/a/x"), new URI("file:/c:/a/b")}, //
+ //
+ new URI[] {new URI("b"), new URI("file:/C:/a/"), new URI("file:/C:/a/b")}, //
+ new URI[] {new URI("b"), new URI("file:/C:/a"), new URI("file:/C:/a/b")}, //
+ new URI[] {new URI("file:/c:/"), new URI("file:/d:/"), new URI("file:/c:/")}, //
+ new URI[] {new URI(""), new URI("file:/c:/"), new URI("file:/c:/")}, //
+ //
+ new URI[] {new URI("../plugins/foo.jar"), new URI("file:/c:/eclipse/configuration"), new URI("file:/c:/eclipse/plugins/foo.jar")}, //
+ */
+ new URI[] {new URI("file:../plugins/foo.jar"), new URI("file:/c:/eclipse/configuration"), new URI("file:/c:/eclipse/plugins/foo.jar")}, //
+ };
+
+ for (int i = 0; i < data.length; i++) {
+ URI location = data[i][0];
+ URI root = data[i][1];
+ URI expected = data[i][2];
+ URI actual = URIUtil.makeAbsolute(location, root);
+ assertEquals(Integer.toString(i), expected, actual);
+ }
+ }
+
+ public void testMakeRelative() throws URISyntaxException {
+ URI[][] data = new URI[][] {
+ // simple path
+ new URI[] {new URI("file:/c:/a/b"), new URI("file:/c:/a/x"), new URI("b")},
+ // common root
+ new URI[] {new URI("file:/c:/eclipse/plugins/foo.jar"), new URI("file:/c:/eclipse/"), new URI("plugins/foo.jar")},
+ // different drives
+ new URI[] {new URI("file:/c:/a/b"), new URI("file:/d:/a/x"), new URI("file:/c:/a/b")}, //
+ new URI[] {new URI("file:/c:/eclipse/plugins/foo.jar"), new URI("file:/d:/eclipse/"), new URI("file:/c:/eclipse/plugins/foo.jar")},
+ // non-local
+ new URI[] {new URI("http:/c:/a/b"), new URI("file:/c:/a/x"), new URI("http:/c:/a/b")}, //
+ new URI[] {new URI("file:/c:/a/b"), new URI("http:/c:/a/x"), new URI("file:/c:/a/b")}, //
+ //
+ new URI[] {new URI("file:/c:/a/b"), new URI("file:/C:/a/x"), new URI("b")}, //
+ new URI[] {new URI("file:/c:/"), new URI("file:/d:/"), new URI("file:/c:/")}, //
+ new URI[] {new URI("file:/c:/"), new URI("file:/c:/"), new URI("")}, //
+ };
+
+ for (int i = 0; i < data.length; i++) {
+ URI location = data[i][0];
+ URI root = data[i][1];
+ URI expected = data[i][2];
+ URI actual = URIUtil.makeRelative(location, root);
+ assertEquals(Integer.toString(i), expected, actual);
+ }
+ }
}

Back to the top