Methods Summary |
---|
private void | authenticateDigestAlgorithm(java.lang.String algorithm)
String challenge = "Digest realm=\"protected area\", "
+ "nonce=\"dcd98b7102dd2f0e8b11d0f600bfb0c093\", "
+ "algorithm=" + algorithm;
DigestScheme digestScheme = new DigestScheme();
digestScheme.processChallenge(new BasicHeader("WWW-Authenticate", challenge));
HttpGet get = new HttpGet();
digestScheme.authenticate(new UsernamePasswordCredentials("username", "password"), get);
|
private java.lang.String | contentToString(org.apache.http.HttpResponse response)
StringWriter writer = new StringWriter();
char[] buffer = new char[1024];
Reader reader = new InputStreamReader(response.getEntity().getContent());
int length;
while ((length = reader.read(buffer)) != -1) {
writer.write(buffer, 0, length);
}
reader.close();
return writer.toString();
|
protected void | tearDown()
server.shutdown();
super.tearDown();
|
public void | testDigestSchemeAlgorithms()
authenticateDigestAlgorithm("MD5");
authenticateDigestAlgorithm("MD5-sess");
authenticateDigestAlgorithm("md5");
authenticateDigestAlgorithm("md5-sess");
authenticateDigestAlgorithm("md5-SESS");
authenticateDigestAlgorithm("MD5-SESS");
try {
authenticateDigestAlgorithm("MD5-");
} catch (AuthenticationException expected) {
}
try {
authenticateDigestAlgorithm("MD6");
} catch (AuthenticationException expected) {
}
try {
authenticateDigestAlgorithm("MD");
} catch (AuthenticationException expected) {
}
try {
authenticateDigestAlgorithm("");
} catch (AuthenticationException expected) {
}
|
private void | testServerClosesOutput(com.google.mockwebserver.SocketPolicy socketPolicy)
server.enqueue(new MockResponse()
.setBody("This connection won't pool properly")
.setSocketPolicy(socketPolicy));
server.enqueue(new MockResponse()
.setBody("This comes after a busted connection"));
server.play();
DefaultHttpClient client = new DefaultHttpClient();
HttpResponse a = client.execute(new HttpGet(server.getUrl("/a").toURI()));
assertEquals("This connection won't pool properly", contentToString(a));
assertEquals(0, server.takeRequest().getSequenceNumber());
HttpResponse b = client.execute(new HttpGet(server.getUrl("/b").toURI()));
assertEquals("This comes after a busted connection", contentToString(b));
// sequence number 0 means the HTTP socket connection was not reused
assertEquals(0, server.takeRequest().getSequenceNumber());
|
public void | testServerClosesSocket()
testServerClosesOutput(DISCONNECT_AT_END);
|
public void | testServerShutdownInput()
testServerClosesOutput(SHUTDOWN_INPUT_AT_END);
|
public void | testServerShutdownOutput()DefaultHttpClient fails if the server shutdown the output after the
response was sent. http://b/2612240
testServerClosesOutput(SHUTDOWN_OUTPUT_AT_END);
|