Skip to content

Upgrading all the Integ test case of UrlHttpClient to junit 5 #3375

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

Merged
merged 1 commit into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
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 @@ -18,21 +18,21 @@
import static org.assertj.core.api.Assertions.assertThat;
import static software.amazon.awssdk.testutils.service.S3BucketUtils.temporaryBucketName;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.core.sync.RequestBody;
import software.amazon.awssdk.services.s3.S3Client;

public class EmptyFileS3IntegrationTest extends UrlHttpConnectionS3IntegrationTestBase {
private static final String BUCKET = temporaryBucketName(EmptyFileS3IntegrationTest.class);

@BeforeClass
@BeforeAll
public static void setup() {
createBucket(BUCKET);
}

@AfterClass
@AfterAll
public static void cleanup() {
deleteBucketAndAllContents(BUCKET);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,28 @@
package software.amazon.awssdk.http.urlconnection;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static software.amazon.awssdk.testutils.service.S3BucketUtils.temporaryBucketName;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.UUID;
import java.util.zip.GZIPOutputStream;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.core.sync.RequestBody;
import software.amazon.awssdk.services.s3.model.HeadObjectResponse;
import software.amazon.awssdk.services.s3.model.NoSuchKeyException;
import software.amazon.awssdk.services.s3.model.PutObjectRequest;

public class HeadObjectIntegrationTest extends UrlHttpConnectionS3IntegrationTestBase {
private static final String BUCKET = temporaryBucketName(HeadObjectIntegrationTest.class);

private static final String GZIPPED_KEY = "some-key";

@BeforeClass
@BeforeAll
public static void setupFixture() throws IOException {
createBucket(BUCKET);

Expand All @@ -56,7 +59,14 @@ public void syncClientSupportsGzippedObjects() {
assertThat(response.contentEncoding()).isEqualTo("gzip");
}

@AfterClass
@Test
public void syncClient_throwsRightException_withGzippedObjects() {
assertThrows(NoSuchKeyException.class,
() -> s3.headObject(r -> r.bucket(BUCKET + UUID.randomUUID()).key(GZIPPED_KEY)));

}

@AfterAll
public static void cleanup() {
deleteBucketAndAllContents(BUCKET);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.core.interceptor.Context;
import software.amazon.awssdk.core.interceptor.ExecutionAttributes;
import software.amazon.awssdk.core.interceptor.ExecutionInterceptor;
Expand All @@ -38,7 +37,6 @@
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.S3ClientBuilder;
import software.amazon.awssdk.services.s3.S3Configuration;
import software.amazon.awssdk.services.s3.model.CreateBucketConfiguration;
import software.amazon.awssdk.services.s3.model.CreateBucketRequest;
import software.amazon.awssdk.services.s3.model.DeleteBucketRequest;
Expand All @@ -64,7 +62,7 @@ public class S3WithUrlHttpClientIntegrationTest {
/**
* Creates all the test resources for the tests.
*/
@BeforeClass
@BeforeAll
public static void createResources() throws Exception {
S3ClientBuilder s3ClientBuilder = S3Client.builder()
.region(REGION)
Expand All @@ -82,13 +80,13 @@ public static void createResources() throws Exception {
/**
* Releases all resources created in this test.
*/
@AfterClass
@AfterAll
public static void tearDown() {
deleteObject(BUCKET_NAME, KEY);
deleteBucket(BUCKET_NAME);
}

@Before
@BeforeEach
public void methodSetup() {
capturingInterceptor.reset();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import java.util.Iterator;
import java.util.List;
import org.junit.BeforeClass;
import org.junit.jupiter.api.BeforeAll;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.S3ClientBuilder;
Expand Down Expand Up @@ -48,7 +48,7 @@ public class UrlHttpConnectionS3IntegrationTestBase extends AwsTestBase {
* Loads the AWS account info for the integration tests and creates an S3
* client for tests to use.
*/
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
s3 = s3ClientBuilder().build();
}
Expand Down