@Test
    void testHttpLocationWithRedirectFragment() throws Exception {
        final HttpHost target = new HttpHost("http", "localhost", -1);
        final URI requestURI = new URI("/~tim");

        final URI redirect1 = new URI("http://localhost/People.htm#tim");
        final URI redirect2 = new URI("http://localhost/people.html");

        final URI location = URIUtils.resolve(requestURI, target, Arrays.asList(redirect1, redirect2));
        final URI expectedURI = new URIBuilder()
                .setHost(target.getHostName())
                .setScheme(target.getSchemeName())
                .setPath("/people.html")
                .setFragment("tim")
                .build();
        Assertions.assertEquals(expectedURI, location);
    }
This TestCase contains test methods for URI resolving according to RFC 3986.
The examples are listed in section "5.4 Reference Resolution Examples"
httpclient5/src/test/java/org/apache/hc/client5/http/utils/TestURIUtils.java