james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From matth...@apache.org
Subject [16/18] james-project git commit: fixup! MAILBOX-304 Provides a new version of AttachmentDao relying on Blobs storage
Date Mon, 11 Sep 2017 08:56:39 GMT
fixup! MAILBOX-304 Provides a new version of AttachmentDao relying on Blobs storage


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/f16436aa
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/f16436aa
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/f16436aa

Branch: refs/heads/master
Commit: f16436aa63f0abb4ff609df7d32a3325d2d73ddc
Parents: 55faae7
Author: benwa <btellier@linagora.com>
Authored: Fri Sep 8 18:44:03 2017 +0700
Committer: benwa <btellier@linagora.com>
Committed: Fri Sep 8 18:44:03 2017 +0700

----------------------------------------------------------------------
 .../mail/CassandraAttachmentFallbackTest.java   | 180 +++++++++++++++++++
 .../CassandraAttachmentFallbackTestTest.java    | 180 -------------------
 2 files changed, 180 insertions(+), 180 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/f16436aa/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentFallbackTest.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..91a6c6c
--- /dev/null
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentFallbackTest.java
@@ -0,0 +1,180 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.mailbox.cassandra.mail;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import java.nio.charset.StandardCharsets;
+
+import org.apache.james.backends.cassandra.CassandraCluster;
+import org.apache.james.backends.cassandra.DockerCassandraRule;
+import org.apache.james.backends.cassandra.init.CassandraModuleComposite;
+import org.apache.james.mailbox.cassandra.ids.BlobId;
+import org.apache.james.mailbox.cassandra.modules.CassandraAttachmentModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraBlobModule;
+import org.apache.james.mailbox.exception.AttachmentNotFoundException;
+import org.apache.james.mailbox.model.Attachment;
+import org.apache.james.mailbox.model.AttachmentId;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.testcontainers.shaded.com.google.common.collect.ImmutableList;
+
+public class CassandraAttachmentFallbackTest {
+    public static final AttachmentId ATTACHMENT_ID_1 = AttachmentId.from("id1");
+    public static final AttachmentId ATTACHMENT_ID_2 = AttachmentId.from("id2");
+
+    @ClassRule
+    public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
+
+    private CassandraCluster cassandra;
+
+    private CassandraAttachmentDAOV2 attachmentDAOV2;
+    private CassandraAttachmentDAO attachmentDAO;
+    private CassandraAttachmentMapper attachmentMapper;
+    private CassandraBlobsDAO blobsDAO;
+
+    @Before
+    public void setUp() throws Exception {
+        CassandraModuleComposite compositeModule = new CassandraModuleComposite(
+            new CassandraAttachmentModule(),
+            new CassandraBlobModule());
+
+        cassandra = CassandraCluster.create(
+            compositeModule,
+            cassandraServer.getIp(),
+            cassandraServer.getBindingPort());
+
+        attachmentDAOV2 = new CassandraAttachmentDAOV2(cassandra.getConf());
+        attachmentDAO = new CassandraAttachmentDAO(cassandra.getConf());
+        blobsDAO = new CassandraBlobsDAO(cassandra.getConf());
+        attachmentMapper = new CassandraAttachmentMapper(attachmentDAO, attachmentDAOV2,
blobsDAO);
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        cassandra.close();
+    }
+
+    @Test
+    public void getAttachmentShouldThrowWhenAbsentFromV1AndV2() throws Exception {
+        assertThatThrownBy(() -> attachmentMapper.getAttachment(ATTACHMENT_ID_1))
+            .isInstanceOf(AttachmentNotFoundException.class);
+    }
+
+    @Test
+    public void getAttachmentsShouldReturnEmptyWhenAbsentFromV1AndV2() throws Exception {
+        assertThat(attachmentMapper.getAttachments(ImmutableList.of(ATTACHMENT_ID_1)))
+            .isEmpty();
+    }
+
+    @Test
+    public void getAttachmentShouldReturnV2WhenPresentInV1AndV2() throws Exception {
+        Attachment attachment = Attachment.builder()
+            .attachmentId(ATTACHMENT_ID_1)
+            .type("application/json")
+            .bytes("{\"property\":`\"value\"}".getBytes(StandardCharsets.UTF_8))
+            .build();
+        Attachment otherAttachment = Attachment.builder()
+            .attachmentId(ATTACHMENT_ID_1)
+            .type("application/json")
+            .bytes("{\"property\":`\"different\"}".getBytes(StandardCharsets.UTF_8))
+            .build();
+
+        BlobId blobId = blobsDAO.save(attachment.getBytes()).join();
+        attachmentDAOV2.storeAttachment(CassandraAttachmentDAOV2.from(attachment, blobId)).join();
+        attachmentDAO.storeAttachment(otherAttachment).join();
+
+        assertThat(attachmentMapper.getAttachment(ATTACHMENT_ID_1))
+            .isEqualTo(attachment);
+    }
+
+    @Test
+    public void getAttachmentShouldReturnV1WhenV2Absent() throws Exception {
+        Attachment attachment = Attachment.builder()
+            .attachmentId(ATTACHMENT_ID_1)
+            .type("application/json")
+            .bytes("{\"property\":`\"value\"}".getBytes(StandardCharsets.UTF_8))
+            .build();
+
+        attachmentDAO.storeAttachment(attachment).join();
+
+        assertThat(attachmentMapper.getAttachment(ATTACHMENT_ID_1))
+            .isEqualTo(attachment);
+    }
+
+    @Test
+    public void getAttachmentsShouldReturnV2WhenV2AndV1() throws Exception {
+        Attachment attachment = Attachment.builder()
+            .attachmentId(ATTACHMENT_ID_1)
+            .type("application/json")
+            .bytes("{\"property\":`\"value\"}".getBytes(StandardCharsets.UTF_8))
+            .build();
+        Attachment otherAttachment = Attachment.builder()
+            .attachmentId(ATTACHMENT_ID_1)
+            .type("application/json")
+            .bytes("{\"property\":`\"different\"}".getBytes(StandardCharsets.UTF_8))
+            .build();
+
+        BlobId blobId = blobsDAO.save(attachment.getBytes()).join();
+        attachmentDAOV2.storeAttachment(CassandraAttachmentDAOV2.from(attachment, blobId)).join();
+        attachmentDAO.storeAttachment(otherAttachment).join();
+
+        assertThat(attachmentMapper.getAttachments(ImmutableList.of(ATTACHMENT_ID_1)))
+            .containsExactly(attachment);
+    }
+
+    @Test
+    public void getAttachmentsShouldReturnV1WhenV2Absent() throws Exception {
+        Attachment attachment = Attachment.builder()
+            .attachmentId(ATTACHMENT_ID_1)
+            .type("application/json")
+            .bytes("{\"property\":`\"value\"}".getBytes(StandardCharsets.UTF_8))
+            .build();
+
+        attachmentDAO.storeAttachment(attachment).join();
+
+        assertThat(attachmentMapper.getAttachments(ImmutableList.of(ATTACHMENT_ID_1)))
+            .containsExactly(attachment);
+    }
+
+    @Test
+    public void getAttachmentsShouldCombineElementsFromV1AndV2() throws Exception {
+        Attachment attachment = Attachment.builder()
+            .attachmentId(ATTACHMENT_ID_1)
+            .type("application/json")
+            .bytes("{\"property\":`\"value\"}".getBytes(StandardCharsets.UTF_8))
+            .build();
+        Attachment otherAttachment = Attachment.builder()
+            .attachmentId(ATTACHMENT_ID_2)
+            .type("application/json")
+            .bytes("{\"property\":`\"different\"}".getBytes(StandardCharsets.UTF_8))
+            .build();
+
+        BlobId blobId = blobsDAO.save(attachment.getBytes()).join();
+        attachmentDAOV2.storeAttachment(CassandraAttachmentDAOV2.from(attachment, blobId)).join();
+        attachmentDAO.storeAttachment(otherAttachment).join();
+
+        assertThat(attachmentMapper.getAttachments(ImmutableList.of(ATTACHMENT_ID_1, ATTACHMENT_ID_2)))
+            .containsExactly(attachment, otherAttachment);
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/f16436aa/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentFallbackTestTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentFallbackTestTest.java
b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentFallbackTestTest.java
deleted file mode 100644
index a186bbc..0000000
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentFallbackTestTest.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.mailbox.cassandra.mail;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
-import java.nio.charset.StandardCharsets;
-
-import org.apache.james.backends.cassandra.CassandraCluster;
-import org.apache.james.backends.cassandra.DockerCassandraRule;
-import org.apache.james.backends.cassandra.init.CassandraModuleComposite;
-import org.apache.james.mailbox.cassandra.ids.BlobId;
-import org.apache.james.mailbox.cassandra.modules.CassandraAttachmentModule;
-import org.apache.james.mailbox.cassandra.modules.CassandraBlobModule;
-import org.apache.james.mailbox.exception.AttachmentNotFoundException;
-import org.apache.james.mailbox.model.Attachment;
-import org.apache.james.mailbox.model.AttachmentId;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.testcontainers.shaded.com.google.common.collect.ImmutableList;
-
-public class CassandraAttachmentFallbackTestTest {
-    public static final AttachmentId ATTACHMENT_ID_1 = AttachmentId.from("id1");
-    public static final AttachmentId ATTACHMENT_ID_2 = AttachmentId.from("id2");
-
-    @ClassRule
-    public static DockerCassandraRule cassandraServer = new DockerCassandraRule();
-
-    private CassandraCluster cassandra;
-
-    private CassandraAttachmentDAOV2 attachmentDAOV2;
-    private CassandraAttachmentDAO attachmentDAO;
-    private CassandraAttachmentMapper attachmentMapper;
-    private CassandraBlobsDAO blobsDAO;
-
-    @Before
-    public void setUp() throws Exception {
-        CassandraModuleComposite compositeModule = new CassandraModuleComposite(
-            new CassandraAttachmentModule(),
-            new CassandraBlobModule());
-
-        cassandra = CassandraCluster.create(
-            compositeModule,
-            cassandraServer.getIp(),
-            cassandraServer.getBindingPort());
-
-        attachmentDAOV2 = new CassandraAttachmentDAOV2(cassandra.getConf());
-        attachmentDAO = new CassandraAttachmentDAO(cassandra.getConf());
-        blobsDAO = new CassandraBlobsDAO(cassandra.getConf());
-        attachmentMapper = new CassandraAttachmentMapper(attachmentDAO, attachmentDAOV2,
blobsDAO);
-    }
-
-    @After
-    public void tearDown() throws Exception {
-        cassandra.close();
-    }
-
-    @Test
-    public void getAttachmentShouldThrowWhenAbsentFromV1AndV2() throws Exception {
-        assertThatThrownBy(() -> attachmentMapper.getAttachment(ATTACHMENT_ID_1))
-            .isInstanceOf(AttachmentNotFoundException.class);
-    }
-
-    @Test
-    public void getAttachmentsShouldReturnEmptyWhenAbsentFromV1AndV2() throws Exception {
-        assertThat(attachmentMapper.getAttachments(ImmutableList.of(ATTACHMENT_ID_1)))
-            .isEmpty();
-    }
-
-    @Test
-    public void getAttachmentShouldReturnV2WhenPresentInV1AndV2() throws Exception {
-        Attachment attachment = Attachment.builder()
-            .attachmentId(ATTACHMENT_ID_1)
-            .type("application/json")
-            .bytes("{\"property\":`\"value\"}".getBytes(StandardCharsets.UTF_8))
-            .build();
-        Attachment otherAttachment = Attachment.builder()
-            .attachmentId(ATTACHMENT_ID_1)
-            .type("application/json")
-            .bytes("{\"property\":`\"different\"}".getBytes(StandardCharsets.UTF_8))
-            .build();
-
-        BlobId blobId = blobsDAO.save(attachment.getBytes()).join();
-        attachmentDAOV2.storeAttachment(CassandraAttachmentDAOV2.from(attachment, blobId)).join();
-        attachmentDAO.storeAttachment(otherAttachment).join();
-
-        assertThat(attachmentMapper.getAttachment(ATTACHMENT_ID_1))
-            .isEqualTo(attachment);
-    }
-
-    @Test
-    public void getAttachmentShouldReturnV1WhenV2Absent() throws Exception {
-        Attachment attachment = Attachment.builder()
-            .attachmentId(ATTACHMENT_ID_1)
-            .type("application/json")
-            .bytes("{\"property\":`\"value\"}".getBytes(StandardCharsets.UTF_8))
-            .build();
-
-        attachmentDAO.storeAttachment(attachment).join();
-
-        assertThat(attachmentMapper.getAttachment(ATTACHMENT_ID_1))
-            .isEqualTo(attachment);
-    }
-
-    @Test
-    public void getAttachmentsShouldReturnV2WhenV2AndV1() throws Exception {
-        Attachment attachment = Attachment.builder()
-            .attachmentId(ATTACHMENT_ID_1)
-            .type("application/json")
-            .bytes("{\"property\":`\"value\"}".getBytes(StandardCharsets.UTF_8))
-            .build();
-        Attachment otherAttachment = Attachment.builder()
-            .attachmentId(ATTACHMENT_ID_1)
-            .type("application/json")
-            .bytes("{\"property\":`\"different\"}".getBytes(StandardCharsets.UTF_8))
-            .build();
-
-        BlobId blobId = blobsDAO.save(attachment.getBytes()).join();
-        attachmentDAOV2.storeAttachment(CassandraAttachmentDAOV2.from(attachment, blobId)).join();
-        attachmentDAO.storeAttachment(otherAttachment).join();
-
-        assertThat(attachmentMapper.getAttachments(ImmutableList.of(ATTACHMENT_ID_1)))
-            .containsExactly(attachment);
-    }
-
-    @Test
-    public void getAttachmentsShouldReturnV1WhenV2Absent() throws Exception {
-        Attachment attachment = Attachment.builder()
-            .attachmentId(ATTACHMENT_ID_1)
-            .type("application/json")
-            .bytes("{\"property\":`\"value\"}".getBytes(StandardCharsets.UTF_8))
-            .build();
-
-        attachmentDAO.storeAttachment(attachment).join();
-
-        assertThat(attachmentMapper.getAttachments(ImmutableList.of(ATTACHMENT_ID_1)))
-            .containsExactly(attachment);
-    }
-
-    @Test
-    public void getAttachmentsShouldCombineElementsFromV1AndV2() throws Exception {
-        Attachment attachment = Attachment.builder()
-            .attachmentId(ATTACHMENT_ID_1)
-            .type("application/json")
-            .bytes("{\"property\":`\"value\"}".getBytes(StandardCharsets.UTF_8))
-            .build();
-        Attachment otherAttachment = Attachment.builder()
-            .attachmentId(ATTACHMENT_ID_2)
-            .type("application/json")
-            .bytes("{\"property\":`\"different\"}".getBytes(StandardCharsets.UTF_8))
-            .build();
-
-        BlobId blobId = blobsDAO.save(attachment.getBytes()).join();
-        attachmentDAOV2.storeAttachment(CassandraAttachmentDAOV2.from(attachment, blobId)).join();
-        attachmentDAO.storeAttachment(otherAttachment).join();
-
-        assertThat(attachmentMapper.getAttachments(ImmutableList.of(ATTACHMENT_ID_1, ATTACHMENT_ID_2)))
-            .containsExactly(attachment, otherAttachment);
-    }
-}


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message