當前位置: 首頁>>代碼示例>>Java>>正文


Java ClientConfiguration類代碼示例

本文整理匯總了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));
}
 
開發者ID:rpgreen,項目名稱:apigateway-generic-java-sdk,代碼行數:26,代碼來源:GenericApiGatewayClientTest.java

示例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;
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:20,代碼來源:S3Client.java

示例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");
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:18,代碼來源:AWSSignersTests.java

示例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());
}
 
開發者ID:IBM,項目名稱:ibm-cos-sdk-java,代碼行數:32,代碼來源:AwsClientBuilderTest.java

示例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);
}
 
開發者ID:IBM,項目名稱:ibm-cos-sdk-java,代碼行數:20,代碼來源:MockedClientTests.java

示例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();
}
 
開發者ID:shinesolutions,項目名稱:aem-orchestrator,代碼行數:10,代碼來源:AwsConfig.java

示例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));
}
 
開發者ID:shinesolutions,項目名稱:aem-orchestrator,代碼行數:19,代碼來源:AwsConfigTest.java

示例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);
}
 
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:21,代碼來源:KMSEncryptionFeature.java

示例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());
    }
}
 
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:19,代碼來源:AmazonIdentityConfiguration.java

示例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;
}
 
開發者ID:riboseinc,項目名稱:aws-codecommit-trigger-plugin,代碼行數:17,代碼來源:SQSFactoryImpl.java

示例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);
  }
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:22,代碼來源:S3FileSystem.java

示例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


注:本文中的com.amazonaws.ClientConfiguration類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。