1.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/ResourcesTest.java Sat Sep 28 02:04:01 2013 +0200
1.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/ResourcesTest.java Sat Sep 28 02:11:01 2013 +0200
1.3 @@ -18,6 +18,7 @@
1.4 package org.apidesign.bck2brwsr.tck;
1.5
1.6 import java.io.InputStream;
1.7 +import java.net.URL;
1.8 import org.apidesign.bck2brwsr.vmtest.Compare;
1.9 import org.apidesign.bck2brwsr.vmtest.VMTest;
1.10 import org.testng.annotations.Factory;
1.11 @@ -39,6 +40,11 @@
1.12 return sb.toString();
1.13 }
1.14
1.15 + @Compare public String toURIFromURL() throws Exception {
1.16 + URL u = new URL("http://apidesign.org");
1.17 + return u.toURI().toString();
1.18 + }
1.19 +
1.20 @Factory public static Object[] create() {
1.21 return VMTest.create(ResourcesTest.class);
1.22 }
2.1 --- a/rt/emul/mini/src/main/java/java/net/URL.java Sat Sep 28 02:04:01 2013 +0200
2.2 +++ b/rt/emul/mini/src/main/java/java/net/URL.java Sat Sep 28 02:11:01 2013 +0200
2.3 @@ -920,6 +920,23 @@
2.4 }
2.5
2.6 /**
2.7 + * Returns a {@link java.net.URI} equivalent to this URL.
2.8 + * This method functions in the same way as <code>new URI (this.toString())</code>.
2.9 + * <p>Note, any URL instance that complies with RFC 2396 can be converted
2.10 + * to a URI. However, some URLs that are not strictly in compliance
2.11 + * can not be converted to a URI.
2.12 + *
2.13 + * @exception URISyntaxException if this URL is not formatted strictly according to
2.14 + * to RFC2396 and cannot be converted to a URI.
2.15 + *
2.16 + * @return a URI instance equivalent to this URL.
2.17 + * @since 1.5
2.18 + */
2.19 + public URI toURI() throws URISyntaxException {
2.20 + return new URI (toString());
2.21 + }
2.22 +
2.23 + /**
2.24 * Returns a {@link java.net.URLConnection URLConnection} instance that
2.25 * represents a connection to the remote object referred to by the
2.26 * {@code URL}.