Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Arthorne2009-08-11 21:07:07 +0000
committerJohn Arthorne2009-08-11 21:07:07 +0000
commit9759965a60222b5ef13bf271952185ab3d490394 (patch)
treedde7561a414815f1188cd20a3fd84ba702b9f7d4 /bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core
parent727c17b0788bdbecdc287d38a2529900644689d3 (diff)
downloadrt.equinox.p2-9759965a60222b5ef13bf271952185ab3d490394.tar.gz
rt.equinox.p2-9759965a60222b5ef13bf271952185ab3d490394.tar.xz
rt.equinox.p2-9759965a60222b5ef13bf271952185ab3d490394.zip
Bug 276391 URIUtil.toFile(URL) does not handle relative URLs correctly
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/URLUtilTest.java31
1 files changed, 30 insertions, 1 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/URLUtilTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/URLUtilTest.java
index a67cc18b2..34e8de114 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/URLUtilTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/URLUtilTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others.
+ * Copyright (c) 2008, 2009 IBM Corporation 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
@@ -41,6 +41,23 @@ public class URLUtilTest extends AbstractProvisioningTest {
}
/**
+ * Tests for {@link URLUtil#toFile(URL)}.
+ */
+ public void testToFileRelative() throws URISyntaxException {
+ for (int i = 0; i < testPaths.length; i++) {
+ File original = new File(testPaths[i]);
+ URI uri = new URI(null, testPaths[i], null);
+ try {
+ URL encoded = new URL("file:" + uri.getRawPath());
+ File result = URLUtil.toFile(encoded);
+ assertEquals("1." + i, original, result);
+ } catch (MalformedURLException e) {
+ fail("1.99", e);
+ }
+ }
+ }
+
+ /**
* Tests for {@link URLUtil#toURI(URL)}.
*/
public void testToFileFromLocalURL() throws Exception {
@@ -51,4 +68,16 @@ public class URLUtilTest extends AbstractProvisioningTest {
assertEquals("1.0", original, result);
}
+ public void testToFileFromUNC() throws Exception {
+ File original = new File("\\\\a\\b c");
+ // this tests the two slash UNC path that URL creates
+ URL url = new URL("file:" + original.toString());
+ File result = URLUtil.toFile(url);
+ assertEquals("1.0", original, result);
+
+ // this tests the four slash UNC path that URI creates
+ url = original.toURI().toURL();
+ result = URLUtil.toFile(url);
+ assertEquals("1.1", original, result);
+ }
}

Back to the top