james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [06/11] james-project git commit: JAMES-1746 Mappers should be tested using junit-contracts
Date Wed, 08 Jun 2016 10:10:30 GMT
JAMES-1746 Mappers should be tested using junit-contracts


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

Branch: refs/heads/JAMES-1746
Commit: 8c08956229a3ae7e52edc045a1a5d75a69f7a45e
Parents: e44fba5
Author: Benoit Tellier <btellier@linagora.com>
Authored: Mon Jun 6 17:38:50 2016 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Wed Jun 8 17:09:17 2016 +0700

----------------------------------------------------------------------
 mailbox/cassandra/pom.xml                       |   5 +
 .../mail/CassandraAttachmentMapperTest.java     |  30 -
 .../mail/CassandraMailboxMapperTest.java        |  27 -
 .../mail/CassandraMailboxMessageMapperTest.java |  27 -
 .../cassandra/mail/CassandraMapperProvider.java |   5 +
 .../cassandra/mail/CassandraMappersTests.java   |  60 ++
 .../mail/CassandraMessageMoveTest.java          |  29 -
 mailbox/memory/pom.xml                          |   5 +
 .../mail/InMemoryMailboxMapperTest.java         |  29 -
 .../inmemory/mail/InMemoryMapperProvider.java   |   5 +
 .../mail/InMemoryMessageMapperTest.java         |  40 -
 .../inmemory/mail/InMemoryMessageMoveTest.java  |  29 -
 .../inmemory/mail/MemoryMappersTests.java       |  60 ++
 mailbox/store/pom.xml                           |   5 +
 .../model/AbstractAttachmentMapperTest.java     |  90 ---
 .../mail/model/AbstractMailboxMapperTest.java   | 267 -------
 .../mail/model/AbstractMessageMapperTest.java   | 740 ------------------
 .../mail/model/AbstractMessageMoveTest.java     | 147 ----
 .../store/mail/model/AttachmentMapperTest.java  |  95 +++
 .../store/mail/model/MailboxMapperTest.java     | 278 +++++++
 .../store/mail/model/MapperProvider.java        |   2 +
 .../store/mail/model/MessageMapperTest.java     | 755 +++++++++++++++++++
 .../store/mail/model/MessageMoveTest.java       | 157 ++++
 23 files changed, 1432 insertions(+), 1455 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/8c089562/mailbox/cassandra/pom.xml
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/pom.xml b/mailbox/cassandra/pom.xml
index 7bae6c7..a05adca 100644
--- a/mailbox/cassandra/pom.xml
+++ b/mailbox/cassandra/pom.xml
@@ -147,6 +147,11 @@
             </activation>
             <dependencies>
                 <dependency>
+                    <groupId>org.xenei</groupId>
+                    <artifactId>junit-contracts</artifactId>
+                    <scope>test</scope>
+                </dependency>
+                <dependency>
                     <groupId>com.google.guava</groupId>
                     <artifactId>guava</artifactId>
                 </dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/8c089562/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentMapperTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentMapperTest.java
