Skip to content

Commit 68fbd5c

Browse files
committed
Upgrading all the Integ test case of UrlHttpClient to junit 5
1 parent a9d5cce commit 68fbd5c

File tree

4 files changed

+29
-21
lines changed

4 files changed

+29
-21
lines changed

http-clients/url-connection-client/src/it/java/software/amazon/awssdk/http/urlconnection/EmptyFileS3IntegrationTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,21 @@
1818
import static org.assertj.core.api.Assertions.assertThat;
1919
import static software.amazon.awssdk.testutils.service.S3BucketUtils.temporaryBucketName;
2020

21-
import org.junit.AfterClass;
22-
import org.junit.BeforeClass;
23-
import org.junit.Test;
21+
import org.junit.jupiter.api.AfterAll;
22+
import org.junit.jupiter.api.BeforeAll;
23+
import org.junit.jupiter.api.Test;
2424
import software.amazon.awssdk.core.sync.RequestBody;
2525
import software.amazon.awssdk.services.s3.S3Client;
2626

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

30-
@BeforeClass
30+
@BeforeAll
3131
public static void setup() {
3232
createBucket(BUCKET);
3333
}
3434

35-
@AfterClass
35+
@AfterAll
3636
public static void cleanup() {
3737
deleteBucketAndAllContents(BUCKET);
3838
}

http-clients/url-connection-client/src/it/java/software/amazon/awssdk/http/urlconnection/HeadObjectIntegrationTest.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,28 @@
1616
package software.amazon.awssdk.http.urlconnection;
1717

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

2122
import java.io.ByteArrayOutputStream;
2223
import java.io.IOException;
2324
import java.nio.charset.StandardCharsets;
25+
import java.util.UUID;
2426
import java.util.zip.GZIPOutputStream;
25-
import org.junit.AfterClass;
26-
import org.junit.BeforeClass;
27-
import org.junit.Test;
27+
import org.junit.jupiter.api.AfterAll;
28+
import org.junit.jupiter.api.BeforeAll;
29+
import org.junit.jupiter.api.Test;
2830
import software.amazon.awssdk.core.sync.RequestBody;
2931
import software.amazon.awssdk.services.s3.model.HeadObjectResponse;
32+
import software.amazon.awssdk.services.s3.model.NoSuchKeyException;
3033
import software.amazon.awssdk.services.s3.model.PutObjectRequest;
3134

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

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

37-
@BeforeClass
40+
@BeforeAll
3841
public static void setupFixture() throws IOException {
3942
createBucket(BUCKET);
4043

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

59-
@AfterClass
62+
@Test
63+
public void syncClient_throwsRightException_withGzippedObjects() {
64+
assertThrows(NoSuchKeyException.class,
65+
() -> s3.headObject(r -> r.bucket(BUCKET + UUID.randomUUID()).key(GZIPPED_KEY)));
66+
67+
}
68+
69+
@AfterAll
6070
public static void cleanup() {
6171
deleteBucketAndAllContents(BUCKET);
6272
}

http-clients/url-connection-client/src/it/java/software/amazon/awssdk/http/urlconnection/S3WithUrlHttpClientIntegrationTest.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,10 @@
2424
import java.util.Collections;
2525
import java.util.List;
2626
import java.util.stream.Collectors;
27-
import org.junit.AfterClass;
28-
import org.junit.Before;
29-
import org.junit.BeforeClass;
30-
import org.junit.Test;
31-
import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
27+
import org.junit.jupiter.api.AfterAll;
28+
import org.junit.jupiter.api.BeforeAll;
29+
import org.junit.jupiter.api.BeforeEach;
30+
import org.junit.jupiter.api.Test;
3231
import software.amazon.awssdk.core.interceptor.Context;
3332
import software.amazon.awssdk.core.interceptor.ExecutionAttributes;
3433
import software.amazon.awssdk.core.interceptor.ExecutionInterceptor;
@@ -38,7 +37,6 @@
3837
import software.amazon.awssdk.regions.Region;
3938
import software.amazon.awssdk.services.s3.S3Client;
4039
import software.amazon.awssdk.services.s3.S3ClientBuilder;
41-
import software.amazon.awssdk.services.s3.S3Configuration;
4240
import software.amazon.awssdk.services.s3.model.CreateBucketConfiguration;
4341
import software.amazon.awssdk.services.s3.model.CreateBucketRequest;
4442
import software.amazon.awssdk.services.s3.model.DeleteBucketRequest;
@@ -64,7 +62,7 @@ public class S3WithUrlHttpClientIntegrationTest {
6462
/**
6563
* Creates all the test resources for the tests.
6664
*/
67-
@BeforeClass
65+
@BeforeAll
6866
public static void createResources() throws Exception {
6967
S3ClientBuilder s3ClientBuilder = S3Client.builder()
7068
.region(REGION)
@@ -82,13 +80,13 @@ public static void createResources() throws Exception {
8280
/**
8381
* Releases all resources created in this test.
8482
*/
85-
@AfterClass
83+
@AfterAll
8684
public static void tearDown() {
8785
deleteObject(BUCKET_NAME, KEY);
8886
deleteBucket(BUCKET_NAME);
8987
}
9088

91-
@Before
89+
@BeforeEach
9290
public void methodSetup() {
9391
capturingInterceptor.reset();
9492
}

http-clients/url-connection-client/src/it/java/software/amazon/awssdk/http/urlconnection/UrlHttpConnectionS3IntegrationTestBase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import java.util.Iterator;
1919
import java.util.List;
20-
import org.junit.BeforeClass;
20+
import org.junit.jupiter.api.BeforeAll;
2121
import software.amazon.awssdk.regions.Region;
2222
import software.amazon.awssdk.services.s3.S3Client;
2323
import software.amazon.awssdk.services.s3.S3ClientBuilder;
@@ -48,7 +48,7 @@ public class UrlHttpConnectionS3IntegrationTestBase extends AwsTestBase {
4848
* Loads the AWS account info for the integration tests and creates an S3
4949
* client for tests to use.
5050
*/
51-
@BeforeClass
51+
@BeforeAll
5252
public static void setUp() throws Exception {
5353
s3 = s3ClientBuilder().build();
5454
}

0 commit comments

Comments
 (0)