23
23
import static software .amazon .awssdk .services .s3 .regression .S3ChecksumsTestUtils .crc32 ;
24
24
import static software .amazon .awssdk .services .s3 .regression .S3ChecksumsTestUtils .makeAsyncClient ;
25
25
import static software .amazon .awssdk .services .s3 .regression .S3ChecksumsTestUtils .makeSyncClient ;
26
+ import static software .amazon .awssdk .services .s3 .regression .S3ClientFlavor .MULTIPART_ENABLED ;
27
+ import static software .amazon .awssdk .services .s3 .regression .S3ClientFlavor .STANDARD_ASYNC ;
26
28
import static software .amazon .awssdk .services .s3 .regression .TestConfig .testConfigs ;
27
29
28
30
import io .reactivex .Flowable ;
@@ -124,15 +126,15 @@ void putObject(UploadConfig config) throws Exception {
124
126
125
127
// For testing purposes, ContentProvider is Publisher<ByteBuffer> for async clients
126
128
// There is no way to create AsyncRequestBody with a Publisher<ByteBuffer> and also provide the content length
129
+ S3ClientFlavor flavor = config .getBaseConfig ().getFlavor ();
127
130
Assumptions .assumeFalse (config .getBodyType () == BodyType .CONTENT_PROVIDER_WITH_LENGTH
128
- && config . getBaseConfig (). getFlavor () .isAsync (),
131
+ && flavor .isAsync (),
129
132
"No way to create AsyncRequestBody by giving both an Publisher and the content length" );
130
133
131
134
// Payload signing doesn't work correctly for async java based
132
135
// TODO(sra-identity-auth) remove when chunked encoding support is added in async code path
133
136
Assumptions .assumeFalse (
134
- (config .getBaseConfig ().getFlavor () == S3ClientFlavor .STANDARD_ASYNC ||
135
- config .getBaseConfig ().getFlavor () == S3ClientFlavor .MULTIPART_ENABLED )
137
+ (flavor == STANDARD_ASYNC || flavor == MULTIPART_ENABLED )
136
138
&& (config .payloadSigning ()
137
139
// MRAP requires body signing
138
140
|| config .getBaseConfig ().getBucketType () == BucketType .MRAP ),
@@ -141,8 +143,7 @@ void putObject(UploadConfig config) throws Exception {
141
143
// For testing purposes, ContentProvider is Publisher<ByteBuffer> for async clients
142
144
// Async java based clients don't currently support unknown content-length bodies
143
145
Assumptions .assumeFalse (
144
- (config .getBaseConfig ().getFlavor () == S3ClientFlavor .STANDARD_ASYNC ||
145
- config .getBaseConfig ().getFlavor () == S3ClientFlavor .MULTIPART_ENABLED )
146
+ flavor == STANDARD_ASYNC
146
147
&& config .getBodyType () == BodyType .CONTENT_PROVIDER_NO_LENGTH ,
147
148
"Async Java based support unknown content length" );
148
149
@@ -176,13 +177,13 @@ void putObject(UploadConfig config) throws Exception {
176
177
boolean requestBodyHasContentLength = false ;
177
178
String actualCrc32 ;
178
179
179
- if (!config . getBaseConfig (). getFlavor () .isAsync ()) {
180
+ if (!flavor .isAsync ()) {
180
181
TestRequestBody body = getRequestBody (config .getBodyType (), config .getContentSize ());
181
182
callable = callPutObject (request , body , config .getBaseConfig (), overrideConfiguration .build ());
182
183
actualContentLength = body .getActualContentLength ();
183
184
requestBodyHasContentLength = body .optionalContentLength ().isPresent ();
184
185
actualCrc32 = body .getChecksum ();
185
- } else if (config . getBaseConfig (). getFlavor () == S3ClientFlavor . MULTIPART_ENABLED ) {
186
+ } else if (flavor == MULTIPART_ENABLED ) {
186
187
TestAsyncBody body = getAsyncRequestBody (config .getBodyType (), config .contentSize );
187
188
callable = callTmUpload (request , body , config .getBaseConfig (), overrideConfiguration .build ());
188
189
actualContentLength = body .getActualContentLength ();
@@ -201,19 +202,19 @@ void putObject(UploadConfig config) throws Exception {
201
202
recordObjectToCleanup (bucketType , key );
202
203
203
204
// mpu not supported
204
- if (config . getBaseConfig (). getFlavor () == S3ClientFlavor . MULTIPART_ENABLED ) {
205
+ if (flavor == MULTIPART_ENABLED ) {
205
206
return ;
206
207
}
207
208
208
209
// We only validate when configured to WHEN_SUPPORTED since checksums are optional for PutObject
209
210
if (config .getBaseConfig ().getRequestChecksumValidation () == RequestChecksumCalculation .WHEN_SUPPORTED
210
211
// CRT switches to MPU under the hood which doesn't support checksums
211
- && config . getBaseConfig (). getFlavor () != S3ClientFlavor .CRT_BASED ) {
212
+ && flavor != S3ClientFlavor .CRT_BASED ) {
212
213
assertThat (response .checksumCRC32 ()).isEqualTo (actualCrc32 );
213
214
}
214
215
215
216
// We can't set an execution interceptor when using CRT
216
- if (config . getBaseConfig (). getFlavor () == S3ClientFlavor .CRT_BASED ) {
217
+ if (flavor == S3ClientFlavor .CRT_BASED ) {
217
218
return ;
218
219
}
219
220
0 commit comments