james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rouaz...@apache.org
Subject [1/7] james-project git commit: MAILBOX-279: JPAMappersTest should work
Date Wed, 07 Dec 2016 09:12:43 GMT
Repository: james-project
Updated Branches:
  refs/heads/master 290fd5193 -> 444105e5d


MAILBOX-279: JPAMappersTest should work


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

Branch: refs/heads/master
Commit: e87321296d86457c10eb28511c25696dbb71c326
Parents: aa46db4
Author: Quynh Nguyen <qnguyen@linagora.com>
Authored: Tue Nov 29 11:40:05 2016 +0700
Committer: Quynh Nguyen <qnguyen@linagora.com>
Committed: Wed Dec 7 14:51:26 2016 +0700

----------------------------------------------------------------------
 .../mailbox/jpa/mail/JPAMailboxMapper.java      |  44 ++++--
 .../mailbox/jpa/mail/model/JPAMailbox.java      |  28 ++--
 .../mailbox/jpa/mail/JPAMapperProvider.java     |  14 +-
 .../jpa/mail/TransactionalMailboxMapper.java    | 111 +++++++++++++++
 .../LuceneMailboxMessageSearchIndexTest.java    |   3 +-
 .../store/mail/model/impl/SimpleMailbox.java    |  36 ++---
 .../store/MailboxEventDispatcherTest.java       |  80 ++---------
 .../store/mail/model/ListMailboxAssert.java     | 106 ++++++++++++++
 .../store/mail/model/ListMailboxAssertTest.java | 118 ++++++++++++++++
 .../store/mail/model/MailboxMapperTest.java     | 140 +++++++++++--------
 .../model/MessageWithAttachmentMapperTest.java  |   2 +-
 11 files changed, 492 insertions(+), 190 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/e8732129/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAMailboxMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAMailboxMapper.java b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAMailboxMapper.java
index c3c7a3a..d2d883b 100644
--- a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAMailboxMapper.java
+++ b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAMailboxMapper.java
@@ -32,6 +32,7 @@ import org.apache.james.mailbox.exception.MailboxExistsException;
 import org.apache.james.mailbox.exception.MailboxNotFoundException;
 import org.apache.james.mailbox.jpa.JPAId;
 import org.apache.james.mailbox.jpa.JPATransactionalMapper;
+import org.apache.james.mailbox.jpa.mail.model.JPAMailbox;
 import org.apache.james.mailbox.model.MailboxACL;
 import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxPath;
