Code example for URI

Methods: getFragment, getQuery, resolve

0
        assertEquals(null, uri.getHost());
        assertEquals(-1, uri.getPort());
    } 
 
    public void testRelativePathOnQuery() throws Exception { 
        URI base = new URI("http://host/file?query/x");
        URI uri = base.resolve("another");
        assertEquals("http://host/another", uri.toString());
        assertEquals("/another", uri.getPath());
        assertEquals(null, uri.getQuery());
        assertEquals(null, uri.getFragment());
    } 
 
    public void testRelativeFragmentOnQuery() throws Exception { 
        URI base = new URI("http://host/file?query/x#fragment");
        URI uri = base.resolve("#another");
        assertEquals("http://host/file?query/x#another", uri.toString());
        assertEquals("/file", uri.getPath());
        assertEquals("query/x", uri.getQuery());
        assertEquals("another", uri.getFragment());
    }