@Test
  public void fromOpaqueUri() throws URISyntaxException {
    URI uri = new URI("mailto:[email protected]#baz");
    UriComponents result = UriComponentsBuilder.fromUri(uri).build();
    assertEquals("mailto", result.getScheme());
    assertEquals("*****@*****.**", result.getSchemeSpecificPart());
    assertEquals("baz", result.getFragment());

    assertEquals("Invalid result URI", uri, result.toUri());
  }
  @Test
  public void fromHierarchicalUri() throws URISyntaxException {
    URI uri = new URI("http://example.com/foo?bar#baz");
    UriComponents result = UriComponentsBuilder.fromUri(uri).build();
    assertEquals("http", result.getScheme());
    assertEquals("example.com", result.getHost());
    assertEquals("/foo", result.getPath());
    assertEquals("bar", result.getQuery());
    assertEquals("baz", result.getFragment());

    assertEquals("Invalid result URI", uri, result.toUri());
  }
  @Test // SPR-9317
  public void fromUriEncodedQuery() throws URISyntaxException {
    URI uri = new URI("http://www.example.org/?param=aGVsbG9Xb3JsZA%3D%3D");
    String fromUri = UriComponentsBuilder.fromUri(uri).build().getQueryParams().get("param").get(0);
    String fromUriString =
        UriComponentsBuilder.fromUriString(uri.toString())
            .build()
            .getQueryParams()
            .get("param")
            .get(0);

    assertEquals(fromUri, fromUriString);
  }