/** Tests parsing a URI into its parts. */
  public void testParseUri() throws Exception {
    // Simple name
    GenericFileName name = GenericFileName.parseUri("ftp://hostname/file", 21);
    assertEquals("ftp", name.getScheme());
    assertNull(name.getUserName());
    assertNull(name.getPassword());
    assertEquals("hostname", name.getHostName());
    assertEquals(21, name.getPort());
    assertEquals(name.getDefaultPort(), name.getPort());
    assertEquals("/file", name.getPath());
    assertEquals("ftp://hostname/", name.getRootURI());
    assertEquals("ftp://hostname/file", name.getURI());

    // Name with port
    name = GenericFileName.parseUri("ftp://*****:*****@hostname/file", 21);
    assertEquals("ftp", name.getScheme());
    assertEquals("user", name.getUserName());
    assertNull(name.getPassword());
    assertEquals("hostname", name.getHostName());
    assertEquals(21, name.getPort());
    assertEquals("/file", name.getPath());
    assertEquals("ftp://user@hostname/", name.getRootURI());
    assertEquals("ftp://user@hostname/file", name.getURI());

    // Name with username and password
    name = GenericFileName.parseUri("ftp://*****:*****@hostname/file", 21);
    assertEquals("ftp", name.getScheme());
    assertEquals("user", name.getUserName());
    assertEquals("password", name.getPassword());
    assertEquals("hostname", name.getHostName());
    assertEquals(21, name.getPort());
    assertEquals("/file", name.getPath());
    assertEquals("ftp://*****:*****@hostname/", name.getRootURI());
    assertEquals("ftp://*****:*****@hostname/file", name.getURI());

    // Encoded username and password
    name = GenericFileName.parseUri("ftp://%75ser%3A:%40@hostname", 21);
    assertEquals("ftp", name.getScheme());
    assertEquals("user:"******"@", name.getPassword());
    assertEquals("hostname", name.getHostName());
    assertEquals(21, name.getPort());
    assertEquals("/", name.getPath());
    assertEquals("ftp://user%3a:%40@hostname/", name.getRootURI());
    assertEquals("ftp://user%3a:%40@hostname/", name.getURI());
  }