|
5 | 5 |
|
6 | 6 | package software.amazon.nio.spi.s3; |
7 | 7 |
|
8 | | -import java.time.Instant; |
9 | | -import org.mockito.Mock; |
10 | | -import software.amazon.awssdk.core.ResponseBytes; |
11 | | -import software.amazon.awssdk.core.async.AsyncRequestBody; |
12 | | -import software.amazon.awssdk.core.async.AsyncResponseTransformer; |
13 | | -import software.amazon.awssdk.services.s3.S3AsyncClient; |
14 | | -import software.amazon.awssdk.services.s3.model.*; |
| 8 | +import static java.nio.file.StandardOpenOption.CREATE; |
| 9 | +import static java.nio.file.StandardOpenOption.READ; |
| 10 | +import static java.nio.file.StandardOpenOption.WRITE; |
| 11 | +import static org.junit.jupiter.api.Assertions.assertArrayEquals; |
| 12 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 13 | +import static org.junit.jupiter.api.Assertions.assertFalse; |
| 14 | +import static org.junit.jupiter.api.Assertions.assertNotNull; |
| 15 | +import static org.junit.jupiter.api.Assertions.assertThrows; |
| 16 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
| 17 | +import static org.mockito.Mockito.any; |
| 18 | +import static org.mockito.Mockito.lenient; |
| 19 | +import static org.mockito.Mockito.when; |
| 20 | +import static software.amazon.nio.spi.s3.S3Matchers.anyConsumer; |
15 | 21 |
|
16 | 22 | import java.io.IOException; |
17 | 23 | import java.net.URI; |
18 | 24 | import java.nio.ByteBuffer; |
19 | 25 | import java.nio.charset.StandardCharsets; |
20 | 26 | import java.nio.file.OpenOption; |
| 27 | +import java.time.Instant; |
21 | 28 | import java.util.Collections; |
22 | 29 | import java.util.Set; |
23 | 30 | import java.util.concurrent.CompletableFuture; |
24 | 31 | import org.junit.jupiter.api.AfterEach; |
25 | | - |
26 | | -import static java.nio.file.StandardOpenOption.CREATE; |
27 | | -import static java.nio.file.StandardOpenOption.READ; |
28 | | -import static java.nio.file.StandardOpenOption.WRITE; |
29 | | -import static org.junit.jupiter.api.Assertions.*; |
30 | 32 | import org.junit.jupiter.api.BeforeEach; |
31 | 33 | import org.junit.jupiter.api.Test; |
32 | 34 | import org.junit.jupiter.api.extension.ExtendWith; |
33 | | - |
34 | | -import static org.mockito.Mockito.any; |
35 | | -import static org.mockito.Mockito.lenient; |
36 | | -import static org.mockito.Mockito.when; |
37 | | -import static software.amazon.nio.spi.s3.S3Matchers.anyConsumer; |
38 | | - |
| 35 | +import org.mockito.Mock; |
39 | 36 | import org.mockito.junit.jupiter.MockitoExtension; |
| 37 | +import software.amazon.awssdk.core.ResponseBytes; |
| 38 | +import software.amazon.awssdk.core.async.AsyncRequestBody; |
| 39 | +import software.amazon.awssdk.core.async.AsyncResponseTransformer; |
| 40 | +import software.amazon.awssdk.services.s3.S3AsyncClient; |
| 41 | +import software.amazon.awssdk.services.s3.model.GetObjectRequest; |
| 42 | +import software.amazon.awssdk.services.s3.model.GetObjectResponse; |
| 43 | +import software.amazon.awssdk.services.s3.model.HeadObjectRequest; |
| 44 | +import software.amazon.awssdk.services.s3.model.HeadObjectResponse; |
| 45 | +import software.amazon.awssdk.services.s3.model.NoSuchKeyException; |
| 46 | +import software.amazon.awssdk.services.s3.model.PutObjectRequest; |
| 47 | +import software.amazon.awssdk.services.s3.model.PutObjectResponse; |
40 | 48 |
|
41 | 49 | @ExtendWith(MockitoExtension.class) |
42 | 50 | @SuppressWarnings("unchecked") |
@@ -149,4 +157,15 @@ private S3SeekableByteChannel seekableByteChannelForRead() throws IOException { |
149 | 157 | return new S3SeekableByteChannel(path, mockClient, Collections.singleton(READ)); |
150 | 158 | } |
151 | 159 |
|
| 160 | + // test that the S3SeekableByteChannel uses the buffer size from the configuration set for the FileSystem |
| 161 | + @Test |
| 162 | + public void testBufferSize() throws IOException { |
| 163 | + fs.configuration().withMaxFragmentSize(10000); |
| 164 | + fs.configuration().withMaxFragmentNumber(10); |
| 165 | + try(var channel = (S3SeekableByteChannel) fs.provider().newByteChannel(path, Set.of(READ))) { |
| 166 | + assertEquals(10000, ((S3ReadAheadByteChannel) channel.getReadDelegate()).getMaxFragmentSize()); |
| 167 | + assertEquals(10, ((S3ReadAheadByteChannel) channel.getReadDelegate()).getMaxNumberFragments()); |
| 168 | + } |
| 169 | + } |
| 170 | + |
152 | 171 | } |
0 commit comments