Search in sources :

Example 1 with MockSyncHttpClient

use of software.amazon.awssdk.testutils.service.http.MockSyncHttpClient in project aws-sdk-java-v2 by aws.

the class TraceIdTest method traceIdInterceptorIsEnabled.

@Test
public void traceIdInterceptorIsEnabled() {
    EnvironmentVariableHelper.run(env -> {
        env.set("AWS_LAMBDA_FUNCTION_NAME", "foo");
        env.set("_X_AMZN_TRACE_ID", "bar");
        try (MockSyncHttpClient mockHttpClient = new MockSyncHttpClient();
            ProtocolRestJsonClient client = ProtocolRestJsonClient.builder().region(Region.US_WEST_2).credentialsProvider(AnonymousCredentialsProvider.create()).httpClient(mockHttpClient).build()) {
            mockHttpClient.stubNextResponse(HttpExecuteResponse.builder().response(SdkHttpResponse.builder().statusCode(200).build()).responseBody(AbortableInputStream.create(new StringInputStream("{}"))).build());
            client.allTypes();
            assertThat(mockHttpClient.getLastRequest().firstMatchingHeader("X-Amzn-Trace-Id")).hasValue("bar");
        }
    });
}
Also used : StringInputStream(software.amazon.awssdk.utils.StringInputStream) ProtocolRestJsonClient(software.amazon.awssdk.services.protocolrestjson.ProtocolRestJsonClient) MockSyncHttpClient(software.amazon.awssdk.testutils.service.http.MockSyncHttpClient) Test(org.junit.jupiter.api.Test)

Example 2 with MockSyncHttpClient

use of software.amazon.awssdk.testutils.service.http.MockSyncHttpClient in project aws-sdk-java-v2 by aws.

the class S3ObjectLambdaEndpointResolutionTest method setup.

@BeforeEach
public void setup() throws UnsupportedEncodingException {
    mockHttpClient = new MockSyncHttpClient();
    mockHttpClient.stubNextResponse(mockListObjectsResponse());
}
Also used : MockSyncHttpClient(software.amazon.awssdk.testutils.service.http.MockSyncHttpClient) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with MockSyncHttpClient

use of software.amazon.awssdk.testutils.service.http.MockSyncHttpClient in project aws-sdk-java-v2 by aws.

the class MultiRegionAccessPointSigningFunctionalTest method setup.

@BeforeEach
public void setup() throws UnsupportedEncodingException {
    mockHttpClient = new MockSyncHttpClient();
    mockHttpClient.stubNextResponse(mockListObjectsResponse());
}
Also used : MockSyncHttpClient(software.amazon.awssdk.testutils.service.http.MockSyncHttpClient) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with MockSyncHttpClient

use of software.amazon.awssdk.testutils.service.http.MockSyncHttpClient in project aws-sdk-java-v2 by aws.

the class OutpostAccessPointArnEndpointResolutionTest method setup.

@BeforeEach
public void setup() {
    mockHttpClient = new MockSyncHttpClient();
    mockSigner = (request, executionAttributes) -> request;
}
Also used : MockSyncHttpClient(software.amazon.awssdk.testutils.service.http.MockSyncHttpClient) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with MockSyncHttpClient

use of software.amazon.awssdk.testutils.service.http.MockSyncHttpClient in project aws-sdk-java-v2 by aws.

the class HostPrefixTest method setupClient.

@BeforeEach
public void setupClient() {
    mockHttpClient = new MockSyncHttpClient();
    mockAsyncClient = new MockAsyncHttpClient();
    client = ProtocolRestJsonClient.builder().credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("akid", "skid"))).region(Region.US_EAST_1).endpointOverride(URI.create("http://localhost")).httpClient(mockHttpClient).build();
    asyncClient = ProtocolRestJsonAsyncClient.builder().credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("akid", "skid"))).region(Region.US_EAST_1).endpointOverride(URI.create("http://localhost")).httpClient(mockAsyncClient).build();
}
Also used : MockAsyncHttpClient(software.amazon.awssdk.testutils.service.http.MockAsyncHttpClient) MockSyncHttpClient(software.amazon.awssdk.testutils.service.http.MockSyncHttpClient) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

MockSyncHttpClient (software.amazon.awssdk.testutils.service.http.MockSyncHttpClient)7 BeforeEach (org.junit.jupiter.api.BeforeEach)5 MockAsyncHttpClient (software.amazon.awssdk.testutils.service.http.MockAsyncHttpClient)2 Before (org.junit.Before)1 Test (org.junit.jupiter.api.Test)1 ProtocolRestJsonClient (software.amazon.awssdk.services.protocolrestjson.ProtocolRestJsonClient)1 StringInputStream (software.amazon.awssdk.utils.StringInputStream)1