You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by er...@apache.org on 2015/06/04 16:55:23 UTC

svn commit: r1683566 - in /james/mailbox/trunk: memory/src/test/java/org/apache/james/mailbox/inmemory/ memory/src/test/java/org/apache/james/mailbox/inmemory/mail/ store/src/test/java/org/apache/james/mailbox/store/

Author: eric
Date: Thu Jun  4 14:55:23 2015
New Revision: 1683566

URL: http://svn.apache.org/r1683566
Log:
Fix eric mess (MAILBOX-11)

Added:
    james/mailbox/trunk/memory/src/test/java/org/apache/james/mailbox/inmemory/InMemoryMailboxMapperTest.java
    james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerTest.java
Removed:
    james/mailbox/trunk/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/
    james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManager.java

Added: james/mailbox/trunk/memory/src/test/java/org/apache/james/mailbox/inmemory/InMemoryMailboxMapperTest.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/memory/src/test/java/org/apache/james/mailbox/inmemory/InMemoryMailboxMapperTest.java?rev=1683566&view=auto
==============================================================================
--- james/mailbox/trunk/memory/src/test/java/org/apache/james/mailbox/inmemory/InMemoryMailboxMapperTest.java (added)
+++ james/mailbox/trunk/memory/src/test/java/org/apache/james/mailbox/inmemory/InMemoryMailboxMapperTest.java Thu Jun  4 14:55:23 2015
@@ -0,0 +1,86 @@
+/****************************************************************
+ * 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;
+
+import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.mock.MockMailboxSession;
+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.mail.model.impl.SimpleMailbox;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class InMemoryMailboxMapperTest {
+
+    public static final int UID_VALIDITY = 10;
+
+    private MailboxPath user1InboxPath;
+    private MailboxPath user1SubMailbox1Path;
+    private MailboxPath user1SubMailbox2Path;
+    private MailboxPath user2OtherBoxPath;
+    private MailboxPath user1OtherNamespacePath;
+
+    private Mailbox<Long> user1Inbox;
+    private Mailbox<Long> user1SubMailbox1;
+    private Mailbox<Long> user1SubMailbox2;
+
+    private MailboxMapper<Long> mapper;
+
+    @Before
+    public void setUp() throws MailboxException {
+        user1InboxPath = new MailboxPath("#private", "user1", "INBOX");
+        user1SubMailbox1Path = new MailboxPath("#private", "user1", "INBOX.sub1");
+        user1SubMailbox2Path = new MailboxPath("#private", "user1", "INBOX.sub2");
+        user2OtherBoxPath = new MailboxPath("#private", "user2", "other.user");
+        user1OtherNamespacePath = new MailboxPath("#namspace", "user1", "other.namespace");
+        user1Inbox = new SimpleMailbox<Long>(user1InboxPath, UID_VALIDITY);
+        user1SubMailbox1 = new SimpleMailbox<Long>(user1SubMailbox1Path, UID_VALIDITY);
+        user1SubMailbox2 = new SimpleMailbox<Long>(user1SubMailbox2Path, UID_VALIDITY);
+        mapper = new InMemoryMailboxSessionMapperFactory().createMailboxMapper(new MockMailboxSession("user"));
+        mapper.save(user1Inbox);
+        mapper.save(user1SubMailbox1);
+        mapper.save(user1SubMailbox2);
+        mapper.save(new SimpleMailbox<Long>(user2OtherBoxPath, UID_VALIDITY));
+        mapper.save(new SimpleMailbox<Long>(user1OtherNamespacePath, UID_VALIDITY));
+    }
+
+    @Test
+    public void findMailboxWithPatchLikeOnAllMaillboxesShouldReturnMailboxesBelongingToThisNamespaceAndUser() throws MailboxException{
+        assertThat(mapper.findMailboxWithPathLike(new MailboxPath("#private", "user1", "%")))
+            .containsOnly(user1Inbox, user1SubMailbox1, user1SubMailbox2);
+    }
+
+    @Test
+    public void findMailboxWithPatchLikeBasedOnInboxShouldReturnItsChildren() throws MailboxException{
+        assertThat(mapper.findMailboxWithPathLike(new MailboxPath("#private", "user1", "INBOX.%")))
+            .containsOnly(user1SubMailbox1, user1SubMailbox2);
+    }
+
+    @Test
+    public void findMailboxWithPatchLikeBasedOnAStringShouldReturnMailboxesStartingWithThisString() throws MailboxException{
+        assertThat(mapper.findMailboxWithPathLike(new MailboxPath("#private", "user1", "IN%")))
+            .containsOnly(user1Inbox, user1SubMailbox1, user1SubMailbox2);
+    }
+
+}
+

Added: james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerTest.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerTest.java?rev=1683566&view=auto
==============================================================================
--- james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerTest.java (added)
+++ james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerTest.java Thu Jun  4 14:55:23 2015
@@ -0,0 +1,102 @@
+/****************************************************************
+ * 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;
+
+import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
+import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
+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 static org.assertj.core.api.Assertions.assertThat;
+
+public class StoreMailboxManagerTest {
+
+    public static final int UID_VALIDITY = 42;
+    private StoreMailboxManager storeMailboxManager;
+
+    @Before
+    public void setUp() {
+        storeMailboxManager = new StoreMailboxManager(null, new MockAuthenticator(), new JVMMailboxPathLocker(), new UnionMailboxACLResolver(), new SimpleGroupMembershipResolver());
+    }
+
+    @Test
+    public void belongsToNamespaceAndUserShouldReturnTrueWithIdenticalMailboxes() {
+        MailboxPath path = new MailboxPath("namespace", "user", "name");
+        assertThat(storeMailboxManager.belongsToNamespaceAndUser(path, new SimpleMailbox(path, UID_VALIDITY))).isTrue();
+    }
+
+    @Test
+    public void belongsToNamespaceAndUserShouldReturnTrueWithIdenticalMailboxesWithNullUser() {
+        MailboxPath path = new MailboxPath("namespace", null, "name");
+        assertThat(storeMailboxManager.belongsToNamespaceAndUser(path, new SimpleMailbox(path, UID_VALIDITY))).isTrue();
+    }
+
+    @Test
+    public void belongsToNamespaceAndUserShouldReturnTrueWithIdenticalMailboxesWithNullNamespace() {
+        MailboxPath path = new MailboxPath(null, "user", "name");
+        assertThat(storeMailboxManager.belongsToNamespaceAndUser(path,
+            new SimpleMailbox(new MailboxPath(null, "user", "name"), UID_VALIDITY))).isTrue();
+    }
+
+    @Test
+    public void belongsToNamespaceAndUserShouldReturnTrueWithMailboxWithSameNamespaceAndUserWithNullUser() {
+        MailboxPath path = new MailboxPath("namespace", null, "name");
+        assertThat(storeMailboxManager.belongsToNamespaceAndUser(path,
+            new SimpleMailbox(new MailboxPath("namespace", null, "name2"), UID_VALIDITY))).isTrue();
+    }
+
+    @Test
+    public void belongsToNamespaceAndUserShouldReturnTrueWithMailboxWithSameNamespaceAndUser() {
+        MailboxPath path = new MailboxPath("namespace", "user", "name");
+        assertThat(storeMailboxManager.belongsToNamespaceAndUser(path,
+            new SimpleMailbox(new MailboxPath("namespace", "user", "name2"), UID_VALIDITY))).isTrue();
+    }
+
+    @Test
+    public void belongsToNamespaceAndUserShouldReturnFalseWithDifferentNamespace() {
+        MailboxPath path = new MailboxPath("namespace", "user", "name");
+        assertThat(storeMailboxManager.belongsToNamespaceAndUser(path,
+            new SimpleMailbox(new MailboxPath("namespace2", "user", "name"), UID_VALIDITY))).isFalse();
+    }
+
+    @Test
+    public void belongsToNamespaceAndUserShouldReturnFalseWithDifferentUser() {
+        MailboxPath path = new MailboxPath("namespace", "user", "name");
+        assertThat(storeMailboxManager.belongsToNamespaceAndUser(path,
+            new SimpleMailbox(new MailboxPath("namespace", "user2", "name"), UID_VALIDITY))).isFalse();
+    }
+    @Test
+    public void belongsToNamespaceAndUserShouldReturnFalseWithOneOfTheUserNull() {
+        MailboxPath path = new MailboxPath("namespace", null, "name");
+        assertThat(storeMailboxManager.belongsToNamespaceAndUser(path,
+            new SimpleMailbox(new MailboxPath("namespace", "user", "name"), UID_VALIDITY))).isFalse();
+    }
+    @Test
+    public void belongsToNamespaceAndUserShouldReturnFalseIfNamespaceAreDifferentWithNullUser() {
+        MailboxPath path = new MailboxPath("namespace", null, "name");
+        assertThat(storeMailboxManager.belongsToNamespaceAndUser(path,
+            new SimpleMailbox(new MailboxPath("namespace2", null, "name"), UID_VALIDITY))).isFalse();
+    }
+
+
+}
+



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