Uprade to aws-java-sdk-s3 1.11.84

Address various deprecations.
pull/185/head
Andrew Gaul 2017-01-25 12:20:27 -08:00
rodzic 48f7fe2742
commit dc0c8663b8
2 zmienionych plików z 44 dodań i 25 usunięć

Wyświetl plik

@ -284,7 +284,7 @@
<dependency> <dependency>
<groupId>com.amazonaws</groupId> <groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId> <artifactId>aws-java-sdk-s3</artifactId>
<version>1.11.18</version> <version>1.11.84</version>
<scope>test</scope> <scope>test</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>

Wyświetl plik

@ -40,10 +40,11 @@ import javax.net.ssl.X509TrustManager;
import com.amazonaws.ClientConfiguration; import com.amazonaws.ClientConfiguration;
import com.amazonaws.HttpMethod; import com.amazonaws.HttpMethod;
import com.amazonaws.SDKGlobalConfiguration; import com.amazonaws.SDKGlobalConfiguration;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials; import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration;
import com.amazonaws.services.s3.AmazonS3; import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3Client; import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import com.amazonaws.services.s3.S3ClientOptions;
import com.amazonaws.services.s3.model.AbortMultipartUploadRequest; import com.amazonaws.services.s3.model.AbortMultipartUploadRequest;
import com.amazonaws.services.s3.model.AccessControlList; import com.amazonaws.services.s3.model.AccessControlList;
import com.amazonaws.services.s3.model.AmazonS3Exception; import com.amazonaws.services.s3.model.AmazonS3Exception;
@ -88,8 +89,11 @@ public final class S3AwsSdkTest {
} }
private static final ByteSource BYTE_SOURCE = ByteSource.wrap(new byte[1]); private static final ByteSource BYTE_SOURCE = ByteSource.wrap(new byte[1]);
private static final ClientConfiguration V2_SIGNER_CONFIG =
new ClientConfiguration().withSignerOverride("S3SignerType");
private URI s3Endpoint; private URI s3Endpoint;
private EndpointConfiguration s3EndpointConfig;
private S3Proxy s3Proxy; private S3Proxy s3Proxy;
private BlobStoreContext context; private BlobStoreContext context;
private String blobStoreType; private String blobStoreType;
@ -105,9 +109,12 @@ public final class S3AwsSdkTest {
context = info.getBlobStore().getContext(); context = info.getBlobStore().getContext();
s3Proxy = info.getS3Proxy(); s3Proxy = info.getS3Proxy();
s3Endpoint = info.getEndpoint(); s3Endpoint = info.getEndpoint();
client = new AmazonS3Client(awsCreds, s3EndpointConfig = new EndpointConfiguration(
new ClientConfiguration()); s3Endpoint.toString(), "us-east-1");
client.setEndpoint(s3Endpoint.toString()); client = AmazonS3ClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(awsCreds))
.withEndpointConfiguration(s3EndpointConfig)
.build();
containerName = createRandomContainerName(); containerName = createRandomContainerName();
info.getBlobStore().createContainerInLocation(null, containerName); info.getBlobStore().createContainerInLocation(null, containerName);
@ -134,9 +141,12 @@ public final class S3AwsSdkTest {
@Test @Test
public void testAwsV2Signature() throws Exception { public void testAwsV2Signature() throws Exception {
client = new AmazonS3Client(awsCreds, client = AmazonS3ClientBuilder.standard()
new ClientConfiguration().withSignerOverride("S3SignerType")); .withClientConfiguration(V2_SIGNER_CONFIG)
client.setEndpoint(s3Endpoint.toString()); .withCredentials(new AWSStaticCredentialsProvider(awsCreds))
.withEndpointConfiguration(s3EndpointConfig)
.build();
ObjectMetadata metadata = new ObjectMetadata(); ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentLength(BYTE_SOURCE.size()); metadata.setContentLength(BYTE_SOURCE.size());
client.putObject(containerName, "foo", BYTE_SOURCE.openStream(), client.putObject(containerName, "foo", BYTE_SOURCE.openStream(),
@ -153,9 +163,6 @@ public final class S3AwsSdkTest {
@Test @Test
public void testAwsV4Signature() throws Exception { public void testAwsV4Signature() throws Exception {
client = new AmazonS3Client(awsCreds);
client.setEndpoint(s3Endpoint.toString());
ObjectMetadata metadata = new ObjectMetadata(); ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentLength(BYTE_SOURCE.size()); metadata.setContentLength(BYTE_SOURCE.size());
client.putObject(containerName, "foo", client.putObject(containerName, "foo",
@ -172,10 +179,11 @@ public final class S3AwsSdkTest {
@Test @Test
public void testAwsV4SignatureNonChunked() throws Exception { public void testAwsV4SignatureNonChunked() throws Exception {
client = new AmazonS3Client(awsCreds); client = AmazonS3ClientBuilder.standard()
client.setEndpoint(s3Endpoint.toString()); .withChunkedEncodingDisabled(true)
client.setS3ClientOptions( .withCredentials(new AWSStaticCredentialsProvider(awsCreds))
S3ClientOptions.builder().disableChunkedEncoding().build()); .withEndpointConfiguration(s3EndpointConfig)
.build();
ObjectMetadata metadata = new ObjectMetadata(); ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentLength(BYTE_SOURCE.size()); metadata.setContentLength(BYTE_SOURCE.size());
@ -193,9 +201,13 @@ public final class S3AwsSdkTest {
@Test @Test
public void testAwsV4SignatureBadIdentity() throws Exception { public void testAwsV4SignatureBadIdentity() throws Exception {
client = new AmazonS3Client(new BasicAWSCredentials( client = AmazonS3ClientBuilder.standard()
"bad-identity", awsCreds.getAWSSecretKey())); .withCredentials(new AWSStaticCredentialsProvider(
client.setEndpoint(s3Endpoint.toString()); new BasicAWSCredentials(
"bad-access-key", awsCreds.getAWSSecretKey())))
.withEndpointConfiguration(s3EndpointConfig)
.build();
ObjectMetadata metadata = new ObjectMetadata(); ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentLength(BYTE_SOURCE.size()); metadata.setContentLength(BYTE_SOURCE.size());
@ -210,9 +222,14 @@ public final class S3AwsSdkTest {
@Test @Test
public void testAwsV4SignatureBadCredential() throws Exception { public void testAwsV4SignatureBadCredential() throws Exception {
client = new AmazonS3Client(new BasicAWSCredentials( client = AmazonS3ClientBuilder.standard()
awsCreds.getAWSAccessKeyId(), "bad-credential")); .withCredentials(new AWSStaticCredentialsProvider(
client.setEndpoint(s3Endpoint.toString()); new BasicAWSCredentials(
awsCreds.getAWSAccessKeyId(),
"bad-secret-key")))
.withEndpointConfiguration(s3EndpointConfig)
.build();
ObjectMetadata metadata = new ObjectMetadata(); ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentLength(BYTE_SOURCE.size()); metadata.setContentLength(BYTE_SOURCE.size());
@ -230,9 +247,11 @@ public final class S3AwsSdkTest {
// AWSS3BlobRequestSigner.signForTemporaryAccess. // AWSS3BlobRequestSigner.signForTemporaryAccess.
@Test @Test
public void testAwsV2UrlSigning() throws Exception { public void testAwsV2UrlSigning() throws Exception {
client = new AmazonS3Client(awsCreds, client = AmazonS3ClientBuilder.standard()
new ClientConfiguration().withSignerOverride("S3SignerType")); .withClientConfiguration(V2_SIGNER_CONFIG)
client.setEndpoint(s3Endpoint.toString()); .withCredentials(new AWSStaticCredentialsProvider(awsCreds))
.withEndpointConfiguration(s3EndpointConfig)
.build();
String blobName = "foo"; String blobName = "foo";
ObjectMetadata metadata = new ObjectMetadata(); ObjectMetadata metadata = new ObjectMetadata();