@@ -76,7 +77,13 @@ public class JPAMailboxMapper extends JPATransactionalMapper implements MailboxM
     public void save(Mailbox mailbox) throws MailboxException {
         try {
             this.lastMailboxName = mailbox.getName();
-            getEntityManager().persist(mailbox);
+            if (mailbox instanceof JPAMailbox) {
+                getEntityManager().persist(mailbox);
+            } else {
+                JPAMailbox persistedData = new JPAMailbox(mailbox);
+                getEntityManager().persist(persistedData);
+                mailbox.setMailboxId(persistedData.getMailboxId());
+            }
         } catch (PersistenceException e) {
             throw new MailboxException("Save of mailbox " + mailbox.getName() +" failed", e);
         } 
@@ -88,22 +95,31 @@ public class JPAMailboxMapper extends JPATransactionalMapper implements MailboxM
     public Mailbox findMailboxByPath(MailboxPath mailboxPath) throws MailboxException, MailboxNotFoundException {
         try {
             if (mailboxPath.getUser() == null) {
-                return (Mailbox) getEntityManager().createNamedQuery("findMailboxByName").setParameter("nameParam", mailboxPath.getName()).setParameter("namespaceParam", mailboxPath.getNamespace()).getSingleResult();
+                return getEntityManager().createNamedQuery("findMailboxByName", JPAMailbox.class)
+                    .setParameter("nameParam", mailboxPath.getName())
+                    .setParameter("namespaceParam", mailboxPath.getNamespace())
+                    .getSingleResult();
             } else {
-                return (Mailbox) getEntityManager().createNamedQuery("findMailboxByNameWithUser").setParameter("nameParam", mailboxPath.getName()).setParameter("namespaceParam", mailboxPath.getNamespace()).setParameter("userParam", mailboxPath.getUser()).getSingleResult();
+                return getEntityManager().createNamedQuery("findMailboxByNameWithUser", JPAMailbox.class)
+                    .setParameter("nameParam", mailboxPath.getName())
+                    .setParameter("namespaceParam", mailboxPath.getNamespace())
+                    .setParameter("userParam", mailboxPath.getUser())
+                    .getSingleResult();
             }
         } catch (NoResultException e) {
             throw new MailboxNotFoundException(mailboxPath);
         } catch (PersistenceException e) {
             throw new MailboxException("Search of mailbox " + mailboxPath + " failed", e);
-        } 
+        }
     }
 
     @Override
     public Mailbox findMailboxById(MailboxId id) throws MailboxException, MailboxNotFoundException {
         JPAId mailboxId = (JPAId)id;
         try {
-            return (Mailbox) getEntityManager().createNamedQuery("findMailboxById").setParameter("idParam", mailboxId.getRawId()).getSingleResult();
+            return getEntityManager().createNamedQuery("findMailboxById", JPAMailbox.class)
+                .setParameter("idParam", mailboxId.getRawId())
+                .getSingleResult();
         } catch (NoResultException e) {
             throw new MailboxNotFoundException(mailboxId.serialize());
         } catch (PersistenceException e) {
@@ -118,7 +134,8 @@ public class JPAMailboxMapper extends JPATransactionalMapper implements MailboxM
         try {  
             JPAId mailboxId = (JPAId) mailbox.getMailboxId();
             getEntityManager().createNamedQuery("deleteMessages").setParameter("idParam", mailboxId.getRawId()).executeUpdate();
-            getEntityManager().remove(mailbox);
+            JPAMailbox jpaMailbox = getEntityManager().find(JPAMailbox.class, mailboxId.getRawId());
+            getEntityManager().remove(jpaMailbox);
         } catch (PersistenceException e) {
             throw new MailboxException("Delete of mailbox " + mailbox + " failed", e);
         } 
@@ -127,13 +144,19 @@ public class JPAMailboxMapper extends JPATransactionalMapper implements MailboxM
     /**
      * @see org.apache.james.mailbox.store.mail.MailboxMapper#findMailboxWithPathLike(MailboxPath)
      */
-    @SuppressWarnings("unchecked")
     public List<Mailbox> findMailboxWithPathLike(MailboxPath path) throws MailboxException {
         try {
             if (path.getUser() == null) {
-                return getEntityManager().createNamedQuery("findMailboxWithNameLike").setParameter("nameParam", SQL_WILDCARD_CHAR + path.getName() + SQL_WILDCARD_CHAR).setParameter("namespaceParam", path.getNamespace()).getResultList();
+                return getEntityManager().createNamedQuery("findMailboxWithNameLike", Mailbox.class)
+                    .setParameter("nameParam", path.getName())
+                    .setParameter("namespaceParam", path.getNamespace())
+                    .getResultList();
             } else {
-                return getEntityManager().createNamedQuery("findMailboxWithNameLikeWithUser").setParameter("nameParam", SQL_WILDCARD_CHAR + path.getName() + SQL_WILDCARD_CHAR).setParameter("namespaceParam", path.getNamespace()).setParameter("userParam", path.getUser()).getResultList();
+                return getEntityManager().createNamedQuery("findMailboxWithNameLikeWithUser", Mailbox.class)
+                    .setParameter("nameParam", path.getName())
+                    .setParameter("namespaceParam", path.getNamespace())
+                    .setParameter("userParam", path.getUser())
+                    .getResultList();
             }
         } catch (PersistenceException e) {
             throw new MailboxException("Search of mailbox " + path + " failed", e);
@@ -174,10 +197,9 @@ public class JPAMailboxMapper extends JPATransactionalMapper implements MailboxM
 	/**
      * @see org.apache.james.mailbox.store.mail.MailboxMapper#list()
      */
-    @SuppressWarnings("unchecked")
     public List<Mailbox> list() throws MailboxException{
         try {
-            return getEntityManager().createNamedQuery("listMailboxes").getResultList();
+            return getEntityManager().createNamedQuery("listMailboxes", Mailbox.class).getResultList();
         } catch (PersistenceException e) {
             throw new MailboxException("Delete of mailboxes failed", e);
         } 

http://git-wip-us.apache.org/repos/asf/james-project/blob/e8732129/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/JPAMailbox.java
----------------------------------------------------------------------
diff --git a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/JPAMailbox.java b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/JPAMailbox.java
index d45329f..95adcd7 100644
--- a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/JPAMailbox.java
+++ b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/JPAMailbox.java
@@ -38,7 +38,7 @@ import org.apache.james.mailbox.store.mail.model.Mailbox;
 @Table(name="JAMES_MAILBOX")
 @NamedQueries({
     @NamedQuery(name="findMailboxById",
-        query="SELECT mailbox FROM Mailbox mailbox WHERE mailbox.mailbox.mailboxId = :idParam"),
+        query="SELECT mailbox FROM Mailbox mailbox WHERE mailbox.mailboxId = :idParam"),
     @NamedQuery(name="findMailboxByName",
         query="SELECT mailbox FROM Mailbox mailbox WHERE mailbox.name = :nameParam and mailbox.user is NULL and mailbox.namespace= :namespaceParam"),
     @NamedQuery(name="findMailboxByNameWithUser",
@@ -80,8 +80,8 @@ public class JPAMailbox implements Mailbox {
     @Column(name = "MAILBOX_UID_VALIDITY", nullable = false)
     private long uidValidity;
 
-    @Basic(optional = false)
-    @Column(name = "USER_NAME", nullable = false, length = 200)
+    @Basic(optional = true)
+    @Column(name = "USER_NAME", nullable = true, length = 200)
     private String user;
     
     @Basic(optional = false)
@@ -89,11 +89,11 @@ public class JPAMailbox implements Mailbox {
     private String namespace;
 
     @Basic(optional = false)
-    @Column(name = "MAILBOX_LAST_UID", nullable = false)
+    @Column(name = "MAILBOX_LAST_UID", nullable = true)
     private long lastUid;
     
     @Basic(optional = false)
-    @Column(name = "MAILBOX_HIGHEST_MODSEQ", nullable = false)
+    @Column(name = "MAILBOX_HIGHEST_MODSEQ", nullable = true)
     private long highestModSeq;
     
     /**
@@ -101,17 +101,19 @@ public class JPAMailbox implements Mailbox {
      */
     @Deprecated
     public JPAMailbox() {
-        super();
     }
     
-    public JPAMailbox(MailboxPath path, int uidValidity) {
-        this();
+    public JPAMailbox(MailboxPath path, long uidValidity) {
         this.name = path.getName();
         this.user = path.getUser();
         this.namespace = path.getNamespace();
         this.uidValidity = uidValidity;
     }
 
+    public JPAMailbox(Mailbox mailbox) {
+        this(new MailboxPath(mailbox.getNamespace(), mailbox.getUser(), mailbox.getName()), mailbox.getUidValidity());
+    }
+
     /**
      * @see org.apache.james.mailbox.store.mail.model.Mailbox#getMailboxId()
      */
@@ -220,21 +222,13 @@ public class JPAMailbox implements Mailbox {
         return ++highestModSeq;
     }
     
-    /* (non-Javadoc)
-     * @see org.apache.james.mailbox.store.mail.model.Mailbox#getACL()
-     */
     @Override
     public MailboxACL getACL() {
-        // TODO ACL support
-        return SimpleMailboxACL.OWNER_FULL_ACL;
+        return SimpleMailboxACL.EMPTY;
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.james.mailbox.store.mail.model.Mailbox#setACL(org.apache.james.mailbox.MailboxACL)
-     */
     @Override
     public void setACL(MailboxACL acl) {
-        // TODO ACL support
     }
     
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/e8732129/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/JPAMapperProvider.java
----------------------------------------------------------------------
diff --git a/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/JPAMapperProvider.java b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/JPAMapperProvider.java
index 3a5b553..62cb25b 100644
--- a/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/JPAMapperProvider.java
+++ b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/JPAMapperProvider.java
@@ -52,7 +52,7 @@ public class JPAMapperProvider implements MapperProvider {
 
     @Override
     public MailboxMapper createMailboxMapper() throws MailboxException {
-        throw new NotImplementedException();
+        return new TransactionalMailboxMapper(new JPAMailboxMapper(createEntityManagerFactory()));
     }
 
     @Override
@@ -84,11 +84,11 @@ public class JPAMapperProvider implements MapperProvider {
     public void clearMapper() throws MailboxException {
         EntityManager entityManager = createEntityManagerFactory().createEntityManager();
         entityManager.getTransaction().begin();
-        entityManager.createNativeQuery("TRUNCATE table JAMES_MAIL_USERFLAG;");
-        entityManager.createNativeQuery("TRUNCATE table JAMES_MAIL_PROPERTY;");
-        entityManager.createNativeQuery("TRUNCATE table JAMES_MAILBOX_ANNOTATION;");
-        entityManager.createNativeQuery("TRUNCATE table JAMES_MAILBOX;");
-        entityManager.createNativeQuery("TRUNCATE table JAMES_MAIL;");
+        entityManager.createNativeQuery("TRUNCATE table JAMES_MAIL_USERFLAG;").executeUpdate();
+        entityManager.createNativeQuery("TRUNCATE table JAMES_MAIL_PROPERTY;").executeUpdate();
+        entityManager.createNativeQuery("TRUNCATE table JAMES_MAILBOX_ANNOTATION;").executeUpdate();
+        entityManager.createNativeQuery("TRUNCATE table JAMES_MAILBOX;").executeUpdate();
+        entityManager.createNativeQuery("TRUNCATE table JAMES_MAIL;").executeUpdate();
         entityManager.getTransaction().commit();
         entityManager.close();
     }
@@ -124,6 +124,6 @@ public class JPAMapperProvider implements MapperProvider {
 
     @Override
     public List<Capabilities> getNotImplemented() {
-        return ImmutableList.of(Capabilities.MAILBOX, Capabilities.MESSAGE, Capabilities.ATTACHMENT);
+        return ImmutableList.of(Capabilities.MESSAGE, Capabilities.ATTACHMENT);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/e8732129/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/TransactionalMailboxMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/TransactionalMailboxMapper.java b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/TransactionalMailboxMapper.java
new file mode 100644
index 0000000..4fcd3b0
--- /dev/null
+++ b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/TransactionalMailboxMapper.java
@@ -0,0 +1,111 @@
+/****************************************************************
+ * 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.jpa.mail;
+
+import java.util.List;
+
+import org.apache.commons.lang.NotImplementedException;
+import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.exception.MailboxNotFoundException;
+import org.apache.james.mailbox.model.MailboxACL.MailboxACLCommand;
+import org.apache.james.mailbox.model.MailboxId;
+import org.apache.james.mailbox.model.MailboxPath;
+import org.apache.james.mailbox.store.mail.MailboxMapper;
+import org.apache.james.mailbox.store.mail.model.Mailbox;
+import org.apache.james.mailbox.store.transaction.Mapper.VoidTransaction;
+
+import com.google.common.base.Throwables;
+
+public class TransactionalMailboxMapper implements MailboxMapper {
+    private final JPAMailboxMapper wrapped;
+
+    public TransactionalMailboxMapper(JPAMailboxMapper wrapped) {
+        this.wrapped = wrapped;
+    }
+
+    @Override
+    public void endRequest() {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public <T> T execute(Transaction<T> transaction) throws MailboxException {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public void save(final Mailbox mailbox) throws MailboxException {
+        try {
+            wrapped.execute(new VoidTransaction() {
+                @Override
+                public void runVoid() throws MailboxException {
+                    wrapped.save(mailbox);
+                }
+            });
+        } catch (MailboxException e) {
+            Throwables.propagate(e);
+        }
+    }
+
+    @Override
+    public void delete(final Mailbox mailbox) throws MailboxException {
+        try {
+            wrapped.execute(new VoidTransaction() {
+                @Override
+                public void runVoid() throws MailboxException {
+                    wrapped.delete(mailbox);
+                }
+            });
+        } catch (MailboxException e) {
+            Throwables.propagate(e);
+        }
+    }
+
+    @Override
+    public Mailbox findMailboxByPath(MailboxPath mailboxPath) throws MailboxException, MailboxNotFoundException {
+        return wrapped.findMailboxByPath(mailboxPath);
+    }
+
+    @Override
+    public Mailbox findMailboxById(MailboxId mailboxId) throws MailboxException, MailboxNotFoundException {
+        return wrapped.findMailboxById(mailboxId);
+    }
+
+    @Override
+    public List<Mailbox> findMailboxWithPathLike(MailboxPath mailboxPath) throws MailboxException {
+        return wrapped.findMailboxWithPathLike(mailboxPath);
+    }
+
+    @Override
+    public boolean hasChildren(Mailbox mailbox, char delimiter) throws MailboxException, MailboxNotFoundException {
+        return wrapped.hasChildren(mailbox, delimiter);
+    }
+
+    @Override
+    public void updateACL(Mailbox mailbox, MailboxACLCommand mailboxACLCommand) throws MailboxException {
+        wrapped.updateACL(mailbox, mailboxACLCommand);
+    }
+
+    @Override
+    public List<Mailbox> list() throws MailboxException {
+        return wrapped.list();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/e8732129/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMailboxMessageSearchIndexTest.java
----------------------------------------------------------------------
diff --git a/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMailboxMessageSearchIndexTest.java b/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMailboxMessageSearchIndexTest.java
index 4515ba9..909ecd3 100644
--- a/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMailboxMessageSearchIndexTest.java
+++ b/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMailboxMessageSearchIndexTest.java
@@ -606,14 +606,13 @@ public class LuceneMailboxMessageSearchIndexTest {
     }
     
     private final class SimpleMailbox implements Mailbox {
-        private TestId id;
+        private final TestId id;
 
         public SimpleMailbox(long id) {
         	this.id = TestId.of(id);
         }
 
         public void setMailboxId(MailboxId id) {
-            this.id = (TestId)id;
         }
 
         public TestId getMailboxId() {

http://git-wip-us.apache.org/repos/asf/james-project/blob/e8732129/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailbox.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailbox.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailbox.java
index b3316b6..69e7bf0 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailbox.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailbox.java
@@ -24,6 +24,9 @@ import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.SimpleMailboxACL;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Objects;
+
 public class SimpleMailbox implements Mailbox {
 
     private MailboxId id = null;
@@ -115,17 +118,9 @@ public class SimpleMailbox implements Mailbox {
      * @see java.lang.Object#equals(java.lang.Object)
      */
     public boolean equals(Object obj) {
-        if (obj == this) {
-            return true;
-        }
         if (obj instanceof SimpleMailbox) {
-            if (id != null) {
-                if (id.equals(((SimpleMailbox) obj).getMailboxId()))
-                    return true;
-            } else {
-                if (((SimpleMailbox) obj).getMailboxId() == null)
-                    return true;
-            }
+            SimpleMailbox o = (SimpleMailbox)obj;
+            return Objects.equal(id, o.getMailboxId());
         }
         return false;
     }
@@ -135,14 +130,7 @@ public class SimpleMailbox implements Mailbox {
      */
     @Override
     public int hashCode() {
-        final int PRIME = 31;
-        int result = 1;
-        result = PRIME * result + namespace.hashCode();
-        if (user != null) {
-            result = PRIME * result + user.hashCode();
-        }
-        result = PRIME * result + name.hashCode();
-        return result;
+        return Objects.hashCode(namespace, user, name);
     }
 
     /**
@@ -150,7 +138,11 @@ public class SimpleMailbox implements Mailbox {
      */
     @Override
     public String toString() {
-        return namespace + ":" + user + ":" + name;
+        return MoreObjects.toStringHelper(this)
+            .add("namespace", namespace)
+            .add("user", user)
+            .add("name", name)
+            .toString();
     }
 
     @Override
@@ -158,17 +150,11 @@ public class SimpleMailbox implements Mailbox {
         this.id = id;
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.james.mailbox.store.mail.model.Mailbox#getACL()
-     */
     @Override
     public MailboxACL getACL() {
         return acl;
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.james.mailbox.store.mail.model.Mailbox#setACL(org.apache.james.mailbox.MailboxACL)
-     */
     @Override
     public void setACL(MailboxACL acl) {
         this.acl = acl;

http://git-wip-us.apache.org/repos/asf/james-project/blob/e8732129/mailbox/store/src/test/java/org/apache/james/mailbox/store/MailboxEventDispatcherTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/MailboxEventDispatcherTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/MailboxEventDispatcherTest.java
index b7b6b35..8558571 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/MailboxEventDispatcherTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/MailboxEventDispatcherTest.java
@@ -19,13 +19,12 @@
 
 package org.apache.james.mailbox.store;
 
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 import java.util.Arrays;
 import java.util.Iterator;
@@ -36,10 +35,7 @@ import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.mock.MockMailboxSession;
-import org.apache.james.mailbox.model.MailboxACL;
-import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MessageResult;
-import org.apache.james.mailbox.model.SimpleMailboxACL;
 import org.apache.james.mailbox.model.UpdatedFlags;
 import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
@@ -48,85 +44,35 @@ import org.junit.Before;
 import org.junit.Test;
 
 public class MailboxEventDispatcherTest {
+    private static final int sessionId = 10;
 
-    MailboxEventDispatcher dispatcher;
+    private MailboxEventDispatcher dispatcher;
 
-    EventCollector collector;
+    private EventCollector collector;
 
-    MessageResult result;
-    int sessionId = 10;
+    private MessageResult result;
 
-    private MailboxSession session = new MockMailboxSession("test") {
+    private Mailbox mailbox;
 
+    private MailboxSession session = new MockMailboxSession("test") {
         @Override
         public long getSessionId() {
             return sessionId;
         }
-        
     };
 
-    private Mailbox mailbox = new Mailbox() {
-
-        @Override
-        public TestId getMailboxId() {
-            return TestId.of(1L);
-        }
-
-        @Override
-        public String getNamespace() {
-            return null;
-        }
-
-        @Override
-        public void setNamespace(String namespace) {            
-        }
-
-        @Override
-        public String getUser() {
-            return null;
-        }
-
-        @Override
-        public void setUser(String user) {
-            
-        }
-
-        @Override
-        public String getName() {
-            return "test";
-        }
-
-        @Override
-        public void setName(String name) {
-        }
-
-        @Override
-        public long getUidValidity() {
-            return 0;
-        }
-        
-        @Override
-        public MailboxACL getACL() {
-            return SimpleMailboxACL.EMPTY;
-        }
-
-        @Override
-        public void setACL(MailboxACL acl) {
-        }
-
-        @Override
-        public void setMailboxId(MailboxId id) {
-        }
-
-    };
-    
     @Before
     public void setUp() throws Exception {
         collector = new EventCollector();
 
         dispatcher = new MailboxEventDispatcher(collector);
         result = mock(MessageResult.class);
+        mailbox = mock(Mailbox.class);
+
         when(result.getUid()).thenReturn(MessageUid.of(23));
+        when(mailbox.getNamespace()).thenReturn("namespace");
+        when(mailbox.getUser()).thenReturn("user");
+        when(mailbox.getName()).thenReturn("name");
     }
 
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/e8732129/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMailboxAssert.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMailboxAssert.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMailboxAssert.java
new file mode 100644
index 0000000..5590f12
--- /dev/null
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMailboxAssert.java
@@ -0,0 +1,106 @@
+/****************************************************************
+ * 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.util.List;
+
+import org.apache.james.mailbox.model.MailboxId;
+
+import com.google.common.base.Function;
+import com.google.common.base.Objects;
+import com.google.common.collect.FluentIterable;
+import com.google.common.collect.Lists;
+
+public class ListMailboxAssert {
+
+    private final List<Mailbox> actual;
+
+    private final List<InnerMailbox> mailboxtoInnerMailbox(List<Mailbox> mailboxes) {
+        return FluentIterable.from(mailboxes).transform(new Function<Mailbox, InnerMailbox>() {
+            @Override
+            public InnerMailbox apply(Mailbox input) {
+                return new InnerMailbox(input.getMailboxId(), input.getUser(), input.getName(), input.getNamespace());
+            }
+            
+        }).toList();
+    }
+
+    private ListMailboxAssert(List<Mailbox> actual) {
+        this.actual = actual;
+    }
+
+    public static ListMailboxAssert assertMailboxes(List<Mailbox> actual) {
+        return new ListMailboxAssert(actual);
+    }
+
+    public void containOnly(Mailbox... expecteds) {
+        assertThat(mailboxtoInnerMailbox(actual)).containsOnlyElementsOf(mailboxtoInnerMailbox(Lists.newArrayList(expecteds)));
+    }
+
+    private final class InnerMailbox {
+        private final MailboxId id;
+        private final String user;
+        private final String name;
+        private final String namespace;
+
+        public InnerMailbox(MailboxId id, String user, String name, String namespace) {
+            this.id = id;
+            this.user = user;
+            this.name = name;
+            this.namespace = namespace;
+        }
+
+        public MailboxId getId() {
+            return id;
+        }
+
+        public String getUser() {
+            return user;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public String getNamespace() {
+            return namespace;
+        }
+
+        @Override
+        public int hashCode() {
+            return Objects.hashCode(id, user, name, namespace);
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (obj instanceof InnerMailbox) {
+                InnerMailbox o = (InnerMailbox)obj;
+                return Objects.equal(id, o.getId()) 
+                    && Objects.equal(name, o.getName()) 
+                    && Objects.equal(namespace, o.getNamespace()) 
+                    && Objects.equal(user, o.getUser());
+            }
+            return false;
+        }
+        
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/e8732129/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMailboxAssertTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMailboxAssertTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMailboxAssertTest.java
new file mode 100644
index 0000000..1410ab9
--- /dev/null
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/ListMailboxAssertTest.java
@@ -0,0 +1,118 @@
+/****************************************************************
+ * 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.apache.james.mailbox.store.mail.model.ListMailboxAssert.assertMailboxes;
+
+import java.util.List;
+
+import org.apache.james.mailbox.model.MailboxACL;
+import org.apache.james.mailbox.model.MailboxId;
+import org.apache.james.mailbox.model.MailboxPath;
+import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableList;
+
+public class ListMailboxAssertTest {
+    private static final String OTHER_NAMESPACE = "other_namespace";
+    private static final String NAME = "name";
+    private static final String USER = "user";
+    private static final String NAMESPACE = "namespace";
+    private static final long UID_VALIDITY = 42;
+    private static final Mailbox mailbox1 = new SimpleMailbox(new MailboxPath(NAMESPACE, USER, NAME), UID_VALIDITY);
+    private static final Mailbox mailbox2 = new SimpleMailbox(new MailboxPath(OTHER_NAMESPACE, USER, NAME), UID_VALIDITY);
+
+    private ListMailboxAssert listMaiboxAssert;
+    private List<Mailbox> actualMailbox;
+
+    @Before
+    public void setUp() {
+        actualMailbox = ImmutableList.of(mailbox1, mailbox2);
+        listMaiboxAssert = ListMailboxAssert.assertMailboxes(actualMailbox);
+    }
+
+    @Test
+    public void initListMailboxAssertShouldWork() throws Exception {
+        assertThat(listMaiboxAssert).isNotNull();
+    }
+
+    @Test
+    public void assertListMailboxShouldWork() throws Exception {
+        assertMailboxes(actualMailbox).containOnly(createMailbox(NAMESPACE, USER, NAME, UID_VALIDITY), 
+            createMailbox(OTHER_NAMESPACE, USER, NAME, UID_VALIDITY));
+    }
+    
+    private Mailbox createMailbox(final String namespace, final String user, final String name, final long uid_validity) {
+        return new Mailbox() {
+            @Override
+            public void setUser(String user) {
+            }
+            
+            @Override
+            public void setNamespace(String namespace) {
+            }
+            
+            @Override
+            public void setName(String name) {
+            }
+            
+            @Override
+            public void setMailboxId(MailboxId id) {
+            }
+            
+            @Override
+            public void setACL(MailboxACL acl) {
+            }
+            
+            @Override
+            public String getUser() {
+                return user;
+            }
+            
+            @Override
+            public long getUidValidity() {
+                return uid_validity;
+            }
+            
+            @Override
+            public String getNamespace() {
+                return namespace;
+            }
+            
+            @Override
+            public String getName() {
+                return name;
+            }
+            
+            @Override
+            public MailboxId getMailboxId() {
+                return null;
+            }
+            
+            @Override
+            public MailboxACL getACL() {
+                return null;
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/e8732129/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperTest.java
index 7fc2a15..710bc35 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperTest.java
@@ -19,6 +19,7 @@
 
 package org.apache.james.mailbox.store.mail.model;
 
+import static org.apache.james.mailbox.store.mail.model.ListMailboxAssert.assertMailboxes;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.fail;
 
@@ -50,80 +51,50 @@ public class MailboxMapperTest<T extends MapperProvider> {
     private final static char WILDCARD = '%';
     private final static long UID_VALIDITY = 42;
 
-    private IProducer<T> producer;
-    private MailboxMapper mailboxMapper;
-
     private MailboxPath benwaInboxPath;
-    private SimpleMailbox benwaInboxMailbox;
+    private Mailbox benwaInboxMailbox;
     private MailboxPath benwaWorkPath;
-    private SimpleMailbox benwaWorkMailbox;
+    private Mailbox benwaWorkMailbox;
     private MailboxPath benwaWorkTodoPath;
-    private SimpleMailbox benwaWorkTodoMailbox;
+    private Mailbox benwaWorkTodoMailbox;
     private MailboxPath benwaPersoPath;
-    private SimpleMailbox benwaPersoMailbox;
+    private Mailbox benwaPersoMailbox;
     private MailboxPath benwaWorkDonePath;
-    private SimpleMailbox benwaWorkDoneMailbox;
+    private Mailbox benwaWorkDoneMailbox;
     private MailboxPath bobInboxPath;
-    private SimpleMailbox bobyMailbox;
+    private Mailbox bobyMailbox;
     private MailboxPath bobyMailboxPath;
-    private SimpleMailbox bobInboxMailbox;
+    private Mailbox bobInboxMailbox;
     private MailboxPath esnDevGroupInboxPath;
-    private SimpleMailbox esnDevGroupInboxMailbox;
+    private Mailbox esnDevGroupInboxMailbox;
     private MailboxPath esnDevGroupHublinPath;
-    private SimpleMailbox esnDevGroupHublinMailbox;
+    private Mailbox esnDevGroupHublinMailbox;
     private MailboxPath esnDevGroupJamesPath;
-    private SimpleMailbox esnDevGroupJamesMailbox;
+    private Mailbox esnDevGroupJamesMailbox;
     private MailboxPath obmTeamGroupInboxPath;
-    private SimpleMailbox obmTeamGroupInboxMailbox;
+    private Mailbox obmTeamGroupInboxMailbox;
     private MailboxPath obmTeamGroupOPushPath;
-    private SimpleMailbox obmTeamGroupOPushMailbox;
+    private Mailbox obmTeamGroupOPushMailbox;
     private MailboxPath obmTeamGroupRoundCubePath;
-    private SimpleMailbox obmTeamGroupRoundCubeMailbox;
+    private Mailbox obmTeamGroupRoundCubeMailbox;
     private MailboxPath bobDifferentNamespacePath;
-    private SimpleMailbox bobDifferentNamespaceMailbox;
+    private Mailbox bobDifferentNamespaceMailbox;
 
     @Rule
     public ExpectedException expected = ExpectedException.none();
+    private IProducer<T> producer;
+    private MailboxMapper mailboxMapper;
     private T mapperProvider;
 
     @Contract.Inject
     public final void setProducer(IProducer<T> producer) throws MailboxException {
-        this.producer = producer;
         this.mapperProvider = producer.newInstance();
         Assume.assumeFalse(mapperProvider.getNotImplemented().contains(MapperProvider.Capabilities.MAILBOX));
 
-        this.mapperProvider.ensureMapperPrepared();
+        this.producer = producer;
         this.mailboxMapper = mapperProvider.createMailboxMapper();
-
-        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);
+        
+        initData();
     }
 
     @After
@@ -153,10 +124,14 @@ public class MailboxMapperTest<T extends MapperProvider> {
     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);
-    }
 
+        assertMailboxes(mailboxes)
+            .containOnly(benwaInboxMailbox, benwaWorkMailbox, benwaWorkTodoMailbox, benwaPersoMailbox, benwaWorkDoneMailbox, 
+                esnDevGroupInboxMailbox, esnDevGroupHublinMailbox, esnDevGroupJamesMailbox, 
+                obmTeamGroupInboxMailbox, obmTeamGroupOPushMailbox, obmTeamGroupRoundCubeMailbox, 
+                bobyMailbox, bobDifferentNamespaceMailbox, bobInboxMailbox);
+    }
+    
     @ContractTest
     public void hasChildrenShouldReturnFalseWhenNoChildrenExists() throws MailboxException {
         saveAll();
@@ -191,9 +166,11 @@ public class MailboxMapperTest<T extends MapperProvider> {
     public void findMailboxWithPathLikeShouldBeLimitedToUserAndNamespace() throws MailboxException {
         saveAll();
         MailboxPath mailboxPathQuery = new MailboxPath(bobInboxMailbox.getNamespace(), bobInboxMailbox.getUser(), "IN" + WILDCARD);
-        assertThat(mailboxMapper.findMailboxWithPathLike(mailboxPathQuery)).containsOnly(bobInboxMailbox);
-    }
+        List<Mailbox> mailboxes = mailboxMapper.findMailboxWithPathLike(mailboxPathQuery);
 
+        assertMailboxes(mailboxes).containOnly(bobInboxMailbox);
+    }
+    
     @ContractTest
     public void deleteShouldEraseTheGivenMailbox() throws MailboxException {
         expected.expect(MailboxNotFoundException.class);
@@ -222,28 +199,39 @@ public class MailboxMapperTest<T extends MapperProvider> {
     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);
+        List<Mailbox> mailboxes = mailboxMapper.findMailboxWithPathLike(regexPath);
+
+        assertMailboxes(mailboxes).containOnly(benwaWorkMailbox, benwaWorkDoneMailbox, benwaWorkTodoMailbox);
     }
 
     @ContractTest
     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);
-    }
 
+        List<Mailbox> mailboxes = mailboxMapper.findMailboxWithPathLike(regexPath);
+
+        assertMailboxes(mailboxes).containOnly(obmTeamGroupInboxMailbox, obmTeamGroupOPushMailbox, obmTeamGroupRoundCubeMailbox);
+    }
+    
     @ContractTest
     public void findMailboxWithPathLikeWithRegexShouldRetrieveCorrespondingMailbox() throws MailboxException {
         saveAll();
         MailboxPath regexPath = new MailboxPath(benwaInboxPath.getNamespace(), benwaInboxPath.getUser(), WILDCARD + "X");
-        assertThat(mailboxMapper.findMailboxWithPathLike(regexPath)).containsOnly(benwaInboxMailbox);
+
+        List<Mailbox> mailboxes = mailboxMapper.findMailboxWithPathLike(regexPath);
+
+        assertMailboxes(mailboxes).containOnly(benwaInboxMailbox);
     }
 
     @ContractTest
     public void findMailboxWithPathLikeWithNullUserWithRegexShouldRetrieveCorrespondingMailbox() throws MailboxException {
         saveAll();
         MailboxPath regexPath = new MailboxPath(esnDevGroupInboxPath.getNamespace(), esnDevGroupInboxPath.getUser(), WILDCARD + "X");
-        assertThat(mailboxMapper.findMailboxWithPathLike(regexPath)).contains(esnDevGroupInboxMailbox);
+
+        List<Mailbox> mailboxes = mailboxMapper.findMailboxWithPathLike(regexPath);
+
+        assertMailboxes(mailboxes).containOnly(esnDevGroupInboxMailbox);
     }
 
     @ContractTest
@@ -257,7 +245,7 @@ public class MailboxMapperTest<T extends MapperProvider> {
     public void findMailboxByIdShouldReturnExistingMailbox() throws MailboxException {
         saveAll();
         Mailbox actual = mailboxMapper.findMailboxById(benwaInboxMailbox.getMailboxId());
-        assertThat(actual).isEqualTo(benwaInboxMailbox);
+        MailboxAssert.assertThat(actual).isEqualTo(benwaInboxMailbox);
     }
     
     @ContractTest
@@ -269,6 +257,38 @@ public class MailboxMapperTest<T extends MapperProvider> {
         mailboxMapper.findMailboxById(removed);
     }
 
+    private void initData() {
+        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);
+    }
+
     private void saveAll() throws MailboxException{
         mailboxMapper.save(benwaInboxMailbox);
         mailboxMapper.save(benwaWorkMailbox);

http://git-wip-us.apache.org/repos/asf/james-project/blob/e8732129/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageWithAttachmentMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageWithAttachmentMapperTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageWithAttachmentMapperTest.java
index 6548aa6..2bcecff 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageWithAttachmentMapperTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageWithAttachmentMapperTest.java
@@ -53,7 +53,7 @@ import org.xenei.junit.contract.IProducer;
 
 import com.google.common.collect.ImmutableList;
 
-//@Contract(MapperProvider.class)
+@Contract(MapperProvider.class)
 public class MessageWithAttachmentMapperTest<T extends MapperProvider> {
 
     private static final int LIMIT = 10;


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