Search in sources :

Example 1 with HttpClientDependencies

use of software.amazon.awssdk.core.internal.http.HttpClientDependencies in project aws-sdk-java-v2 by aws.

the class MergeCustomHeadersStageTest method singleHeader_inMarshalledRequest_overriddenOnClient.

@Test
public void singleHeader_inMarshalledRequest_overriddenOnClient() throws Exception {
    SdkHttpFullRequest.Builder requestBuilder = SdkHttpFullRequest.builder();
    RequestExecutionContext ctx = requestContext(NoopTestRequest.builder().build());
    requestBuilder.putHeader(singleHeaderName, "marshaller");
    Map<String, List<String>> clientHeaders = new HashMap<>();
    clientHeaders.put(singleHeaderName, Collections.singletonList("client"));
    HttpClientDependencies clientDeps = HttpClientDependencies.builder().clientConfiguration(SdkClientConfiguration.builder().option(SdkClientOption.ADDITIONAL_HTTP_HEADERS, clientHeaders).build()).build();
    MergeCustomHeadersStage stage = new MergeCustomHeadersStage(clientDeps);
    stage.execute(requestBuilder, ctx);
    assertThat(requestBuilder.headers().get(singleHeaderName)).containsExactly("client");
}
Also used : SdkHttpFullRequest(software.amazon.awssdk.http.SdkHttpFullRequest) HashMap(java.util.HashMap) RequestExecutionContext(software.amazon.awssdk.core.internal.http.RequestExecutionContext) List(java.util.List) HttpClientDependencies(software.amazon.awssdk.core.internal.http.HttpClientDependencies) Test(org.junit.Test)

Example 2 with HttpClientDependencies

use of software.amazon.awssdk.core.internal.http.HttpClientDependencies in project aws-sdk-java-v2 by aws.

the class MergeCustomHeadersStageTest method singleHeader_inRequestAsList_keepsMultipleValues.

@Test
public void singleHeader_inRequestAsList_keepsMultipleValues() throws Exception {
    SdkHttpFullRequest.Builder requestBuilder = SdkHttpFullRequest.builder();
    requestBuilder.putHeader(singleHeaderName, "marshaller");
    RequestExecutionContext ctx = requestContext(NoopTestRequest.builder().overrideConfiguration(SdkRequestOverrideConfiguration.builder().putHeader(singleHeaderName, Arrays.asList("request", "request2", "request3")).build()).build());
    Map<String, List<String>> clientHeaders = new HashMap<>();
    HttpClientDependencies clientDeps = HttpClientDependencies.builder().clientConfiguration(SdkClientConfiguration.builder().option(SdkClientOption.ADDITIONAL_HTTP_HEADERS, clientHeaders).build()).build();
    MergeCustomHeadersStage stage = new MergeCustomHeadersStage(clientDeps);
    stage.execute(requestBuilder, ctx);
    assertThat(requestBuilder.headers().get(singleHeaderName)).containsExactly("request", "request2", "request3");
}
Also used : SdkHttpFullRequest(software.amazon.awssdk.http.SdkHttpFullRequest) HashMap(java.util.HashMap) RequestExecutionContext(software.amazon.awssdk.core.internal.http.RequestExecutionContext) List(java.util.List) HttpClientDependencies(software.amazon.awssdk.core.internal.http.HttpClientDependencies) Test(org.junit.Test)

Example 3 with HttpClientDependencies

use of software.amazon.awssdk.core.internal.http.HttpClientDependencies in project aws-sdk-java-v2 by aws.

the class MergeCustomHeadersStageTest method singleHeader_inMarshalledRequest_overriddenOnRequest.

@Test
public void singleHeader_inMarshalledRequest_overriddenOnRequest() throws Exception {
    SdkHttpFullRequest.Builder requestBuilder = SdkHttpFullRequest.builder();
    requestBuilder.putHeader(singleHeaderName, "marshaller");
    RequestExecutionContext ctx = requestContext(NoopTestRequest.builder().overrideConfiguration(SdkRequestOverrideConfiguration.builder().putHeader(singleHeaderName, "request").build()).build());
    HttpClientDependencies clientDeps = HttpClientDependencies.builder().clientConfiguration(SdkClientConfiguration.builder().option(SdkClientOption.ADDITIONAL_HTTP_HEADERS, Collections.emptyMap()).build()).build();
    MergeCustomHeadersStage stage = new MergeCustomHeadersStage(clientDeps);
    stage.execute(requestBuilder, ctx);
    assertThat(requestBuilder.headers().get(singleHeaderName)).containsExactly("request");
}
Also used : SdkHttpFullRequest(software.amazon.awssdk.http.SdkHttpFullRequest) RequestExecutionContext(software.amazon.awssdk.core.internal.http.RequestExecutionContext) HttpClientDependencies(software.amazon.awssdk.core.internal.http.HttpClientDependencies) Test(org.junit.Test)

