@@ -182,6 +182,29 @@ public void testNewInputStreamWithAccessPoint() throws Exception {
182182 validateRead (s3FileIO );
183183 }
184184
185+ @ Test
186+ public void testCrossRegionAccessEnabled () throws Exception {
187+ clientFactory .initialize (
188+ ImmutableMap .of (S3FileIOProperties .CROSS_REGION_ACCESS_ENABLED , "true" ));
189+ S3Client s3Client = clientFactory .s3 ();
190+ String crossBucketObjectKey = String .format ("%s/%s" , prefix , UUID .randomUUID ());
191+ String crossBucketObjectUri =
192+ String .format ("s3://%s/%s" , crossRegionBucketName , crossBucketObjectKey );
193+ try {
194+ s3Client .putObject (
195+ PutObjectRequest .builder ()
196+ .bucket (crossRegionBucketName )
197+ .key (crossBucketObjectKey )
198+ .build (),
199+ RequestBody .fromBytes (contentBytes ));
200+ // make a copy in cross-region bucket
201+ S3FileIO s3FileIO = new S3FileIO (clientFactory ::s3 );
202+ validateRead (s3FileIO , crossBucketObjectUri );
203+ } finally {
204+ AwsIntegTestUtil .cleanS3Bucket (s3Client , crossRegionBucketName , crossBucketObjectKey );
205+ }
206+ }
207+
185208 @ Test
186209 public void testNewInputStreamWithCrossRegionAccessPoint () throws Exception {
187210 clientFactory .initialize (ImmutableMap .of (S3FileIOProperties .USE_ARN_REGION_ENABLED , "true" ));
@@ -550,6 +573,10 @@ private void write(S3FileIO s3FileIO, String uri) throws Exception {
550573 }
551574
552575 private void validateRead (S3FileIO s3FileIO ) throws Exception {
576+ validateRead (s3FileIO , objectUri );
577+ }
578+
579+ private void validateRead (S3FileIO s3FileIO , String objectUri ) throws Exception {
553580 InputFile file = s3FileIO .newInputFile (objectUri );
554581 assertThat (file .getLength ()).isEqualTo (contentBytes .length );
555582 try (InputStream stream = file .newStream ()) {
0 commit comments