18
18
import static software .amazon .awssdk .testutils .service .S3BucketUtils .temporaryBucketName ;
19
19
20
20
import java .util .StringJoiner ;
21
+ import org .junit .AfterClass ;
21
22
import org .junit .BeforeClass ;
22
23
import org .junit .Test ;
23
24
import software .amazon .awssdk .core .sync .RequestBody ;
24
25
import software .amazon .awssdk .regions .Region ;
25
26
import software .amazon .awssdk .services .s3 .model .GetObjectRequest ;
26
27
import software .amazon .awssdk .services .s3 .model .PutObjectRequest ;
27
28
import software .amazon .awssdk .services .s3control .S3ControlClient ;
28
- import software .amazon .awssdk .services .s3control .model .S3ControlException ;
29
29
import software .amazon .awssdk .services .sts .StsClient ;
30
30
31
31
public class AccessPointsIntegrationTest extends S3IntegrationTestBase {
32
32
33
- private static final String BUCKET = temporaryBucketName (AclIntegrationTest .class );
33
+ private static final String BUCKET = temporaryBucketName (AccessPointsIntegrationTest .class );
34
34
35
- private static final String AP_NAME = "java-sdk" ;
35
+ private static final String AP_NAME = "java-sdk-" + System . currentTimeMillis () ;
36
36
37
37
private static final String KEY = "some-key" ;
38
38
@@ -57,14 +57,15 @@ public static void setupFixture() {
57
57
.build ();
58
58
59
59
accountId = sts .getCallerIdentity ().account ();
60
+ s3control .createAccessPoint (r -> r .accountId (accountId )
61
+ .bucket (BUCKET )
62
+ .name (AP_NAME ));
63
+ }
60
64
61
- try {
62
- s3control .createAccessPoint (r -> r .accountId (accountId )
63
- .bucket (BUCKET )
64
- .name (AP_NAME ));
65
- } catch (S3ControlException e ) {
66
- // Do nothing as the access point is already created
67
- }
65
+ @ AfterClass
66
+ public static void tearDown () {
67
+ deleteBucketAndAllContents (BUCKET );
68
+ s3control .deleteAccessPoint (b -> b .accountId (accountId ).name (AP_NAME ));
68
69
}
69
70
70
71
@ Test
0 commit comments