/** * Test method for {@link org.apache.ace.connectionfactory.impl.UrlCredentials#UrlCredentials(java.net.URL)}. */ @Test(expectedExceptions = IllegalArgumentException.class) public void testUrlCredentialsNullURLFail() throws Exception { new UrlCredentials(null); }
/** * Test method for {@link org.apache.ace.connectionfactory.impl.UrlCredentials#UrlCredentials(org.apache.ace.connectionfactory.impl.UrlCredentials.AuthType, java.net.URL, java.lang.Object[])}. */ @Test public void testUrlCredentialsTypeAndURLOk() throws Exception { new UrlCredentials(AuthType.NONE, new URL("http://localhost:8080/")); }
/** * Test method for {@link org.apache.ace.connectionfactory.impl.UrlCredentials#UrlCredentials(java.net.URL)}. */ @Test public void testUrlCredentialsURLOk() throws Exception { new UrlCredentials(new URL("http://localhost:8080/")); }
/** * Test method for {@link org.apache.ace.connectionfactory.impl.UrlCredentials#UrlCredentials(org.apache.ace.connectionfactory.impl.UrlCredentials.AuthType, java.net.URL, java.lang.Object[])}. */ @Test(expectedExceptions = IllegalArgumentException.class) public void testUrlCredentialsNullTypeFail() throws Exception { new UrlCredentials(null, new URL("http://localhost:8080/")); }
/** * Test method for {@link org.apache.ace.connectionfactory.impl.UrlCredentials#matches(java.net.URL)}. */ @Test public void testMatchesNullURLOk() throws Exception { UrlCredentials creds = new UrlCredentials(AuthType.NONE, new URL("http://localhost:8080/")); assert creds.matches(null) == false : "Null URL should never match any credentials!"; }
/** * Test method for {@link org.apache.ace.connectionfactory.impl.UrlCredentials#matches(java.net.URL)}. */ @Test public void testMatchesValidURLOk() throws Exception { UrlCredentials creds = new UrlCredentials(AuthType.NONE, new URL("http://localhost:8080/")); assert creds.matches(new URL("http://localhost:8080/obr")) : "Base URL should match given URL!"; assert creds.matches(new URL("http://localhost:8080")) == false : "Base URL shouldn't match given URL!"; assert creds.matches(new URL("http://localhost:8081/")) == false : "Base URL shouldn't match given URL!"; }
/** * Test method for {@link org.apache.ace.connectionfactory.impl.UrlCredentials#getCredentials()}. */ @Test public void testGetCredentialsOk() throws Exception { UrlCredentials creds = new UrlCredentials(AuthType.NONE, new URL("http://localhost:8080/")); assertArrayEquals(new Object[0], creds.getCredentials()); creds = new UrlCredentials(AuthType.NONE, new URL("http://localhost:8080/"), "foo"); assertArrayEquals(new Object[] { "foo" }, creds.getCredentials()); creds = new UrlCredentials(AuthType.NONE, new URL("http://localhost:8080/"), (Object[]) null ); assertArrayEquals(new Object[0], creds.getCredentials()); creds = new UrlCredentials(AuthType.NONE, new URL("http://localhost:8080/"), (Object) null); assertArrayEquals(new Object[] { null }, creds.getCredentials()); }
return new UrlCredentials(type, baseURL, creds);