Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add repeated test * 1000 #1398

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,24 @@

package com.adobe.testing.s3mock.testcontainers;

import static org.assertj.core.api.Assertions.assertThat;

import java.io.File;
import org.assertj.core.groups.Tuple;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.RepeatedTest;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
import software.amazon.awssdk.core.sync.RequestBody;
import software.amazon.awssdk.services.s3.model.Bucket;
import software.amazon.awssdk.services.s3.model.CreateBucketRequest;
import software.amazon.awssdk.services.s3.model.ListBucketsResponse;
import software.amazon.awssdk.services.s3.model.ListObjectsV2Request;
import software.amazon.awssdk.services.s3.model.PutObjectRequest;
import software.amazon.awssdk.services.s3.model.PutObjectResponse;
import software.amazon.awssdk.services.s3.model.S3Object;

/**
* This shows how to let JUnit 5 Jupiter start and stop the S3MockContainer.
Expand All @@ -41,4 +56,33 @@ void setUp() {
var endpoint = s3Mock.getHttpsEndpoint();
s3Client = createS3ClientV2(endpoint);
}

/**
* Creates a bucket, stores a file, lists the bucket.
*/
@RepeatedTest(1000)
void testListBucketsCreateBucketPutObjectAndListBucket(TestInfo testInfo) {
var bucketName = bucketName(testInfo);
var uploadFile = new File(UPLOAD_FILE_NAME);

var listBucketsResponse = s3Client.listBuckets();
assertThat(listBucketsResponse.buckets())
.hasSize(2)
.extracting(Bucket::name)
.containsExactlyInAnyOrder("bucket-a", "bucket-b");

s3Client.createBucket(CreateBucketRequest.builder().bucket(bucketName).build());
var putObjectResponse = s3Client.putObject(
PutObjectRequest.builder().bucket(bucketName).key(uploadFile.getName()).build(),
RequestBody.fromFile(uploadFile));

var listObjectsV2Response =
s3Client.listObjectsV2(ListObjectsV2Request.builder().bucket(bucketName).build());

assertThat(listObjectsV2Response.contents())
.hasSize(1)
.extracting(S3Object::key, S3Object::eTag)
.containsExactly(new Tuple(uploadFile.getName(), putObjectResponse.eTag()));
}

}