17
17
18
18
import static org .assertj .core .api .Assertions .assertThat ;
19
19
import static org .assertj .core .api .Assertions .assertThatExceptionOfType ;
20
+ import static software .amazon .awssdk .testutils .service .S3BucketUtils .temporaryBucketName ;
20
21
21
22
import java .io .BufferedReader ;
22
23
import java .io .InputStreamReader ;
44
45
import software .amazon .awssdk .services .s3 .model .ChecksumMode ;
45
46
import software .amazon .awssdk .services .s3 .model .GetObjectRequest ;
46
47
import software .amazon .awssdk .services .s3 .model .GetObjectResponse ;
48
+ import software .amazon .awssdk .services .s3 .model .NoSuchBucketException ;
47
49
import software .amazon .awssdk .services .s3 .model .PutObjectRequest ;
48
50
import software .amazon .awssdk .services .s3 .model .PutObjectResponse ;
49
51
import software .amazon .awssdk .services .s3 .model .S3Exception ;
50
52
import software .amazon .awssdk .services .s3 .utils .CaptureChecksumValidationInterceptor ;
51
- import software .amazon .awssdk .services . s3 . utils . S3TestUtils ;
53
+ import software .amazon .awssdk .testutils . Waiter ;
52
54
53
55
public class HttpChecksumIntegrationTest extends S3IntegrationTestBase {
54
56
@@ -57,18 +59,29 @@ public class HttpChecksumIntegrationTest extends S3IntegrationTestBase {
57
59
public static CaptureChecksumValidationInterceptor interceptor = new CaptureChecksumValidationInterceptor ();
58
60
protected static S3Client s3Https ;
59
61
protected static S3AsyncClient s3HttpAsync ;
60
- private static String BUCKET ;
62
+ private static String BUCKET = temporaryBucketName ( HttpChecksumIntegrationTest . class ) ;
61
63
62
64
@ BeforeAll
63
65
public static void setUp () throws Exception {
66
+
67
+ // Http Client to generate Signed request
64
68
s3 = s3ClientBuilder ().overrideConfiguration (o -> o .addExecutionInterceptor (interceptor ))
65
- .build ();
69
+ .endpointOverride (URI .create ("http://s3." + DEFAULT_REGION + ".amazonaws.com" )).build ();
70
+
66
71
s3Async = s3AsyncClientBuilder ().overrideConfiguration (o -> o .addExecutionInterceptor (interceptor )).build ();
67
- s3Https = s3ClientBuilder ().overrideConfiguration (o -> o .addExecutionInterceptor (interceptor ))
68
- .endpointOverride (URI .create ("https://s3.us-west-2.amazonaws.com" )).build ();
72
+
73
+ s3Https = s3ClientBuilder ().overrideConfiguration (o -> o .addExecutionInterceptor (interceptor )).build ();
74
+
75
+ // Http Client to generate Signed request
69
76
s3HttpAsync = s3AsyncClientBuilder ().overrideConfiguration (o -> o .addExecutionInterceptor (interceptor ))
70
- .endpointOverride (URI .create ("http://s3.us-west-2.amazonaws.com" )).build ();
71
- BUCKET = S3TestUtils .getTestBucket (s3 );
77
+ .endpointOverride (URI .create ("http://s3." + DEFAULT_REGION + ".amazonaws.com" )).build ();
78
+
79
+
80
+ createBucket (BUCKET );
81
+
82
+ Waiter .run (() -> s3 .headBucket (r -> r .bucket (BUCKET )))
83
+ .ignoringException (NoSuchBucketException .class )
84
+ .orFail ();
72
85
interceptor .reset ();
73
86
}
74
87
0 commit comments