This is an automated email from the ASF dual-hosted git repository. btellier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 54bac2e7a93496dec8f102bf90fafbc810466ac9 Author: Tran Tien Duc <[email protected]> AuthorDate: Wed Jun 26 17:28:10 2019 +0700 JAMES-2806 Replace BucketName.DEFAULT by blobStore.getDefaultBucketName in everywhere possible --- .../cassandra/mail/CassandraAttachmentMapper.java | 7 +- .../cassandra/mail/CassandraMessageDAO.java | 7 +- .../mail/migration/AttachmentV2Migration.java | 3 +- .../mail/CassandraAttachmentFallbackTest.java | 7 +- .../mail/migration/AttachmentV2MigrationTest.java | 16 ++-- .../main/java/org/apache/james/blob/api/Store.java | 4 +- .../apache/james/blob/api/BlobStoreContract.java | 52 ++++++------ .../blob/api/MetricableBlobStoreContract.java | 24 +++--- .../blob/cassandra/CassandraBlobsDAOTest.java | 9 +-- .../export/file/LocalFileBlobExportMechanism.java | 3 +- .../file/LocalFileBlobExportMechanismTest.java | 11 ++- .../ObjectStorageBlobsDAOContract.java | 8 +- .../objectstorage/ObjectStorageBlobsDAOTest.java | 38 ++++----- .../aws/AwsS3ObjectStorageBlobsDAOBuilderTest.java | 14 ++-- ...tKeystone2ObjectStorageBlobsDAOBuilderTest.java | 13 +-- ...tKeystone3ObjectStorageBlobsDAOBuilderTest.java | 13 +-- ...ftTempAuthObjectStorageBlobsDAOBuilderTest.java | 13 +-- .../james/blob/union/UnionBlobStoreTest.java | 94 +++++++++++----------- .../james/blob/mail/MimeMessageStoreTest.java | 5 +- .../objectstorage/aws/s3/DockerAwsS3TestRule.java | 4 +- .../objectstorage/swift/DockerSwiftTestRule.java | 4 +- .../swift/ObjectStorageBlobStoreModuleTest.java | 2 +- .../james/webadmin/vault/routes/ExportService.java | 3 +- .../routes/DeletedMessagesVaultRoutesTest.java | 3 +- .../linshare/LinshareBlobExportMechanism.java | 3 +- .../linshare/LinshareBlobExportMechanismTest.java | 9 +-- 26 files changed, 181 insertions(+), 188 deletions(-) diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentMapper.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentMapper.java index 38f840e..449a639 100644 --- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentMapper.java +++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentMapper.java @@ -25,7 +25,6 @@ import java.util.List; import javax.inject.Inject; import org.apache.james.blob.api.BlobStore; -import org.apache.james.blob.api.BucketName; import org.apache.james.mailbox.cassandra.mail.CassandraAttachmentDAOV2.DAOAttachment; import org.apache.james.mailbox.exception.AttachmentNotFoundException; import org.apache.james.mailbox.exception.MailboxException; @@ -80,7 +79,7 @@ public class CassandraAttachmentMapper implements AttachmentMapper { } private Mono<Attachment> retrievePayload(DAOAttachment daoAttachment) { - return blobStore.readBytes(BucketName.DEFAULT, daoAttachment.getBlobId()) + return blobStore.readBytes(blobStore.getDefaultBucketName(), daoAttachment.getBlobId()) .map(daoAttachment::toAttachment); } @@ -111,7 +110,7 @@ public class CassandraAttachmentMapper implements AttachmentMapper { @Override public void storeAttachmentForOwner(Attachment attachment, Username owner) throws MailboxException { ownerDAO.addOwner(attachment.getAttachmentId(), owner) - .then(blobStore.save(BucketName.DEFAULT, attachment.getBytes())) + .then(blobStore.save(blobStore.getDefaultBucketName(), attachment.getBytes())) .map(blobId -> CassandraAttachmentDAOV2.from(attachment, blobId)) .flatMap(attachmentDAOV2::storeAttachment) .block(); @@ -138,7 +137,7 @@ public class CassandraAttachmentMapper implements AttachmentMapper { } public Mono<Void> storeAttachmentAsync(Attachment attachment, MessageId ownerMessageId) { - return blobStore.save(BucketName.DEFAULT, attachment.getBytes()) + return blobStore.save(blobStore.getDefaultBucketName(), attachment.getBytes()) .map(blobId -> CassandraAttachmentDAOV2.from(attachment, blobId)) .flatMap(daoAttachment -> storeAttachmentWithIndex(daoAttachment, ownerMessageId)); } diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAO.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAO.java index 8457cbd..de53a32 100644 --- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAO.java +++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAO.java @@ -57,7 +57,6 @@ import org.apache.james.backends.cassandra.init.configuration.CassandraConfigura import org.apache.james.backends.cassandra.utils.CassandraAsyncExecutor; import org.apache.james.blob.api.BlobId; import org.apache.james.blob.api.BlobStore; -import org.apache.james.blob.api.BucketName; import org.apache.james.mailbox.cassandra.ids.CassandraMessageId; import org.apache.james.mailbox.cassandra.table.CassandraMessageV2Table; import org.apache.james.mailbox.cassandra.table.CassandraMessageV2Table.Attachments; @@ -183,8 +182,8 @@ public class CassandraMessageDAO { byte[] headerContent = IOUtils.toByteArray(message.getHeaderContent()); byte[] bodyContent = IOUtils.toByteArray(message.getBodyContent()); - Mono<BlobId> bodyFuture = blobStore.save(BucketName.DEFAULT, bodyContent); - Mono<BlobId> headerFuture = blobStore.save(BucketName.DEFAULT, headerContent); + Mono<BlobId> bodyFuture = blobStore.save(blobStore.getDefaultBucketName(), bodyContent); + Mono<BlobId> headerFuture = blobStore.save(blobStore.getDefaultBucketName(), headerContent); return headerFuture.zipWith(bodyFuture); } catch (IOException e) { @@ -359,7 +358,7 @@ public class CassandraMessageDAO { } private Mono<byte[]> getFieldContent(String field, Row row) { - return blobStore.readBytes(BucketName.DEFAULT, blobIdFactory.from(row.getString(field))); + return blobStore.readBytes(blobStore.getDefaultBucketName(), blobIdFactory.from(row.getString(field))); } public static MessageResult notFound(ComposedMessageIdWithMetaData id) { diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/migration/AttachmentV2Migration.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/migration/AttachmentV2Migration.java index 308d090..1bcb329 100644 --- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/migration/AttachmentV2Migration.java +++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/migration/AttachmentV2Migration.java @@ -23,7 +23,6 @@ import javax.inject.Inject; import org.apache.james.backends.cassandra.migration.Migration; import org.apache.james.blob.api.BlobStore; -import org.apache.james.blob.api.BucketName; import org.apache.james.mailbox.cassandra.mail.CassandraAttachmentDAO; import org.apache.james.mailbox.cassandra.mail.CassandraAttachmentDAOV2; import org.apache.james.mailbox.model.Attachment; @@ -63,7 +62,7 @@ public class AttachmentV2Migration implements Migration { } private Mono<Result> migrateAttachment(Attachment attachment) { - return blobStore.save(BucketName.DEFAULT, attachment.getBytes()) + return blobStore.save(blobStore.getDefaultBucketName(), attachment.getBytes()) .map(blobId -> CassandraAttachmentDAOV2.from(attachment, blobId)) .flatMap(attachmentDAOV2::storeAttachment) .then(attachmentDAOV1.deleteAttachment(attachment.getAttachmentId())) diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentFallbackTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentFallbackTest.java index cd6b58b..1be26d1 100644 --- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentFallbackTest.java +++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentFallbackTest.java @@ -31,7 +31,6 @@ import org.apache.james.backends.cassandra.CassandraRestartExtension; import org.apache.james.backends.cassandra.components.CassandraModule; import org.apache.james.backends.cassandra.init.configuration.CassandraConfiguration; import org.apache.james.blob.api.BlobId; -import org.apache.james.blob.api.BucketName; import org.apache.james.blob.api.HashBlobId; import org.apache.james.blob.cassandra.CassandraBlobModule; import org.apache.james.blob.cassandra.CassandraBlobsDAO; @@ -102,7 +101,7 @@ class CassandraAttachmentFallbackTest { .bytes("{\"property\":`\"different\"}".getBytes(StandardCharsets.UTF_8)) .build(); - BlobId blobId = blobsDAO.save(BucketName.DEFAULT, attachment.getBytes()).block(); + BlobId blobId = blobsDAO.save(blobsDAO.getDefaultBucketName(), attachment.getBytes()).block(); attachmentDAOV2.storeAttachment(CassandraAttachmentDAOV2.from(attachment, blobId)).block(); attachmentDAO.storeAttachment(otherAttachment).block(); @@ -137,7 +136,7 @@ class CassandraAttachmentFallbackTest { .bytes("{\"property\":`\"different\"}".getBytes(StandardCharsets.UTF_8)) .build(); - BlobId blobId = blobsDAO.save(BucketName.DEFAULT, attachment.getBytes()).block(); + BlobId blobId = blobsDAO.save(blobsDAO.getDefaultBucketName(), attachment.getBytes()).block(); attachmentDAOV2.storeAttachment(CassandraAttachmentDAOV2.from(attachment, blobId)).block(); attachmentDAO.storeAttachment(otherAttachment).block(); @@ -172,7 +171,7 @@ class CassandraAttachmentFallbackTest { .bytes("{\"property\":`\"different\"}".getBytes(StandardCharsets.UTF_8)) .build(); - BlobId blobId = blobsDAO.save(BucketName.DEFAULT, attachment.getBytes()).block(); + BlobId blobId = blobsDAO.save(blobsDAO.getDefaultBucketName(), attachment.getBytes()).block(); attachmentDAOV2.storeAttachment(CassandraAttachmentDAOV2.from(attachment, blobId)).block(); attachmentDAO.storeAttachment(otherAttachment).block(); diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/migration/AttachmentV2MigrationTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/migration/AttachmentV2MigrationTest.java index d3ec71f..29aeede 100644 --- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/migration/AttachmentV2MigrationTest.java +++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/migration/AttachmentV2MigrationTest.java @@ -114,9 +114,9 @@ class AttachmentV2MigrationTest { .contains(CassandraAttachmentDAOV2.from(attachment1, BLOB_ID_FACTORY.forPayload(attachment1.getBytes()))); assertThat(attachmentDAOV2.getAttachment(ATTACHMENT_ID_2).blockOptional()) .contains(CassandraAttachmentDAOV2.from(attachment2, BLOB_ID_FACTORY.forPayload(attachment2.getBytes()))); - assertThat(blobsDAO.readBytes(BucketName.DEFAULT, BLOB_ID_FACTORY.forPayload(attachment1.getBytes())).block()) + assertThat(blobsDAO.readBytes(blobsDAO.getDefaultBucketName(), BLOB_ID_FACTORY.forPayload(attachment1.getBytes())).block()) .isEqualTo(attachment1.getBytes()); - assertThat(blobsDAO.readBytes(BucketName.DEFAULT, BLOB_ID_FACTORY.forPayload(attachment2.getBytes())).block()) + assertThat(blobsDAO.readBytes(blobsDAO.getDefaultBucketName(), BLOB_ID_FACTORY.forPayload(attachment2.getBytes())).block()) .isEqualTo(attachment2.getBytes()); } @@ -170,9 +170,9 @@ class AttachmentV2MigrationTest { when(attachmentDAO.retrieveAll()).thenReturn(Flux.just( attachment1, attachment2)); - when(blobsDAO.save(BucketName.DEFAULT, attachment1.getBytes())) + when(blobsDAO.save(blobsDAO.getDefaultBucketName(), attachment1.getBytes())) .thenReturn(Mono.just(BLOB_ID_FACTORY.forPayload(attachment1.getBytes()))); - when(blobsDAO.save(BucketName.DEFAULT, attachment2.getBytes())) + when(blobsDAO.save(blobsDAO.getDefaultBucketName(), attachment2.getBytes())) .thenReturn(Mono.just(BLOB_ID_FACTORY.forPayload(attachment2.getBytes()))); when(attachmentDAOV2.storeAttachment(any())).thenThrow(new RuntimeException()); @@ -189,9 +189,9 @@ class AttachmentV2MigrationTest { when(attachmentDAO.retrieveAll()).thenReturn(Flux.just( attachment1, attachment2)); - when(blobsDAO.save(BucketName.DEFAULT, attachment1.getBytes())) + when(blobsDAO.save(blobsDAO.getDefaultBucketName(), attachment1.getBytes())) .thenReturn(Mono.just(BLOB_ID_FACTORY.forPayload(attachment1.getBytes()))); - when(blobsDAO.save(BucketName.DEFAULT, attachment2.getBytes())) + when(blobsDAO.save(blobsDAO.getDefaultBucketName(), attachment2.getBytes())) .thenReturn(Mono.just(BLOB_ID_FACTORY.forPayload(attachment2.getBytes()))); when(attachmentDAOV2.storeAttachment(any())).thenReturn(Mono.empty()); when(attachmentDAO.deleteAttachment(any())).thenThrow(new RuntimeException()); @@ -209,9 +209,9 @@ class AttachmentV2MigrationTest { when(attachmentDAO.retrieveAll()).thenReturn(Flux.just( attachment1, attachment2)); - when(blobsDAO.save(BucketName.DEFAULT, attachment1.getBytes())) + when(blobsDAO.save(blobsDAO.getDefaultBucketName(), attachment1.getBytes())) .thenReturn(Mono.just(BLOB_ID_FACTORY.forPayload(attachment1.getBytes()))); - when(blobsDAO.save(BucketName.DEFAULT, attachment2.getBytes())) + when(blobsDAO.save(blobsDAO.getDefaultBucketName(), attachment2.getBytes())) .thenThrow(new RuntimeException()); when(attachmentDAOV2.storeAttachment(any())).thenReturn(Mono.empty()); when(attachmentDAO.deleteAttachment(any())).thenReturn(Mono.empty()); diff --git a/server/blob/blob-api/src/main/java/org/apache/james/blob/api/Store.java b/server/blob/blob-api/src/main/java/org/apache/james/blob/api/Store.java index ce640d5..5feef59 100644 --- a/server/blob/blob-api/src/main/java/org/apache/james/blob/api/Store.java +++ b/server/blob/blob-api/src/main/java/org/apache/james/blob/api/Store.java @@ -112,7 +112,7 @@ public interface Store<T, I> { private Mono<Tuple2<BlobType, BlobId>> saveEntry(Pair<BlobType, ValueToSave> entry) { return Mono.just(entry.getLeft()) - .zipWith(entry.getRight().saveIn(BucketName.DEFAULT, blobStore)); + .zipWith(entry.getRight().saveIn(blobStore.getDefaultBucketName(), blobStore)); } @Override @@ -120,7 +120,7 @@ public interface Store<T, I> { return Flux.fromIterable(blobIds.asMap().entrySet()) .publishOn(Schedulers.elastic()) .flatMapSequential( - entry -> blobStore.readBytes(BucketName.DEFAULT, entry.getValue()) + entry -> blobStore.readBytes(blobStore.getDefaultBucketName(), entry.getValue()) .zipWith(Mono.just(entry.getKey()))) .map(entry -> Pair.of(entry.getT2(), entry.getT1())) .collectList() diff --git a/server/blob/blob-api/src/test/java/org/apache/james/blob/api/BlobStoreContract.java b/server/blob/blob-api/src/test/java/org/apache/james/blob/api/BlobStoreContract.java index 34ef95e..07d4588 100644 --- a/server/blob/blob-api/src/test/java/org/apache/james/blob/api/BlobStoreContract.java +++ b/server/blob/blob-api/src/test/java/org/apache/james/blob/api/BlobStoreContract.java @@ -44,59 +44,59 @@ public interface BlobStoreContract { @Test default void saveShouldThrowWhenNullData() { - assertThatThrownBy(() -> testee().save(BucketName.DEFAULT, (byte[]) null).block()) + assertThatThrownBy(() -> testee().save(testee().getDefaultBucketName(), (byte[]) null).block()) .isInstanceOf(NullPointerException.class); } @Test default void saveShouldThrowWhenNullString() { - assertThatThrownBy(() -> testee().save(BucketName.DEFAULT, (String) null).block()) + assertThatThrownBy(() -> testee().save(testee().getDefaultBucketName(), (String) null).block()) .isInstanceOf(NullPointerException.class); } @Test default void saveShouldThrowWhenNullInputStream() { - assertThatThrownBy(() -> testee().save(BucketName.DEFAULT, (InputStream) null).block()) + assertThatThrownBy(() -> testee().save(testee().getDefaultBucketName(), (InputStream) null).block()) .isInstanceOf(NullPointerException.class); } @Test default void saveShouldSaveEmptyData() { - BlobId blobId = testee().save(BucketName.DEFAULT, EMPTY_BYTEARRAY).block(); + BlobId blobId = testee().save(testee().getDefaultBucketName(), EMPTY_BYTEARRAY).block(); - byte[] bytes = testee().readBytes(BucketName.DEFAULT, blobId).block(); + byte[] bytes = testee().readBytes(testee().getDefaultBucketName(), blobId).block(); assertThat(new String(bytes, StandardCharsets.UTF_8)).isEmpty(); } @Test default void saveShouldSaveEmptyString() { - BlobId blobId = testee().save(BucketName.DEFAULT, new String()).block(); + BlobId blobId = testee().save(testee().getDefaultBucketName(), new String()).block(); - byte[] bytes = testee().readBytes(BucketName.DEFAULT, blobId).block(); + byte[] bytes = testee().readBytes(testee().getDefaultBucketName(), blobId).block(); assertThat(new String(bytes, StandardCharsets.UTF_8)).isEmpty(); } @Test default void saveShouldSaveEmptyInputStream() { - BlobId blobId = testee().save(BucketName.DEFAULT, new ByteArrayInputStream(EMPTY_BYTEARRAY)).block(); + BlobId blobId = testee().save(testee().getDefaultBucketName(), new ByteArrayInputStream(EMPTY_BYTEARRAY)).block(); - byte[] bytes = testee().readBytes(BucketName.DEFAULT, blobId).block(); + byte[] bytes = testee().readBytes(testee().getDefaultBucketName(), blobId).block(); assertThat(new String(bytes, StandardCharsets.UTF_8)).isEmpty(); } @Test default void saveShouldReturnBlobId() { - BlobId blobId = testee().save(BucketName.DEFAULT, SHORT_BYTEARRAY).block(); + BlobId blobId = testee().save(testee().getDefaultBucketName(), SHORT_BYTEARRAY).block(); assertThat(blobId).isEqualTo(blobIdFactory().from("31f7a65e315586ac198bd798b6629ce4903d0899476d5741a9f32e2e521b6a66")); } @Test default void saveShouldReturnBlobIdOfString() { - BlobId blobId = testee().save(BucketName.DEFAULT, SHORT_STRING).block(); + BlobId blobId = testee().save(testee().getDefaultBucketName(), SHORT_STRING).block(); assertThat(blobId).isEqualTo(blobIdFactory().from("31f7a65e315586ac198bd798b6629ce4903d0899476d5741a9f32e2e521b6a66")); } @@ -104,64 +104,64 @@ public interface BlobStoreContract { @Test default void saveShouldReturnBlobIdOfInputStream() { BlobId blobId = - testee().save(BucketName.DEFAULT, new ByteArrayInputStream(SHORT_BYTEARRAY)).block(); + testee().save(testee().getDefaultBucketName(), new ByteArrayInputStream(SHORT_BYTEARRAY)).block(); assertThat(blobId).isEqualTo(blobIdFactory().from("31f7a65e315586ac198bd798b6629ce4903d0899476d5741a9f32e2e521b6a66")); } @Test default void readBytesShouldThrowWhenNoExisting() { - assertThatThrownBy(() -> testee().readBytes(BucketName.DEFAULT, blobIdFactory().from("unknown")).block()) + assertThatThrownBy(() -> testee().readBytes(testee().getDefaultBucketName(), blobIdFactory().from("unknown")).block()) .isExactlyInstanceOf(ObjectStoreException.class); } @Test default void readBytesShouldReturnSavedData() { - BlobId blobId = testee().save(BucketName.DEFAULT, SHORT_BYTEARRAY).block(); + BlobId blobId = testee().save(testee().getDefaultBucketName(), SHORT_BYTEARRAY).block(); - byte[] bytes = testee().readBytes(BucketName.DEFAULT, blobId).block(); + byte[] bytes = testee().readBytes(testee().getDefaultBucketName(), blobId).block(); assertThat(bytes).isEqualTo(SHORT_BYTEARRAY); } @Test default void readBytesShouldReturnLongSavedData() { - BlobId blobId = testee().save(BucketName.DEFAULT, ELEVEN_KILOBYTES).block(); + BlobId blobId = testee().save(testee().getDefaultBucketName(), ELEVEN_KILOBYTES).block(); - byte[] bytes = testee().readBytes(BucketName.DEFAULT, blobId).block(); + byte[] bytes = testee().readBytes(testee().getDefaultBucketName(), blobId).block(); assertThat(bytes).isEqualTo(ELEVEN_KILOBYTES); } @Test default void readBytesShouldReturnBigSavedData() { - BlobId blobId = testee().save(BucketName.DEFAULT, TWELVE_MEGABYTES).block(); + BlobId blobId = testee().save(testee().getDefaultBucketName(), TWELVE_MEGABYTES).block(); - byte[] bytes = testee().readBytes(BucketName.DEFAULT, blobId).block(); + byte[] bytes = testee().readBytes(testee().getDefaultBucketName(), blobId).block(); assertThat(bytes).isEqualTo(TWELVE_MEGABYTES); } @Test default void readShouldThrowWhenNoExistingStream() { - assertThatThrownBy(() -> testee().read(BucketName.DEFAULT, blobIdFactory().from("unknown"))) + assertThatThrownBy(() -> testee().read(testee().getDefaultBucketName(), blobIdFactory().from("unknown"))) .isInstanceOf(ObjectStoreException.class); } @Test default void readShouldReturnSavedData() { - BlobId blobId = testee().save(BucketName.DEFAULT, SHORT_BYTEARRAY).block(); + BlobId blobId = testee().save(testee().getDefaultBucketName(), SHORT_BYTEARRAY).block(); - InputStream read = testee().read(BucketName.DEFAULT, blobId); + InputStream read = testee().read(testee().getDefaultBucketName(), blobId); assertThat(read).hasSameContentAs(new ByteArrayInputStream(SHORT_BYTEARRAY)); } @Test default void readShouldReturnLongSavedData() { - BlobId blobId = testee().save(BucketName.DEFAULT, ELEVEN_KILOBYTES).block(); + BlobId blobId = testee().save(testee().getDefaultBucketName(), ELEVEN_KILOBYTES).block(); - InputStream read = testee().read(BucketName.DEFAULT, blobId); + InputStream read = testee().read(testee().getDefaultBucketName(), blobId); assertThat(read).hasSameContentAs(new ByteArrayInputStream(ELEVEN_KILOBYTES)); } @@ -169,9 +169,9 @@ public interface BlobStoreContract { @Test default void readShouldReturnBigSavedData() { // 12 MB of text - BlobId blobId = testee().save(BucketName.DEFAULT, TWELVE_MEGABYTES).block(); + BlobId blobId = testee().save(testee().getDefaultBucketName(), TWELVE_MEGABYTES).block(); - InputStream read = testee().read(BucketName.DEFAULT, blobId); + InputStream read = testee().read(testee().getDefaultBucketName(), blobId); assertThat(read).hasSameContentAs(new ByteArrayInputStream(TWELVE_MEGABYTES)); } diff --git a/server/blob/blob-api/src/test/java/org/apache/james/blob/api/MetricableBlobStoreContract.java b/server/blob/blob-api/src/test/java/org/apache/james/blob/api/MetricableBlobStoreContract.java index 983c516..38f5188 100644 --- a/server/blob/blob-api/src/test/java/org/apache/james/blob/api/MetricableBlobStoreContract.java +++ b/server/blob/blob-api/src/test/java/org/apache/james/blob/api/MetricableBlobStoreContract.java @@ -58,8 +58,8 @@ public interface MetricableBlobStoreContract extends BlobStoreContract { @Test default void saveBytesShouldPublishSaveBytesTimerMetrics() { - testee().save(BucketName.DEFAULT, BYTES_CONTENT).block(); - testee().save(BucketName.DEFAULT, BYTES_CONTENT).block(); + testee().save(testee().getDefaultBucketName(), BYTES_CONTENT).block(); + testee().save(testee().getDefaultBucketName(), BYTES_CONTENT).block(); assertThat(metricsTestExtension.getMetricFactory().executionTimesFor(SAVE_BYTES_TIMER_NAME)) .hasSize(2); @@ -67,8 +67,8 @@ public interface MetricableBlobStoreContract extends BlobStoreContract { @Test default void saveStringShouldPublishSaveBytesTimerMetrics() { - testee().save(BucketName.DEFAULT, STRING_CONTENT).block(); - testee().save(BucketName.DEFAULT, STRING_CONTENT).block(); + testee().save(testee().getDefaultBucketName(), STRING_CONTENT).block(); + testee().save(testee().getDefaultBucketName(), STRING_CONTENT).block(); assertThat(metricsTestExtension.getMetricFactory().executionTimesFor(SAVE_BYTES_TIMER_NAME)) .hasSize(2); @@ -76,8 +76,8 @@ public interface MetricableBlobStoreContract extends BlobStoreContract { @Test default void saveInputStreamShouldPublishSaveInputStreamTimerMetrics() { - testee().save(BucketName.DEFAULT, new ByteArrayInputStream(BYTES_CONTENT)).block(); - testee().save(BucketName.DEFAULT, new ByteArrayInputStream(BYTES_CONTENT)).block(); + testee().save(testee().getDefaultBucketName(), new ByteArrayInputStream(BYTES_CONTENT)).block(); + testee().save(testee().getDefaultBucketName(), new ByteArrayInputStream(BYTES_CONTENT)).block(); assertThat(metricsTestExtension.getMetricFactory().executionTimesFor(SAVE_INPUT_STREAM_TIMER_NAME)) .hasSize(2); @@ -85,9 +85,9 @@ public interface MetricableBlobStoreContract extends BlobStoreContract { @Test default void readBytesShouldPublishReadBytesTimerMetrics() { - BlobId blobId = testee().save(BucketName.DEFAULT, BYTES_CONTENT).block(); - testee().readBytes(BucketName.DEFAULT, blobId).block(); - testee().readBytes(BucketName.DEFAULT, blobId).block(); + BlobId blobId = testee().save(testee().getDefaultBucketName(), BYTES_CONTENT).block(); + testee().readBytes(testee().getDefaultBucketName(), blobId).block(); + testee().readBytes(testee().getDefaultBucketName(), blobId).block(); assertThat(metricsTestExtension.getMetricFactory().executionTimesFor(READ_BYTES_TIMER_NAME)) .hasSize(2); @@ -95,9 +95,9 @@ public interface MetricableBlobStoreContract extends BlobStoreContract { @Test default void readShouldPublishReadTimerMetrics() { - BlobId blobId = testee().save(BucketName.DEFAULT, BYTES_CONTENT).block(); - testee().read(BucketName.DEFAULT, blobId); - testee().read(BucketName.DEFAULT, blobId); + BlobId blobId = testee().save(testee().getDefaultBucketName(), BYTES_CONTENT).block(); + testee().read(testee().getDefaultBucketName(), blobId); + testee().read(testee().getDefaultBucketName(), blobId); assertThat(metricsTestExtension.getMetricFactory().executionTimesFor(READ_TIMER_NAME)) .hasSize(2); diff --git a/server/blob/blob-cassandra/src/test/java/org/apache/james/blob/cassandra/CassandraBlobsDAOTest.java b/server/blob/blob-cassandra/src/test/java/org/apache/james/blob/cassandra/CassandraBlobsDAOTest.java index 23e3375..5bf792f 100644 --- a/server/blob/blob-cassandra/src/test/java/org/apache/james/blob/cassandra/CassandraBlobsDAOTest.java +++ b/server/blob/blob-cassandra/src/test/java/org/apache/james/blob/cassandra/CassandraBlobsDAOTest.java @@ -29,7 +29,6 @@ import org.apache.james.backends.cassandra.CassandraClusterExtension; import org.apache.james.backends.cassandra.init.configuration.CassandraConfiguration; import org.apache.james.blob.api.BlobId; import org.apache.james.blob.api.BlobStore; -import org.apache.james.blob.api.BucketName; import org.apache.james.blob.api.HashBlobId; import org.apache.james.blob.api.MetricableBlobStore; import org.apache.james.blob.api.MetricableBlobStoreContract; @@ -80,17 +79,17 @@ public class CassandraBlobsDAOTest implements MetricableBlobStoreContract { @Test void readBytesShouldReturnSplitSavedDataByChunk() { String longString = Strings.repeat("0123456789\n", MULTIPLE_CHUNK_SIZE); - BlobId blobId = testee.save(BucketName.DEFAULT, longString).block(); + BlobId blobId = testee.save(testee.getDefaultBucketName(), longString).block(); - byte[] bytes = testee.readBytes(BucketName.DEFAULT, blobId).block(); + byte[] bytes = testee.readBytes(testee.getDefaultBucketName(), blobId).block(); assertThat(new String(bytes, StandardCharsets.UTF_8)).isEqualTo(longString); } @Test void blobStoreShouldSupport100MBBlob() { - BlobId blobId = testee.save(BucketName.DEFAULT, new ZeroedInputStream(100_000_000)).block(); - InputStream bytes = testee.read(BucketName.DEFAULT, blobId); + BlobId blobId = testee.save(testee.getDefaultBucketName(), new ZeroedInputStream(100_000_000)).block(); + InputStream bytes = testee.read(testee.getDefaultBucketName(), blobId); assertThat(bytes).hasSameContentAs(new ZeroedInputStream(100_000_000)); } diff --git a/server/blob/blob-export-file/src/main/java/org/apache/james/blob/export/file/LocalFileBlobExportMechanism.java b/server/blob/blob-export-file/src/main/java/org/apache/james/blob/export/file/LocalFileBlobExportMechanism.java index d6b047e..5ec6e2c 100644 --- a/server/blob/blob-export-file/src/main/java/org/apache/james/blob/export/file/LocalFileBlobExportMechanism.java +++ b/server/blob/blob-export-file/src/main/java/org/apache/james/blob/export/file/LocalFileBlobExportMechanism.java @@ -30,7 +30,6 @@ import javax.inject.Inject; import org.apache.commons.io.FileUtils; import org.apache.james.blob.api.BlobId; import org.apache.james.blob.api.BlobStore; -import org.apache.james.blob.api.BucketName; import org.apache.james.blob.export.api.BlobExportMechanism; import org.apache.james.blob.export.api.ExportedFileNamesGenerator; import org.apache.james.blob.export.api.FileExtension; @@ -121,7 +120,7 @@ public class LocalFileBlobExportMechanism implements BlobExportMechanism { String fileName = ExportedFileNamesGenerator.generateFileName(fileCustomPrefix, blobId, fileExtension); String fileURL = configuration.exportDirectory + "/" + fileName; File file = fileSystem.getFile(fileURL); - FileUtils.copyToFile(blobStore.read(BucketName.DEFAULT, blobId), file); + FileUtils.copyToFile(blobStore.read(blobStore.getDefaultBucketName(), blobId), file); return file.getAbsolutePath(); } catch (IOException e) { diff --git a/server/blob/blob-export-file/src/test/java/org/apache/james/blob/export/file/LocalFileBlobExportMechanismTest.java b/server/blob/blob-export-file/src/test/java/org/apache/james/blob/export/file/LocalFileBlobExportMechanismTest.java index 6b4f196..c9adbc9 100644 --- a/server/blob/blob-export-file/src/test/java/org/apache/james/blob/export/file/LocalFileBlobExportMechanismTest.java +++ b/server/blob/blob-export-file/src/test/java/org/apache/james/blob/export/file/LocalFileBlobExportMechanismTest.java @@ -37,7 +37,6 @@ import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.IOUtils; import org.apache.james.blob.api.BlobId; import org.apache.james.blob.api.BlobStore; -import org.apache.james.blob.api.BucketName; import org.apache.james.blob.api.HashBlobId; import org.apache.james.blob.api.ObjectStoreException; import org.apache.james.blob.export.api.FileExtension; @@ -80,7 +79,7 @@ class LocalFileBlobExportMechanismTest { @Test void exportingBlobShouldSendAMail() { - BlobId blobId = blobStore.save(BucketName.DEFAULT, BLOB_CONTENT).block(); + BlobId blobId = blobStore.save(blobStore.getDefaultBucketName(), BLOB_CONTENT).block(); String explanation = "The content of a deleted message vault had been shared with you."; testee.blobId(blobId) @@ -113,7 +112,7 @@ class LocalFileBlobExportMechanismTest { @Test void exportingBlobShouldCreateAFileWithTheCorrespondingContent(FileSystem fileSystem) { - BlobId blobId = blobStore.save(BucketName.DEFAULT, BLOB_CONTENT).block(); + BlobId blobId = blobStore.save(blobStore.getDefaultBucketName(), BLOB_CONTENT).block(); testee.blobId(blobId) .with(MailAddressFixture.RECIPIENT1) @@ -151,7 +150,7 @@ class LocalFileBlobExportMechanismTest { @Test void exportingBlobShouldCreateAFileWithoutExtensionWhenNotDeclaringExtension() { - BlobId blobId = blobStore.save(BucketName.DEFAULT, BLOB_CONTENT).block(); + BlobId blobId = blobStore.save(blobStore.getDefaultBucketName(), BLOB_CONTENT).block(); testee.blobId(blobId) .with(MailAddressFixture.RECIPIENT1) @@ -175,7 +174,7 @@ class LocalFileBlobExportMechanismTest { @Test void exportingBlobShouldCreateAFileWithExtensionWhenDeclaringExtension() { - BlobId blobId = blobStore.save(BucketName.DEFAULT, BLOB_CONTENT).block(); + BlobId blobId = blobStore.save(blobStore.getDefaultBucketName(), BLOB_CONTENT).block(); testee.blobId(blobId) .with(MailAddressFixture.RECIPIENT1) @@ -200,7 +199,7 @@ class LocalFileBlobExportMechanismTest { @Test void exportingBlobShouldCreateAFileWithPrefixWhenDeclaringPrefix() { - BlobId blobId = blobStore.save(BucketName.DEFAULT, BLOB_CONTENT).block(); + BlobId blobId = blobStore.save(blobStore.getDefaultBucketName(), BLOB_CONTENT).block(); String filePrefix = "[email protected]"; testee.blobId(blobId) diff --git a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAOContract.java b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAOContract.java index ba597e2..f25393a 100644 --- a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAOContract.java +++ b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAOContract.java @@ -33,15 +33,15 @@ public interface ObjectStorageBlobsDAOContract { String CONTENT = "content"; - BucketName bucketName(); + BucketName defaultBucketName(); default void assertBlobsDAOCanStoreAndRetrieve(ObjectStorageBlobsDAOBuilder.ReadyToBuild builder) { ObjectStorageBlobsDAO dao = builder.build(); - dao.createBucket(bucketName()).block(); + dao.createBucket(dao.getDefaultBucketName()).block(); - BlobId blobId = dao.save(BucketName.DEFAULT, CONTENT).block(); + BlobId blobId = dao.save(dao.getDefaultBucketName(), CONTENT).block(); - InputStream inputStream = dao.read(BucketName.DEFAULT, blobId); + InputStream inputStream = dao.read(dao.getDefaultBucketName(), blobId); assertThat(inputStream).hasSameContentAs(IOUtils.toInputStream(CONTENT, StandardCharsets.UTF_8)); } } diff --git a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAOTest.java b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAOTest.java index ad794fe..14772bb 100644 --- a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAOTest.java +++ b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAOTest.java @@ -68,7 +68,7 @@ public class ObjectStorageBlobsDAOTest implements MetricableBlobStoreContract { .password(PASSWORD.value().toCharArray()) .build(); - private BucketName bucketName; + private BucketName defaultBucketName; private org.jclouds.blobstore.BlobStore blobStore; private SwiftTempAuthObjectStorage.Configuration testConfig; private ObjectStorageBlobsDAO objectStorageBlobsDAO; @@ -76,7 +76,7 @@ public class ObjectStorageBlobsDAOTest implements MetricableBlobStoreContract { @BeforeEach void setUp(DockerSwift dockerSwift) { - bucketName = BucketName.DEFAULT; + defaultBucketName = BucketName.of(UUID.randomUUID().toString()); testConfig = SwiftTempAuthObjectStorage.configBuilder() .endpoint(dockerSwift.swiftEndpoint()) .identity(SWIFT_IDENTITY) @@ -87,17 +87,17 @@ public class ObjectStorageBlobsDAOTest implements MetricableBlobStoreContract { BlobId.Factory blobIdFactory = blobIdFactory(); ObjectStorageBlobsDAOBuilder.ReadyToBuild daoBuilder = ObjectStorageBlobsDAO .builder(testConfig) - .defaultBucketName(bucketName) + .defaultBucketName(defaultBucketName) .blobIdFactory(blobIdFactory); blobStore = daoBuilder.getSupplier().get(); objectStorageBlobsDAO = daoBuilder.build(); - objectStorageBlobsDAO.createBucket(bucketName).block(); + objectStorageBlobsDAO.createBucket(defaultBucketName).block(); testee = new MetricableBlobStore(metricsTestExtension.getMetricFactory(), objectStorageBlobsDAO); } @AfterEach void tearDown() { - blobStore.deleteContainer(bucketName.asString()); + blobStore.deleteContainer(defaultBucketName.asString()); blobStore.getContext().close(); } @@ -137,14 +137,14 @@ public class ObjectStorageBlobsDAOTest implements MetricableBlobStoreContract { void supportsEncryptionWithCustomPayloadCodec() throws IOException { ObjectStorageBlobsDAO encryptedDao = ObjectStorageBlobsDAO .builder(testConfig) - .defaultBucketName(bucketName) + .defaultBucketName(defaultBucketName) .blobIdFactory(blobIdFactory()) .payloadCodec(new AESPayloadCodec(CRYPTO_CONFIG)) .build(); String content = "James is the best!"; - BlobId blobId = encryptedDao.save(BucketName.DEFAULT, content).block(); + BlobId blobId = encryptedDao.save(encryptedDao.getDefaultBucketName(), content).block(); - InputStream read = encryptedDao.read(BucketName.DEFAULT, blobId); + InputStream read = encryptedDao.read(encryptedDao.getDefaultBucketName(), blobId); String expectedContent = IOUtils.toString(read, Charsets.UTF_8); assertThat(content).isEqualTo(expectedContent); } @@ -153,27 +153,27 @@ public class ObjectStorageBlobsDAOTest implements MetricableBlobStoreContract { void encryptionWithCustomPayloadCodeCannotBeReadFromUnencryptedDAO() throws Exception { ObjectStorageBlobsDAO encryptedDao = ObjectStorageBlobsDAO .builder(testConfig) - .defaultBucketName(bucketName) + .defaultBucketName(defaultBucketName) .blobIdFactory(blobIdFactory()) .payloadCodec(new AESPayloadCodec(CRYPTO_CONFIG)) .build(); String content = "James is the best!"; - BlobId blobId = encryptedDao.save(BucketName.DEFAULT, content).block(); + BlobId blobId = encryptedDao.save(encryptedDao.getDefaultBucketName(), content).block(); - InputStream encryptedIs = testee.read(BucketName.DEFAULT, blobId); + InputStream encryptedIs = testee.read(encryptedDao.getDefaultBucketName(), blobId); assertThat(encryptedIs).isNotNull(); String encryptedString = IOUtils.toString(encryptedIs, Charsets.UTF_8); assertThat(encryptedString).isNotEqualTo(content); - InputStream clearTextIs = encryptedDao.read(BucketName.DEFAULT, blobId); + InputStream clearTextIs = encryptedDao.read(encryptedDao.getDefaultBucketName(), blobId); String expectedContent = IOUtils.toString(clearTextIs, Charsets.UTF_8); assertThat(content).isEqualTo(expectedContent); } @Test void deleteContainerShouldDeleteSwiftContainer() { - objectStorageBlobsDAO.deleteContainer(bucketName); - assertThat(blobStore.containerExists(bucketName.asString())) + objectStorageBlobsDAO.deleteContainer(defaultBucketName); + assertThat(blobStore.containerExists(defaultBucketName.asString())) .isFalse(); } @@ -181,7 +181,7 @@ public class ObjectStorageBlobsDAOTest implements MetricableBlobStoreContract { void saveBytesShouldNotCompleteWhenDoesNotAwait() { // String need to be big enough to get async thread busy hence could not return result instantly Mono<BlobId> blobIdFuture = testee - .save(BucketName.DEFAULT, BIG_STRING.getBytes(StandardCharsets.UTF_8)) + .save(testee.getDefaultBucketName(), BIG_STRING.getBytes(StandardCharsets.UTF_8)) .subscribeOn(Schedulers.elastic()); assertThat(blobIdFuture.toFuture()).isNotCompleted(); } @@ -189,7 +189,7 @@ public class ObjectStorageBlobsDAOTest implements MetricableBlobStoreContract { @Test void saveStringShouldNotCompleteWhenDoesNotAwait() { Mono<BlobId> blobIdFuture = testee - .save(BucketName.DEFAULT, BIG_STRING) + .save(testee.getDefaultBucketName(), BIG_STRING) .subscribeOn(Schedulers.elastic()); assertThat(blobIdFuture.toFuture()).isNotCompleted(); } @@ -197,15 +197,15 @@ public class ObjectStorageBlobsDAOTest implements MetricableBlobStoreContract { @Test void saveInputStreamShouldNotCompleteWhenDoesNotAwait() { Mono<BlobId> blobIdFuture = testee - .save(BucketName.DEFAULT, new ByteArrayInputStream(BIG_STRING.getBytes(StandardCharsets.UTF_8))) + .save(testee.getDefaultBucketName(), new ByteArrayInputStream(BIG_STRING.getBytes(StandardCharsets.UTF_8))) .subscribeOn(Schedulers.elastic()); assertThat(blobIdFuture.toFuture()).isNotCompleted(); } @Test void readBytesShouldNotCompleteWhenDoesNotAwait() { - BlobId blobId = testee().save(BucketName.DEFAULT, BIG_STRING).block(); - Mono<byte[]> resultFuture = testee.readBytes(BucketName.DEFAULT, blobId).subscribeOn(Schedulers.elastic()); + BlobId blobId = testee().save(testee.getDefaultBucketName(), BIG_STRING).block(); + Mono<byte[]> resultFuture = testee.readBytes(testee.getDefaultBucketName(), blobId).subscribeOn(Schedulers.elastic()); assertThat(resultFuture.toFuture()).isNotCompleted(); } } diff --git a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/aws/AwsS3ObjectStorageBlobsDAOBuilderTest.java b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/aws/AwsS3ObjectStorageBlobsDAOBuilderTest.java index 3501086..87b87f6 100644 --- a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/aws/AwsS3ObjectStorageBlobsDAOBuilderTest.java +++ b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/aws/AwsS3ObjectStorageBlobsDAOBuilderTest.java @@ -21,6 +21,8 @@ package org.apache.james.blob.objectstorage.aws; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import java.util.UUID; + import org.apache.james.blob.api.BucketName; import org.apache.james.blob.api.HashBlobId; import org.apache.james.blob.objectstorage.ObjectStorageBlobsDAO; @@ -34,14 +36,14 @@ import org.junit.jupiter.api.extension.ExtendWith; @ExtendWith(DockerAwsS3Extension.class) class AwsS3ObjectStorageBlobsDAOBuilderTest implements ObjectStorageBlobsDAOContract { - private BucketName bucketName; + private BucketName defaultBucketName; private AwsS3AuthConfiguration configuration; private AwsS3ObjectStorage awsS3ObjectStorage; @BeforeEach void setUp(DockerAwsS3Container dockerAwsS3Container) { awsS3ObjectStorage = new AwsS3ObjectStorage(); - bucketName = BucketName.DEFAULT; + defaultBucketName = BucketName.of(UUID.randomUUID().toString()); configuration = AwsS3AuthConfiguration.builder() .endpoint(dockerAwsS3Container.getEndpoint()) .accessKeyId(DockerAwsS3Container.ACCESS_KEY_ID) @@ -55,8 +57,8 @@ class AwsS3ObjectStorageBlobsDAOBuilderTest implements ObjectStorageBlobsDAOCont } @Override - public BucketName bucketName() { - return bucketName; + public BucketName defaultBucketName() { + return defaultBucketName; } @Test @@ -73,7 +75,7 @@ class AwsS3ObjectStorageBlobsDAOBuilderTest implements ObjectStorageBlobsDAOCont void blobIdFactoryIsMandatoryToBuildBlobsDAO() { ObjectStorageBlobsDAOBuilder.ReadyToBuild builder = ObjectStorageBlobsDAO .builder(configuration) - .defaultBucketName(bucketName) + .defaultBucketName(defaultBucketName) .blobIdFactory(null); assertThatThrownBy(builder::build).isInstanceOf(IllegalStateException.class); @@ -83,7 +85,7 @@ class AwsS3ObjectStorageBlobsDAOBuilderTest implements ObjectStorageBlobsDAOCont void builtBlobsDAOCanStoreAndRetrieve() { ObjectStorageBlobsDAOBuilder.ReadyToBuild builder = ObjectStorageBlobsDAO .builder(configuration) - .defaultBucketName(bucketName) + .defaultBucketName(defaultBucketName) .blobIdFactory(new HashBlobId.Factory()) .putBlob(awsS3ObjectStorage.putBlob(configuration)); diff --git a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/swift/SwiftKeystone2ObjectStorageBlobsDAOBuilderTest.java b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/swift/SwiftKeystone2ObjectStorageBlobsDAOBuilderTest.java index b1178a6..38d2386 100644 --- a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/swift/SwiftKeystone2ObjectStorageBlobsDAOBuilderTest.java +++ b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/swift/SwiftKeystone2ObjectStorageBlobsDAOBuilderTest.java @@ -22,6 +22,7 @@ package org.apache.james.blob.objectstorage.swift; import static org.assertj.core.api.Assertions.assertThatThrownBy; import java.net.URI; +import java.util.UUID; import org.apache.james.blob.api.BucketName; import org.apache.james.blob.api.HashBlobId; @@ -41,13 +42,13 @@ class SwiftKeystone2ObjectStorageBlobsDAOBuilderTest implements ObjectStorageBlo private static final UserName USER_NAME = UserName.of("demo"); private static final Credentials PASSWORD = Credentials.of("demo"); private static final Identity SWIFT_IDENTITY = Identity.of(TENANT_NAME, USER_NAME); - private BucketName bucketName; + private BucketName defaultBucketName; private URI endpoint; private SwiftKeystone2ObjectStorage.Configuration testConfig; @BeforeEach void setUp(DockerSwift dockerSwift) { - bucketName = BucketName.DEFAULT; + defaultBucketName = BucketName.of(UUID.randomUUID().toString()); endpoint = dockerSwift.keystoneV2Endpoint(); testConfig = SwiftKeystone2ObjectStorage.configBuilder() .endpoint(endpoint) @@ -57,8 +58,8 @@ class SwiftKeystone2ObjectStorageBlobsDAOBuilderTest implements ObjectStorageBlo } @Override - public BucketName bucketName() { - return bucketName; + public BucketName defaultBucketName() { + return defaultBucketName; } @Test @@ -75,7 +76,7 @@ class SwiftKeystone2ObjectStorageBlobsDAOBuilderTest implements ObjectStorageBlo void blobIdFactoryIsMandatoryToBuildBlobsDAO() { ObjectStorageBlobsDAOBuilder.ReadyToBuild builder = ObjectStorageBlobsDAO .builder(testConfig) - .defaultBucketName(bucketName) + .defaultBucketName(defaultBucketName) .blobIdFactory(null); assertThatThrownBy(builder::build).isInstanceOf(IllegalStateException.class); @@ -85,7 +86,7 @@ class SwiftKeystone2ObjectStorageBlobsDAOBuilderTest implements ObjectStorageBlo void builtBlobsDAOCanStoreAndRetrieve() { ObjectStorageBlobsDAOBuilder.ReadyToBuild builder = ObjectStorageBlobsDAO .builder(testConfig) - .defaultBucketName(bucketName) + .defaultBucketName(defaultBucketName) .blobIdFactory(new HashBlobId.Factory()); assertBlobsDAOCanStoreAndRetrieve(builder); diff --git a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/swift/SwiftKeystone3ObjectStorageBlobsDAOBuilderTest.java b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/swift/SwiftKeystone3ObjectStorageBlobsDAOBuilderTest.java index b7d24ae..246efae 100644 --- a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/swift/SwiftKeystone3ObjectStorageBlobsDAOBuilderTest.java +++ b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/swift/SwiftKeystone3ObjectStorageBlobsDAOBuilderTest.java @@ -23,6 +23,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import java.util.HashMap; import java.util.Map; +import java.util.UUID; import org.apache.james.blob.api.BucketName; import org.apache.james.blob.api.HashBlobId; @@ -68,7 +69,7 @@ class SwiftKeystone3ObjectStorageBlobsDAOBuilderTest implements ObjectStorageBlo .credentials(DEMO_PASSWORD) .project(Project.of(PROJECT_NAME, DOMAIN_ID)); - private BucketName bucketName; + private BucketName defaultBucketName; private SwiftKeystone3ObjectStorage.Configuration testConfig; private DockerSwift dockerSwift; @@ -77,7 +78,7 @@ class SwiftKeystone3ObjectStorageBlobsDAOBuilderTest implements ObjectStorageBlo @BeforeEach void setUp(DockerSwift dockerSwift) { this.dockerSwift = dockerSwift; - bucketName = BucketName.DEFAULT; + defaultBucketName = BucketName.of(UUID.randomUUID().toString()); testConfig = PROJECT_CONFIG .endpoint(dockerSwift.keystoneV3Endpoint()) .build(); @@ -90,8 +91,8 @@ class SwiftKeystone3ObjectStorageBlobsDAOBuilderTest implements ObjectStorageBlo } @Override - public BucketName bucketName() { - return bucketName; + public BucketName defaultBucketName() { + return defaultBucketName; } @Test @@ -108,7 +109,7 @@ class SwiftKeystone3ObjectStorageBlobsDAOBuilderTest implements ObjectStorageBlo void blobIdFactoryIsMandatoryToBuildBlobsDAO() { ObjectStorageBlobsDAOBuilder.ReadyToBuild builder = ObjectStorageBlobsDAO .builder(testConfig) - .defaultBucketName(bucketName) + .defaultBucketName(defaultBucketName) .blobIdFactory(null); assertThatThrownBy(builder::build).isInstanceOf(IllegalStateException.class); @@ -121,7 +122,7 @@ class SwiftKeystone3ObjectStorageBlobsDAOBuilderTest implements ObjectStorageBlo configBuilders.get(key).endpoint(dockerSwift.keystoneV3Endpoint()).build(); ObjectStorageBlobsDAOBuilder.ReadyToBuild builder = ObjectStorageBlobsDAO .builder(config) - .defaultBucketName(bucketName) + .defaultBucketName(defaultBucketName) .blobIdFactory(new HashBlobId.Factory()); assertBlobsDAOCanStoreAndRetrieve(builder); diff --git a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/swift/SwiftTempAuthObjectStorageBlobsDAOBuilderTest.java b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/swift/SwiftTempAuthObjectStorageBlobsDAOBuilderTest.java index 971d7f4..853b382 100644 --- a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/swift/SwiftTempAuthObjectStorageBlobsDAOBuilderTest.java +++ b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/swift/SwiftTempAuthObjectStorageBlobsDAOBuilderTest.java @@ -22,6 +22,7 @@ package org.apache.james.blob.objectstorage.swift; import static org.assertj.core.api.Assertions.assertThatThrownBy; import java.net.URI; +import java.util.UUID; import org.apache.james.blob.api.BucketName; import org.apache.james.blob.api.HashBlobId; @@ -41,13 +42,13 @@ class SwiftTempAuthObjectStorageBlobsDAOBuilderTest implements ObjectStorageBlob private static final UserName USER_NAME = UserName.of("tester"); private static final Credentials PASSWORD = Credentials.of("testing"); private static final Identity SWIFT_IDENTITY = Identity.of(TENANT_NAME, USER_NAME); - private BucketName bucketName; + private BucketName defaultBucketName; private URI endpoint; private SwiftTempAuthObjectStorage.Configuration testConfig; @BeforeEach void setUp(DockerSwift dockerSwift) { - bucketName = BucketName.DEFAULT; + defaultBucketName = BucketName.of(UUID.randomUUID().toString()); endpoint = dockerSwift.swiftEndpoint(); testConfig = SwiftTempAuthObjectStorage.configBuilder() .endpoint(endpoint) @@ -59,8 +60,8 @@ class SwiftTempAuthObjectStorageBlobsDAOBuilderTest implements ObjectStorageBlob } @Override - public BucketName bucketName() { - return bucketName; + public BucketName defaultBucketName() { + return defaultBucketName; } @Test @@ -77,7 +78,7 @@ class SwiftTempAuthObjectStorageBlobsDAOBuilderTest implements ObjectStorageBlob void blobIdFactoryIsMandatoryToBuildBlobsDAO() { ObjectStorageBlobsDAOBuilder.ReadyToBuild builder = ObjectStorageBlobsDAO .builder(testConfig) - .defaultBucketName(bucketName) + .defaultBucketName(defaultBucketName) .blobIdFactory(null); assertThatThrownBy(builder::build).isInstanceOf(IllegalStateException.class); @@ -87,7 +88,7 @@ class SwiftTempAuthObjectStorageBlobsDAOBuilderTest implements ObjectStorageBlob void builtBlobsDAOCanStoreAndRetrieve() { ObjectStorageBlobsDAOBuilder.ReadyToBuild builder = ObjectStorageBlobsDAO .builder(testConfig) - .defaultBucketName(bucketName) + .defaultBucketName(defaultBucketName) .blobIdFactory(new HashBlobId.Factory()); assertBlobsDAOCanStoreAndRetrieve(builder); 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 abda30a..ab197cb 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 @@ -68,7 +68,7 @@ class UnionBlobStoreTest implements BlobStoreContract { @Override public BucketName getDefaultBucketName() { - throw new RuntimeException("broken everywhere"); + return BucketName.DEFAULT; } @Override @@ -112,7 +112,7 @@ class UnionBlobStoreTest implements BlobStoreContract { @Override public BucketName getDefaultBucketName() { - throw new RuntimeException("broken everywhere"); + return BucketName.DEFAULT; } @Override @@ -180,12 +180,12 @@ class UnionBlobStoreTest implements BlobStoreContract { .current(new ThrowingBlobStore()) .legacy(legacyBlobStore) .build(); - BlobId blobId = unionBlobStore.save(BucketName.DEFAULT, BLOB_CONTENT).block(); + BlobId blobId = unionBlobStore.save(unionBlobStore.getDefaultBucketName(), BLOB_CONTENT).block(); SoftAssertions.assertSoftly(softly -> { - softly.assertThat(unionBlobStore.read(BucketName.DEFAULT, blobId)) + softly.assertThat(unionBlobStore.read(unionBlobStore.getDefaultBucketName(), blobId)) .hasSameContentAs(new ByteArrayInputStream(BLOB_CONTENT)); - softly.assertThat(legacyBlobStore.read(BucketName.DEFAULT, blobId)) + softly.assertThat(legacyBlobStore.read(unionBlobStore.getDefaultBucketName(), blobId)) .hasSameContentAs(new ByteArrayInputStream(BLOB_CONTENT)); }); } @@ -197,12 +197,12 @@ class UnionBlobStoreTest implements BlobStoreContract { .current(new ThrowingBlobStore()) .legacy(legacyBlobStore) .build(); - BlobId blobId = unionBlobStore.save(BucketName.DEFAULT, new ByteArrayInputStream(BLOB_CONTENT)).block(); + BlobId blobId = unionBlobStore.save(unionBlobStore.getDefaultBucketName(), new ByteArrayInputStream(BLOB_CONTENT)).block(); SoftAssertions.assertSoftly(softly -> { - softly.assertThat(unionBlobStore.read(BucketName.DEFAULT, blobId)) + softly.assertThat(unionBlobStore.read(unionBlobStore.getDefaultBucketName(), blobId)) .hasSameContentAs(new ByteArrayInputStream(BLOB_CONTENT)); - softly.assertThat(legacyBlobStore.read(BucketName.DEFAULT, blobId)) + softly.assertThat(legacyBlobStore.read(unionBlobStore.getDefaultBucketName(), blobId)) .hasSameContentAs(new ByteArrayInputStream(BLOB_CONTENT)); }); } @@ -218,12 +218,12 @@ class UnionBlobStoreTest implements BlobStoreContract { .current(new FailingBlobStore()) .legacy(legacyBlobStore) .build(); - BlobId blobId = unionBlobStore.save(BucketName.DEFAULT, BLOB_CONTENT).block(); + BlobId blobId = unionBlobStore.save(unionBlobStore.getDefaultBucketName(), BLOB_CONTENT).block(); SoftAssertions.assertSoftly(softly -> { - softly.assertThat(unionBlobStore.read(BucketName.DEFAULT, blobId)) + softly.assertThat(unionBlobStore.read(unionBlobStore.getDefaultBucketName(), blobId)) .hasSameContentAs(new ByteArrayInputStream(BLOB_CONTENT)); - softly.assertThat(legacyBlobStore.read(BucketName.DEFAULT, blobId)) + softly.assertThat(legacyBlobStore.read(unionBlobStore.getDefaultBucketName(), blobId)) .hasSameContentAs(new ByteArrayInputStream(BLOB_CONTENT)); }); } @@ -235,12 +235,12 @@ class UnionBlobStoreTest implements BlobStoreContract { .current(new FailingBlobStore()) .legacy(legacyBlobStore) .build(); - BlobId blobId = unionBlobStore.save(BucketName.DEFAULT, new ByteArrayInputStream(BLOB_CONTENT)).block(); + BlobId blobId = unionBlobStore.save(unionBlobStore.getDefaultBucketName(), new ByteArrayInputStream(BLOB_CONTENT)).block(); SoftAssertions.assertSoftly(softly -> { - softly.assertThat(unionBlobStore.read(BucketName.DEFAULT, blobId)) + softly.assertThat(unionBlobStore.read(unionBlobStore.getDefaultBucketName(), blobId)) .hasSameContentAs(new ByteArrayInputStream(BLOB_CONTENT)); - softly.assertThat(legacyBlobStore.read(BucketName.DEFAULT, blobId)) + softly.assertThat(legacyBlobStore.read(unionBlobStore.getDefaultBucketName(), blobId)) .hasSameContentAs(new ByteArrayInputStream(BLOB_CONTENT)); }); } @@ -257,9 +257,9 @@ class UnionBlobStoreTest implements BlobStoreContract { .current(new ThrowingBlobStore()) .legacy(legacyBlobStore) .build(); - BlobId blobId = legacyBlobStore.save(BucketName.DEFAULT, BLOB_CONTENT).block(); + BlobId blobId = legacyBlobStore.save(unionBlobStore.getDefaultBucketName(), BLOB_CONTENT).block(); - assertThat(unionBlobStore.read(BucketName.DEFAULT, blobId)) + assertThat(unionBlobStore.read(unionBlobStore.getDefaultBucketName(), blobId)) .hasSameContentAs(new ByteArrayInputStream(BLOB_CONTENT)); } @@ -271,9 +271,9 @@ class UnionBlobStoreTest implements BlobStoreContract { .current(new ThrowingBlobStore()) .legacy(legacyBlobStore) .build(); - BlobId blobId = legacyBlobStore.save(BucketName.DEFAULT, BLOB_CONTENT).block(); + BlobId blobId = legacyBlobStore.save(unionBlobStore.getDefaultBucketName(), BLOB_CONTENT).block(); - assertThat(unionBlobStore.readBytes(BucketName.DEFAULT, blobId).block()) + assertThat(unionBlobStore.readBytes(unionBlobStore.getDefaultBucketName(), blobId).block()) .isEqualTo(BLOB_CONTENT); } @@ -289,9 +289,9 @@ class UnionBlobStoreTest implements BlobStoreContract { .current(new FailingBlobStore()) .legacy(legacyBlobStore) .build(); - BlobId blobId = legacyBlobStore.save(BucketName.DEFAULT, BLOB_CONTENT).block(); + BlobId blobId = legacyBlobStore.save(unionBlobStore.getDefaultBucketName(), BLOB_CONTENT).block(); - assertThat(unionBlobStore.read(BucketName.DEFAULT, blobId)) + assertThat(unionBlobStore.read(unionBlobStore.getDefaultBucketName(), blobId)) .hasSameContentAs(new ByteArrayInputStream(BLOB_CONTENT)); } @@ -302,9 +302,9 @@ class UnionBlobStoreTest implements BlobStoreContract { .current(new FailingBlobStore()) .legacy(legacyBlobStore) .build(); - BlobId blobId = legacyBlobStore.save(BucketName.DEFAULT, BLOB_CONTENT).block(); + BlobId blobId = legacyBlobStore.save(unionBlobStore.getDefaultBucketName(), BLOB_CONTENT).block(); - assertThat(unionBlobStore.readBytes(BucketName.DEFAULT, blobId).block()) + assertThat(unionBlobStore.readBytes(unionBlobStore.getDefaultBucketName(), blobId).block()) .isEqualTo(BLOB_CONTENT); } } @@ -316,15 +316,15 @@ class UnionBlobStoreTest implements BlobStoreContract { Stream<Function<UnionBlobStore, Mono<?>>> blobStoreOperationsReturnFutures() { return Stream.of( - blobStore -> blobStore.save(BucketName.DEFAULT, BLOB_CONTENT), - blobStore -> blobStore.save(BucketName.DEFAULT, STRING_CONTENT), - blobStore -> blobStore.save(BucketName.DEFAULT, new ByteArrayInputStream(BLOB_CONTENT)), - blobStore -> blobStore.readBytes(BucketName.DEFAULT, BLOB_ID_FACTORY.randomId())); + blobStore -> blobStore.save(blobStore.getDefaultBucketName(), BLOB_CONTENT), + blobStore -> blobStore.save(blobStore.getDefaultBucketName(), STRING_CONTENT), + blobStore -> blobStore.save(blobStore.getDefaultBucketName(), new ByteArrayInputStream(BLOB_CONTENT)), + blobStore -> blobStore.readBytes(blobStore.getDefaultBucketName(), BLOB_ID_FACTORY.randomId())); } Stream<Function<UnionBlobStore, InputStream>> blobStoreOperationsNotReturnFutures() { return Stream.of( - blobStore -> blobStore.read(BucketName.DEFAULT, BLOB_ID_FACTORY.randomId())); + blobStore -> blobStore.read(blobStore.getDefaultBucketName(), BLOB_ID_FACTORY.randomId())); } Stream<Arguments> blobStoresCauseReturnExceptionallyFutures() { @@ -380,81 +380,81 @@ class UnionBlobStoreTest implements BlobStoreContract { @Test void readShouldReturnFromCurrentWhenAvailable() { - BlobId blobId = currentBlobStore.save(BucketName.DEFAULT, BLOB_CONTENT).block(); + BlobId blobId = currentBlobStore.save(currentBlobStore.getDefaultBucketName(), BLOB_CONTENT).block(); - assertThat(unionBlobStore.read(BucketName.DEFAULT, blobId)) + assertThat(unionBlobStore.read(unionBlobStore.getDefaultBucketName(), blobId)) .hasSameContentAs(new ByteArrayInputStream(BLOB_CONTENT)); } @Test void readShouldReturnFromLegacyWhenCurrentNotAvailable() { - BlobId blobId = legacyBlobStore.save(BucketName.DEFAULT, BLOB_CONTENT).block(); + BlobId blobId = legacyBlobStore.save(unionBlobStore.getDefaultBucketName(), BLOB_CONTENT).block(); - assertThat(unionBlobStore.read(BucketName.DEFAULT, blobId)) + assertThat(unionBlobStore.read(unionBlobStore.getDefaultBucketName(), blobId)) .hasSameContentAs(new ByteArrayInputStream(BLOB_CONTENT)); } @Test void readBytesShouldReturnFromCurrentWhenAvailable() { - BlobId blobId = currentBlobStore.save(BucketName.DEFAULT, BLOB_CONTENT).block(); + BlobId blobId = currentBlobStore.save(currentBlobStore.getDefaultBucketName(), BLOB_CONTENT).block(); - assertThat(unionBlobStore.readBytes(BucketName.DEFAULT, blobId).block()) + assertThat(unionBlobStore.readBytes(currentBlobStore.getDefaultBucketName(), blobId).block()) .isEqualTo(BLOB_CONTENT); } @Test void readBytesShouldReturnFromLegacyWhenCurrentNotAvailable() { - BlobId blobId = legacyBlobStore.save(BucketName.DEFAULT, BLOB_CONTENT).block(); + BlobId blobId = legacyBlobStore.save(unionBlobStore.getDefaultBucketName(), BLOB_CONTENT).block(); - assertThat(unionBlobStore.readBytes(BucketName.DEFAULT, blobId).block()) + assertThat(unionBlobStore.readBytes(unionBlobStore.getDefaultBucketName(), blobId).block()) .isEqualTo(BLOB_CONTENT); } @Test void saveShouldWriteToCurrent() { - BlobId blobId = unionBlobStore.save(BucketName.DEFAULT, BLOB_CONTENT).block(); + BlobId blobId = unionBlobStore.save(unionBlobStore.getDefaultBucketName(), BLOB_CONTENT).block(); - assertThat(currentBlobStore.readBytes(BucketName.DEFAULT, blobId).block()) + assertThat(currentBlobStore.readBytes(currentBlobStore.getDefaultBucketName(), blobId).block()) .isEqualTo(BLOB_CONTENT); } @Test void saveShouldNotWriteToLegacy() { - BlobId blobId = unionBlobStore.save(BucketName.DEFAULT, BLOB_CONTENT).block(); + BlobId blobId = unionBlobStore.save(unionBlobStore.getDefaultBucketName(), BLOB_CONTENT).block(); - assertThatThrownBy(() -> legacyBlobStore.readBytes(BucketName.DEFAULT, blobId).block()) + assertThatThrownBy(() -> legacyBlobStore.readBytes(legacyBlobStore.getDefaultBucketName(), blobId).block()) .isInstanceOf(ObjectStoreException.class); } @Test void saveStringShouldWriteToCurrent() { - BlobId blobId = unionBlobStore.save(BucketName.DEFAULT, STRING_CONTENT).block(); + BlobId blobId = unionBlobStore.save(unionBlobStore.getDefaultBucketName(), STRING_CONTENT).block(); - assertThat(currentBlobStore.readBytes(BucketName.DEFAULT, blobId).block()) + assertThat(currentBlobStore.readBytes(currentBlobStore.getDefaultBucketName(), blobId).block()) .isEqualTo(BLOB_CONTENT); } @Test void saveStringShouldNotWriteToLegacy() { - BlobId blobId = unionBlobStore.save(BucketName.DEFAULT, STRING_CONTENT).block(); + BlobId blobId = unionBlobStore.save(unionBlobStore.getDefaultBucketName(), STRING_CONTENT).block(); - assertThatThrownBy(() -> legacyBlobStore.readBytes(BucketName.DEFAULT, blobId).block()) + assertThatThrownBy(() -> legacyBlobStore.readBytes(legacyBlobStore.getDefaultBucketName(), blobId).block()) .isInstanceOf(ObjectStoreException.class); } @Test void saveInputStreamShouldWriteToCurrent() { - BlobId blobId = unionBlobStore.save(BucketName.DEFAULT, new ByteArrayInputStream(BLOB_CONTENT)).block(); + BlobId blobId = unionBlobStore.save(unionBlobStore.getDefaultBucketName(), new ByteArrayInputStream(BLOB_CONTENT)).block(); - assertThat(currentBlobStore.readBytes(BucketName.DEFAULT, blobId).block()) + assertThat(currentBlobStore.readBytes(currentBlobStore.getDefaultBucketName(), blobId).block()) .isEqualTo(BLOB_CONTENT); } @Test void saveInputStreamShouldNotWriteToLegacy() { - BlobId blobId = unionBlobStore.save(BucketName.DEFAULT, new ByteArrayInputStream(BLOB_CONTENT)).block(); + BlobId blobId = unionBlobStore.save(unionBlobStore.getDefaultBucketName(), new ByteArrayInputStream(BLOB_CONTENT)).block(); - assertThatThrownBy(() -> legacyBlobStore.readBytes(BucketName.DEFAULT, blobId).block()) + assertThatThrownBy(() -> legacyBlobStore.readBytes(legacyBlobStore.getDefaultBucketName(), blobId).block()) .isInstanceOf(ObjectStoreException.class); } diff --git a/server/blob/mail-store/src/test/java/org/apache/james/blob/mail/MimeMessageStoreTest.java b/server/blob/mail-store/src/test/java/org/apache/james/blob/mail/MimeMessageStoreTest.java index 6053366..9bd8327 100644 --- a/server/blob/mail-store/src/test/java/org/apache/james/blob/mail/MimeMessageStoreTest.java +++ b/server/blob/mail-store/src/test/java/org/apache/james/blob/mail/MimeMessageStoreTest.java @@ -28,7 +28,6 @@ import javax.mail.internet.MimeMessage; import org.apache.james.blob.api.BlobId; import org.apache.james.blob.api.BlobStore; -import org.apache.james.blob.api.BucketName; import org.apache.james.blob.api.HashBlobId; import org.apache.james.blob.api.Store; import org.apache.james.blob.memory.MemoryBlobStore; @@ -113,7 +112,7 @@ class MimeMessageStoreTest { BlobId headerBlobId = parts.getHeaderBlobId(); BlobId bodyBlobId = parts.getBodyBlobId(); - softly.assertThat(new String(blobStore.readBytes(BucketName.DEFAULT, headerBlobId).block(), StandardCharsets.UTF_8)) + softly.assertThat(new String(blobStore.readBytes(blobStore.getDefaultBucketName(), headerBlobId).block(), StandardCharsets.UTF_8)) .isEqualTo("Date: Thu, 6 Sep 2018 13:29:13 +0700 (ICT)\r\n" + "From: [email protected]\r\n" + "To: [email protected]\r\n" + @@ -122,7 +121,7 @@ class MimeMessageStoreTest { "MIME-Version: 1.0\r\n" + "Content-Type: text/plain; charset=UTF-8\r\n" + "Content-Transfer-Encoding: 7bit\r\n\r\n"); - softly.assertThat(new String(blobStore.readBytes(BucketName.DEFAULT, bodyBlobId).block(), StandardCharsets.UTF_8)) + softly.assertThat(new String(blobStore.readBytes(blobStore.getDefaultBucketName(), bodyBlobId).block(), StandardCharsets.UTF_8)) .isEqualTo("Important mail content"); }); } diff --git a/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/aws/s3/DockerAwsS3TestRule.java b/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/aws/s3/DockerAwsS3TestRule.java index 68b8a03..6f2b8e3 100644 --- a/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/aws/s3/DockerAwsS3TestRule.java +++ b/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/aws/s3/DockerAwsS3TestRule.java @@ -106,7 +106,7 @@ public class DockerAwsS3TestRule implements GuiceModuleTestRule { @Override public Module getModule() { - BucketName bucketName = BucketName.of(UUID.randomUUID().toString()); + BucketName defaultBucketName = BucketName.of(UUID.randomUUID().toString()); AwsS3AuthConfiguration authConfiguration = AwsS3AuthConfiguration.builder() .endpoint(DockerAwsS3Singleton.singleton.getEndpoint()) .accessKeyId(DockerAwsS3Container.ACCESS_KEY_ID) @@ -119,7 +119,7 @@ public class DockerAwsS3TestRule implements GuiceModuleTestRule { .authConfiguration(authConfiguration) .aesSalt("c603a7327ee3dcbc031d8d34b1096c605feca5e1") .aesPassword("dockerAwsS3Encryption".toCharArray()) - .defaultBucketName(Optional.of(bucketName)) + .defaultBucketName(Optional.of(defaultBucketName)) .build(); return binder -> { diff --git a/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/swift/DockerSwiftTestRule.java b/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/swift/DockerSwiftTestRule.java index 9289465..d706221 100644 --- a/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/swift/DockerSwiftTestRule.java +++ b/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/swift/DockerSwiftTestRule.java @@ -106,7 +106,7 @@ public class DockerSwiftTestRule implements GuiceModuleTestRule { .endpoint(swiftContainer.dockerSwift().keystoneV2Endpoint()) .build(); - BucketName bucketName = BucketName.of(UUID.randomUUID().toString()); + BucketName defaultBucketName = BucketName.of(UUID.randomUUID().toString()); ObjectStorageBlobConfiguration configuration = ObjectStorageBlobConfiguration.builder() .codec(payloadCodecFactory) .provider(ObjectStorageProvider.SWIFT) @@ -116,7 +116,7 @@ public class DockerSwiftTestRule implements GuiceModuleTestRule { Optional.empty())) .aesSalt("c603a7327ee3dcbc031d8d34b1096c605feca5e1") .aesPassword("dockerSwiftEncryption".toCharArray()) - .defaultBucketName(Optional.of(bucketName)) + .defaultBucketName(Optional.of(defaultBucketName)) .build(); return binder -> { diff --git a/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/swift/ObjectStorageBlobStoreModuleTest.java b/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/swift/ObjectStorageBlobStoreModuleTest.java index 22b9f8d..38bafac 100644 --- a/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/swift/ObjectStorageBlobStoreModuleTest.java +++ b/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/swift/ObjectStorageBlobStoreModuleTest.java @@ -141,7 +141,7 @@ class ObjectStorageBlobStoreModuleTest { BlobStore blobStore = injector.getInstance(Key.get(BlobStore.class, Names.named(MetricableBlobStore.BLOB_STORE_IMPLEMENTATION))); - assertThatCode(() -> blobStore.save(BucketName.DEFAULT, new byte[] {0x00})).doesNotThrowAnyException(); + assertThatCode(() -> blobStore.save(blobStore.getDefaultBucketName(), new byte[] {0x00})).doesNotThrowAnyException(); } } diff --git a/server/protocols/webadmin/webadmin-mailbox-deleted-message-vault/src/main/java/org/apache/james/webadmin/vault/routes/ExportService.java b/server/protocols/webadmin/webadmin-mailbox-deleted-message-vault/src/main/java/org/apache/james/webadmin/vault/routes/ExportService.java index ee5bf96..0ccef9f 100644 --- a/server/protocols/webadmin/webadmin-mailbox-deleted-message-vault/src/main/java/org/apache/james/webadmin/vault/routes/ExportService.java +++ b/server/protocols/webadmin/webadmin-mailbox-deleted-message-vault/src/main/java/org/apache/james/webadmin/vault/routes/ExportService.java @@ -27,7 +27,6 @@ import javax.inject.Inject; import org.apache.commons.io.FileUtils; import org.apache.james.blob.api.BlobId; import org.apache.james.blob.api.BlobStore; -import org.apache.james.blob.api.BucketName; import org.apache.james.blob.export.api.BlobExportMechanism; import org.apache.james.blob.export.api.FileExtension; import org.apache.james.core.MailAddress; @@ -77,7 +76,7 @@ class ExportService { try (FileBackedOutputStream fileOutputStream = new FileBackedOutputStream(FileUtils.ONE_MB_BI.intValue())) { zipper.zip(contentLoader(user), messages.toStream(), fileOutputStream); ByteSource byteSource = fileOutputStream.asByteSource(); - return blobStore.save(BucketName.DEFAULT, byteSource.openStream()).block(); + return blobStore.save(blobStore.getDefaultBucketName(), byteSource.openStream()).block(); } } diff --git a/server/protocols/webadmin/webadmin-mailbox-deleted-message-vault/src/test/java/org/apache/james/webadmin/vault/routes/DeletedMessagesVaultRoutesTest.java b/server/protocols/webadmin/webadmin-mailbox-deleted-message-vault/src/test/java/org/apache/james/webadmin/vault/routes/DeletedMessagesVaultRoutesTest.java index aae07a5..0441abb 100644 --- a/server/protocols/webadmin/webadmin-mailbox-deleted-message-vault/src/test/java/org/apache/james/webadmin/vault/routes/DeletedMessagesVaultRoutesTest.java +++ b/server/protocols/webadmin/webadmin-mailbox-deleted-message-vault/src/test/java/org/apache/james/webadmin/vault/routes/DeletedMessagesVaultRoutesTest.java @@ -72,7 +72,6 @@ import java.util.stream.Stream; import org.apache.commons.configuration.DefaultConfigurationBuilder; import org.apache.james.blob.api.BlobId; -import org.apache.james.blob.api.BucketName; import org.apache.james.blob.api.HashBlobId; import org.apache.james.blob.export.api.BlobExportMechanism; import org.apache.james.blob.memory.MemoryBlobStore; @@ -1905,7 +1904,7 @@ class DeletedMessagesVaultRoutesTest { byte[] expectedZippedData = zippedMessagesData(); - assertThat(blobStore.read(BucketName.DEFAULT, blobIdFactory.forPayload(expectedZippedData))) + assertThat(blobStore.read(blobStore.getDefaultBucketName(), blobIdFactory.forPayload(expectedZippedData))) .hasSameContentAs(new ByteArrayInputStream(expectedZippedData)); } diff --git a/third-party/linshare/src/main/java/org/apache/james/linshare/LinshareBlobExportMechanism.java b/third-party/linshare/src/main/java/org/apache/james/linshare/LinshareBlobExportMechanism.java index 69258eb..f01c301 100644 --- a/third-party/linshare/src/main/java/org/apache/james/linshare/LinshareBlobExportMechanism.java +++ b/third-party/linshare/src/main/java/org/apache/james/linshare/LinshareBlobExportMechanism.java @@ -28,7 +28,6 @@ import javax.inject.Inject; import org.apache.commons.io.FileUtils; import org.apache.james.blob.api.BlobId; import org.apache.james.blob.api.BlobStore; -import org.apache.james.blob.api.BucketName; import org.apache.james.blob.export.api.BlobExportMechanism; import org.apache.james.blob.export.api.ExportedFileNamesGenerator; import org.apache.james.blob.export.api.FileExtension; @@ -68,7 +67,7 @@ public class LinshareBlobExportMechanism implements BlobExportMechanism { String fileName = ExportedFileNamesGenerator.generateFileName(fileCustomPrefix, blobId, fileExtension); File tempFile = new File(tempDir, fileName); try { - FileUtils.copyInputStreamToFile(blobStore.read(BucketName.DEFAULT, blobId), tempFile); + FileUtils.copyInputStreamToFile(blobStore.read(blobStore.getDefaultBucketName(), blobId), tempFile); uploadAndShare(mailAddress, tempFile, explanation); } finally { FileUtils.forceDelete(tempFile); diff --git a/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareBlobExportMechanismTest.java b/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareBlobExportMechanismTest.java index ef9b6e4..542900a 100644 --- a/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareBlobExportMechanismTest.java +++ b/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareBlobExportMechanismTest.java @@ -32,7 +32,6 @@ import java.nio.charset.StandardCharsets; import java.util.Optional; import org.apache.james.blob.api.BlobId; -import org.apache.james.blob.api.BucketName; import org.apache.james.blob.api.HashBlobId; import org.apache.james.blob.export.api.BlobExportMechanism; import org.apache.james.blob.export.api.FileExtension; @@ -75,7 +74,7 @@ class LinshareBlobExportMechanismTest { @Test void exportShouldShareTheDocumentViaLinshare() throws Exception { - BlobId blobId = blobStore.save(BucketName.DEFAULT, FILE_CONTENT).block(); + BlobId blobId = blobStore.save(blobStore.getDefaultBucketName(), FILE_CONTENT).block(); String filePrefix = "[email protected]"; testee.blobId(blobId) @@ -94,7 +93,7 @@ class LinshareBlobExportMechanismTest { @Test void exportShouldSendAnEmailToSharee() throws Exception { - BlobId blobId = blobStore.save(BucketName.DEFAULT, FILE_CONTENT).block(); + BlobId blobId = blobStore.save(blobStore.getDefaultBucketName(), FILE_CONTENT).block(); testee.blobId(blobId) .with(new MailAddress(USER_2.getUsername())) @@ -123,7 +122,7 @@ class LinshareBlobExportMechanismTest { @Test void exportShouldShareTheDocumentAndAllowDownloadViaLinshare() throws Exception { - BlobId blobId = blobStore.save(BucketName.DEFAULT, FILE_CONTENT).block(); + BlobId blobId = blobStore.save(blobStore.getDefaultBucketName(), FILE_CONTENT).block(); testee.blobId(blobId) .with(new MailAddress(USER_2.getUsername())) @@ -153,7 +152,7 @@ class LinshareBlobExportMechanismTest { @Test void exportWithFilePrefixShouldCreateFileWithCustomPrefix() throws Exception { - BlobId blobId = blobStore.save(BucketName.DEFAULT, FILE_CONTENT).block(); + BlobId blobId = blobStore.save(blobStore.getDefaultBucketName(), FILE_CONTENT).block(); String filePrefix = "[email protected]"; testee.blobId(blobId) --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
