/**
   * Ensures that the values returned by {@link FileURL#getGuestCredentials()} and {@link
   * SchemeHandler#getGuestCredentials()} match the expected one returned by {@link
   * #getGuestCredentials()}.
   *
   * @throws MalformedURLException should not happen
   */
  @Test
  public void testGuestCredentials() throws MalformedURLException {
    FileURL url = getRootURL();
    Credentials expectedGuestCredentials = getGuestCredentials();

    // Assert that the guest credentials values returned by the FileURL and its handler match the
    // expected one
    // and are consistent
    if (expectedGuestCredentials == null) {
      assert url.getGuestCredentials() == null;
      assert url.getHandler().getGuestCredentials() == null;
    } else {
      assert expectedGuestCredentials.equals(url.getGuestCredentials());
      assert expectedGuestCredentials.equals(url.getHandler().getGuestCredentials());
    }
  }
  /**
   * Ensures that FileURL#getParent() works as expected.
   *
   * @throws MalformedURLException should not happen
   */
  @Test
  public void testParent() throws MalformedURLException {
    FileURL url = getURL("login", "password", "host", 10000, "/path/to", "query&param=value");
    url.setProperty("key", "value");

    FileURL parentURL = url.getParent();

    // Test path and filename
    assertPathEquals(getSchemePath("/path/"), parentURL);
    assert "path".equals(parentURL.getFilename());

    // Assert that schemes, hosts and ports match
    assert url.getScheme().equals(parentURL.getScheme());
    assert url.getHost().equals(parentURL.getHost());
    assert url.getPort() == parentURL.getPort();

    // Assert that credentials match
    assert url.getCredentials().equals(parentURL.getCredentials());
    assert url.getLogin().equals(parentURL.getLogin());
    assert url.getPassword().equals(parentURL.getPassword());

    // Assert that the sample property is in the parent URL
    assert "value".equals(parentURL.getProperty("key"));

    // Assert that handlers match
    assert url.getHandler().equals(parentURL.getHandler());

    // Assert that the query part is null
    assert parentURL.getQuery() == null;

    // One more time, the parent path is now "/"

    url = parentURL;
    parentURL = url.getParent();

    // Test path and filename
    assertPathEquals(getSchemePath("/"), parentURL);
    assert parentURL.getFilename() == null;

    // The parent URL should now be null

    // Test path and filename
    url = parentURL;
    assert url.getParent() == null;
  }
  /**
   * Ensures that the values returned by {@link FileURL#getPathSeparator()} and {@link
   * SchemeHandler#getPathSeparator()} match the expected one returned by {@link
   * #getPathSeparator()}.
   *
   * @throws MalformedURLException should not happen
   */
  @Test
  public void testPathSeparator() throws MalformedURLException {
    FileURL url = getRootURL();
    String expectedPathSeparator = url.getPathSeparator();

    // Assert that the path separator values returned by the FileURL and its handler match the
    // expected one
    // and are consistent
    assert expectedPathSeparator.equals(url.getPathSeparator());
    assert expectedPathSeparator.equals(url.getHandler().getPathSeparator());
  }
  /**
   * Ensures that the values returned by {@link FileURL#getStandardPort()} and {@link
   * SchemeHandler#getStandardPort()} match the expected one returned by {@link #getDefaultPort()}.
   *
   * @throws MalformedURLException should not happen
   */
  @Test
  public void testDefaultPort() throws MalformedURLException {
    FileURL url = getRootURL();
    int expectedDefaultPort = getDefaultPort();

    // Assert that the default port value returned by the FileURL and its handler match the expected
    // one
    // and are consistent
    assert expectedDefaultPort == url.getStandardPort();
    assert expectedDefaultPort == url.getHandler().getStandardPort();

    // Assert that the default port value is valid: either -1 or comprised between 1 and 65535
    assert expectedDefaultPort == -1 || (expectedDefaultPort > 0 && expectedDefaultPort < 65536);
  }
  /**
   * Ensures that the values returned by {@link FileURL#getAuthenticationType()} ()} and {@link
   * SchemeHandler#getAuthenticationType()} match the expected value returned by {@link
   * #getAuthenticationType()}, and that the value is one of the constants defined in {@link
   * AuthenticationType}. If the authentication type is {@link
   * AuthenticationType#NO_AUTHENTICATION}, verifies that {@link #getGuestCredentials()} returns
   * <code>null</code>.
   *
   * @throws MalformedURLException should not happen
   */
  @Test
  public void testAuthenticationType() throws MalformedURLException {
    FileURL url = getRootURL();
    AuthenticationType expectedAuthenticationType = getAuthenticationType();

    assert expectedAuthenticationType.equals(url.getAuthenticationType());
    assert expectedAuthenticationType.equals(url.getHandler().getAuthenticationType());

    assert expectedAuthenticationType == AuthenticationType.NO_AUTHENTICATION
        || expectedAuthenticationType == AuthenticationType.AUTHENTICATION_REQUIRED
        || expectedAuthenticationType == AuthenticationType.AUTHENTICATION_OPTIONAL;

    if (expectedAuthenticationType == AuthenticationType.NO_AUTHENTICATION)
      assert url.getGuestCredentials() == null;
  }