Code example for URI

Methods: getAuthority, getUserInfo

0
        } catch (URISyntaxException expected) {
        } 
    } 
 
    public void testAtSignInUserInfo() throws Exception { 
        URI uri = new URI("http://user@userhost.com:password@host");
        assertEquals("user@userhost.com:password@host", uri.getAuthority());
        assertEquals(null, uri.getUserInfo());
        assertEquals(null, uri.getHost());
    } 
 
    public void testUserNoPassword() throws Exception { 
        URI uri = new URI("http://user@host");
        assertEquals("user@host", uri.getAuthority());
        assertEquals("user", uri.getUserInfo());
        assertEquals("host", uri.getHost());
    } 
 
    public void testUserNoPasswordExplicitPort() throws Exception { 
        URI uri = new URI("http://user@host:8080");
        assertEquals("user@host:8080", uri.getAuthority());