james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject svn commit: r1686803 - in /james/mailbox/trunk: cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/utils/ store/src/main/java/org/apache/james/mailbox/store/ store/src/test/java/org/apache/james/mailbox/store/
Date Mon, 22 Jun 2015 08:14:12 GMT
Author: btellier
Date: Mon Jun 22 08:14:12 2015
New Revision: 1686803

URL: http://svn.apache.org/r1686803
Log:
MAILBOX-219 Mailbox with #private namespace are not groups

Added:
    james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/GroupFolderResolverTest.java
Modified:
    james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/utils/SimpleMailboxACLJsonConverterTest.java
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/GroupFolderResolver.java

Modified: james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/utils/SimpleMailboxACLJsonConverterTest.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/utils/SimpleMailboxACLJsonConverterTest.java?rev=1686803&r1=1686802&r2=1686803&view=diff
==============================================================================
--- james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/utils/SimpleMailboxACLJsonConverterTest.java
(original)
+++ james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/utils/SimpleMailboxACLJsonConverterTest.java
Mon Jun 22 08:14:12 2015
@@ -25,6 +25,9 @@ import static org.assertj.core.api.Asser
 import java.util.HashMap;
 import java.util.Map;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.james.mailbox.model.MailboxACL;
 import org.apache.james.mailbox.model.SimpleMailboxACL;
 import org.junit.Test;

Modified: james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/GroupFolderResolver.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/GroupFolderResolver.java?rev=1686803&r1=1686802&r2=1686803&view=diff
==============================================================================
--- james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/GroupFolderResolver.java
(original)
+++ james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/GroupFolderResolver.java
Mon Jun 22 08:14:12 2015
@@ -20,6 +20,7 @@
 package org.apache.james.mailbox.store;
 
 import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.model.MailboxConstants;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 
 public class GroupFolderResolver {
@@ -30,8 +31,11 @@ public class GroupFolderResolver {
         this.mailboxSession = mailboxSession;
     }
 
-    public boolean isGroupFolder(Mailbox mailbox) {
+    public boolean isGroupFolder(Mailbox<?> mailbox) {
         String namespace = mailbox.getNamespace();
-        return namespace == null || (!namespace.equals(mailboxSession.getPersonalSpace())
&& !namespace.equals(mailboxSession.getOtherUsersSpace()));
+        return namespace == null || 
+                (!namespace.equals(mailboxSession.getPersonalSpace())
+                && !namespace.equals(MailboxConstants.USER_NAMESPACE)
+                && !namespace.equals(mailboxSession.getOtherUsersSpace()));
     }
 }

Added: james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/GroupFolderResolverTest.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/GroupFolderResolverTest.java?rev=1686803&view=auto
==============================================================================
--- james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/GroupFolderResolverTest.java
(added)
+++ james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/GroupFolderResolverTest.java
Mon Jun 22 08:14:12 2015
@@ -0,0 +1,78 @@
+/****************************************************************
+ * 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 static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.List;
+import java.util.Locale;
+
+import org.apache.james.mailbox.MailboxSession.SessionType;
+import org.apache.james.mailbox.model.MailboxConstants;
+import org.apache.james.mailbox.model.MailboxPath;
+import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
+import org.junit.Test;
+import org.slf4j.Logger;
+
+public class GroupFolderResolverTest {
+
+    private static final long UID_VALIDITY = 9999;
+    private Logger log = null;
+    private List<Locale> localePreferences = null;
+    private List<String> sharedSpaces = null;
+    private char pathSeparator = ' ';
+    
+    @Test
+    public void isGroupFolderShouldReturnFalseWhenMailboxNamespaceIsNull() {
+        SimpleMailboxSession mailboxSession = new SimpleMailboxSession(1, "username", "password",
log, localePreferences, sharedSpaces, null, pathSeparator, SessionType.User);
+        GroupFolderResolver testee =  new GroupFolderResolver(mailboxSession);
+        
+        SimpleMailbox<Long> mailbox = new SimpleMailbox<Long>(new MailboxPath(null,
"user", "name"), UID_VALIDITY);
+        assertThat(testee.isGroupFolder(mailbox)).isFalse();
+    }
+    
+    @Test
+    public void isGroupFolderShouldReturnFalseWhenMailboxNamespaceEqualsToUserNamespace()
{
+        SimpleMailboxSession mailboxSession = new SimpleMailboxSession(1, "username", "password",
log, localePreferences, sharedSpaces, null, pathSeparator, SessionType.User);
+        GroupFolderResolver testee =  new GroupFolderResolver(mailboxSession);
+        
+        SimpleMailbox<Long> mailbox = new SimpleMailbox<Long>(new MailboxPath(MailboxConstants.USER_NAMESPACE,
"user", "name"), UID_VALIDITY);
+        assertThat(testee.isGroupFolder(mailbox)).isFalse();
+    }
+    
+    @Test
+    public void isGroupFolderShouldReturnFalseWhenMailboxNamespaceEqualsToOtherUsersNamespace()
{
+        String otherUsersSpace = "other";
+        SimpleMailboxSession mailboxSession = new SimpleMailboxSession(1, "username", "password",
log, localePreferences, sharedSpaces, otherUsersSpace, pathSeparator, SessionType.User);
+        GroupFolderResolver testee =  new GroupFolderResolver(mailboxSession);
+        
+        SimpleMailbox<Long> mailbox = new SimpleMailbox<Long>(new MailboxPath("other",
"user", "name"), UID_VALIDITY);
+        assertThat(testee.isGroupFolder(mailbox)).isFalse();
+    }
+    
+    @Test
+    public void isGroupFolderShouldReturnTrueWhenMailboxNamespaceDoesntEqualToOtherUsersNamespace()
{
+        String otherUsersSpace = "other";
+        SimpleMailboxSession mailboxSession = new SimpleMailboxSession(1, "username", "password",
log, localePreferences, sharedSpaces, otherUsersSpace, pathSeparator, SessionType.User);
+        GroupFolderResolver testee =  new GroupFolderResolver(mailboxSession);
+        
+        SimpleMailbox<Long> mailbox = new SimpleMailbox<Long>(new MailboxPath("namespace",
"user", "name"), UID_VALIDITY);
+        assertThat(testee.isGroupFolder(mailbox)).isTrue();
+    }
+}



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