|
26 | 26 | import java.nio.file.Files;
|
27 | 27 | import java.nio.file.Path;
|
28 | 28 | import java.time.Duration;
|
29 |
| -import java.util.List; |
30 | 29 | import java.util.Optional;
|
31 | 30 | import org.apache.commons.lang3.RandomStringUtils;
|
32 | 31 | import org.apache.logging.log4j.Level;
|
33 |
| -import org.apache.logging.log4j.core.LogEvent; |
| 32 | +import org.assertj.core.api.Assertions; |
34 | 33 | import org.junit.jupiter.api.AfterAll;
|
35 | 34 | import org.junit.jupiter.api.BeforeAll;
|
36 | 35 | import org.junit.jupiter.params.ParameterizedTest;
|
@@ -104,26 +103,31 @@ void pauseAndResume_ObjectEtagChange_shouldRestartDownload(S3TransferManager tm)
|
104 | 103 |
|
105 | 104 | String newEtag = putResponse.eTag();
|
106 | 105 | assertThat(newEtag).isNotEqualTo(originalEtag);
|
107 |
| - try (LogCaptor logCaptor = LogCaptor.create(Level.DEBUG)) { |
108 | 106 |
|
| 107 | + boolean isCrtClient = tm.getClass().getName().contains("Crt"); |
| 108 | + if (isCrtClient) { |
| 109 | + try (LogCaptor logCaptor = LogCaptor.create(Level.DEBUG)) { |
| 110 | + FileDownload resumedFileDownload = tm.resumeDownloadFile(resumableFileDownload); |
| 111 | + CompletedFileDownload completedDownload = resumedFileDownload.completionFuture().join(); |
| 112 | + |
| 113 | + assertThat(completedDownload.response().eTag()).isEqualTo(newEtag); |
| 114 | + assertThat(testDownloadListener.transferInitiatedCount == 2).isTrue(); |
| 115 | + |
| 116 | + Assertions.assertThat(logCaptor.loggedEvents()) |
| 117 | + .anySatisfy(logEvent -> Assertions.assertThat(logEvent.getMessage().getFormattedMessage()) |
| 118 | + .contains(String.format("The ETag of the requested object in bucket (%s) with key (%s) " |
| 119 | + + "has changed since the last " |
| 120 | + + "pause. The SDK will download the S3 object from " |
| 121 | + + "the beginning", |
| 122 | + BUCKET, KEY))); |
| 123 | + } |
| 124 | + } else { |
| 125 | + // skip the log assertion for Netty because DEBUG level will log the entire byte stream and crash codebuild |
109 | 126 | FileDownload resumedFileDownload = tm.resumeDownloadFile(resumableFileDownload);
|
110 | 127 | CompletedFileDownload completedDownload = resumedFileDownload.completionFuture().join();
|
111 | 128 |
|
112 | 129 | assertThat(completedDownload.response().eTag()).isEqualTo(newEtag);
|
113 | 130 | assertThat(testDownloadListener.transferInitiatedCount == 2).isTrue();
|
114 |
| - |
115 |
| - List<LogEvent> logEvents = logCaptor.loggedEvents(); |
116 |
| - StringBuilder sb = new StringBuilder(); |
117 |
| - logEvents.forEach(logEvent -> { |
118 |
| - sb.append(logEvent.getMessage().getFormattedMessage()); |
119 |
| - }); |
120 |
| - |
121 |
| - assertThat(sb) |
122 |
| - .contains(String.format("The ETag of the requested object in bucket (%s) with key (%s) " |
123 |
| - + "has changed since the last " |
124 |
| - + "pause. The SDK will download the S3 object from " |
125 |
| - + "the beginning", |
126 |
| - BUCKET, KEY)); |
127 | 131 | }
|
128 | 132 | }
|
129 | 133 |
|
|
0 commit comments