Fix AWS S3 integration test should remove all objects in finally block
@@ -164,6 +164,7 @@ class Aws2S3Test {
final String oid = UUID.randomUUID().toString();
final String blobContent = "Hello KMS " + oid;
+ try {
// Create
RestAssured.given()
.contentType(ContentType.TEXT)
@@ -177,16 +178,18 @@ class Aws2S3Test {
.then()
.statusCode(200)
.body(is(blobContent));
-
+ } finally {
// Delete
deleteObject(oid);
}
+ }
@Test
public void upload() throws Exception {
final String oid = UUID.randomUUID().toString();
final String content = RandomStringUtils.randomAlphabetic(8 * 1024 * 1024);
+ try {
RestAssured.given()
.contentType(ContentType.TEXT)
.body(content)
@@ -199,12 +202,13 @@ class Aws2S3Test {
.statusCode(200)
.extract().asString();
- // Delete
- deleteObject(oid);
-
// strip the chuck-signature
result = result.replaceAll("\\s*[0-9]+;chunk-signature=\\w{64}\\s*", "");
assertEquals(content, result);
+ } finally {
+ // Delete
+ deleteObject(oid);
+ }
}
@Test
@@ -284,6 +288,7 @@ class Aws2S3Test {
final String oid = UUID.randomUUID().toString();
final String blobContent = "Hello " + oid;
+ try {
// Create
createObject(oid, blobContent);
@@ -294,15 +299,18 @@ class Aws2S3Test {
.then()
.statusCode(200);
+ } finally {
// Delete
deleteObject(oid);
}
+ }
@Test
public void objectRange() {
final String oid = UUID.randomUUID().toString();
final String blobContent = "Hello " + oid;
+ try {
// Create
createObject(oid, blobContent);
@@ -314,10 +322,11 @@ class Aws2S3Test {
.then()
.statusCode(200)
.body(is("Hello"));
-
+ } finally {
// Delete
deleteObject(oid);
}
+ }
private void createObject(String oid, String blobContent) {
RestAssured.given()
