diff options
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/HttpAuthTest.java | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/HttpAuthTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/HttpAuthTest.java index c142bc23aa..5a64b458fa 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/HttpAuthTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/HttpAuthTest.java @@ -45,7 +45,6 @@ package org.eclipse.jgit.transport; import static org.junit.Assert.fail; import java.io.IOException; -import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; @@ -53,6 +52,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.eclipse.jgit.transport.http.JDKHttpConnection; import org.junit.Test; public class HttpAuthTest { @@ -71,7 +71,7 @@ public class HttpAuthTest { private static String DIGEST = "Digest"; @Test - public void testHttpAuthScanResponse() throws MalformedURLException { + public void testHttpAuthScanResponse() { checkResponse(new String[] { basicHeader }, BASIC); checkResponse(new String[] { digestHeader }, DIGEST); checkResponse(new String[] { basicHeader, digestHeader }, DIGEST); @@ -83,10 +83,15 @@ public class HttpAuthTest { } private static void checkResponse(String[] headers, - String expectedAuthMethod) throws MalformedURLException { + String expectedAuthMethod) { - AuthHeadersResponse responce = new AuthHeadersResponse(headers); - HttpAuthMethod authMethod = HttpAuthMethod.scanResponse(responce); + AuthHeadersResponse response = null; + try { + response = new AuthHeadersResponse(headers); + } catch (IOException e) { + fail("Couldn't instantiate AuthHeadersResponse: " + e.toString()); + } + HttpAuthMethod authMethod = HttpAuthMethod.scanResponse(response); if (!expectedAuthMethod.equals(getAuthMethodName(authMethod))) { fail("Wrong authentication method: expected " + expectedAuthMethod @@ -98,21 +103,16 @@ public class HttpAuthTest { return authMethod.getClass().getSimpleName(); } - private static class AuthHeadersResponse extends HttpURLConnection { + private static class AuthHeadersResponse extends JDKHttpConnection { Map<String, List<String>> headerFields = new HashMap<String, List<String>>(); public AuthHeadersResponse(String[] authHeaders) - throws MalformedURLException { + throws MalformedURLException, IOException { super(new URL(URL_SAMPLE)); parseHeaders(authHeaders); } @Override - public void disconnect() { - fail("The disconnect method shouldn't be invoked"); - } - - @Override public boolean usingProxy() { return false; } |