Search in sources :

Example 1 with RandomTempFile

use of software.amazon.awssdk.testutils.RandomTempFile in project aws-sdk-java-v2 by aws.

the class CrtExceptionTransformationIntegrationTest method setupFixture.

@BeforeClass
public static void setupFixture() throws IOException {
    createBucket(BUCKET);
    testFile = new RandomTempFile(BUCKET, OBJ_SIZE);
    s3Crt = S3CrtAsyncClient.builder().credentialsProvider(CREDENTIALS_PROVIDER_CHAIN).region(S3IntegrationTestBase.DEFAULT_REGION).build();
    transferManager = S3TransferManager.builder().s3ClientConfiguration(b -> b.credentialsProvider(CREDENTIALS_PROVIDER_CHAIN).region(S3IntegrationTestBase.DEFAULT_REGION)).build();
}
Also used : RandomTempFile(software.amazon.awssdk.testutils.RandomTempFile) BeforeClass(org.junit.BeforeClass)

Example 2 with RandomTempFile

use of software.amazon.awssdk.testutils.RandomTempFile in project aws-sdk-java-v2 by aws.

the class S3CrtGetObjectIntegrationTest method setup.

@BeforeClass
public static void setup() throws IOException {
    S3IntegrationTestBase.createBucket(BUCKET);
    crtClient = S3CrtAsyncClient.builder().region(S3IntegrationTestBase.DEFAULT_REGION).credentialsProvider(AwsTestBase.CREDENTIALS_PROVIDER_CHAIN).build();
    file = new RandomTempFile(10_000);
    S3IntegrationTestBase.s3.putObject(PutObjectRequest.builder().bucket(BUCKET).key(KEY).build(), file.toPath());
    executorService = Executors.newFixedThreadPool(2);
}
Also used : RandomTempFile(software.amazon.awssdk.testutils.RandomTempFile) BeforeClass(org.junit.BeforeClass)

Example 3 with RandomTempFile

use of software.amazon.awssdk.testutils.RandomTempFile in project aws-sdk-java-v2 by aws.

the class BucketAccelerateIntegrationTest method testAccelerateEndpoint.

@Test
public void testAccelerateEndpoint() throws Exception {
    String status = s3.getBucketAccelerateConfiguration(GetBucketAccelerateConfigurationRequest.builder().bucket(US_BUCKET_NAME).build()).statusAsString();
    if (status == null || !status.equals("Enabled")) {
        enableAccelerateOnBucket();
    }
    // PutObject
    File uploadFile = new RandomTempFile(KEY_NAME, 1000);
    try {
        accelerateClient.putObject(PutObjectRequest.builder().bucket(US_BUCKET_NAME).key(KEY_NAME).build(), RequestBody.fromFile(uploadFile));
    } catch (Exception e) {
    // We really only need to verify the request is using the accelerate endpoint
    }
}
Also used : RandomTempFile(software.amazon.awssdk.testutils.RandomTempFile) File(java.io.File) RandomTempFile(software.amazon.awssdk.testutils.RandomTempFile) Test(org.junit.Test)

Example 4 with RandomTempFile

use of software.amazon.awssdk.testutils.RandomTempFile in project aws-sdk-java-v2 by aws.

the class ListObjectsV2PaginatorsIntegrationTest method createKey.

/**
 * Creates a test object in S3 with the specified name, using random ASCII
 * data of the default content length as defined in this test class.
 *
 * @param key The key under which to create the object in this test class'
 *            test bucket.
 */
private static void createKey(String key) throws Exception {
    File file = new RandomTempFile("list-objects-integ-test-" + new Date().getTime(), CONTENT_LENGTH);
    s3.putObject(PutObjectRequest.builder().bucket(bucketName).key(key).build(), RequestBody.fromFile(file));
    keys.add(key);
}
Also used : RandomTempFile(software.amazon.awssdk.testutils.RandomTempFile) File(java.io.File) RandomTempFile(software.amazon.awssdk.testutils.RandomTempFile) Date(java.util.Date)

Example 5 with RandomTempFile

use of software.amazon.awssdk.testutils.RandomTempFile in project aws-sdk-java-v2 by aws.

the class ServerSideEncryptionIntegrationTestBase method setupFixture.

@BeforeClass
public static void setupFixture() throws IOException {
    createBucket(BUCKET);
    createBucket(BUCKET_WITH_SSE);
    keyId = KMS.createKey().keyMetadata().keyId();
    s3.putBucketEncryption(r -> r.bucket(BUCKET_WITH_SSE).serverSideEncryptionConfiguration(ssec -> ssec.rules(rule -> rule.applyServerSideEncryptionByDefault(d -> d.kmsMasterKeyID(keyId).sseAlgorithm(ServerSideEncryption.AWS_KMS)))));
    file = new RandomTempFile(10_000);
}
Also used : SecureRandom(java.security.SecureRandom) ServerSideEncryption(software.amazon.awssdk.services.s3.model.ServerSideEncryption) AfterClass(org.junit.AfterClass) BeforeClass(org.junit.BeforeClass) KmsClient(software.amazon.awssdk.services.kms.KmsClient) S3BucketUtils.temporaryBucketName(software.amazon.awssdk.testutils.service.S3BucketUtils.temporaryBucketName) IOException(java.io.IOException) S3IntegrationTestBase.createBucket(software.amazon.awssdk.services.s3.S3IntegrationTestBase.createBucket) Fail.fail(org.assertj.core.api.Fail.fail) RandomTempFile(software.amazon.awssdk.testutils.RandomTempFile) File(java.io.File) KeyGenerator(javax.crypto.KeyGenerator) RandomTempFile(software.amazon.awssdk.testutils.RandomTempFile) BeforeClass(org.junit.BeforeClass)

Aggregations

RandomTempFile (software.amazon.awssdk.testutils.RandomTempFile)22 BeforeClass (org.junit.BeforeClass)12 File (java.io.File)11 Test (org.junit.Test)7 IOException (java.io.IOException)4 Date (java.util.Date)4 AfterClass (org.junit.AfterClass)2 S3BucketUtils.temporaryBucketName (software.amazon.awssdk.testutils.service.S3BucketUtils.temporaryBucketName)2 ByteBuffer (java.nio.ByteBuffer)1 StandardCharsets (java.nio.charset.StandardCharsets)1 Files (java.nio.file.Files)1 Path (java.nio.file.Path)1 SecureRandom (java.security.SecureRandom)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 KeyGenerator (javax.crypto.KeyGenerator)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Fail.fail (org.assertj.core.api.Fail.fail)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 SdkResponse (software.amazon.awssdk.core.SdkResponse)1 AsyncResponseTransformer (software.amazon.awssdk.core.async.AsyncResponseTransformer)1