15
15
16
16
package software .amazon .awssdk .http .urlconnection ;
17
17
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 ;
19
20
import static software .amazon .awssdk .testutils .service .S3BucketUtils .temporaryBucketName ;
20
21
21
22
import java .io .ByteArrayOutputStream ;
22
23
import java .io .IOException ;
23
24
import java .nio .charset .StandardCharsets ;
25
+ import java .util .UUID ;
24
26
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 ;
28
31
import software .amazon .awssdk .core .sync .RequestBody ;
29
32
import software .amazon .awssdk .services .s3 .model .HeadObjectResponse ;
33
+ import software .amazon .awssdk .services .s3 .model .NoSuchBucketException ;
30
34
import software .amazon .awssdk .services .s3 .model .PutObjectRequest ;
31
35
32
36
public class HeadObjectIntegrationTest extends UrlHttpConnectionS3IntegrationTestBase {
33
37
private static final String BUCKET = temporaryBucketName (HeadObjectIntegrationTest .class );
34
38
35
39
private static final String GZIPPED_KEY = "some-key" ;
36
40
37
- @ BeforeClass
41
+ @ BeforeAll
38
42
public static void setupFixture () throws IOException {
39
43
createBucket (BUCKET );
40
44
@@ -50,15 +54,23 @@ public static void setupFixture() throws IOException {
50
54
RequestBody .fromBytes (baos .toByteArray ()));
51
55
}
52
56
57
+ @ AfterAll
58
+ public static void cleanup () {
59
+ deleteBucketAndAllContents (BUCKET );
60
+ }
61
+
53
62
@ Test
54
63
public void syncClientSupportsGzippedObjects () {
55
64
HeadObjectResponse response = s3 .headObject (r -> r .bucket (BUCKET ).key (GZIPPED_KEY ));
56
- assertThat (response .contentEncoding ()). isEqualTo ( "gzip" );
65
+ assertEquals (response .contentEncoding (), "gzip" );
57
66
}
58
67
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
+
62
74
}
63
75
64
76
}
0 commit comments