Code example for URI

Methods: getAuthority, getPort, parseServerAuthority

0
        } catch (URISyntaxException expected) {
        } 
    } 
 
    public void testParseServerAuthorityOmittedAuthority() throws Exception { 
        URI uri = new URI("http:file");
        uri.parseServerAuthority(); // does nothing!
        assertNull(uri.getAuthority());
        assertNull(uri.getHost());
        assertEquals(-1, uri.getPort());
    } 
 
    public void testEncodingParts() throws Exception { 
        URI uri = new URI("http", "user:pa55w?rd", "host", 80, "/doc|search",
                "q=green robots", "over 6\""); 
        assertEquals("http", uri.getScheme());
        assertEquals("user:pa55w?rd@host:80", uri.getAuthority());
        assertEquals("user:pa55w%3Frd@host:80", uri.getRawAuthority());
        assertEquals("user:pa55w?rd", uri.getUserInfo());
        assertEquals("user:pa55w%3Frd", uri.getRawUserInfo());
        assertEquals("/doc|search", uri.getPath());