Example 4 with HttpClientDependencies

use of software.amazon.awssdk.core.internal.http.HttpClientDependencies in project aws-sdk-java-v2 by aws.

the class MergeCustomHeadersStageTest method singleHeader_inClient_overriddenOnRequest.

@Test
public void singleHeader_inClient_overriddenOnRequest() throws Exception {
    SdkHttpFullRequest.Builder requestBuilder = SdkHttpFullRequest.builder();
    RequestExecutionContext ctx = requestContext(NoopTestRequest.builder().overrideConfiguration(SdkRequestOverrideConfiguration.builder().putHeader(singleHeaderName, "request").build()).build());
    Map<String, List<String>> clientHeaders = new HashMap<>();
    clientHeaders.put(singleHeaderName, Collections.singletonList("client"));
    HttpClientDependencies clientDeps = HttpClientDependencies.builder().clientConfiguration(SdkClientConfiguration.builder().option(SdkClientOption.ADDITIONAL_HTTP_HEADERS, clientHeaders).build()).build();
    MergeCustomHeadersStage stage = new MergeCustomHeadersStage(clientDeps);
    stage.execute(requestBuilder, ctx);
    assertThat(requestBuilder.headers().get(singleHeaderName)).containsExactly("request");
}
Also used : SdkHttpFullRequest(software.amazon.awssdk.http.SdkHttpFullRequest) HashMap(java.util.HashMap) RequestExecutionContext(software.amazon.awssdk.core.internal.http.RequestExecutionContext) List(java.util.List) HttpClientDependencies(software.amazon.awssdk.core.internal.http.HttpClientDependencies) Test(org.junit.Test)

Example 5 with HttpClientDependencies

use of software.amazon.awssdk.core.internal.http.HttpClientDependencies in project aws-sdk-java-v2 by aws.

the class MergeCustomHeadersStageTest method singleHeader_inMarshalledRequest_inClient_inRequest.

@Test
public void singleHeader_inMarshalledRequest_inClient_inRequest() throws Exception {
    SdkHttpFullRequest.Builder requestBuilder = SdkHttpFullRequest.builder();
    requestBuilder.putHeader(singleHeaderName, "marshaller");
    RequestExecutionContext ctx = requestContext(NoopTestRequest.builder().overrideConfiguration(SdkRequestOverrideConfiguration.builder().putHeader(singleHeaderName, "request").build()).build());
    Map<String, List<String>> clientHeaders = new HashMap<>();
    clientHeaders.put(singleHeaderName, Collections.singletonList("client"));
    HttpClientDependencies clientDeps = HttpClientDependencies.builder().clientConfiguration(SdkClientConfiguration.builder().option(SdkClientOption.ADDITIONAL_HTTP_HEADERS, clientHeaders).build()).build();
    MergeCustomHeadersStage stage = new MergeCustomHeadersStage(clientDeps);
    stage.execute(requestBuilder, ctx);
    assertThat(requestBuilder.headers().get(singleHeaderName)).containsExactly("request");
}
Also used : SdkHttpFullRequest(software.amazon.awssdk.http.SdkHttpFullRequest) HashMap(java.util.HashMap) RequestExecutionContext(software.amazon.awssdk.core.internal.http.RequestExecutionContext) List(java.util.List) HttpClientDependencies(software.amazon.awssdk.core.internal.http.HttpClientDependencies) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)5 HttpClientDependencies (software.amazon.awssdk.core.internal.http.HttpClientDependencies)5 RequestExecutionContext (software.amazon.awssdk.core.internal.http.RequestExecutionContext)5 SdkHttpFullRequest (software.amazon.awssdk.http.SdkHttpFullRequest)5 HashMap (java.util.HashMap)4 List (java.util.List)4