Skip to content

Commit d4dd845

Browse files
authored
Transfer Manager tests refactoring (#3420)
* Remove use of Junit4, clean up and consolidate tests in tm module * Ignoring the test if unicode can't be used as directory name
1 parent 21db023 commit d4dd845

21 files changed

+684
-999
lines changed

services-custom/s3-transfer-manager/pom.xml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,21 +111,42 @@
111111
<artifactId>service-test-utils</artifactId>
112112
<version>${awsjavasdk.version}</version>
113113
<scope>test</scope>
114+
<exclusions>
115+
<exclusion>
116+
<groupId>junit</groupId>
117+
<artifactId>junit</artifactId>
118+
</exclusion>
119+
<exclusion>
120+
<groupId>org.junit.vintage</groupId>
121+
<artifactId>junit-vintage-engine</artifactId>
122+
</exclusion>
123+
</exclusions>
114124
</dependency>
115125
<dependency>
116126
<groupId>software.amazon.awssdk</groupId>
117127
<artifactId>test-utils</artifactId>
118128
<version>${awsjavasdk.version}</version>
119129
<scope>test</scope>
130+
<exclusions>
131+
<exclusion>
132+
<groupId>junit</groupId>
133+
<artifactId>junit</artifactId>
134+
</exclusion>
135+
<exclusion>
136+
<groupId>org.junit.vintage</groupId>
137+
<artifactId>junit-vintage-engine</artifactId>
138+
</exclusion>
139+
</exclusions>
120140
</dependency>
121141
<dependency>
122142
<groupId>org.junit.jupiter</groupId>
123143
<artifactId>junit-jupiter</artifactId>
124144
<scope>test</scope>
125145
</dependency>
126146
<dependency>
127-
<groupId>org.junit.vintage</groupId>
128-
<artifactId>junit-vintage-engine</artifactId>
147+
<groupId>org.junit.jupiter</groupId>
148+
<artifactId>junit-jupiter-engine</artifactId>
149+
<version>${junit5.version}</version>
129150
<scope>test</scope>
130151
</dependency>
131152
<dependency>

services-custom/s3-transfer-manager/src/it/java/software/amazon/awssdk/transfer/s3/S3IntegrationTestBase.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import software.amazon.awssdk.services.s3.S3AsyncClientBuilder;
2525
import software.amazon.awssdk.services.s3.S3Client;
2626
import software.amazon.awssdk.services.s3.S3ClientBuilder;
27+
import software.amazon.awssdk.services.s3.internal.crt.S3CrtAsyncClient;
2728
import software.amazon.awssdk.services.s3.model.BucketLocationConstraint;
2829
import software.amazon.awssdk.services.s3.model.CreateBucketConfiguration;
2930
import software.amazon.awssdk.services.s3.model.CreateBucketRequest;
@@ -52,6 +53,10 @@ public class S3IntegrationTestBase extends AwsTestBase {
5253

5354
protected static S3AsyncClient s3Async;
5455

56+
protected static S3AsyncClient s3CrtAsync;
57+
58+
protected static S3TransferManager tm;
59+
5560
/**
5661
* Loads the AWS account info for the integration tests and creates an S3
5762
* client for tests to use.
@@ -62,12 +67,21 @@ public static void setUp() throws Exception {
6267
System.setProperty("aws.crt.debugnative", "true");
6368
s3 = s3ClientBuilder().build();
6469
s3Async = s3AsyncClientBuilder().build();
70+
s3CrtAsync = S3CrtAsyncClient.builder()
71+
.credentialsProvider(CREDENTIALS_PROVIDER_CHAIN)
72+
.region(DEFAULT_REGION)
73+
.build();
74+
tm = S3TransferManager.builder()
75+
.s3AsyncClient(s3CrtAsync)
76+
.build();
6577
}
6678

6779
@AfterAll
6880
public static void cleanUp() {
6981
s3.close();
7082
s3Async.close();
83+
s3CrtAsync.close();
84+
tm.close();
7185
CrtResource.waitForNoResources();
7286
}
7387

services-custom/s3-transfer-manager/src/it/java/software/amazon/awssdk/transfer/s3/S3TransferManagerCopyIntegrationTest.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
import software.amazon.awssdk.core.ResponseBytes;
2828
import software.amazon.awssdk.core.sync.RequestBody;
2929
import software.amazon.awssdk.core.sync.ResponseTransformer;
30-
import software.amazon.awssdk.services.s3.S3AsyncClient;
31-
import software.amazon.awssdk.services.s3.internal.crt.S3CrtAsyncClient;
3230
import software.amazon.awssdk.services.s3.model.GetObjectResponse;
3331
import software.amazon.awssdk.transfer.s3.model.CompletedCopy;
3432
import software.amazon.awssdk.transfer.s3.model.Copy;
@@ -42,26 +40,14 @@ public class S3TransferManagerCopyIntegrationTest extends S3IntegrationTestBase
4240
private static final String COPIED_OBJ_SPECIAL_CHARACTER = "special-special-chars-@$%";
4341
private static final long OBJ_SIZE = ThreadLocalRandom.current().nextLong(8 * MB, 16 * MB + 1);
4442

45-
private static S3TransferManager tm;
46-
47-
private static S3AsyncClient s3AsyncClient;
48-
4943
@BeforeAll
5044
public static void setUp() throws Exception {
5145
S3IntegrationTestBase.setUp();
5246
createBucket(BUCKET);
53-
s3AsyncClient = S3CrtAsyncClient.builder().credentialsProvider(CREDENTIALS_PROVIDER_CHAIN)
54-
.region(DEFAULT_REGION)
55-
.maxConcurrency(100)
56-
.build();
57-
tm = S3TransferManager.builder()
58-
.s3AsyncClient(s3AsyncClient)
59-
.build();
6047
}
6148

6249
@AfterAll
6350
public static void teardown() throws Exception {
64-
s3AsyncClient.close();
6551
tm.close();
6652
deleteBucketAndAllContents(BUCKET);
6753
S3IntegrationTestBase.cleanUp();

services-custom/s3-transfer-manager/src/it/java/software/amazon/awssdk/transfer/s3/S3TransferManagerDownloadDirectoryIntegrationTest.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,14 @@
2929
import java.util.concurrent.TimeUnit;
3030
import java.util.stream.Stream;
3131
import org.apache.commons.lang3.RandomStringUtils;
32-
import org.junit.ComparisonFailure;
3332
import org.junit.jupiter.api.AfterAll;
3433
import org.junit.jupiter.api.AfterEach;
3534
import org.junit.jupiter.api.BeforeAll;
3635
import org.junit.jupiter.api.BeforeEach;
3736
import org.junit.jupiter.api.Test;
3837
import org.junit.jupiter.params.ParameterizedTest;
3938
import org.junit.jupiter.params.provider.ValueSource;
40-
import software.amazon.awssdk.services.s3.internal.crt.S3CrtAsyncClient;
39+
import org.opentest4j.AssertionFailedError;
4140
import software.amazon.awssdk.testutils.FileUtils;
4241
import software.amazon.awssdk.transfer.s3.model.CompletedDirectoryDownload;
4342
import software.amazon.awssdk.transfer.s3.model.DirectoryDownload;
@@ -50,7 +49,6 @@ public class S3TransferManagerDownloadDirectoryIntegrationTest extends S3Integra
5049
+ "-delimiter");
5150
private static final String CUSTOM_DELIMITER = "-";
5251

53-
private static S3TransferManager tm;
5452
private static Path sourceDirectory;
5553
private Path directory;
5654

@@ -61,14 +59,6 @@ public static void setUp() throws Exception {
6159
createBucket(TEST_BUCKET_CUSTOM_DELIMITER);
6260
sourceDirectory = createLocalTestDirectory();
6361

64-
tm = S3TransferManager.builder()
65-
.s3AsyncClient(S3CrtAsyncClient.builder()
66-
.credentialsProvider(CREDENTIALS_PROVIDER_CHAIN)
67-
.region(DEFAULT_REGION)
68-
.maxConcurrency(100)
69-
.build())
70-
.build();
71-
7262
tm.uploadDirectory(u -> u.sourceDirectory(sourceDirectory).bucket(TEST_BUCKET)).completionFuture().join();
7363

7464
tm.uploadDirectory(u -> u.sourceDirectory(sourceDirectory)
@@ -236,7 +226,7 @@ private static void assertLeftHasRight(Path left, Path right) {
236226
try {
237227
assertThat(rightPath).exists();
238228
} catch (AssertionError e) {
239-
throw new ComparisonFailure(e.getMessage(), toFileTreeString(left), toFileTreeString(right));
229+
throw new AssertionFailedError(e.getMessage(), toFileTreeString(left), toFileTreeString(right));
240230
}
241231
if (Files.isRegularFile(leftPath)) {
242232
assertThat(leftPath).hasSameBinaryContentAs(rightPath);

services-custom/s3-transfer-manager/src/it/java/software/amazon/awssdk/transfer/s3/S3TransferManagerDownloadIntegrationTest.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public class S3TransferManagerDownloadIntegrationTest extends S3IntegrationTestB
4949
private static final String BUCKET = temporaryBucketName(S3TransferManagerDownloadIntegrationTest.class);
5050
private static final String KEY = "key";
5151
private static final int OBJ_SIZE = 16 * 1024 * 1024;
52-
private static S3TransferManager tm;
5352
private static File file;
5453

5554
@BeforeAll
@@ -60,17 +59,11 @@ public static void setup() throws IOException {
6059
.bucket(BUCKET)
6160
.key(KEY)
6261
.build(), file.toPath());
63-
tm = S3TransferManager.builder()
64-
.s3AsyncClient(S3CrtAsyncClient.builder().credentialsProvider(CREDENTIALS_PROVIDER_CHAIN)
65-
.region(DEFAULT_REGION)
66-
.build())
67-
.build();
6862
}
6963

7064
@AfterAll
7165
public static void cleanup() {
7266
deleteBucketAndAllContents(BUCKET);
73-
tm.close();
7467
S3IntegrationTestBase.cleanUp();
7568
}
7669

services-custom/s3-transfer-manager/src/it/java/software/amazon/awssdk/transfer/s3/S3TransferManagerDownloadPauseResumeIntegrationTest.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ public class S3TransferManagerDownloadPauseResumeIntegrationTest extends S3Integ
5151
private static final String KEY = "key";
5252
// 24 * MB is chosen to make sure we have data written in the file already upon pausing.
5353
private static final long OBJ_SIZE = 24 * MB;
54-
private static S3TransferManager tm;
5554
private static File sourceFile;
5655

5756
@BeforeAll
@@ -63,18 +62,11 @@ public static void setup() throws Exception {
6362
.bucket(BUCKET)
6463
.key(KEY)
6564
.build(), sourceFile.toPath());
66-
tm =
67-
S3TransferManager.builder().s3AsyncClient(S3AsyncClient.builder()
68-
.credentialsProvider(CREDENTIALS_PROVIDER_CHAIN)
69-
.region(DEFAULT_REGION)
70-
.build())
71-
.build();
7265
}
7366

7467
@AfterAll
7568
public static void cleanup() {
7669
deleteBucketAndAllContents(BUCKET);
77-
tm.close();
7870
sourceFile.delete();
7971
S3IntegrationTestBase.cleanUp();
8072
}

0 commit comments

Comments
 (0)