Java Code Examples for software.amazon.awssdk.utils.AttributeMap#empty()

The following examples show how to use software.amazon.awssdk.utils.AttributeMap#empty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NettyNioAsyncHttpClientWireMockTest.java    From aws-sdk-java-v2 with Apache License 2.0 6 votes vote down vote up
@Test
public void closeClient_shouldCloseUnderlyingResources() {
    SdkEventLoopGroup eventLoopGroup = SdkEventLoopGroup.builder().build();
    ChannelPool channelPool = mock(ChannelPool.class);
    SdkChannelPoolMap<URI, ChannelPool> sdkChannelPoolMap = new SdkChannelPoolMap<URI, ChannelPool>() {
        @Override
        protected ChannelPool newPool(URI key) {
            return channelPool;
        }
    };

    sdkChannelPoolMap.get(URI.create("http://blah"));
    NettyConfiguration nettyConfiguration = new NettyConfiguration(AttributeMap.empty());

    SdkAsyncHttpClient customerClient =
        new NettyNioAsyncHttpClient(eventLoopGroup, sdkChannelPoolMap, nettyConfiguration);

    customerClient.close();
    assertThat(eventLoopGroup.eventLoopGroup().isShuttingDown()).isTrue();
    assertThat(eventLoopGroup.eventLoopGroup().isTerminated()).isTrue();
    assertThat(sdkChannelPoolMap).isEmpty();
    Mockito.verify(channelPool).close();
}
 
Example 2
Source File: NettyRequestExecutorTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
    mockChannelPool = mock(ChannelPool.class);

    eventLoopGroup = new NioEventLoopGroup();

    requestContext = new RequestContext(mockChannelPool,
                                        eventLoopGroup,
                                        AsyncExecuteRequest.builder().build(),
                                        new NettyConfiguration(AttributeMap.empty()));
    nettyRequestExecutor = new NettyRequestExecutor(requestContext);
}
 
Example 3
Source File: ApacheHttpClientWireMockTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
@Test
public void closeClient_shouldCloseUnderlyingResources() {
    ApacheHttpClient client = new ApacheHttpClient(httpClient, ApacheHttpRequestConfig.builder().build(), AttributeMap.empty());
    when(httpClient.getHttpClientConnectionManager()).thenReturn(connectionManager);

    client.close();
    verify(connectionManager).shutdown();
}
 
Example 4
Source File: SdkDefaultClientBuilder.java    From aws-sdk-java-v2 with Apache License 2.0 4 votes vote down vote up
/**
 * Optionally overridden by child implementations to provide implementation-specific default HTTP configuration.
 */
protected AttributeMap childHttpConfig() {
    return AttributeMap.empty();
}
 
Example 5
Source File: AwsDefaultClientBuilder.java    From aws-sdk-java-v2 with Apache License 2.0 4 votes vote down vote up
/**
 * Optionally overridden by child classes to define service-specific HTTP configuration defaults.
 */
protected AttributeMap serviceHttpConfig() {
    return AttributeMap.empty();
}
 
Example 6
Source File: UrlConnectionHttpClient.java    From aws-sdk-java-v2 with Apache License 2.0 2 votes vote down vote up
/**
 * Use this method if you want to control the way a {@link HttpURLConnection} is created.
 * This will ignore SDK defaults like {@link SdkHttpConfigurationOption#CONNECTION_TIMEOUT}
 * and {@link SdkHttpConfigurationOption#READ_TIMEOUT}
 * @param connectionFactory a function that, given a {@link URI} will create an {@link HttpURLConnection}
 * @return an {@link UrlConnectionHttpClient}
 */
public static SdkHttpClient create(UrlConnectionFactory connectionFactory) {
    return new UrlConnectionHttpClient(AttributeMap.empty(), connectionFactory);
}