deleted file mode 100644
index d4162bb..0000000
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentMapperTest.java
+++ /dev/null
@@ -1,30 +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 org.apache.james.mailbox.store.mail.model.AbstractAttachmentMapperTest;
-
-public class CassandraAttachmentMapperTest extends AbstractAttachmentMapperTest {
-
-    public CassandraAttachmentMapperTest() {
-        super(new CassandraMapperProvider());
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/8c089562/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperTest.java
deleted file mode 100644
index a6b1291..0000000
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperTest.java
+++ /dev/null
@@ -1,27 +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 org.apache.james.mailbox.store.mail.model.AbstractMailboxMapperTest;
-
-public class CassandraMailboxMapperTest extends AbstractMailboxMapperTest {
-    public CassandraMailboxMapperTest() {
-        super(new CassandraMapperProvider());
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/8c089562/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMessageMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMessageMapperTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMessageMapperTest.java
deleted file mode 100644
index a656d28..0000000
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMessageMapperTest.java
+++ /dev/null
@@ -1,27 +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 org.apache.james.mailbox.store.mail.model.AbstractMessageMapperTest;
-
-public class CassandraMailboxMessageMapperTest extends AbstractMessageMapperTest {
-    public CassandraMailboxMessageMapperTest() {
-        super(new CassandraMapperProvider());
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/8c089562/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java
index 1aa82dc..0bb915b 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java
@@ -91,4 +91,9 @@ public class CassandraMapperProvider implements MapperProvider {
     public void ensureMapperPrepared() throws MailboxException {
         cassandra.ensureAllTables();
     }
+
+    @Override
+    public boolean supportPartialAttachmentFetch() {
+        return true;
+    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/8c089562/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMappersTests.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMappersTests.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMappersTests.java
new file mode 100644
index 0000000..205c886
--- /dev/null
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMappersTests.java
@@ -0,0 +1,60 @@
+/****************************************************************
+ * 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 org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.store.mail.model.MapperProvider;
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.IProducer;
+
+import com.google.common.base.Throwables;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(CassandraMapperProvider.class)
+public class CassandraMappersTests {
+
+    private IProducer<MapperProvider> producer = new IProducer<MapperProvider>() {
+
+        private final CassandraMapperProvider cassandraMapperProvider = new CassandraMapperProvider();
+
+        @Override
+        public CassandraMapperProvider newInstance() {
+            return cassandraMapperProvider;
+        }
+
+        @Override
+        public void cleanUp() {
+            try {
+                cassandraMapperProvider.clearMapper();
+            } catch (MailboxException e) {
+                throw Throwables.propagate(e);
+            }
+        }
+    };
+
+    @Contract.Inject
+    public IProducer<MapperProvider> getProducer() {
+        return producer;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/8c089562/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMoveTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMoveTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMoveTest.java
deleted file mode 100644
index fbf7804..0000000
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMoveTest.java
+++ /dev/null
@@ -1,29 +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 org.apache.james.mailbox.store.mail.model.AbstractMessageMoveTest;
-
-public class CassandraMessageMoveTest extends AbstractMessageMoveTest {
-
-    public CassandraMessageMoveTest() {
-        super(new CassandraMapperProvider());
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/8c089562/mailbox/memory/pom.xml
----------------------------------------------------------------------
diff --git a/mailbox/memory/pom.xml b/mailbox/memory/pom.xml
index a08a5d1..0667a91 100644
--- a/mailbox/memory/pom.xml
+++ b/mailbox/memory/pom.xml
@@ -80,6 +80,11 @@
             <version>${assertj-1.version}</version>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.xenei</groupId>
+            <artifactId>junit-contracts</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>

http://git-wip-us.apache.org/repos/asf/james-project/blob/8c089562/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxMapperTest.java b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxMapperTest.java
deleted file mode 100644
index 8abdae8..0000000
--- a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxMapperTest.java
+++ /dev/null
@@ -1,29 +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.inmemory.mail;
-
-import org.apache.james.mailbox.store.mail.model.AbstractMailboxMapperTest;
-
-public class InMemoryMailboxMapperTest extends AbstractMailboxMapperTest {
-
-    public InMemoryMailboxMapperTest() {
-        super(new InMemoryMapperProvider());
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/8c089562/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMapperProvider.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMapperProvider.java b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMapperProvider.java
index 3fa98da..39a3623 100644
--- a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMapperProvider.java
+++ b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMapperProvider.java
@@ -48,4 +48,9 @@ public class InMemoryMapperProvider implements MapperProvider {
     public void ensureMapperPrepared() throws MailboxException {
 
     }
+
+    @Override
+    public boolean supportPartialAttachmentFetch() {
+        return false;
+    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/8c089562/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMessageMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMessageMapperTest.java b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMessageMapperTest.java
deleted file mode 100644
index ad61d5e..0000000
--- a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMessageMapperTest.java
+++ /dev/null
@@ -1,40 +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.inmemory.mail;
-
-import org.apache.james.mailbox.store.mail.model.AbstractMessageMapperTest;
-import org.junit.Ignore;
-
-public class InMemoryMessageMapperTest extends AbstractMessageMapperTest {
-
-    public InMemoryMessageMapperTest() {
-        super(new InMemoryMapperProvider());
-    }
-
-    @Ignore("Partial fetch not supported by InMemory backend")
-    @Override
-    public void messagesRetrievedUsingFetchTypeHeadersShouldHaveAttachmentsIdsEmptyWhenOneAttachment() {
-    }
-
-    @Ignore("Partial fetch not supported by InMemory backend")
-    @Override
-    public void messagesRetrievedUsingFetchTypeMetadataShouldHaveAttachmentsIdsEmptyWhenOneAttachment() {
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/8c089562/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMessageMoveTest.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMessageMoveTest.java b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMessageMoveTest.java
deleted file mode 100644
index 8244bcb..0000000
--- a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMessageMoveTest.java
+++ /dev/null
@@ -1,29 +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.inmemory.mail;
-
-import org.apache.james.mailbox.store.mail.model.AbstractMessageMoveTest;
-
-public class InMemoryMessageMoveTest extends AbstractMessageMoveTest {
-
-    public InMemoryMessageMoveTest() {
-        super(new InMemoryMapperProvider());
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/8c089562/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryMappersTests.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryMappersTests.java b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryMappersTests.java
new file mode 100644
index 0000000..ca3af9a
--- /dev/null
+++ b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/MemoryMappersTests.java
@@ -0,0 +1,60 @@
+/****************************************************************
+ * 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.inmemory.mail;
+
+import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.store.mail.model.MapperProvider;
+import org.junit.runner.RunWith;
+import org.xenei.junit.contract.Contract;
+import org.xenei.junit.contract.ContractImpl;
+import org.xenei.junit.contract.ContractSuite;
+import org.xenei.junit.contract.IProducer;
+
+import com.google.common.base.Throwables;
+
+@RunWith(ContractSuite.class)
+@ContractImpl(InMemoryMapperProvider.class)
+public class MemoryMappersTests {
+
+    private IProducer<MapperProvider> producer = new IProducer<MapperProvider>() {
+
+        private final InMemoryMapperProvider mapperProvider = new InMemoryMapperProvider();
+
+        @Override
+        public InMemoryMapperProvider newInstance() {
+            return mapperProvider;
+        }
+
+        @Override
+        public void cleanUp() {
+            try {
+                mapperProvider.clearMapper();
+            } catch (MailboxException e) {
+                throw Throwables.propagate(e);
+            }
+        }
+    };
+
+    @Contract.Inject
+    public IProducer<MapperProvider> getProducer() {
+        return producer;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/8c089562/mailbox/store/pom.xml
----------------------------------------------------------------------
diff --git a/mailbox/store/pom.xml b/mailbox/store/pom.xml
index 3add150..599e1bc 100644
--- a/mailbox/store/pom.xml
+++ b/mailbox/store/pom.xml
@@ -118,6 +118,11 @@
             <version>0.7.0-p9</version>
         </dependency>
         <dependency>
+            <groupId>org.xenei</groupId>
+            <artifactId>junit-contracts</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>org.apache.james</groupId>
             <artifactId>apache-james-mailbox-api</artifactId>
             <type>test-jar</type>

http://git-wip-us.apache.org/repos/asf/james-project/blob/8c089562/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractAttachmentMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractAttachmentMapperTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractAttachmentMapperTest.java
deleted file mode 100644
index 2030cfb..0000000
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractAttachmentMapperTest.java
+++ /dev/null
@@ -1,90 +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.store.mail.model;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import org.apache.james.mailbox.exception.AttachmentNotFoundException;
-import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.store.mail.AttachmentMapper;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.google.common.collect.ImmutableList;
-
-public abstract class AbstractAttachmentMapperTest {
-
-    private MapperProvider mapperProvider;
-    private AttachmentMapper attachmentMapper;
-
-    public AbstractAttachmentMapperTest(MapperProvider mapperProvider) {
-        this.mapperProvider = mapperProvider;
-    }
-
-    @Before
-    public void setUp() throws MailboxException {
-        mapperProvider.ensureMapperPrepared();
-        attachmentMapper = mapperProvider.createAttachmentMapper();
-    }
-
-    @After
-    public void tearDown() throws MailboxException {
-        mapperProvider.clearMapper();
-    }
-
-    @Test (expected = IllegalArgumentException.class)
-    public void getAttachmentShouldThrowWhenNullAttachmentId() throws Exception {
-        attachmentMapper.getAttachment(null);
-    }
-
-    @Test (expected = AttachmentNotFoundException.class)
-    public void getAttachmentShouldThrowWhenNonReferencedAttachmentId() throws Exception {
-        attachmentMapper.getAttachment(AttachmentId.forPayload("unknown".getBytes()));
-    }
-
-    @Test
-    public void getAttachmentShouldReturnTheAttachmentWhenReferenced() throws Exception {
-        //Given
-        Attachment expected = Attachment.from("payload".getBytes(), "content");
-        AttachmentId attachmentId = expected.getAttachmentId();
-        attachmentMapper.storeAttachment(expected);
-        //When
-        Attachment attachment = attachmentMapper.getAttachment(attachmentId);
-        //Then
-        assertThat(attachment).isEqualTo(expected);
-    }
-
-    @Test
-    public void getAttachmentShouldReturnTheAttachmentsWhenMultipleStored() throws Exception {
-        //Given
-        Attachment expected1 = Attachment.from("payload1".getBytes(), "content1");
-        Attachment expected2 = Attachment.from("payload2".getBytes(), "content2");
-        AttachmentId attachmentId1 = expected1.getAttachmentId();
-        AttachmentId attachmentId2 = expected2.getAttachmentId();
-        //When
-        attachmentMapper.storeAttachments(ImmutableList.of(expected1, expected2));
-        //Then
-        Attachment attachment1 = attachmentMapper.getAttachment(attachmentId1);
-        Attachment attachment2 = attachmentMapper.getAttachment(attachmentId2);
-        assertThat(attachment1).isEqualTo(expected1);
-        assertThat(attachment2).isEqualTo(expected2);
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/8c089562/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractMailboxMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractMailboxMapperTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractMailboxMapperTest.java
deleted file mode 100644
index bd3884a..0000000
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractMailboxMapperTest.java
+++ /dev/null
@@ -1,267 +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.store.mail.model;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.fail;
-
-import java.util.List;
-
-import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.exception.MailboxNotFoundException;
-import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.store.mail.MailboxMapper;
-import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Generic purpose tests for your implementation MailboxMapper.
- * 
- * You then just need to instantiate your mailbox mapper and an IdGenerator.
- */
-public abstract class AbstractMailboxMapperTest {
-    
-    private final static char DELIMITER = ':';
-    private final static char WILDCARD = '%';
-    private final static long UID_VALIDITY = 42;
-
-    private MapperProvider mapperProvider;
-    
-    private MailboxMapper mailboxMapper;
-
-    private MailboxPath benwaInboxPath;
-    private SimpleMailbox benwaInboxMailbox;
-    private MailboxPath benwaWorkPath;
-    private SimpleMailbox benwaWorkMailbox;
-    private MailboxPath benwaWorkTodoPath;
-    private SimpleMailbox benwaWorkTodoMailbox;
-    private MailboxPath benwaPersoPath;
-    private SimpleMailbox benwaPersoMailbox;
-    private MailboxPath benwaWorkDonePath;
-    private SimpleMailbox benwaWorkDoneMailbox;
-    private MailboxPath bobInboxPath;
-    private SimpleMailbox bobyMailbox;
-    private MailboxPath bobyMailboxPath;
-    private SimpleMailbox bobInboxMailbox;
-    private MailboxPath esnDevGroupInboxPath;
-    private SimpleMailbox esnDevGroupInboxMailbox;
-    private MailboxPath esnDevGroupHublinPath;
-    private SimpleMailbox esnDevGroupHublinMailbox;
-    private MailboxPath esnDevGroupJamesPath;
-    private SimpleMailbox esnDevGroupJamesMailbox;
-    private MailboxPath obmTeamGroupInboxPath;
-    private SimpleMailbox obmTeamGroupInboxMailbox;
-    private MailboxPath obmTeamGroupOPushPath;
-    private SimpleMailbox obmTeamGroupOPushMailbox;
-    private MailboxPath obmTeamGroupRoundCubePath;
-    private SimpleMailbox obmTeamGroupRoundCubeMailbox;
-    private MailboxPath bobDifferentNamespacePath;
-    private SimpleMailbox bobDifferentNamespaceMailbox;
-
-    public AbstractMailboxMapperTest(MapperProvider mapperProvider) {
-        this.mapperProvider = mapperProvider;
-
-        benwaInboxPath = new MailboxPath("#private", "benwa", "INBOX");
-        benwaWorkPath = new MailboxPath("#private", "benwa", "INBOX"+DELIMITER+"work");
-        benwaWorkTodoPath = new MailboxPath("#private", "benwa", "INBOX"+DELIMITER+"work"+DELIMITER+"todo");
-        benwaPersoPath = new MailboxPath("#private", "benwa", "INBOX"+DELIMITER+"perso");
-        benwaWorkDonePath = new MailboxPath("#private", "benwa", "INBOX"+DELIMITER+"work"+DELIMITER+"done");
-        bobInboxPath = new MailboxPath("#private", "bob", "INBOX");
-        bobyMailboxPath = new MailboxPath("#private", "boby", "INBOX.that.is.a.trick");
-        bobDifferentNamespacePath = new MailboxPath("#private_bob", "bob", "INBOX.bob");
-        esnDevGroupInboxPath = new MailboxPath("#community_ESN_DEV", null, "INBOX");
-        esnDevGroupHublinPath = new MailboxPath("#community_ESN_DEV", null, "INBOX"+DELIMITER+"hublin");
-        esnDevGroupJamesPath = new MailboxPath("#community_ESN_DEV", null, "INBOX"+DELIMITER+"james");
-        obmTeamGroupInboxPath = new MailboxPath("#community_OBM_Core_Team", null, "INBOX");
-        obmTeamGroupOPushPath = new MailboxPath("#community_OBM_Core_Team", null, "INBOX"+DELIMITER+"OPush");
-        obmTeamGroupRoundCubePath = new MailboxPath("#community_OBM_Core_Team", null, "INBOX"+DELIMITER+"roundCube");
-
-        benwaInboxMailbox = createMailbox(benwaInboxPath);
-        benwaWorkMailbox = createMailbox(benwaWorkPath);
-        benwaWorkTodoMailbox = createMailbox(benwaWorkTodoPath);
-        benwaPersoMailbox = createMailbox(benwaPersoPath);
-        benwaWorkDoneMailbox = createMailbox(benwaWorkDonePath);
-        bobInboxMailbox = createMailbox(bobInboxPath);
-        esnDevGroupInboxMailbox = createMailbox(esnDevGroupInboxPath);
-        esnDevGroupHublinMailbox = createMailbox(esnDevGroupHublinPath);
-        esnDevGroupJamesMailbox = createMailbox(esnDevGroupJamesPath);
-        obmTeamGroupInboxMailbox = createMailbox(obmTeamGroupInboxPath);
-        obmTeamGroupOPushMailbox = createMailbox(obmTeamGroupOPushPath);
-        obmTeamGroupRoundCubeMailbox = createMailbox(obmTeamGroupRoundCubePath);
-        bobyMailbox = createMailbox(bobyMailboxPath);
-        bobDifferentNamespaceMailbox = createMailbox(bobDifferentNamespacePath);
-    }
-
-    @Before
-    public void setUp() throws MailboxException {
-        mapperProvider.ensureMapperPrepared();
-        mailboxMapper = mapperProvider.createMailboxMapper();
-    }
-
-    @After
-    public void tearDown() throws MailboxException {
-        mapperProvider.clearMapper();
-    }
-
-    @Test(expected=MailboxNotFoundException.class)
-    public void findMailboxByPathWhenAbsentShouldFail() throws MailboxException {
-        mailboxMapper.findMailboxByPath(new MailboxPath("#private", "benwa", "INBOX"));
-    }
-    
-    @Test
-    public void saveShouldPersistTheMailbox() throws MailboxException{
-        mailboxMapper.save(benwaInboxMailbox);
-        MailboxAssert.assertThat(mailboxMapper.findMailboxByPath(benwaInboxPath)).isEqualTo(benwaInboxMailbox);
-    }
-
-    @Test
-    public void saveWithNullUserShouldPersistTheMailbox() throws MailboxException{
-        mailboxMapper.save(esnDevGroupInboxMailbox);
-        MailboxAssert.assertThat(mailboxMapper.findMailboxByPath(esnDevGroupInboxPath)).isEqualTo(esnDevGroupInboxMailbox);
-    }
-    
-    @Test
-    public void listShouldRetrieveAllMailbox() throws MailboxException {
-        saveAll();
-        List<Mailbox> mailboxes = mailboxMapper.list();
-        assertThat(mailboxes).contains(benwaInboxMailbox, benwaWorkMailbox, benwaWorkTodoMailbox, benwaPersoMailbox, benwaWorkDoneMailbox, bobInboxMailbox, esnDevGroupInboxMailbox, esnDevGroupHublinMailbox,
-            esnDevGroupJamesMailbox, obmTeamGroupInboxMailbox, obmTeamGroupOPushMailbox, obmTeamGroupRoundCubeMailbox);
-    }
-    
-    @Test
-    public void hasChildrenShouldReturnFalseWhenNoChildrenExists() throws MailboxException {
-        saveAll();
-        assertThat(mailboxMapper.hasChildren(benwaWorkTodoMailbox, DELIMITER)).isFalse();
-    }
-
-    @Test
-    public void hasChildrenShouldReturnTrueWhenChildrenExists() throws MailboxException {
-        saveAll();
-        assertThat(mailboxMapper.hasChildren(benwaInboxMailbox, DELIMITER)).isTrue();
-    }
-
-    @Test
-    public void hasChildrenWithNullUserShouldReturnFalseWhenNoChildrenExists() throws MailboxException {
-        saveAll();
-        assertThat(mailboxMapper.hasChildren(esnDevGroupHublinMailbox, DELIMITER)).isFalse();
-    }
-
-    @Test
-    public void hasChildrenWithNullUserShouldReturnTrueWhenChildrenExists() throws MailboxException {
-        saveAll();
-        assertThat(mailboxMapper.hasChildren(esnDevGroupInboxMailbox, DELIMITER)).isTrue();
-    }
-
-    @Test
-    public void hasChildrenShouldNotBeAcrossUsersAndNamespace() throws MailboxException {
-        saveAll();
-        assertThat(mailboxMapper.hasChildren(bobInboxMailbox, '.')).isFalse();
-    }
-
-    @Test
-    public void findMailboxWithPathLikeShouldBeLimitedToUserAndNamespace() throws MailboxException {
-        saveAll();
-        MailboxPath mailboxPathQuery = new MailboxPath(bobInboxMailbox.getNamespace(), bobInboxMailbox.getUser(), "IN" + WILDCARD);
-        assertThat(mailboxMapper.findMailboxWithPathLike(mailboxPathQuery)).containsOnly(bobInboxMailbox);
-    }
-
-    @Test(expected=MailboxNotFoundException.class)
-    public void deleteShouldEraseTheGivenMailbox() throws MailboxException {
-        try {
-            saveAll();
-            mailboxMapper.delete(benwaInboxMailbox);
-        } catch(MailboxException exception) {
-            fail("Error was not thrown by the appropriate method", exception);
-        }
-        mailboxMapper.findMailboxByPath(benwaInboxPath);
-    }
-
-    @Test(expected=MailboxNotFoundException.class)
-    public void deleteWithNullUserShouldEraseTheGivenMailbox() throws MailboxException {
-        try {
-            saveAll();
-            mailboxMapper.delete(esnDevGroupJamesMailbox);
-        } catch(MailboxException exception) {
-            fail("Error was not thrown by the appropriate method", exception);
-        }
-        mailboxMapper.findMailboxByPath(esnDevGroupJamesPath);
-    }
-
-    @Test
-    public void findMailboxWithPathLikeWithChildRegexShouldRetrieveChildren() throws MailboxException {
-        saveAll();
-        MailboxPath regexPath = new MailboxPath(benwaWorkPath.getNamespace(), benwaWorkPath.getUser(), benwaWorkPath.getName() + WILDCARD);
-        assertThat(mailboxMapper.findMailboxWithPathLike(regexPath)).containsOnly(benwaWorkMailbox, benwaWorkTodoMailbox, benwaWorkDoneMailbox);
-    }
-
-    @Test
-    public void findMailboxWithPathLikeWithNullUserWithChildRegexShouldRetrieveChildren() throws MailboxException {
-        saveAll();
-        MailboxPath regexPath = new MailboxPath(obmTeamGroupInboxPath.getNamespace(), obmTeamGroupInboxPath.getUser(), obmTeamGroupInboxPath.getName() + WILDCARD);
-        assertThat(mailboxMapper.findMailboxWithPathLike(regexPath)).contains(obmTeamGroupInboxMailbox, obmTeamGroupOPushMailbox, obmTeamGroupRoundCubeMailbox);
-    }
-
-    @Test
-    public void findMailboxWithPathLikeWithRegexShouldRetrieveCorrespondingMailbox() throws MailboxException {
-        saveAll();
-        MailboxPath regexPath = new MailboxPath(benwaInboxPath.getNamespace(), benwaInboxPath.getUser(), WILDCARD + "X");
-        assertThat(mailboxMapper.findMailboxWithPathLike(regexPath)).containsOnly(benwaInboxMailbox);
-    }
-
-    @Test
-    public void findMailboxWithPathLikeWithNullUserWithRegexShouldRetrieveCorrespondingMailbox() throws MailboxException {
-        saveAll();
-        MailboxPath regexPath = new MailboxPath(esnDevGroupInboxPath.getNamespace(), esnDevGroupInboxPath.getUser(), WILDCARD + "X");
-        assertThat(mailboxMapper.findMailboxWithPathLike(regexPath)).contains(esnDevGroupInboxMailbox);
-    }
-
-    @Test
-    public void findMailboxWithPathLikeShouldEscapeMailboxName() throws MailboxException {
-        saveAll();
-        MailboxPath regexPath = new MailboxPath(benwaInboxPath.getNamespace(), benwaInboxPath.getUser(), "INB?X");
-        assertThat(mailboxMapper.findMailboxWithPathLike(regexPath)).isEmpty();
-    }
-    
-    private void saveAll() throws MailboxException{
-        mailboxMapper.save(benwaInboxMailbox);
-        mailboxMapper.save(benwaWorkMailbox);
-        mailboxMapper.save(benwaWorkTodoMailbox);
-        mailboxMapper.save(benwaPersoMailbox);
-        mailboxMapper.save(benwaWorkDoneMailbox);
-        mailboxMapper.save(esnDevGroupInboxMailbox);
-        mailboxMapper.save(esnDevGroupHublinMailbox);
-        mailboxMapper.save(esnDevGroupJamesMailbox);
-        mailboxMapper.save(obmTeamGroupInboxMailbox);
-        mailboxMapper.save(obmTeamGroupOPushMailbox);
-        mailboxMapper.save(obmTeamGroupRoundCubeMailbox);
-        mailboxMapper.save(bobyMailbox);
-        mailboxMapper.save(bobDifferentNamespaceMailbox);
-        mailboxMapper.save(bobInboxMailbox);
-    }
-
-    private SimpleMailbox createMailbox(MailboxPath mailboxPath) {
-        SimpleMailbox mailbox = new SimpleMailbox(mailboxPath, UID_VALIDITY);
-        mailbox.setMailboxId(mapperProvider.generateId());
-        return mailbox;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/8c089562/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractMessageMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractMessageMapperTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractMessageMapperTest.java
deleted file mode 100644
index 7641a52..0000000
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractMessageMapperTest.java
+++ /dev/null
@@ -1,740 +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.store.mail.model;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.io.IOException;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.mail.Flags;
-import javax.mail.util.SharedByteArrayInputStream;
-
-import org.apache.james.mailbox.FlagsBuilder;
-import org.apache.james.mailbox.MessageManager.FlagsUpdateMode;
-import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.model.MessageMetaData;
-import org.apache.james.mailbox.model.MessageRange;
-import org.apache.james.mailbox.model.UpdatedFlags;
-import org.apache.james.mailbox.store.FlagsUpdateCalculator;
-import org.apache.james.mailbox.store.mail.MessageMapper;
-import org.apache.james.mailbox.store.mail.MessageMapper.FetchType;
-import org.apache.james.mailbox.store.mail.model.impl.PropertyBuilder;
-import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
-import org.apache.james.mailbox.store.mail.model.impl.SimpleMailboxMessage;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.google.common.collect.ImmutableList;
-
-public abstract class AbstractMessageMapperTest {
-
-    private final static char DELIMITER = ':';
-    private static final int LIMIT = 10;
-    private static final int BODY_START = 16;
-    public static final int UID_VALIDITY = 42;
-    public static final String USER_FLAG = "userFlag";
-
-    private MapperProvider mapperProvider;
-    private MessageMapper messageMapper;
-
-    private SimpleMailbox benwaInboxMailbox;
-    private SimpleMailbox benwaWorkMailbox;
-    private SimpleMailbox attachmentsMailbox;
-    
-    private SimpleMailboxMessage message1;
-    private SimpleMailboxMessage message2;
-    private SimpleMailboxMessage message3;
-    private SimpleMailboxMessage message4;
-    private SimpleMailboxMessage message5;
-    private SimpleMailboxMessage message6;
-    private SimpleMailboxMessage message7With1Attachment;
-    private SimpleMailboxMessage message8With2Attachments;
-
-    public AbstractMessageMapperTest(MapperProvider mapperProvider) {
-        this.mapperProvider = mapperProvider;
-    }
-
-    @Before
-    public void setUp() throws MailboxException {
-        mapperProvider.ensureMapperPrepared();
-        messageMapper = mapperProvider.createMessageMapper();
-        benwaInboxMailbox = createMailbox(new MailboxPath("#private", "benwa", "INBOX"));
-        benwaWorkMailbox = createMailbox( new MailboxPath("#private", "benwa", "INBOX"+DELIMITER+"work"));
-        attachmentsMailbox = createMailbox( new MailboxPath("#private", "benwa", "Attachments"));
-        message1 = createMessage(benwaInboxMailbox, "Subject: Test1 \n\nBody1\n.\n", BODY_START, new PropertyBuilder());
-        message2 = createMessage(benwaInboxMailbox, "Subject: Test2 \n\nBody2\n.\n", BODY_START, new PropertyBuilder());
-        message3 = createMessage(benwaInboxMailbox, "Subject: Test3 \n\nBody3\n.\n", BODY_START, new PropertyBuilder());
-        message4 = createMessage(benwaInboxMailbox, "Subject: Test4 \n\nBody4\n.\n", BODY_START, new PropertyBuilder());
-        message5 = createMessage(benwaInboxMailbox, "Subject: Test5 \n\nBody5\n.\n", BODY_START, new PropertyBuilder());
-        message6 = createMessage(benwaWorkMailbox, "Subject: Test6 \n\nBody6\n.\n", BODY_START, new PropertyBuilder());
-        message7With1Attachment = createMessage(attachmentsMailbox, "Subject: Test7 \n\nBody7\n.\n", BODY_START, new PropertyBuilder(), ImmutableList.of(AttachmentId.from("123")));
-        message8With2Attachments = createMessage(attachmentsMailbox, "Subject: Test8 \n\nBody8\n.\n", BODY_START, new PropertyBuilder(), ImmutableList.of(AttachmentId.from("123"), AttachmentId.from("456")));
-    }
-
-    @After
-    public void tearDown() throws MailboxException {
-        mapperProvider.clearMapper();
-    }
-    
-    @Test
-    public void emptyMailboxShouldHaveZeroMessageCount() throws MailboxException {
-        assertThat(messageMapper.countMessagesInMailbox(benwaInboxMailbox)).isEqualTo(0);
-    }
-    
-    @Test
-    public void mailboxContainingMessagesShouldHaveTheGoodMessageCount() throws MailboxException {
-        saveMessages();
-        assertThat(messageMapper.countMessagesInMailbox(benwaInboxMailbox)).isEqualTo(5);
-    }
-
-    @Test
-    public void mailboxCountShouldBeDecrementedAfterAMessageDelete() throws MailboxException {
-        saveMessages();
-        messageMapper.delete(benwaInboxMailbox, message1);
-        assertThat(messageMapper.countMessagesInMailbox(benwaInboxMailbox)).isEqualTo(4);
-    }
-    
-    @Test
-    public void emptyMailboxShouldNotHaveUnseenMessages() throws MailboxException {
-        assertThat(messageMapper.countUnseenMessagesInMailbox(benwaInboxMailbox)).isEqualTo(0);
-    }
-    
-    @Test
-    public void mailboxContainingMessagesShouldHaveTheGoodUnseenMessageCount() throws MailboxException {
-        saveMessages();
-        assertThat(messageMapper.countUnseenMessagesInMailbox(benwaInboxMailbox)).isEqualTo(5);
-    }
-
-    @Test
-    public void mailboxUnSeenCountShouldBeDecrementedAfterAMessageIsMarkedSeen() throws MailboxException {
-        saveMessages();
-        messageMapper.updateFlags(benwaInboxMailbox, new FlagsUpdateCalculator(new Flags(Flags.Flag.SEEN), FlagsUpdateMode.REPLACE), MessageRange.one(message1.getUid())).hasNext();
-        assertThat(messageMapper.countUnseenMessagesInMailbox(benwaInboxMailbox)).isEqualTo(4);
-    }
-
-    @Test
-    public void mailboxUnSeenCountShouldBeDecrementedAfterAMessageIsMarkedUnSeen() throws MailboxException {
-        saveMessages();
-        messageMapper.updateFlags(benwaInboxMailbox, new FlagsUpdateCalculator(new Flags(Flags.Flag.SEEN), FlagsUpdateMode.REPLACE), MessageRange.one(message1.getUid()));
-        messageMapper.updateFlags(benwaInboxMailbox, new FlagsUpdateCalculator(new Flags(), FlagsUpdateMode.REPLACE), MessageRange.one(message1.getUid()));
-        assertThat(messageMapper.countUnseenMessagesInMailbox(benwaInboxMailbox)).isEqualTo(5);
-    }
-    
-    @Test
-    public void mailboxUnSeenCountShouldBeDecrementedAfterAMessageDelete() throws MailboxException {
-        saveMessages();
-        messageMapper.delete(benwaInboxMailbox, message1);
-        assertThat(messageMapper.countUnseenMessagesInMailbox(benwaInboxMailbox)).isEqualTo(4);
-    }
-
-    @Test
-    public void deletedMessagesShouldBeRemovedFromStorage() throws MailboxException {
-        saveMessages();
-        messageMapper.delete(benwaInboxMailbox, message1);
-        assertThat(messageMapper.findInMailbox(benwaInboxMailbox, MessageRange.one(message1.getUid()), MessageMapper.FetchType.Metadata, LIMIT)).isEmpty();
-    }
-
-    @Test
-    public void deletingUnExistingMessageShouldHaveNoSideEffect() throws MailboxException, IOException {
-        saveMessages();
-        message6.setUid(messageMapper.getLastUid(benwaInboxMailbox) + 1);
-        messageMapper.delete(benwaInboxMailbox, message6);
-        assertThat(messageMapper.findInMailbox(benwaInboxMailbox, MessageRange.all(), MessageMapper.FetchType.Full, LIMIT))
-            .containsOnly(message1, message2, message3, message4, message5);
-    }
-
-    @Test
-    public void noMessageShouldBeRetrievedInEmptyMailbox() throws MailboxException {
-        assertThat(messageMapper.findInMailbox(benwaInboxMailbox, MessageRange.one(message1.getUid()), MessageMapper.FetchType.Metadata, LIMIT)).isEmpty();
-    }
-
-    @Test
-    public void messagesCanBeRetrievedInMailboxWithRangeTypeOne() throws MailboxException, IOException{
-        saveMessages();
-        MessageMapper.FetchType fetchType = MessageMapper.FetchType.Full;
-        int limit =10;
-        MessageAssert.assertThat(messageMapper.findInMailbox(benwaInboxMailbox, MessageRange.one(message1.getUid()), fetchType, limit).next())
-            .isEqualTo(message1, fetchType);
-    }
-
-    @Test
-    public void messagesCanBeRetrievedInMailboxWithRangeTypeRange() throws MailboxException, IOException{
-        saveMessages();
-        Iterator<MailboxMessage> retrievedMessageIterator = messageMapper
-                .findInMailbox(benwaInboxMailbox, MessageRange.range(message1.getUid(), message4.getUid()), MessageMapper.FetchType.Full, LIMIT);
-        assertThat(retrievedMessageIterator).containsOnly(message1, message2, message3, message4);
-    }
-
-    @Test
-    public void messagesCanBeRetrievedInMailboxWithRangeTypeRangeContainingAHole() throws MailboxException, IOException {
-        saveMessages();
-        messageMapper.delete(benwaInboxMailbox, message3);
-        Iterator<MailboxMessage> retrievedMessageIterator = messageMapper
-            .findInMailbox(benwaInboxMailbox, MessageRange.range(message1.getUid(), message4.getUid()), MessageMapper.FetchType.Full, LIMIT);
-        assertThat(retrievedMessageIterator).containsOnly(message1, message2, message4);
-    }
-
-    @Test
-    public void messagesCanBeRetrievedInMailboxWithRangeTypeFrom() throws MailboxException, IOException {
-        saveMessages();
-        Iterator<MailboxMessage> retrievedMessageIterator = messageMapper
-                .findInMailbox(benwaInboxMailbox, MessageRange.from(message3.getUid()), MessageMapper.FetchType.Full, LIMIT);
-        assertThat(retrievedMessageIterator).containsOnly(message3, message4, message5);
-    }
-
-    @Test
-    public void messagesCanBeRetrievedInMailboxWithRangeTypeFromContainingAHole() throws MailboxException, IOException {
-        saveMessages();
-        messageMapper.delete(benwaInboxMailbox, message4);
-        Iterator<MailboxMessage> retrievedMessageIterator = messageMapper
-                .findInMailbox(benwaInboxMailbox, MessageRange.from(message3.getUid()), MessageMapper.FetchType.Full, LIMIT);
-        assertThat(retrievedMessageIterator).containsOnly(message3, message5);
-    }
-
-    @Test
-    public void messagesCanBeRetrievedInMailboxWithRangeTypeAll() throws MailboxException, IOException {
-        saveMessages();
-        assertThat(messageMapper.findInMailbox(benwaInboxMailbox, MessageRange.all(), MessageMapper.FetchType.Full, LIMIT))
-            .containsOnly(message1, message2, message3, message4, message5);
-    }
-
-    @Test
-    public void messagesCanBeRetrievedInMailboxWithRangeTypeAllContainingHole() throws MailboxException, IOException {
-        saveMessages();
-        messageMapper.delete(benwaInboxMailbox, message1);
-        Iterator<MailboxMessage> retrievedMessageIterator = messageMapper
-                .findInMailbox(benwaInboxMailbox, MessageRange.all(), MessageMapper.FetchType.Full, LIMIT);
-        assertThat(retrievedMessageIterator).containsOnly(message2, message3, message4, message5);
-    }
-    
-    @Test
-    public void messagesRetrievedUsingFetchTypeMetadataShouldHaveAtLastMetadataDataLoaded() throws MailboxException, IOException{
-        saveMessages();
-        MessageMapper.FetchType fetchType = MessageMapper.FetchType.Metadata;
-        Iterator<MailboxMessage> retrievedMessageIterator = messageMapper.findInMailbox(benwaInboxMailbox, MessageRange.one(message1.getUid()), fetchType, LIMIT);
-        MessageAssert.assertThat(retrievedMessageIterator.next()).isEqualTo(message1, fetchType);
-        assertThat(retrievedMessageIterator).isEmpty();
-    }
-
-    @Test
-    public void messagesRetrievedUsingFetchTypeHeaderShouldHaveHeaderDataLoaded() throws MailboxException, IOException{
-        saveMessages();
-        MessageMapper.FetchType fetchType = MessageMapper.FetchType.Headers;
-        Iterator<MailboxMessage> retrievedMessageIterator = messageMapper.findInMailbox(benwaInboxMailbox, MessageRange.one(message1.getUid()), fetchType, LIMIT);
-        MessageAssert.assertThat(retrievedMessageIterator.next()).isEqualTo(message1, fetchType);
-        assertThat(retrievedMessageIterator).isEmpty();
-    }
-
-    @Test
-    public void messagesRetrievedUsingFetchTypeBodyShouldHaveBodyDataLoaded() throws MailboxException, IOException{
-        saveMessages();
-        MessageMapper.FetchType fetchType = MessageMapper.FetchType.Body;
-        Iterator<MailboxMessage> retrievedMessageIterator = messageMapper.findInMailbox(benwaInboxMailbox, MessageRange.one(message1.getUid()), fetchType, LIMIT);
-        MessageAssert.assertThat(retrievedMessageIterator.next()).isEqualTo(message1, fetchType);
-        assertThat(retrievedMessageIterator).isEmpty();
-    }
-
-    @Test
-    public void messagesRetrievedUsingFetchTypeFullShouldHaveAttachmentsIdsEmptyWhenNoAttachment() throws MailboxException, IOException{
-        saveMessages();
-        MessageMapper.FetchType fetchType = MessageMapper.FetchType.Full;
-        Iterator<MailboxMessage> retrievedMessageIterator = messageMapper.findInMailbox(benwaInboxMailbox, MessageRange.one(message1.getUid()), fetchType, LIMIT);
-        assertThat(retrievedMessageIterator.next().getAttachmentsIds()).isEmpty();
-    }
-
-    @Test
-    public void messagesRetrievedUsingFetchTypeFullShouldHaveAttachmentsIdsLoadedWhenOneAttachment() throws MailboxException, IOException{
-        saveMessages();
-        MessageMapper.FetchType fetchType = MessageMapper.FetchType.Full;
-        Iterator<MailboxMessage> retrievedMessageIterator = messageMapper.findInMailbox(attachmentsMailbox, MessageRange.one(message7With1Attachment.getUid()), fetchType, LIMIT);
-        assertThat(retrievedMessageIterator.next().getAttachmentsIds()).isEqualTo(message7With1Attachment.getAttachmentsIds());
-    }
-
-    @Test
-    public void messagesRetrievedUsingFetchTypeFullShouldHaveAttachmentsIdsLoadedWhenTwoAttachments() throws MailboxException, IOException{
-        saveMessages();
-        MessageMapper.FetchType fetchType = MessageMapper.FetchType.Full;
-        Iterator<MailboxMessage> retrievedMessageIterator = messageMapper.findInMailbox(attachmentsMailbox, MessageRange.one(message8With2Attachments.getUid()), fetchType, LIMIT);
-        assertThat(retrievedMessageIterator.next().getAttachmentsIds()).isEqualTo(message8With2Attachments.getAttachmentsIds());
-    }
-
-    @Test
-    public void messagesRetrievedUsingFetchTypeBodyShouldHaveAttachmentsIdsLoadedWhenOneAttachment() throws MailboxException, IOException{
-        saveMessages();
-        MessageMapper.FetchType fetchType = MessageMapper.FetchType.Body;
-        Iterator<MailboxMessage> retrievedMessageIterator = messageMapper.findInMailbox(attachmentsMailbox, MessageRange.one(message7With1Attachment.getUid()), fetchType, LIMIT);
-        assertThat(retrievedMessageIterator.next().getAttachmentsIds()).isEqualTo(message7With1Attachment.getAttachmentsIds());
-    }
-
-    @Test
-    public void messagesRetrievedUsingFetchTypeHeadersShouldHaveAttachmentsIdsEmptyWhenOneAttachment() throws MailboxException, IOException{
-        saveMessages();
-        MessageMapper.FetchType fetchType = MessageMapper.FetchType.Headers;
-        Iterator<MailboxMessage> retrievedMessageIterator = messageMapper.findInMailbox(attachmentsMailbox, MessageRange.one(message7With1Attachment.getUid()), fetchType, LIMIT);
-        assertThat(retrievedMessageIterator.next().getAttachmentsIds()).isEmpty();
-    }
-
-    @Test
-    public void messagesRetrievedUsingFetchTypeMetadataShouldHaveAttachmentsIdsEmptyWhenOneAttachment() throws MailboxException, IOException{
-        saveMessages();
-        MessageMapper.FetchType fetchType = MessageMapper.FetchType.Metadata;
-        Iterator<MailboxMessage> retrievedMessageIterator = messageMapper.findInMailbox(attachmentsMailbox, MessageRange.one(message7With1Attachment.getUid()), fetchType, LIMIT);
-        assertThat(retrievedMessageIterator.next().getAttachmentsIds()).isEmpty();
-    }
-
-    @Test
-    public void retrievingMessagesWithALimitShouldLimitTheNumberOfMessages() throws MailboxException {
-        int limit = 2;
-        saveMessages();
-        assertThat(messageMapper.findInMailbox(benwaInboxMailbox, MessageRange.all(), MessageMapper.FetchType.Full, limit)).hasSize(2);
-    }
-    
-    @Test
-    public void findRecentUidsInMailboxShouldReturnEmptyListWhenNoMessagesMarkedAsRecentArePresentInMailbox() throws MailboxException {
-        assertThat(messageMapper.findRecentMessageUidsInMailbox(benwaInboxMailbox)).isEmpty();
-    }
-
-    @Test
-    public void findRecentUidsInMailboxShouldReturnListOfMessagesHoldingFlagsRecent() throws MailboxException {
-        saveMessages();
-        messageMapper.updateFlags(benwaInboxMailbox, new FlagsUpdateCalculator(new Flags(Flags.Flag.RECENT), FlagsUpdateMode.REPLACE), MessageRange.one(message2.getUid()));
-        messageMapper.updateFlags(benwaInboxMailbox, new FlagsUpdateCalculator(new Flags(Flags.Flag.RECENT), FlagsUpdateMode.REPLACE), MessageRange.one(message4.getUid()));
-        messageMapper.updateFlags(benwaWorkMailbox, new FlagsUpdateCalculator(new Flags(Flags.Flag.RECENT), FlagsUpdateMode.REPLACE), MessageRange.one(message6.getUid()));
-        assertThat(messageMapper.findRecentMessageUidsInMailbox(benwaInboxMailbox)).containsOnly(message2.getUid(), message4.getUid());
-    }
-    
-    @Test
-    public void findFirstUnseenMessageUidShouldReturnNullWhenNoUnseenMessagesCanBeFound() throws MailboxException {
-        assertThat(messageMapper.findFirstUnseenMessageUid(benwaInboxMailbox)).isNull();
-    }
-
-    @Test
-    public void findFirstUnseenMessageUidShouldReturnUid1WhenUid1isNotSeen() throws MailboxException {
-        saveMessages();
-        assertThat(messageMapper.findFirstUnseenMessageUid(benwaInboxMailbox)).isEqualTo(message1.getUid());
-    }
-
-    @Test
-    public void findFirstUnseenMessageUidShouldReturnUid2WhenUid2isSeen() throws MailboxException {
-        saveMessages();
-        messageMapper.updateFlags(benwaInboxMailbox, new FlagsUpdateCalculator(new Flags(Flags.Flag.SEEN), FlagsUpdateMode.REPLACE), MessageRange.one(message1.getUid()));
-        messageMapper.updateFlags(benwaInboxMailbox, new FlagsUpdateCalculator(new Flags(Flags.Flag.SEEN), FlagsUpdateMode.REPLACE), MessageRange.one(message3.getUid()));
-        messageMapper.updateFlags(benwaInboxMailbox, new FlagsUpdateCalculator(new Flags(Flags.Flag.SEEN), FlagsUpdateMode.REPLACE), MessageRange.one(message5.getUid()));
-        assertThat(messageMapper.findFirstUnseenMessageUid(benwaInboxMailbox)).isEqualTo(message2.getUid());
-    }
-    
-    @Test
-    public void expungeMarkedForDeletionInMailboxShouldReturnEmptyResultOnEmptyMailbox() throws MailboxException, IOException {
-        assertThat(messageMapper.expungeMarkedForDeletionInMailbox(benwaInboxMailbox, MessageRange.all())).isEmpty();
-    }
-
-    @Test
-    public void expungeMarkedForDeletionInMailboxShouldReturnEmptyResultWhenNoMessageInMailboxIsDeleted() throws MailboxException, IOException {
-        saveMessages();
-        assertThat(messageMapper.expungeMarkedForDeletionInMailbox(benwaInboxMailbox, MessageRange.all())).isEmpty();
-        assertThat(messageMapper.findInMailbox(benwaInboxMailbox, MessageRange.all(), MessageMapper.FetchType.Full, LIMIT))
-            .containsOnly(message1, message2, message3, message4, message5);
-    }
-
-    @Test
-    public void expungeShouldReturnCorrectMetadataWithRangeAll() throws MailboxException, IOException {
-        saveMessages();
-        MetadataMapAssert.assertThat(markThenPerformExpunge(MessageRange.all()))
-            .hasSize(2)
-            .containsMetadataForMessages(message1, message4);
-    }
-
-    @Test
-    public void expungeShouldModifyUnderlyingStorageWithRangeAll() throws MailboxException, IOException {
-        saveMessages();
-        markThenPerformExpunge(MessageRange.all());
-        assertThat(messageMapper.findInMailbox(benwaInboxMailbox, MessageRange.all(), MessageMapper.FetchType.Full, LIMIT))
-            .containsOnly(message2, message3, message5);
-    }
-
-    @Test
-    public void expungeShouldReturnCorrectMetadataWithRangeOne() throws MailboxException, IOException {
-        saveMessages();
-        MetadataMapAssert.assertThat(markThenPerformExpunge(MessageRange.one(message1.getUid())))
-            .hasSize(1)
-            .containsMetadataForMessages(message1);
-    }
-
-    @Test
-    public void expungeShouldModifyUnderlyingStorageWithRangeOne() throws MailboxException, IOException {
-        saveMessages();
-        markThenPerformExpunge(MessageRange.one(message1.getUid()));
-        assertThat(messageMapper.findInMailbox(benwaInboxMailbox, MessageRange.all(), MessageMapper.FetchType.Full, LIMIT))
-            .containsOnly(message4, message2, message3, message5);
-    }
-
-    @Test
-    public void expungeShouldReturnCorrectMetadataWithRangeFrom() throws MailboxException, IOException {
-        saveMessages();
-        MetadataMapAssert.assertThat(markThenPerformExpunge(MessageRange.from(message3.getUid())))
-            .hasSize(1)
-            .containsMetadataForMessages(message4);
-    }
-
-    @Test
-    public void expungeShouldModifyUnderlyingStorageWithRangeFrom() throws MailboxException, IOException {
-        saveMessages();
-        markThenPerformExpunge(MessageRange.from(message3.getUid()));
-        assertThat(messageMapper.findInMailbox(benwaInboxMailbox, MessageRange.all(), MessageMapper.FetchType.Full, LIMIT))
-            .containsOnly(message1, message2, message3, message5);
-    }
-
-    @Test
-    public void expungeShouldReturnCorrectMetadataWithRange() throws MailboxException, IOException {
-        saveMessages();
-        MetadataMapAssert.assertThat(markThenPerformExpunge(MessageRange.range(message3.getUid(), message5.getUid())))
-            .hasSize(1)
-            .containsMetadataForMessages(message4);
-    }
-
-    @Test
-    public void expungeShouldModifyUnderlyingStorageWithRange() throws MailboxException, IOException {
-        saveMessages();
-        markThenPerformExpunge(MessageRange.range(message3.getUid(), message5.getUid()));
-        assertThat(messageMapper.findInMailbox(benwaInboxMailbox, MessageRange.all(), MessageMapper.FetchType.Full, LIMIT))
-            .containsOnly(message1, message2, message3, message5);
-    }
-
-    @Test
-    public void getHighestMoseqShouldBeEqualToZeroOnEmptyMailbox() throws MailboxException {
-        assertThat(messageMapper.getHighestModSeq(benwaInboxMailbox)).isEqualTo(0);
-    }
-
-    @Test
-    public void insertingAMessageShouldIncrementModSeq() throws MailboxException {
-        messageMapper.add(benwaInboxMailbox, message1);
-        long modSeq = messageMapper.getHighestModSeq(benwaInboxMailbox);
-        assertThat(modSeq).isGreaterThan(0);
-        messageMapper.add(benwaInboxMailbox, message2);
-        assertThat(messageMapper.getHighestModSeq(benwaInboxMailbox)).isGreaterThan(modSeq);
-    }
-
-    @Test
-    public void getLastUidShouldReturn0OnEmptyMailbox() throws MailboxException {
-        assertThat(messageMapper.getLastUid(benwaInboxMailbox)).isEqualTo(0);
-    }
-
-    @Test
-    public void insertingAMessageShouldIncrementLastUid() throws MailboxException {
-        messageMapper.add(benwaInboxMailbox, message1);
-        long uid = messageMapper.getLastUid(benwaInboxMailbox);
-        assertThat(uid).isGreaterThan(0);
-        messageMapper.add(benwaInboxMailbox, message2);
-        assertThat(messageMapper.getLastUid(benwaInboxMailbox)).isGreaterThan(uid);
-    }
-
-    @Test
-    public void copyShouldIncrementUid() throws MailboxException, IOException {
-        saveMessages();
-        long uid = messageMapper.getLastUid(benwaInboxMailbox);
-        messageMapper.copy(benwaInboxMailbox, SimpleMailboxMessage.copy(benwaInboxMailbox.getMailboxId(), message6));
-        assertThat(messageMapper.getLastUid(benwaInboxMailbox)).isGreaterThan(uid);
-    }
-
-    @Test
-    public void copyShouldIncrementMessageCount() throws MailboxException, IOException {
-        saveMessages();
-        messageMapper.copy(benwaInboxMailbox, SimpleMailboxMessage.copy(benwaInboxMailbox.getMailboxId(), message6));
-        assertThat(messageMapper.countMessagesInMailbox(benwaInboxMailbox)).isEqualTo(6);
-    }
-
-    @Test
-    public void copyOfUnSeenMessageShouldIncrementUnSeenMessageCount() throws MailboxException, IOException {
-        saveMessages();
-        messageMapper.copy(benwaInboxMailbox, SimpleMailboxMessage.copy(benwaInboxMailbox.getMailboxId(), message6));
-        assertThat(messageMapper.countUnseenMessagesInMailbox(benwaInboxMailbox)).isEqualTo(6);
-    }
-
-    @Test
-    public void copyShouldIncrementModSeq() throws MailboxException, IOException {
-        saveMessages();
-        long modSeq = messageMapper.getHighestModSeq(benwaInboxMailbox);
-        messageMapper.copy(benwaInboxMailbox, SimpleMailboxMessage.copy(benwaInboxMailbox.getMailboxId(), message6));
-        assertThat(messageMapper.getHighestModSeq(benwaInboxMailbox)).isGreaterThan(modSeq);
-    }
-
-    @Test
-    public void copyShouldCreateAMessageInDestination() throws MailboxException, IOException {
-        saveMessages();
-        MailboxMessage message7 = SimpleMailboxMessage.copy(benwaInboxMailbox.getMailboxId(), message6);
-        messageMapper.copy(benwaInboxMailbox, message7);
-        message7.setModSeq(messageMapper.getHighestModSeq(benwaInboxMailbox));
-        assertThat(messageMapper.getLastUid(benwaInboxMailbox)).isGreaterThan(message6.getUid());
-
-        MailboxMessage result = messageMapper.findInMailbox(benwaInboxMailbox,
-            MessageRange.one(messageMapper.getLastUid(benwaInboxMailbox)),
-            MessageMapper.FetchType.Full,
-            LIMIT)
-            .next();
-
-        MessageAssert.assertThat(result).isEqualToWithoutUid(message7, MessageMapper.FetchType.Full);
-        assertThat(result.getUid()).isEqualTo(messageMapper.getLastUid(benwaInboxMailbox));
-    }
-    
-    @Test
-    public void copyOfSeenMessageShouldNotIncrementUnSeenMessageCount() throws MailboxException {
-        message6.setFlags(new Flags(Flags.Flag.SEEN));
-        messageMapper.copy(benwaInboxMailbox, SimpleMailboxMessage.copy(benwaInboxMailbox.getMailboxId(), message6));
-        assertThat(messageMapper.countUnseenMessagesInMailbox(benwaInboxMailbox)).isEqualTo(0);
-    }
-
-    @Test
-    public void copiedMessageShouldBeMarkedAsRecent() throws MailboxException {
-        MessageMetaData metaData = messageMapper.copy(benwaInboxMailbox, SimpleMailboxMessage.copy(benwaInboxMailbox.getMailboxId(), message6));
-        assertThat(
-            messageMapper.findInMailbox(benwaInboxMailbox,
-                MessageRange.one(metaData.getUid()),
-                MessageMapper.FetchType.Metadata,
-                LIMIT
-            ).next()
-            .isRecent()
-        ).isTrue();
-    }
-
-    @Test
-    public void copiedRecentMessageShouldBeMarkedAsRecent() throws MailboxException {
-        message6.setFlags(new Flags(Flags.Flag.RECENT));
-        MessageMetaData metaData = messageMapper.copy(benwaInboxMailbox, SimpleMailboxMessage.copy(benwaInboxMailbox.getMailboxId(), message6));
-        assertThat(
-            messageMapper.findInMailbox(benwaInboxMailbox,
-                MessageRange.one(metaData.getUid()),
-                MessageMapper.FetchType.Metadata,
-                LIMIT
-            ).next()
-                .isRecent()
-        ).isTrue();
-    }
-
-    @Test
-    public void flagsReplacementShouldReplaceStoredMessageFlags() throws MailboxException {
-        saveMessages();
-        messageMapper.updateFlags(benwaInboxMailbox, new FlagsUpdateCalculator(new Flags(Flags.Flag.FLAGGED), FlagsUpdateMode.REPLACE), MessageRange.one(message1.getUid()));
-        MessageAssert.assertThat(retrieveMessageFromStorage(message1)).hasFlags(new Flags(Flags.Flag.FLAGGED));
-    }
-
-    @Test
-    public void flagsReplacementShouldReturnAnUpdatedFlagHighlightingTheReplacement() throws MailboxException {
-        saveMessages();
-        long modSeq = messageMapper.getHighestModSeq(benwaInboxMailbox);
-        assertThat(messageMapper.updateFlags(benwaInboxMailbox, new FlagsUpdateCalculator(new Flags(Flags.Flag.FLAGGED), FlagsUpdateMode.REPLACE), MessageRange.one(message1.getUid())))
-            .containsOnly(new UpdatedFlags(message1.getUid(), modSeq + 1, new Flags(), new Flags(Flags.Flag.FLAGGED)));
-    }
-
-    @Test
-    public void flagsAdditionShouldReturnAnUpdatedFlagHighlightingTheAddition() throws MailboxException {
-        saveMessages();
-        messageMapper.updateFlags(benwaInboxMailbox, new FlagsUpdateCalculator(new Flags(Flags.Flag.FLAGGED), FlagsUpdateMode.REPLACE), MessageRange.one(message1.getUid()));
-        long modSeq = messageMapper.getHighestModSeq(benwaInboxMailbox);
-        assertThat(messageMapper.updateFlags(benwaInboxMailbox, new FlagsUpdateCalculator(new Flags(Flags.Flag.SEEN), FlagsUpdateMode.ADD), MessageRange.one(message1.getUid())))
-            .containsOnly(new UpdatedFlags(message1.getUid(), modSeq + 1, new Flags(Flags.Flag.FLAGGED), new FlagsBuilder().add(Flags.Flag.SEEN, Flags.Flag.FLAGGED).build()));
-    }
-
-    @Test
-    public void flagsAdditionShouldUpdateStoredMessageFlags() throws MailboxException {
-        saveMessages();
-        messageMapper.updateFlags(benwaInboxMailbox, new FlagsUpdateCalculator(new Flags(Flags.Flag.FLAGGED), FlagsUpdateMode.REPLACE), MessageRange.one(message1.getUid()));
-        messageMapper.updateFlags(benwaInboxMailbox, new FlagsUpdateCalculator(new Flags(Flags.Flag.SEEN), FlagsUpdateMode.ADD), MessageRange.one(message1.getUid()));
-        MessageAssert.assertThat(retrieveMessageFromStorage(message1)).hasFlags(new FlagsBuilder().add(Flags.Flag.SEEN, Flags.Flag.FLAGGED).build());
-    }
-
-    @Test
-    public void flagsRemovalShouldReturnAnUpdatedFlagHighlightingTheRemoval() throws MailboxException {
-        saveMessages();
-        messageMapper.updateFlags(benwaInboxMailbox, new FlagsUpdateCalculator(new FlagsBuilder().add(Flags.Flag.FLAGGED, Flags.Flag.SEEN).build(), FlagsUpdateMode.REPLACE), MessageRange.one(message1.getUid()));
-        long modSeq = messageMapper.getHighestModSeq(benwaInboxMailbox);
-        assertThat(messageMapper.updateFlags(benwaInboxMailbox, new FlagsUpdateCalculator(new Flags(Flags.Flag.SEEN), FlagsUpdateMode.REMOVE), MessageRange.one(message1.getUid())))
-            .containsOnly(new UpdatedFlags(message1.getUid(), modSeq + 1, new FlagsBuilder().add(Flags.Flag.SEEN, Flags.Flag.FLAGGED).build(), new Flags(Flags.Flag.FLAGGED)));
-    }
-
-    @Test
-    public void flagsRemovalShouldUpdateStoredMessageFlags() throws MailboxException {
-        saveMessages();
-        messageMapper.updateFlags(benwaInboxMailbox, new FlagsUpdateCalculator(new FlagsBuilder().add(Flags.Flag.FLAGGED, Flags.Flag.SEEN).build(), FlagsUpdateMode.REPLACE), MessageRange.one(message1.getUid()));
-        messageMapper.updateFlags(benwaInboxMailbox, new FlagsUpdateCalculator(new Flags(Flags.Flag.SEEN), FlagsUpdateMode.REMOVE), MessageRange.one(message1.getUid()));
-        MessageAssert.assertThat(retrieveMessageFromStorage(message1)).hasFlags(new Flags(Flags.Flag.FLAGGED));
-    }
-
-    @Test
-    public void updateFlagsOnRangeShouldAffectMessagesContainedInThisRange() throws MailboxException {
-        saveMessages();
-        assertThat(messageMapper.updateFlags(benwaInboxMailbox, new FlagsUpdateCalculator(new Flags(Flags.Flag.SEEN), FlagsUpdateMode.REPLACE), MessageRange.range(message1.getUid(), message3.getUid())))
-            .hasSize(3);
-    }
-
-    @Test
-    public void updateFlagsWithRangeFromShouldAffectMessagesContainedInThisRange() throws MailboxException {
-        saveMessages();
-        assertThat(messageMapper.updateFlags(benwaInboxMailbox, new FlagsUpdateCalculator(new Flags(Flags.Flag.SEEN), FlagsUpdateMode.REPLACE), MessageRange.from(message3.getUid()))).hasSize(3);
-    }
-
-    @Test
-    public void updateFlagsWithRangeAllRangeShouldAffectAllMessages() throws MailboxException {
-        saveMessages();
-        assertThat(messageMapper.updateFlags(benwaInboxMailbox, new FlagsUpdateCalculator(new Flags(Flags.Flag.SEEN), FlagsUpdateMode.REPLACE), MessageRange.all())).hasSize(5);
-    }
-        
-    @Test
-    public void messagePropertiesShouldBeStored() throws Exception {
-        PropertyBuilder propBuilder = new PropertyBuilder();
-        propBuilder.setMediaType("text");
-        propBuilder.setSubType("html");
-        propBuilder.setTextualLineCount(2L);
-        propBuilder.setProperty(StandardNames.NAMESPACE_RFC_2045, StandardNames.MIME_CONTENT_TRANSFER_ENCODING_NAME, "7bit");
-        propBuilder.setProperty(StandardNames.MIME_CONTENT_TYPE_PARAMETER_SPACE, StandardNames.MIME_CONTENT_TYPE_PARAMETER_CHARSET_NAME, "US-ASCII");
-
-        SimpleMailboxMessage messageWithProperties = createMessage(benwaWorkMailbox, "Subject: messagePropertiesShouldBeStored \n\nBody\n.\n", BODY_START, propBuilder);
-        MessageMetaData messageMetaData = messageMapper.add(benwaInboxMailbox, messageWithProperties);
-        MailboxMessage message = messageMapper.findInMailbox(benwaInboxMailbox, MessageRange.one(messageMetaData.getUid()), FetchType.Body, 1).next();
-        assertThat(message.getProperties()).containsOnlyElementsOf(propBuilder.toProperties());
-    }
-
-    @Test
-    public void messagePropertiesShouldBeStoredWhenDuplicateEntries() throws Exception {
-        PropertyBuilder propBuilder = new PropertyBuilder();
-        propBuilder.setProperty(StandardNames.MIME_CONTENT_LANGUAGE_SPACE, StandardNames.MIME_CONTENT_LANGUAGE_NAME, "us");
-        propBuilder.setProperty(StandardNames.MIME_CONTENT_LANGUAGE_SPACE, StandardNames.MIME_CONTENT_LANGUAGE_NAME, "fr");
-
-        SimpleMailboxMessage messageWithProperties = createMessage(benwaWorkMailbox, "Subject: messagePropertiesShouldBeStoredWhenDuplicateEntries \n\nBody\n.\n", BODY_START, propBuilder);
-        MessageMetaData messageMetaData = messageMapper.add(benwaInboxMailbox, messageWithProperties);
-        MailboxMessage message = messageMapper.findInMailbox(benwaInboxMailbox, MessageRange.one(messageMetaData.getUid()), FetchType.Body, 1).next();
-        assertThat(message.getProperties()).containsOnlyElementsOf(propBuilder.toProperties());
-    }
-
-    @Test
-    public void messagePropertiesShouldBeStoredWhenNoProperty() throws Exception {
-        SimpleMailboxMessage messageWithProperties = createMessage(benwaWorkMailbox, "Subject: messagePropertiesShouldBeStoredWhenNoProperty \n\nBody\n.\n", BODY_START, new PropertyBuilder());
-        MessageMetaData messageMetaData = messageMapper.add(benwaInboxMailbox, messageWithProperties);
-        MailboxMessage message = messageMapper.findInMailbox(benwaInboxMailbox, MessageRange.one(messageMetaData.getUid()), FetchType.Body, 1).next();
-        assertThat(message.getProperties()).isEmpty();
-    }
-
-    @Test
-    public void textualLineCountShouldBeWellStored() throws Exception {
-        long textualLineCount = 48L;
-        PropertyBuilder propBuilder = new PropertyBuilder();
-        propBuilder.setTextualLineCount(textualLineCount);
-
-        SimpleMailboxMessage messageWithProperties = createMessage(benwaWorkMailbox, "Subject: messagePropertiesShouldBeStoredWhenDuplicateEntries \n\nBody\n.\n", BODY_START, propBuilder);
-        MessageMetaData messageMetaData = messageMapper.add(benwaInboxMailbox, messageWithProperties);
-        MailboxMessage message = messageMapper.findInMailbox(benwaInboxMailbox, MessageRange.one(messageMetaData.getUid()), FetchType.Body, 1).next();
-        assertThat(message.getTextualLineCount()).isEqualTo(textualLineCount);
-    }
-
-    @Test
-    public void mediaTypeShouldBeWellStored() throws Exception {
-        String mediaType = "plain";
-        PropertyBuilder propBuilder = new PropertyBuilder();
-        propBuilder.setMediaType(mediaType);
-
-        SimpleMailboxMessage messageWithProperties = createMessage(benwaWorkMailbox, "Subject: messagePropertiesShouldBeStoredWhenDuplicateEntries \n\nBody\n.\n", BODY_START, propBuilder);
-        MessageMetaData messageMetaData = messageMapper.add(benwaInboxMailbox, messageWithProperties);
-        MailboxMessage message = messageMapper.findInMailbox(benwaInboxMailbox, MessageRange.one(messageMetaData.getUid()), FetchType.Body, 1).next();
-        assertThat(message.getMediaType()).isEqualTo(mediaType);
-    }
-
-    @Test
-    public void subTypeShouldBeWellStored() throws Exception {
-        String subType = "text";
-        PropertyBuilder propBuilder = new PropertyBuilder();
-        propBuilder.setSubType(subType);
-
-        SimpleMailboxMessage messageWithProperties = createMessage(benwaWorkMailbox, "Subject: messagePropertiesShouldBeStoredWhenDuplicateEntries \n\nBody\n.\n", BODY_START, propBuilder);
-        MessageMetaData messageMetaData = messageMapper.add(benwaInboxMailbox, messageWithProperties);
-        MailboxMessage message = messageMapper.findInMailbox(benwaInboxMailbox, MessageRange.one(messageMetaData.getUid()), FetchType.Body, 1).next();
-        assertThat(message.getSubType()).isEqualTo(subType);
-    }
-
-    @Test
-    public void userFlagsShouldBeSupported() throws Exception {
-        saveMessages();
-        messageMapper.updateFlags(benwaInboxMailbox, new FlagsUpdateCalculator(new Flags(USER_FLAG), FlagsUpdateMode.ADD), MessageRange.one(message1.getUid()));
-        MessageAssert.assertThat(retrieveMessageFromStorage(message1)).hasFlags(new Flags(USER_FLAG));
-    }
-
-    @Test
-    public void userFlagsUpdateShouldReturnCorrectUpdatedFlags() throws Exception {
-        saveMessages();
-        long modSeq = messageMapper.getHighestModSeq(benwaInboxMailbox);
-        assertThat(messageMapper.updateFlags(benwaInboxMailbox, new FlagsUpdateCalculator(new Flags(USER_FLAG), FlagsUpdateMode.ADD), MessageRange.one(message1.getUid())))
-            .containsOnly(new UpdatedFlags(message1.getUid(), modSeq + 1, new Flags(), new Flags(USER_FLAG)));
-    }
-
-    @Test
-    public void messagesShouldBeSavedWithTheirUserFlags() throws Exception {
-        MailboxMessage message = SimpleMailboxMessage.copy(benwaInboxMailbox.getMailboxId(), message1);
-        messageMapper.add(benwaInboxMailbox, message);
-        MessageAssert.assertThat(retrieveMessageFromStorage(message)).hasFlags(new Flags(USER_FLAG));
-    }
-
-    private Map<Long, MessageMetaData> markThenPerformExpunge(MessageRange range) throws MailboxException {
-        messageMapper.updateFlags(benwaInboxMailbox, new FlagsUpdateCalculator(new Flags(Flags.Flag.DELETED), FlagsUpdateMode.REPLACE), MessageRange.one(message1.getUid()));
-        messageMapper.updateFlags(benwaInboxMailbox, new FlagsUpdateCalculator(new Flags(Flags.Flag.DELETED), FlagsUpdateMode.REPLACE), MessageRange.one(message4.getUid()));
-        return messageMapper.expungeMarkedForDeletionInMailbox(benwaInboxMailbox, range);
-    }
-
-    private SimpleMailbox createMailbox(MailboxPath mailboxPath) {
-        SimpleMailbox mailbox = new SimpleMailbox(mailboxPath, UID_VALIDITY);
-        MailboxId id = mapperProvider.generateId();
-        mailbox.setMailboxId(id);
-        return mailbox;
-    }
-    
-    private void saveMessages() throws MailboxException {
-        messageMapper.add(benwaInboxMailbox, message1);
-        message1.setModSeq(messageMapper.getHighestModSeq(benwaInboxMailbox));
-        messageMapper.add(benwaInboxMailbox, message2);
-        message2.setModSeq(messageMapper.getHighestModSeq(benwaInboxMailbox));
-        messageMapper.add(benwaInboxMailbox, message3);
-        message3.setModSeq(messageMapper.getHighestModSeq(benwaInboxMailbox));
-        messageMapper.add(benwaInboxMailbox, message4);
-        message4.setModSeq(messageMapper.getHighestModSeq(benwaInboxMailbox));
-        messageMapper.add(benwaInboxMailbox, message5);
-        message5.setModSeq(messageMapper.getHighestModSeq(benwaInboxMailbox));
-        messageMapper.add(benwaWorkMailbox, message6);
-        message6.setModSeq(messageMapper.getHighestModSeq(benwaWorkMailbox));
-        messageMapper.add(attachmentsMailbox, message7With1Attachment);
-        message7With1Attachment.setModSeq(messageMapper.getHighestModSeq(attachmentsMailbox));
-        messageMapper.add(attachmentsMailbox, message8With2Attachments);
-        message8With2Attachments.setModSeq(messageMapper.getHighestModSeq(attachmentsMailbox));
-    }
-
-    private MailboxMessage retrieveMessageFromStorage(MailboxMessage message) throws MailboxException {
-        return messageMapper.findInMailbox(benwaInboxMailbox, MessageRange.one(message.getUid()), MessageMapper.FetchType.Metadata, LIMIT).next();
-    }
-    
-    private SimpleMailboxMessage createMessage(Mailbox mailbox, String content, int bodyStart, PropertyBuilder propertyBuilder, List<AttachmentId> attachmentsIds) {
-        return new SimpleMailboxMessage(new Date(), content.length(), bodyStart, new SharedByteArrayInputStream(content.getBytes()), new Flags(), propertyBuilder, mailbox.getMailboxId(), attachmentsIds);
-    }
-    
-    private SimpleMailboxMessage createMessage(Mailbox mailbox, String content, int bodyStart, PropertyBuilder propertyBuilder) {
-        return new SimpleMailboxMessage(new Date(), content.length(), bodyStart, new SharedByteArrayInputStream(content.getBytes()), new Flags(), propertyBuilder, mailbox.getMailboxId());
-    }
-}


---------------------------------------------------------------------
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