Skip to content

Commit bf0a94a

Browse files
author
Anirav Kareddy
committed
trying byte array input stream approach
1 parent 8e07851 commit bf0a94a

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/test/java/software/amazon/encryption/s3/S3EncryptionClientStreamTest.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import javax.crypto.KeyGenerator;
3535
import javax.crypto.SecretKey;
3636
import java.io.BufferedInputStream;
37+
import java.io.ByteArrayInputStream;
3738
import java.io.IOException;
3839
import java.io.InputStream;
3940
import java.nio.charset.StandardCharsets;
@@ -332,9 +333,12 @@ public void customSetBufferSizeWithLargeObject() throws IOException {
332333

333334
// Tight bound on the custom buffer size limit of 32MiB
334335
final long fileSizeExceedingDefaultLimit = 1024 * 1024 * 32 + 1;
335-
final InputStream largeObjectStream = new BufferedInputStream(
336-
new BoundedInputStream(fileSizeExceedingDefaultLimit)
337-
);
336+
337+
byte[] data = new byte[(int) fileSizeExceedingDefaultLimit];
338+
for(int j=0; j < data.length; j++) {
339+
data[i] = (byte) (j % 256);
340+
}
341+
final InputStream largeObjectStream = new ByteArrayInputStream(data);
338342
v3ClientWithBuffer32MiB.putObject(PutObjectRequest.builder()
339343
.bucket(BUCKET)
340344
.key(objectKey)
@@ -352,8 +356,9 @@ public void customSetBufferSizeWithLargeObject() throws IOException {
352356
.bucket(BUCKET)
353357
.key(objectKey));
354358

355-
356-
assertTrue(IOUtils.contentEquals(new BoundedInputStream(fileSizeExceedingDefaultLimit), response));
359+
// Create a new ByteArrayInputStream for comparison
360+
InputStream expectedStream = new ByteArrayInputStream(data);
361+
assertTrue(IOUtils.contentEquals(expectedStream, response));
357362
response.close();
358363

359364
// Cleanup

0 commit comments

Comments
 (0)