本文整理汇总了Java中com.amazonaws.ClientConfiguration类的典型用法代码示例。如果您正苦于以下问题:Java ClientConfiguration类的具体用法?Java ClientConfiguration怎么用?Java ClientConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClientConfiguration类属于com.amazonaws包,在下文中一共展示了ClientConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testExecute_noApiKey_noCreds
import com.amazonaws.ClientConfiguration; //导入依赖的package包/类
@Test
public void testExecute_noApiKey_noCreds() throws IOException {
client = new GenericApiGatewayClientBuilder()
.withEndpoint("https://foobar.execute-api.us-east-1.amazonaws.com")
.withRegion(Region.getRegion(Regions.fromName("us-east-1")))
.withClientConfiguration(new ClientConfiguration())
.withHttpClient(new AmazonHttpClient(new ClientConfiguration(), mockClient, null))
.build();
GenericApiGatewayResponse response = client.execute(
new GenericApiGatewayRequestBuilder()
.withBody(new ByteArrayInputStream("test request".getBytes()))
.withHttpMethod(HttpMethodName.POST)
.withResourcePath("/test/orders").build());
assertEquals("Wrong response body", "test payload", response.getBody());
assertEquals("Wrong response status", 200, response.getHttpResponse().getStatusCode());
Mockito.verify(mockClient, times(1)).execute(argThat(new LambdaMatcher<>(
x -> (x.getMethod().equals("POST")
&& x.getFirstHeader("x-api-key") == null
&& x.getFirstHeader("Authorization") == null
&& x.getURI().toString().equals("https://foobar.execute-api.us-east-1.amazonaws.com/test/orders")))),
any(HttpContext.class));
}
示例2: obtainResource
import com.amazonaws.ClientConfiguration; //导入依赖的package包/类
@Override
protected void obtainResource() throws Exception {
// See https://github.com/mhart/kinesalite#cbor-protocol-issues-with-the-java-sdk
System.setProperty(SDKGlobalConfiguration.AWS_CBOR_DISABLE_SYSTEM_PROPERTY, "true");
this.resource = AmazonKinesisAsyncClientBuilder.standard()
.withClientConfiguration(
new ClientConfiguration()
.withMaxErrorRetry(0)
.withConnectionTimeout(1000))
.withEndpointConfiguration(
new AwsClientBuilder.EndpointConfiguration("http://localhost:" + this.port,
Regions.DEFAULT_REGION.getName()))
.withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("", "")))
.build();
// Check connection
this.resource.listStreams();
}
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-aws-kinesis,代码行数:20,代码来源:LocalKinesisResource.java
示例3: createConnectionProperties
import com.amazonaws.ClientConfiguration; //导入依赖的package包/类
private ClientConfiguration createConnectionProperties() {
ClientConfiguration clientConfiguration = new ClientConfiguration();
Optional<HttpProxySettings.HttpProxy> proxyOptional = s3ConnectionProperties.getProxy();
if (proxyOptional.isPresent()) {
HttpProxySettings.HttpProxy proxy = s3ConnectionProperties.getProxy().get();
clientConfiguration.setProxyHost(proxy.host);
clientConfiguration.setProxyPort(proxy.port);
PasswordCredentials credentials = proxy.credentials;
if (credentials != null) {
clientConfiguration.setProxyUsername(credentials.getUsername());
clientConfiguration.setProxyPassword(credentials.getPassword());
}
}
Optional<Integer> maxErrorRetryCount = s3ConnectionProperties.getMaxErrorRetryCount();
if (maxErrorRetryCount.isPresent()) {
clientConfiguration.setMaxErrorRetry(maxErrorRetryCount.get());
}
return clientConfiguration;
}
示例4: testSigners
import com.amazonaws.ClientConfiguration; //导入依赖的package包/类
public void testSigners() {
assertThat(signerTester(null), is(false));
assertThat(signerTester("QueryStringSignerType"), is(true));
assertThat(signerTester("AWS3SignerType"), is(true));
assertThat(signerTester("AWS4SignerType"), is(true));
assertThat(signerTester("NoOpSignerType"), is(true));
assertThat(signerTester("UndefinedSigner"), is(false));
assertThat(signerTester("S3SignerType"), is(false));
assertThat(signerTester("AWSS3V4SignerType"), is(false));
ClientConfiguration configuration = new ClientConfiguration();
AwsSigner.configureSigner("AWS4SignerType", configuration);
assertEquals(configuration.getSignerOverride(), "AWS4SignerType");
AwsSigner.configureSigner("AWS3SignerType", configuration);
assertEquals(configuration.getSignerOverride(), "AWS3SignerType");
}
示例5: clientExecutionTimeoutEnabled_aborted_exception_occurs_timeout_not_expired
import com.amazonaws.ClientConfiguration; //导入依赖的package包/类
@Test(expected = AbortedException.class)
public void
clientExecutionTimeoutEnabled_aborted_exception_occurs_timeout_not_expired()
throws Exception {
ClientConfiguration config = new ClientConfiguration()
.withClientExecutionTimeout(CLIENT_EXECUTION_TIMEOUT)
.withMaxErrorRetry(0);
ConnectionManagerAwareHttpClient rawHttpClient =
createRawHttpClientSpy(config);
doThrow(new AbortedException()).when(rawHttpClient).execute(any
(HttpRequestBase.class), any(HttpContext.class));
httpClient = new AmazonHttpClient(config, rawHttpClient, null);
execute(httpClient, createMockGetRequest());
}
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:18,代码来源:AbortedExceptionClientExecutionTimerIntegrationTest.java
示例6: syncClientBuilder
import com.amazonaws.ClientConfiguration; //导入依赖的package包/类
/**
* The sync client is tested less thoroughly then the async client primarily because the async
* client exercises most of the same code paths so a bug introduced in the sync client builder
* should be exposed via tests written against the async builder. This test is mainly for
* additional coverage of the sync builder in case there is a regression specific to sync
* builders.
*/
@Test
public void syncClientBuilder() {
final List<RequestHandler2> requestHandlers = createRequestHandlerList(
new ConcreteRequestHandler(), new ConcreteRequestHandler());
final AWSCredentialsProvider credentials = mock(AWSCredentialsProvider.class);
final RequestMetricCollector metrics = mock(RequestMetricCollector.class);
//@formatter:off
AmazonConcreteClient client = new ConcreteSyncBuilder()
.withRegion(Regions.EU_CENTRAL_1)
.withClientConfiguration(new ClientConfiguration().withSocketTimeout(1234))
.withCredentials(credentials)
.withMetricsCollector(metrics)
.withRequestHandlers(requestHandlers.toArray(new RequestHandler2[requestHandlers.size()]))
.build();
//@formatter:on
assertEquals(URI.create("https://mockprefix.eu-central-1.amazonaws.com"),
client.getEndpoint());
assertEquals(1234, client.getSyncParams().getClientConfiguration().getSocketTimeout());
assertEquals(requestHandlers, client.getSyncParams().getRequestHandlers());
assertEquals(credentials, client.getSyncParams().getCredentialsProvider());
assertEquals(metrics, client.getSyncParams().getRequestMetricCollector());
}
示例7: clientExecutionTimeoutEnabled_RequestCompletesWithinTimeout_EntityNotBufferedForStreamedResponse
import com.amazonaws.ClientConfiguration; //导入依赖的package包/类
@Test
public void clientExecutionTimeoutEnabled_RequestCompletesWithinTimeout_EntityNotBufferedForStreamedResponse()
throws Exception {
ClientConfiguration config = new ClientConfiguration().withClientExecutionTimeout(CLIENT_EXECUTION_TIMEOUT);
ConnectionManagerAwareHttpClient rawHttpClient = createRawHttpClientSpy(config);
HttpResponseProxy responseProxy = createHttpResponseProxySpy();
doReturn(responseProxy).when(rawHttpClient).execute(any(HttpRequestBase.class), any(HttpContext.class));
httpClient = new AmazonHttpClient(config, rawHttpClient, null);
try {
httpClient.requestExecutionBuilder().request(createMockGetRequest()).execute(new ErrorDuringUnmarshallingResponseHandler().leaveConnectionOpen());
fail("Exception expected");
} catch (AmazonClientException e) {
}
assertResponseWasNotBuffered(responseProxy);
}
示例8: amazonCloudWatchClient
import com.amazonaws.ClientConfiguration; //导入依赖的package包/类
@Bean
public AmazonCloudWatch amazonCloudWatchClient(final AWSCredentialsProvider awsCredentialsProvider,
final ClientConfiguration awsClientConfig, final Region awsRegion) {
return AmazonCloudWatchClientBuilder.standard()
.withCredentials(awsCredentialsProvider)
.withClientConfiguration(awsClientConfig)
.withRegion(awsRegion.getName())
.build();
}
示例9: testAwsClientConfig_NoProxy
import com.amazonaws.ClientConfiguration; //导入依赖的package包/类
@Test
public void testAwsClientConfig_NoProxy() {
String clientProtocol = "http";
int clientConnectionTimeout = 10;
int clientMaxErrorRetry = 20;
setField(awsConfig, "clientProtocol", clientProtocol);
setField(awsConfig, "clientConnectionTimeout", clientConnectionTimeout);
setField(awsConfig, "clientMaxErrorRetry", clientMaxErrorRetry);
setField(awsConfig, "useProxy", false);
ClientConfiguration clientConfiguration = awsConfig.awsClientConfig(null);
assertThat(clientConfiguration.getProxyHost(), nullValue());
assertThat(clientConfiguration.getProxyPort(), equalTo(-1));
assertThat(clientConfiguration.getProtocol().toString(), equalTo(clientProtocol));
assertThat(clientConfiguration.getConnectionTimeout(), equalTo(clientConnectionTimeout));
assertThat(clientConfiguration.getMaxErrorRetry(), equalTo(clientMaxErrorRetry));
}
示例10: KMSEncryptionFeature
import com.amazonaws.ClientConfiguration; //导入依赖的package包/类
public KMSEncryptionFeature(final S3Session session, final int timeout) {
super(session);
this.bookmark = session.getHost();
configuration = new ClientConfiguration();
configuration.setConnectionTimeout(timeout);
configuration.setSocketTimeout(timeout);
final UseragentProvider ua = new PreferencesUseragentProvider();
configuration.setUserAgentPrefix(ua.get());
configuration.setMaxErrorRetry(0);
configuration.setMaxConnections(1);
configuration.setUseGzip(PreferencesFactory.get().getBoolean("http.compression.enable"));
final Proxy proxy = ProxyFactory.get().find(bookmark);
switch(proxy.getType()) {
case HTTP:
case HTTPS:
configuration.setProxyHost(proxy.getHostname());
configuration.setProxyPort(proxy.getPort());
}
locationFeature = session.getFeature(Location.class);
}
示例11: AmazonIdentityConfiguration
import com.amazonaws.ClientConfiguration; //导入依赖的package包/类
public AmazonIdentityConfiguration(final Host bookmark, final int timeout) {
this.bookmark = bookmark;
this.configuration = new ClientConfiguration();
this.configuration.setConnectionTimeout(timeout);
this.configuration.setSocketTimeout(timeout);
final UseragentProvider ua = new PreferencesUseragentProvider();
this.configuration.setUserAgentPrefix(ua.get());
this.configuration.setMaxErrorRetry(0);
this.configuration.setMaxConnections(1);
this.configuration.setUseGzip(PreferencesFactory.get().getBoolean("http.compression.enable"));
final Proxy proxy = ProxyFactory.get().find(bookmark);
switch(proxy.getType()) {
case HTTP:
case HTTPS:
this.configuration.setProxyHost(proxy.getHostname());
this.configuration.setProxyPort(proxy.getPort());
}
}
示例12: clientExecutionTimeoutEnabled_aborted_exception_occurs_timeout_expired
import com.amazonaws.ClientConfiguration; //导入依赖的package包/类
@Test(expected = ClientExecutionTimeoutException.class)
public void
clientExecutionTimeoutEnabled_aborted_exception_occurs_timeout_expired()
throws Exception {
ClientConfiguration config = new ClientConfiguration()
.withClientExecutionTimeout(CLIENT_EXECUTION_TIMEOUT)
.withMaxErrorRetry(0);
ConnectionManagerAwareHttpClient rawHttpClient =
createRawHttpClientSpy(config);
httpClient = new AmazonHttpClient(config, rawHttpClient, null);
execute(httpClient, new EmptyHttpRequest(server.getEndpoint(),
HttpMethodName.PUT, new SdkBufferedInputStream(new InputStream() {
@Override
public int read() throws IOException {
// Sleeping here to avoid OOM issues from a limitless InputStream
try {
Thread.sleep(100);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
return 1;
}
})));
}
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:27,代码来源:AbortedExceptionClientExecutionTimerIntegrationTest.java
示例13: createStandardAsyncClientBuilder
import com.amazonaws.ClientConfiguration; //导入依赖的package包/类
private AmazonSQSAsyncClientBuilder createStandardAsyncClientBuilder(SQSQueue queue, AWSCredentialsProvider credentials) {
ClientConfiguration clientConfiguration = this.getClientConfiguration(queue);
AmazonSQSAsyncClientBuilder builder = AmazonSQSAsyncClientBuilder.standard()
.withClientConfiguration(clientConfiguration)
.withCredentials(credentials)
.withExecutorFactory(this.SQSExecutorFactory);
if (queue != null) {
Regions region = queue.getRegion();
if (region != null) {
builder.withRegion(region);
}
}
return builder;
}
示例14: load
import com.amazonaws.ClientConfiguration; //导入依赖的package包/类
@Override
public AmazonS3Client load(S3ClientKey clientKey) throws Exception {
logger.debug("Opening S3 client connection for {}", clientKey);
ClientConfiguration clientConf = new ClientConfiguration();
clientConf.setProtocol(clientKey.isSecure ? Protocol.HTTPS : Protocol.HTTP);
// Proxy settings (if configured)
clientConf.setProxyHost(clientKey.s3Config.get(Constants.PROXY_HOST));
if (clientKey.s3Config.get(Constants.PROXY_PORT) != null) {
clientConf.setProxyPort(Integer.valueOf(clientKey.s3Config.get(Constants.PROXY_PORT)));
}
clientConf.setProxyDomain(clientKey.s3Config.get(Constants.PROXY_DOMAIN));
clientConf.setProxyUsername(clientKey.s3Config.get(Constants.PROXY_USERNAME));
clientConf.setProxyPassword(clientKey.s3Config.get(Constants.PROXY_PASSWORD));
clientConf.setProxyWorkstation(clientKey.s3Config.get(Constants.PROXY_WORKSTATION));
if (clientKey.accessKey == null){
return new AmazonS3Client(new AnonymousAWSCredentialsProvider(), clientConf);
} else {
return new AmazonS3Client(new BasicAWSCredentials(clientKey.accessKey, clientKey.secretKey), clientConf);
}
}
示例15: testSslHandshakeTimeout
import com.amazonaws.ClientConfiguration; //导入依赖的package包/类
@Test(timeout = 60 * 1000)
public void testSslHandshakeTimeout() {
AmazonHttpClient httpClient = new AmazonHttpClient(new ClientConfiguration()
.withSocketTimeout(CLIENT_SOCKET_TO).withMaxErrorRetry(0));
System.out.println("Sending request to localhost...");
try {
httpClient.requestExecutionBuilder()
.request(new EmptyHttpRequest(server.getHttpsEndpoint(), HttpMethodName.GET))
.execute();
fail("Client-side socket read timeout is expected!");
} catch (AmazonClientException e) {
/**
* Http client catches the SocketTimeoutException and throws a
* ConnectTimeoutException.
* {@link org.apache.http.impl.conn.DefaultHttpClientConnectionOperator#connect(ManagedHttpClientConnection, HttpHost, InetSocketAddress, int, SocketConfig, HttpContext)}
*/
Assert.assertTrue(e.getCause() instanceof ConnectTimeoutException);
ConnectTimeoutException cte = (ConnectTimeoutException) e.getCause();
Assert.assertThat(cte.getMessage(), org.hamcrest.Matchers
.containsString("Read timed out"));
}
}
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:27,代码来源:AmazonHttpClientSslHandshakeTimeoutIntegrationTest.java