Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Kaegi2008-10-10 18:51:28 +0000
committerSimon Kaegi2008-10-10 18:51:28 +0000
commit4622928e4543fe6e2fda21a1db24125a0451f98d (patch)
tree93f256599ceb982beef6d120e51f146075deb845 /bundles/org.eclipse.equinox.p2.tests/src
parentd9250f561a95ed4103b64e3c01802bece38e300c (diff)
downloadrt.equinox.p2-4622928e4543fe6e2fda21a1db24125a0451f98d.tar.gz
rt.equinox.p2-4622928e4543fe6e2fda21a1db24125a0451f98d.tar.xz
rt.equinox.p2-4622928e4543fe6e2fda21a1db24125a0451f98d.zip
Additional tests for Files with spaces and %20
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests/src')
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/URIUtilTest.java42
1 files changed, 41 insertions, 1 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 079caa13d..6406db255 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
@@ -65,6 +65,46 @@ public class URIUtilTest extends AbstractProvisioningTest {
if (!isWindows())
return;
assertEquals("1.1", new URI("file:/c:/foo/bar.txt"), URIUtil.toURI(new URL("file:c:/foo/bar.txt")));
- assertEquals("1.1", new URI("file:/c:/foo/bar.txt"), URIUtil.toURI(new URL("file:/c:/foo/bar.txt")));
+ assertEquals("1.2", new URI("file:/c:/foo/bar.txt"), URIUtil.toURI(new URL("file:/c:/foo/bar.txt")));
+ }
+
+ /**
+ * Tests handling of conversion from a File with spaces to URL and File to URI and equivalence of the resulting URI
+ */
+ public void testFileWithSpaces() throws MalformedURLException, URISyntaxException {
+ File fileWithSpaces = new File("c:\\with spaces\\goo");
+ URI correctURI = fileWithSpaces.toURI();
+ URL fileURL = fileWithSpaces.toURL();
+ URI fileURI = null;
+ try {
+ fileURI = fileURL.toURI();
+ fail();
+ } catch (URISyntaxException e) {
+ fileURI = URIUtil.toURI(fileURL);
+ }
+ assertEquals("1.1", correctURI, fileURI);
+
+ try {
+ fileURI = new URI(fileURL.toString());
+ fail();
+ } catch (URISyntaxException e) {
+ fileURI = URIUtil.fromString(fileURL.toString());
+ }
+ assertEquals("1.2", correctURI, fileURI);
+ }
+
+ /**
+ * Tests handling of conversion from a File with %20 to URL and File to URI and equivalence of the resulting URI
+ */
+ public void testFileWithPercent20() throws MalformedURLException, URISyntaxException {
+ File fileWithPercent20 = new File("c:\\with%20spaces\\goo");
+ URI correctURI = fileWithPercent20.toURI();
+
+ URL fileURL = fileWithPercent20.toURL();
+ assertNotSame("1.1", correctURI, fileURL.toURI());
+ assertEquals("1.2", correctURI, URIUtil.toURI(fileURL));
+ assertNotSame("1.3", correctURI, new URI(fileURL.toString()));
+ // we expect these to not be the same because fromString assumes a decoded URL String
+ assertNotSame("1.4", correctURI, URIUtil.fromString(fileURL.toString()));
}
}

Back to the top