use of software.amazon.awssdk.http.HttpExecuteRequest in project aws-sdk-java-v2 by aws.
the class MetricReportingTest method prepareRequest_connectionManagerNotPooling_callableCalled_metricsReported.
@Test
public void prepareRequest_connectionManagerNotPooling_callableCalled_metricsReported() throws IOException {
ApacheHttpClient client = newClient();
when(mockHttpClient.getHttpClientConnectionManager()).thenReturn(mock(HttpClientConnectionManager.class));
MetricCollector collector = MetricCollector.create("test");
HttpExecuteRequest executeRequest = newRequest(collector);
client.prepareRequest(executeRequest).call();
MetricCollection collected = collector.collect();
assertThat(collected.metricValues(HTTP_CLIENT_NAME)).containsExactly("Apache");
assertThat(collected.metricValues(LEASED_CONCURRENCY)).isEmpty();
assertThat(collected.metricValues(PENDING_CONCURRENCY_ACQUIRES)).isEmpty();
assertThat(collected.metricValues(AVAILABLE_CONCURRENCY)).isEmpty();
assertThat(collected.metricValues(MAX_CONCURRENCY)).isEmpty();
}
use of software.amazon.awssdk.http.HttpExecuteRequest in project aws-sdk-java-v2 by aws.
the class MetricReportingTest method newRequest.
private HttpExecuteRequest newRequest(MetricCollector collector) {
final SdkHttpFullRequest sdkRequest = SdkHttpFullRequest.builder().method(SdkHttpMethod.HEAD).host("amazonaws.com").protocol("https").build();
HttpExecuteRequest executeRequest = HttpExecuteRequest.builder().request(sdkRequest).metricCollector(collector).build();
return executeRequest;
}
use of software.amazon.awssdk.http.HttpExecuteRequest in project aws-sdk-java-v2 by aws.
the class MetricReportingTest method prepareRequest_callableCalled_metricsReported.
@Test
public void prepareRequest_callableCalled_metricsReported() throws IOException {
ApacheHttpClient client = newClient();
MetricCollector collector = MetricCollector.create("test");
HttpExecuteRequest executeRequest = newRequest(collector);
client.prepareRequest(executeRequest).call();
MetricCollection collected = collector.collect();
assertThat(collected.metricValues(HTTP_CLIENT_NAME)).containsExactly("Apache");
assertThat(collected.metricValues(LEASED_CONCURRENCY)).containsExactly(1);
assertThat(collected.metricValues(PENDING_CONCURRENCY_ACQUIRES)).containsExactly(2);
assertThat(collected.metricValues(AVAILABLE_CONCURRENCY)).containsExactly(3);
assertThat(collected.metricValues(MAX_CONCURRENCY)).containsExactly(4);
}
use of software.amazon.awssdk.http.HttpExecuteRequest in project aws-sdk-java-v2 by aws.
the class SignersIntegrationTest method sign_WithoutUsingSdkClient_ThroughExecutionAttributes.
@Test
public void sign_WithoutUsingSdkClient_ThroughExecutionAttributes() throws Exception {
Aws4Signer signer = Aws4Signer.create();
SdkHttpFullRequest httpFullRequest = generateBasicRequest();
// sign the request
SdkHttpFullRequest signedRequest = signer.sign(httpFullRequest, constructExecutionAttributes());
SdkHttpClient httpClient = ApacheHttpClient.builder().build();
HttpExecuteRequest request = HttpExecuteRequest.builder().request(signedRequest).contentStreamProvider(signedRequest.contentStreamProvider().orElse(null)).build();
HttpExecuteResponse response = httpClient.prepareRequest(request).call();
assertEquals("Non success http status code", 200, response.httpResponse().statusCode());
String actualResult = IoUtils.toUtf8String(response.responseBody().get());
assertEquals(getExpectedResult(), actualResult);
}
use of software.amazon.awssdk.http.HttpExecuteRequest in project aws-sdk-java-v2 by aws.
the class SignersIntegrationTest method test_SignMethod_WithModeledParam_And_WithoutUsingSdkClient.
@Test
public void test_SignMethod_WithModeledParam_And_WithoutUsingSdkClient() throws Exception {
Aws4Signer signer = Aws4Signer.create();
SdkHttpFullRequest httpFullRequest = generateBasicRequest();
// sign the request
SdkHttpFullRequest signedRequest = signer.sign(httpFullRequest, constructSignerParams());
SdkHttpClient httpClient = ApacheHttpClient.builder().build();
HttpExecuteRequest request = HttpExecuteRequest.builder().request(signedRequest).contentStreamProvider(signedRequest.contentStreamProvider().orElse(null)).build();
HttpExecuteResponse response = httpClient.prepareRequest(request).call();
assertEquals("Non success http status code", 200, response.httpResponse().statusCode());
String actualResult = IoUtils.toUtf8String(response.responseBody().get());
assertEquals(getExpectedResult(), actualResult);
}
Aggregations