This is an automated email from the ASF dual-hosted git repository. aduprat pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 2a2af7101ec83fa49173412499ea569f84200b36 Author: Rene Cordier <rcord...@linagora.com> AuthorDate: Tue Jul 2 10:39:04 2019 +0700 JAMES-2806 add tests for deleteBucket with UnionBlobStore --- .../james/blob/union/UnionBlobStoreTest.java | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/server/blob/blob-union/src/test/java/org/apache/james/blob/union/UnionBlobStoreTest.java b/server/blob/blob-union/src/test/java/org/apache/james/blob/union/UnionBlobStoreTest.java index a44fd0d..1789129 100644 --- a/server/blob/blob-union/src/test/java/org/apache/james/blob/union/UnionBlobStoreTest.java +++ b/server/blob/blob-union/src/test/java/org/apache/james/blob/union/UnionBlobStoreTest.java @@ -489,4 +489,43 @@ class UnionBlobStoreTest implements BlobStoreContract { assertThat(pushBackIS) .hasSameContentAs(new ByteArrayInputStream(new byte[0])); } + + @Test + void deleteBucketShouldDeleteBothCurrentAndLegacyBuckets() { + BlobId legacyBlobId = legacyBlobStore.save(BucketName.DEFAULT, BLOB_CONTENT).block(); + BlobId currentBlobId = currentBlobStore.save(BucketName.DEFAULT, BLOB_CONTENT).block(); + + unionBlobStore.deleteBucket(BucketName.DEFAULT).block(); + + assertThatThrownBy(() -> legacyBlobStore.readBytes(BucketName.DEFAULT, legacyBlobId).block()) + .isInstanceOf(ObjectStoreException.class); + assertThatThrownBy(() -> currentBlobStore.readBytes(BucketName.DEFAULT, currentBlobId).block()) + .isInstanceOf(ObjectStoreException.class); + } + + @Test + void deleteBucketShouldDeleteCurrentBucketEvenWhenLegacyDoesNotExist() { + BlobId currentBlobId = currentBlobStore.save(BucketName.DEFAULT, BLOB_CONTENT).block(); + + unionBlobStore.deleteBucket(BucketName.DEFAULT).block(); + + assertThatThrownBy(() -> currentBlobStore.readBytes(BucketName.DEFAULT, currentBlobId).block()) + .isInstanceOf(ObjectStoreException.class); + } + + @Test + void deleteBucketShouldDeleteLegacyBucketEvenWhenCurrentDoesNotExist() { + BlobId legacyBlobId = legacyBlobStore.save(BucketName.DEFAULT, BLOB_CONTENT).block(); + + unionBlobStore.deleteBucket(BucketName.DEFAULT).block(); + + assertThatThrownBy(() -> legacyBlobStore.readBytes(BucketName.DEFAULT, legacyBlobId).block()) + .isInstanceOf(ObjectStoreException.class); + } + + @Test + void deleteBucketShouldNotThrowWhenCurrentAndLegacyBucketsDoNotExist() { + assertThatCode(() -> unionBlobStore.deleteBucket(BucketName.DEFAULT).block()) + .doesNotThrowAnyException(); + } } --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org