/** * 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#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 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; }
assert url.getHandler().equals(parentURL.getHandler());