use of com.amazonaws.handlers.CredentialsRequestHandler in project aws-sdk-android by aws-amplify.
the class AmazonHttpClientTest method testRequestHander2s.
@Test
public void testRequestHander2s() {
final Request<?> testRequest = new DefaultRequest<String>("test");
final List<Object> calls = new ArrayList<Object>();
List<RequestHandler2> handlers = new ArrayList<RequestHandler2>();
RequestHandler2 defaultHandler = new RequestHandler2() {
@Override
public void beforeRequest(Request<?> request) {
assertSame(testRequest, request);
calls.add(this);
}
@Override
public void afterResponse(Request<?> request, Response<?> response) {
}
@Override
public void afterError(Request<?> request, Response<?> response, Exception e) {
}
};
RequestHandler2 credentialHandler = new CredentialsRequestHandler() {
@Override
public void beforeRequest(Request<?> request) {
assertSame(testRequest, request);
calls.add(this);
}
@Override
public void afterResponse(Request<?> request, Response<?> response) {
}
@Override
public void afterError(Request<?> request, Response<?> response, Exception e) {
}
};
handlers.add(defaultHandler);
handlers.add(credentialHandler);
ExecutionContext ec = new ExecutionContext(handlers, false, null);
client.requestHandler2s(testRequest, ec);
assertEquals(calls.size(), 2);
assertTrue(calls.contains(defaultHandler));
assertTrue(calls.contains(credentialHandler));
}
Aggregations