Search in sources :

Example 16 with S3Options

use of org.apache.beam.sdk.io.aws2.options.S3Options in project beam by apache.

the class S3FileSystemTest method matchNonGlobForbiddenWithS3Options.

@Test
public void matchNonGlobForbiddenWithS3Options() {
    S3FileSystem s3FileSystem = buildMockedS3FileSystem(s3Options());
    SdkServiceException exception = S3Exception.builder().message("mock exception").statusCode(403).build();
    S3ResourceId path = S3ResourceId.fromUri("s3://testbucket/testdirectory/keyname");
    when(s3FileSystem.getS3Client().headObject(argThat(new GetHeadObjectRequestMatcher(HeadObjectRequest.builder().bucket(path.getBucket()).key(path.getKey()).build())))).thenThrow(exception);
    assertThat(s3FileSystem.matchNonGlobPath(path), MatchResultMatcher.create(MatchResult.Status.ERROR, new IOException(exception)));
}
Also used : SdkServiceException(software.amazon.awssdk.core.exception.SdkServiceException) IOException(java.io.IOException) S3TestUtils.buildMockedS3FileSystem(org.apache.beam.sdk.io.aws2.s3.S3TestUtils.buildMockedS3FileSystem) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)9 S3Options (org.apache.beam.sdk.io.aws2.options.S3Options)8 S3TestUtils.buildMockedS3FileSystem (org.apache.beam.sdk.io.aws2.s3.S3TestUtils.buildMockedS3FileSystem)7 MatchResult (org.apache.beam.sdk.io.fs.MatchResult)4 HeadObjectResponse (software.amazon.awssdk.services.s3.model.HeadObjectResponse)3 SdkServiceException (software.amazon.awssdk.core.exception.SdkServiceException)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 SSECustomerKey (org.apache.beam.sdk.io.aws2.s3.SSECustomerKey)1 DeleteObjectsRequest (software.amazon.awssdk.services.s3.model.DeleteObjectsRequest)1