You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ro...@apache.org on 2019/04/29 08:09:32 UTC
[james-project] branch master updated (bf70673 -> d7f9883)
This is an automated email from the ASF dual-hosted git repository.
rouazana pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git.
from bf70673 Merge remote-tracking branch 'remk/JAMES-2738'
new c496a87 JAMES-2741 Implement new save method for Strings in BlobStore
new f58bfd8 JAMES-2741 Add save(String) tests in BlobStore contract
new 71dcff8 JAMES-2741 Refactor blob store tests with new save Strings methods
new 646d4cb Merge remote-tracking branch 'Arsnael/james-2741-refactor-blobstore-save'
new 229ab26 JAMES-2715 correct DommainMappingRoutes document
new d7f9883 Merge remote-tracking branch 'trantienduchn/fix-domain-mapping-route'
The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../java/org/apache/james/blob/api/BlobStore.java | 5 ++++
.../apache/james/blob/api/BlobStoreContract.java | 25 +++++++++++++++++-
.../blob/api/MetricableBlobStoreContract.java | 13 ++++++++--
.../james/blob/cassandra/CassandraBlobsDAO.java | 1 +
.../blob/cassandra/CassandraBlobsDAOTest.java | 2 +-
.../file/LocalFileBlobExportMechanismTest.java | 6 ++---
.../blob/objectstorage/ObjectStorageBlobsDAO.java | 1 +
.../ObjectStorageBlobsDAOContract.java | 8 +++---
.../objectstorage/ObjectStorageBlobsDAOTest.java | 27 +++++++++++--------
.../apache/james/blob/union/UnionBlobStore.java | 13 ++++++++++
.../james/blob/union/UnionBlobStoreTest.java | 30 +++++++++++++++++++++-
.../webadmin/routes/DomainMappingsRoutes.java | 1 +
src/site/markdown/server/manage-webadmin.md | 3 ++-
.../linshare/LinshareBlobExportMechanismTest.java | 6 ++---
14 files changed, 113 insertions(+), 28 deletions(-)
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 02/06: JAMES-2741 Implement new save method for
Strings in BlobStore
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rouazana pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit c496a877aada006b8f868f11b56739f6699e44a9
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Apr 18 17:53:41 2019 +0700
JAMES-2741 Implement new save method for Strings in BlobStore
---
.../src/main/java/org/apache/james/blob/api/BlobStore.java | 5 +++++
.../org/apache/james/blob/cassandra/CassandraBlobsDAO.java | 1 +
.../james/blob/objectstorage/ObjectStorageBlobsDAO.java | 1 +
.../java/org/apache/james/blob/union/UnionBlobStore.java | 13 +++++++++++++
.../org/apache/james/blob/union/UnionBlobStoreTest.java | 10 ++++++++++
5 files changed, 30 insertions(+)
diff --git a/server/blob/blob-api/src/main/java/org/apache/james/blob/api/BlobStore.java b/server/blob/blob-api/src/main/java/org/apache/james/blob/api/BlobStore.java
index 3d28ab5..d22be29 100644
--- a/server/blob/blob-api/src/main/java/org/apache/james/blob/api/BlobStore.java
+++ b/server/blob/blob-api/src/main/java/org/apache/james/blob/api/BlobStore.java
@@ -19,6 +19,7 @@
package org.apache.james.blob.api;
import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
import reactor.core.publisher.Mono;
@@ -31,4 +32,8 @@ public interface BlobStore {
Mono<byte[]> readBytes(BlobId blobId);
InputStream read(BlobId blobId);
+
+ default Mono<BlobId> save(String data) {
+ return save(data.getBytes(StandardCharsets.UTF_8));
+ }
}
diff --git a/server/blob/blob-cassandra/src/main/java/org/apache/james/blob/cassandra/CassandraBlobsDAO.java b/server/blob/blob-cassandra/src/main/java/org/apache/james/blob/cassandra/CassandraBlobsDAO.java
index 3a9d88d..b637601 100644
--- a/server/blob/blob-cassandra/src/main/java/org/apache/james/blob/cassandra/CassandraBlobsDAO.java
+++ b/server/blob/blob-cassandra/src/main/java/org/apache/james/blob/cassandra/CassandraBlobsDAO.java
@@ -51,6 +51,7 @@ import com.datastax.driver.core.Session;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.common.primitives.Bytes;
+
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;
diff --git a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAO.java b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAO.java
index 857553d..6000680 100644
--- a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAO.java
+++ b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAO.java
@@ -42,6 +42,7 @@ import org.slf4j.LoggerFactory;
import com.google.common.base.Preconditions;
import com.google.common.hash.Hashing;
import com.google.common.hash.HashingInputStream;
+
import reactor.core.publisher.Mono;
public class ObjectStorageBlobsDAO implements BlobStore {
diff --git a/server/blob/blob-union/src/main/java/org/apache/james/blob/union/UnionBlobStore.java b/server/blob/blob-union/src/main/java/org/apache/james/blob/union/UnionBlobStore.java
index ee02c8d..07d0830 100644
--- a/server/blob/blob-union/src/main/java/org/apache/james/blob/union/UnionBlobStore.java
+++ b/server/blob/blob-union/src/main/java/org/apache/james/blob/union/UnionBlobStore.java
@@ -34,6 +34,7 @@ import org.slf4j.LoggerFactory;
import com.github.fge.lambdas.Throwing;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.MoreObjects;
+
import reactor.core.publisher.Mono;
public class UnionBlobStore implements BlobStore {
@@ -92,6 +93,18 @@ public class UnionBlobStore implements BlobStore {
}
@Override
+ public Mono<BlobId> save(String data) {
+ try {
+ return saveToCurrentFallbackIfFails(
+ Mono.defer(() -> currentBlobStore.save(data)),
+ () -> Mono.defer(() -> legacyBlobStore.save(data)));
+ } catch (Exception e) {
+ LOGGER.error("exception directly happens while saving String data, fall back to legacy blob store", e);
+ return legacyBlobStore.save(data);
+ }
+ }
+
+ @Override
public Mono<BlobId> save(InputStream data, long contentLength) {
try {
return saveToCurrentFallbackIfFails(
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 f044606..f2f875e 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
@@ -61,6 +61,11 @@ class UnionBlobStoreTest implements BlobStoreContract {
}
@Override
+ public Mono<BlobId> save(String data) {
+ return Mono.error(new RuntimeException("broken everywhere"));
+ }
+
+ @Override
public Mono<BlobId> save(InputStream data, long contentLength) {
return Mono.error(new RuntimeException("broken everywhere"));
}
@@ -90,6 +95,11 @@ class UnionBlobStoreTest implements BlobStoreContract {
}
@Override
+ public Mono<BlobId> save(String data) {
+ throw new RuntimeException("broken everywhere");
+ }
+
+ @Override
public Mono<BlobId> save(InputStream data, long contentLength) {
throw new RuntimeException("broken everywhere");
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 04/06: JAMES-2741 Refactor blob store tests with
new save Strings methods
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rouazana pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 71dcff813541cb53ab3a5f76b375c19b65dab158
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Mon Apr 22 16:16:53 2019 +0700
JAMES-2741 Refactor blob store tests with new save Strings methods
---
.../blob/cassandra/CassandraBlobsDAOTest.java | 2 +-
.../file/LocalFileBlobExportMechanismTest.java | 6 ++---
.../ObjectStorageBlobsDAOContract.java | 8 +++----
.../objectstorage/ObjectStorageBlobsDAOTest.java | 27 +++++++++++++---------
.../james/blob/union/UnionBlobStoreTest.java | 20 +++++++++++++++-
.../linshare/LinshareBlobExportMechanismTest.java | 6 ++---
6 files changed, 45 insertions(+), 24 deletions(-)
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 3e570ee..9831bed 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
@@ -72,7 +72,7 @@ public class CassandraBlobsDAOTest implements MetricableBlobStoreContract {
@Test
void readBytesShouldReturnSplitSavedDataByChunk() {
String longString = Strings.repeat("0123456789\n", MULTIPLE_CHUNK_SIZE);
- BlobId blobId = testee.save(longString.getBytes(StandardCharsets.UTF_8)).block();
+ BlobId blobId = testee.save(longString).block();
byte[] bytes = testee.readBytes(blobId).block();
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 6e70cbd..2b91681 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
@@ -24,7 +24,6 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.net.InetAddress;
import java.nio.charset.StandardCharsets;
@@ -34,6 +33,7 @@ import javax.mail.internet.InternetAddress;
import org.apache.commons.configuration.PropertiesConfiguration;
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.HashBlobId;
@@ -55,7 +55,7 @@ import nl.jqno.equalsverifier.EqualsVerifier;
@ExtendWith(FileSystemExtension.class)
class LocalFileBlobExportMechanismTest {
- private static final byte[] BLOB_CONTENT = "blob_content".getBytes(StandardCharsets.UTF_8);
+ private static final String BLOB_CONTENT = "blob_content";
private static final String JAMES_HOST = "james-host";
private BlobStore blobStore;
@@ -124,7 +124,7 @@ class LocalFileBlobExportMechanismTest {
try {
String absoluteUrl = sentMail.getMsg().getHeader(LocalFileBlobExportMechanism.CORRESPONDING_FILE_HEADER)[0];
- assertThat(new FileInputStream(absoluteUrl)).hasSameContentAs(new ByteArrayInputStream(BLOB_CONTENT));
+ assertThat(new FileInputStream(absoluteUrl)).hasSameContentAs(IOUtils.toInputStream(BLOB_CONTENT, StandardCharsets.UTF_8));
} catch (Exception e) {
throw new RuntimeException(e);
}
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 409272d..cada68c 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
@@ -21,16 +21,16 @@ package org.apache.james.blob.objectstorage;
import static org.assertj.core.api.Assertions.assertThat;
-import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
+import org.apache.commons.io.IOUtils;
import org.apache.james.blob.api.BlobId;
public interface ObjectStorageBlobsDAOContract {
- byte[] BYTES = "content".getBytes(StandardCharsets.UTF_8);
+ String CONTENT = "content";
ContainerName containerName();
@@ -38,9 +38,9 @@ public interface ObjectStorageBlobsDAOContract {
ObjectStorageBlobsDAO dao = builder.build();
dao.createContainer(containerName()).block();
- BlobId blobId = dao.save(BYTES).block();
+ BlobId blobId = dao.save(CONTENT).block();
InputStream inputStream = dao.read(blobId);
- assertThat(inputStream).hasSameContentAs(new ByteArrayInputStream(BYTES));
+ 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 63ebb7d..b1ec0c4 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
@@ -49,6 +49,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
import com.google.common.base.Charsets;
import com.google.common.base.Strings;
+
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;
@@ -133,12 +134,10 @@ public class ObjectStorageBlobsDAOTest implements MetricableBlobStoreContract {
.payloadCodec(new AESPayloadCodec(CRYPTO_CONFIG))
.build();
String content = "James is the best!";
- byte[] bytes = content.getBytes(StandardCharsets.UTF_8);
- BlobId blobId = encryptedDao.save(bytes).block();
+ BlobId blobId = encryptedDao.save(content).block();
InputStream read = encryptedDao.read(blobId);
- ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
- String expectedContent = IOUtils.toString(inputStream, Charsets.UTF_8);
+ String expectedContent = IOUtils.toString(read, Charsets.UTF_8);
assertThat(content).isEqualTo(expectedContent);
}
@@ -151,17 +150,15 @@ public class ObjectStorageBlobsDAOTest implements MetricableBlobStoreContract {
.payloadCodec(new AESPayloadCodec(CRYPTO_CONFIG))
.build();
String content = "James is the best!";
- byte[] bytes = content.getBytes(StandardCharsets.UTF_8);
- BlobId blobId = encryptedDao.save(bytes).block();
+ BlobId blobId = encryptedDao.save(content).block();
InputStream encryptedIs = testee.read(blobId);
assertThat(encryptedIs).isNotNull();
- byte[] encryptedBytes = IOUtils.toByteArray(encryptedIs);
- assertThat(encryptedBytes).isNotEqualTo(bytes);
+ String encryptedString = IOUtils.toString(encryptedIs, Charsets.UTF_8);
+ assertThat(encryptedString).isNotEqualTo(content);
InputStream clearTextIs = encryptedDao.read(blobId);
- ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
- String expectedContent = IOUtils.toString(inputStream, Charsets.UTF_8);
+ String expectedContent = IOUtils.toString(clearTextIs, Charsets.UTF_8);
assertThat(content).isEqualTo(expectedContent);
}
@@ -182,6 +179,14 @@ public class ObjectStorageBlobsDAOTest implements MetricableBlobStoreContract {
}
@Test
+ void saveStringShouldNotCompleteWhenDoesNotAwait() {
+ Mono<BlobId> blobIdFuture = testee
+ .save(BIG_STRING)
+ .subscribeOn(Schedulers.elastic());
+ assertThat(blobIdFuture.toFuture()).isNotCompleted();
+ }
+
+ @Test
void saveInputStreamShouldNotCompleteWhenDoesNotAwait() {
Mono<BlobId> blobIdFuture = testee
.save(new ByteArrayInputStream(BIG_STRING.getBytes(StandardCharsets.UTF_8)), BIG_STRING.length())
@@ -191,7 +196,7 @@ public class ObjectStorageBlobsDAOTest implements MetricableBlobStoreContract {
@Test
void readBytesShouldNotCompleteWhenDoesNotAwait() {
- BlobId blobId = testee().save(BIG_STRING.getBytes(StandardCharsets.UTF_8)).block();
+ BlobId blobId = testee().save(BIG_STRING).block();
Mono<byte[]> resultFuture = testee.readBytes(blobId).subscribeOn(Schedulers.elastic());
assertThat(resultFuture.toFuture()).isNotCompleted();
}
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 f2f875e..d567a94 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
@@ -122,7 +122,8 @@ class UnionBlobStoreTest implements BlobStoreContract {
}
private static final HashBlobId.Factory BLOB_ID_FACTORY = new HashBlobId.Factory();
- private static final byte [] BLOB_CONTENT = "blob content".getBytes();
+ private static final String STRING_CONTENT = "blob content";
+ private static final byte [] BLOB_CONTENT = STRING_CONTENT.getBytes();
private MemoryBlobStore currentBlobStore;
private MemoryBlobStore legacyBlobStore;
@@ -295,6 +296,7 @@ class UnionBlobStoreTest implements BlobStoreContract {
Stream<Function<UnionBlobStore, Mono<?>>> blobStoreOperationsReturnFutures() {
return Stream.of(
blobStore -> blobStore.save(BLOB_CONTENT),
+ blobStore -> blobStore.save(STRING_CONTENT),
blobStore -> blobStore.save(new ByteArrayInputStream(BLOB_CONTENT), BLOB_CONTENT.length),
blobStore -> blobStore.readBytes(BLOB_ID_FACTORY.randomId()));
}
@@ -404,6 +406,22 @@ class UnionBlobStoreTest implements BlobStoreContract {
}
@Test
+ void saveStringShouldWriteToCurrent() {
+ BlobId blobId = unionBlobStore.save(STRING_CONTENT).block();
+
+ assertThat(currentBlobStore.readBytes(blobId).block())
+ .isEqualTo(BLOB_CONTENT);
+ }
+
+ @Test
+ void saveStringShouldNotWriteToLegacy() {
+ BlobId blobId = unionBlobStore.save(STRING_CONTENT).block();
+
+ assertThatThrownBy(() -> legacyBlobStore.readBytes(blobId).block())
+ .isInstanceOf(ObjectStoreException.class);
+ }
+
+ @Test
void saveInputStreamShouldWriteToCurrent() {
BlobId blobId = unionBlobStore.save(new ByteArrayInputStream(BLOB_CONTENT), BLOB_CONTENT.length).block();
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 569cde9..db04467 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
@@ -28,8 +28,6 @@ import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.hasSize;
-import java.nio.charset.StandardCharsets;
-
import org.apache.james.blob.api.BlobId;
import org.apache.james.blob.api.HashBlobId;
import org.apache.james.blob.export.api.BlobExportMechanism;
@@ -67,7 +65,7 @@ class LinshareBlobExportMechanismTest {
@Test
void exportShouldShareTheDocumentViaLinShare() throws Exception {
- BlobId blobId = blobStore.save("content".getBytes(StandardCharsets.UTF_8)).block();
+ BlobId blobId = blobStore.save("content").block();
testee.blobId(blobId)
.with(new MailAddress(USER_2.getUsername()))
@@ -86,7 +84,7 @@ class LinshareBlobExportMechanismTest {
@Test
void exportShouldSendAnEmailToSharee() throws Exception {
- BlobId blobId = blobStore.save("content".getBytes(StandardCharsets.UTF_8)).block();
+ BlobId blobId = blobStore.save("content").block();
testee.blobId(blobId)
.with(new MailAddress(USER_2.getUsername()))
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 05/06: Merge remote-tracking branch
'Arsnael/james-2741-refactor-blobstore-save'
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rouazana pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 646d4cb2f45d279a3c9e3b490a08e3402d35a3b7
Merge: bf70673 71dcff8
Author: Raphael Ouazana <ra...@linagora.com>
AuthorDate: Mon Apr 29 10:08:37 2019 +0200
Merge remote-tracking branch 'Arsnael/james-2741-refactor-blobstore-save'
.../java/org/apache/james/blob/api/BlobStore.java | 5 ++++
.../apache/james/blob/api/BlobStoreContract.java | 25 +++++++++++++++++-
.../blob/api/MetricableBlobStoreContract.java | 13 ++++++++--
.../james/blob/cassandra/CassandraBlobsDAO.java | 1 +
.../blob/cassandra/CassandraBlobsDAOTest.java | 2 +-
.../file/LocalFileBlobExportMechanismTest.java | 6 ++---
.../blob/objectstorage/ObjectStorageBlobsDAO.java | 1 +
.../ObjectStorageBlobsDAOContract.java | 8 +++---
.../objectstorage/ObjectStorageBlobsDAOTest.java | 27 +++++++++++--------
.../apache/james/blob/union/UnionBlobStore.java | 13 ++++++++++
.../james/blob/union/UnionBlobStoreTest.java | 30 +++++++++++++++++++++-
.../linshare/LinshareBlobExportMechanismTest.java | 6 ++---
12 files changed, 110 insertions(+), 27 deletions(-)
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 06/06: Merge remote-tracking branch
'trantienduchn/fix-domain-mapping-route'
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rouazana pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit d7f98836b9cdc3d2ab444f6e1dec3364bd784ae3
Merge: 646d4cb 229ab26
Author: Raphael Ouazana <ra...@linagora.com>
AuthorDate: Mon Apr 29 10:09:06 2019 +0200
Merge remote-tracking branch 'trantienduchn/fix-domain-mapping-route'
.../java/org/apache/james/webadmin/routes/DomainMappingsRoutes.java | 1 +
src/site/markdown/server/manage-webadmin.md | 3 ++-
2 files changed, 3 insertions(+), 1 deletion(-)
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 03/06: JAMES-2741 Add save(String) tests in
BlobStore contract
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rouazana pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit f58bfd83e95a52a8e10b234caf78fcdce8d4ed0a
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Apr 18 17:54:55 2019 +0700
JAMES-2741 Add save(String) tests in BlobStore contract
---
.../apache/james/blob/api/BlobStoreContract.java | 25 +++++++++++++++++++++-
.../blob/api/MetricableBlobStoreContract.java | 13 +++++++++--
2 files changed, 35 insertions(+), 3 deletions(-)
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 6983485..dbb9863 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
@@ -32,8 +32,9 @@ import com.google.common.base.Strings;
public interface BlobStoreContract {
+ String SHORT_STRING = "toto";
byte[] EMPTY_BYTEARRAY = {};
- byte[] SHORT_BYTEARRAY = "toto".getBytes(StandardCharsets.UTF_8);
+ byte[] SHORT_BYTEARRAY = SHORT_STRING.getBytes(StandardCharsets.UTF_8);
byte[] ELEVEN_KILOBYTES = Strings.repeat("0123456789\n", 1000).getBytes(StandardCharsets.UTF_8);
byte[] TWELVE_MEGABYTES = Strings.repeat("0123456789\r\n", 1024 * 1024).getBytes(StandardCharsets.UTF_8);
@@ -48,6 +49,12 @@ public interface BlobStoreContract {
}
@Test
+ default void saveShouldThrowWhenNullString() {
+ assertThatThrownBy(() -> testee().save((String) null).block())
+ .isInstanceOf(NullPointerException.class);
+ }
+
+ @Test
default void saveShouldThrowWhenNullInputStream() {
assertThatThrownBy(() -> testee().save((InputStream) null, 0).block())
.isInstanceOf(NullPointerException.class);
@@ -63,6 +70,15 @@ public interface BlobStoreContract {
}
@Test
+ default void saveShouldSaveEmptyString() {
+ BlobId blobId = testee().save(new String()).block();
+
+ byte[] bytes = testee().readBytes(blobId).block();
+
+ assertThat(new String(bytes, StandardCharsets.UTF_8)).isEmpty();
+ }
+
+ @Test
default void saveShouldSaveEmptyInputStream() {
BlobId blobId = testee().save(new ByteArrayInputStream(EMPTY_BYTEARRAY), EMPTY_BYTEARRAY.length).block();
@@ -79,6 +95,13 @@ public interface BlobStoreContract {
}
@Test
+ default void saveShouldReturnBlobIdOfString() {
+ BlobId blobId = testee().save(SHORT_STRING).block();
+
+ assertThat(blobId).isEqualTo(blobIdFactory().from("31f7a65e315586ac198bd798b6629ce4903d0899476d5741a9f32e2e521b6a66"));
+ }
+
+ @Test
default void saveShouldReturnBlobIdOfInputStream() {
BlobId blobId =
testee().save(new ByteArrayInputStream(SHORT_BYTEARRAY), SHORT_BYTEARRAY.length).block();
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 9b8cfb5..7ed9b7e 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
@@ -27,7 +27,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
-import java.time.Duration;
import org.apache.james.metrics.tests.RecordingMetricFactory;
import org.junit.jupiter.api.Test;
@@ -53,7 +52,8 @@ public interface MetricableBlobStoreContract extends BlobStoreContract {
@RegisterExtension
MetricableBlobStoreExtension metricsTestExtension = new MetricableBlobStoreExtension();
- byte[] BYTES_CONTENT = "bytes content".getBytes(StandardCharsets.UTF_8);
+ String STRING_CONTENT = "blob content";
+ byte[] BYTES_CONTENT = STRING_CONTENT.getBytes(StandardCharsets.UTF_8);
@Test
default void saveBytesShouldPublishSaveBytesTimerMetrics() {
@@ -65,6 +65,15 @@ public interface MetricableBlobStoreContract extends BlobStoreContract {
}
@Test
+ default void saveStringShouldPublishSaveBytesTimerMetrics() {
+ testee().save(STRING_CONTENT).block();
+ testee().save(STRING_CONTENT).block();
+
+ assertThat(metricsTestExtension.getMetricFactory().executionTimesFor(SAVE_BYTES_TIMER_NAME))
+ .hasSize(2);
+ }
+
+ @Test
default void saveInputStreamShouldPublishSaveInputStreamTimerMetrics() {
testee().save(new ByteArrayInputStream(BYTES_CONTENT), BYTES_CONTENT.length).block();
testee().save(new ByteArrayInputStream(BYTES_CONTENT), BYTES_CONTENT.length).block();
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 01/06: JAMES-2715 correct DommainMappingRoutes
document
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rouazana pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 229ab266369f7a0f4f3248020028c658f86c2ce3
Author: Tran Tien Duc <dt...@linagora.com>
AuthorDate: Fri Apr 26 16:58:34 2019 +0700
JAMES-2715 correct DommainMappingRoutes document
---
.../java/org/apache/james/webadmin/routes/DomainMappingsRoutes.java | 1 +
src/site/markdown/server/manage-webadmin.md | 3 ++-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/DomainMappingsRoutes.java b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/DomainMappingsRoutes.java
index 5344b5c..225aac4 100644
--- a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/DomainMappingsRoutes.java
+++ b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/DomainMappingsRoutes.java
@@ -153,6 +153,7 @@ public class DomainMappingsRoutes implements Routes {
})
@ApiResponses(value = {
@ApiResponse(code = HttpStatus.OK_200, message = "Domain mappings.", responseContainer = "List"),
+ @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Domain name is invalid"),
@ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "Not existing mappings."),
@ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
message = "Internal server error - Something went bad on the server side.")
diff --git a/src/site/markdown/server/manage-webadmin.md b/src/site/markdown/server/manage-webadmin.md
index a1b9a4a..0d205d7 100644
--- a/src/site/markdown/server/manage-webadmin.md
+++ b/src/site/markdown/server/manage-webadmin.md
@@ -1439,7 +1439,8 @@ Response codes:
- 200: OK
- 400: The `fromDomain` resource name is invalid
-
+ - 404: The `fromDomain` resource name is not found
+
### Adding a domain mapping
```
curl -XPUT http://ip:port/domainMappings/sourceDomain.tld
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org