Code example for URI

Methods: getFragment, getQuery, resolve

0
        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());
    } 
 
    public void testPathContainsRelativeParts() throws Exception { 
        URI uri = new URI("http://host/a/b/../c");
//        assertEquals("http://host/a/c", uri.toString()); // RI doesn't canonicalize 
    } 
 
    public void testRelativePathAndFragment() throws Exception { 
        URI base = new URI("http://host/file");
        assertEquals("http://host/another#fragment", base.resolve("another#fragment").toString());