### Question:
AmazonHttpClient { List<RequestHandler2> requestHandler2s(Request<?> request, ExecutionContext executionContext) { final List<RequestHandler2> requestHandler2s = executionContext .getRequestHandler2s(); if (requestHandler2s == null) { return Collections.emptyList(); } for (final RequestHandler2 requestHandler2 : requestHandler2s) { if (requestHandler2 instanceof CredentialsRequestHandler) { ((CredentialsRequestHandler) requestHandler2) .setCredentials(executionContext.getCredentials()); } requestHandler2.beforeRequest(request); } return requestHandler2s; } AmazonHttpClient(ClientConfiguration config); @Deprecated  AmazonHttpClient(ClientConfiguration config,
            RequestMetricCollector requestMetricCollector);  AmazonHttpClient(ClientConfiguration config, HttpClient httpClient); @Deprecated  AmazonHttpClient(ClientConfiguration config, HttpClient httpClient,
            RequestMetricCollector requestMetricCollector); @Deprecated ResponseMetadata getResponseMetadataForRequest(AmazonWebServiceRequest request); Response<T> execute(Request<?> request,
            HttpResponseHandler<AmazonWebServiceResponse<T>> responseHandler,
            HttpResponseHandler<AmazonServiceException> errorResponseHandler,
            ExecutionContext executionContext); void shutdown(); RequestMetricCollector getRequestMetricCollector();  }### Answer:
@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)); }