Skip to content

Commit ea0c5ef

Browse files
authored
Added Junit for request with HeadObject and gzipped enabled (#3363)
1 parent 199b8c9 commit ea0c5ef

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

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

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,30 @@
1515

1616
package software.amazon.awssdk.http.urlconnection;
1717

18-
import static org.assertj.core.api.Assertions.assertThat;
18+
import static org.junit.jupiter.api.Assertions.assertEquals;
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+
28+
import org.junit.jupiter.api.AfterAll;
29+
import org.junit.jupiter.api.BeforeAll;
30+
import org.junit.jupiter.api.Test;
2831
import software.amazon.awssdk.core.sync.RequestBody;
2932
import software.amazon.awssdk.services.s3.model.HeadObjectResponse;
33+
import software.amazon.awssdk.services.s3.model.NoSuchBucketException;
3034
import software.amazon.awssdk.services.s3.model.PutObjectRequest;
3135

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

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

37-
@BeforeClass
41+
@BeforeAll
3842
public static void setupFixture() throws IOException {
3943
createBucket(BUCKET);
4044

@@ -50,15 +54,23 @@ public static void setupFixture() throws IOException {
5054
RequestBody.fromBytes(baos.toByteArray()));
5155
}
5256

57+
@AfterAll
58+
public static void cleanup() {
59+
deleteBucketAndAllContents(BUCKET);
60+
}
61+
5362
@Test
5463
public void syncClientSupportsGzippedObjects() {
5564
HeadObjectResponse response = s3.headObject(r -> r.bucket(BUCKET).key(GZIPPED_KEY));
56-
assertThat(response.contentEncoding()).isEqualTo("gzip");
65+
assertEquals(response.contentEncoding(), "gzip");
5766
}
5867

59-
@AfterClass
60-
public static void cleanup() {
61-
deleteBucketAndAllContents(BUCKET);
68+
@Test
69+
public void syncClient_throwsRightException_withGzippedObjects() {
70+
71+
assertThrows(NoSuchBucketException.class,
72+
() -> s3.headObject(r -> r.bucket(BUCKET + UUID.randomUUID()).key(GZIPPED_KEY)));
73+
6274
}
6375

6476
}

0 commit comments

Comments
 (0)