@Override
  public URI rewriteURI(URI d2Uri)
  {
    String path = d2Uri.getRawPath();

    UriBuilder builder = UriBuilder.fromUri(_httpURI);
    if (path != null)
    {
      builder.path(path);
    }
    builder.replaceQuery(d2Uri.getRawQuery());
    builder.fragment(d2Uri.getRawFragment());
    URI rewrittenUri = builder.build();

    LOGGER.debug("rewrite uri {} -> {}", d2Uri, rewrittenUri);

    return rewrittenUri;
  }
@Test
  public void testSimpleD2Rewrite() throws URISyntaxException
  {
    final URI httpURI = new URIBuilder("http://www.linkedin.com:1234/test").build();
    final URI d2URI = new URIBuilder("d2://serviceName/request/query?q=5678").build();
    final String expectURL = "http://www.linkedin.com:1234/test/request/query?q=5678";

    URIRewriter URIRewriter = new D2URIRewriter(httpURI);

    URI finalURI = URIRewriter.rewriteURI(d2URI);
    Assert.assertEquals(finalURI.toString(), expectURL);
  }