james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject svn commit: r1685957 - /james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractMailboxMapperTest.java
Date Wed, 17 Jun 2015 09:03:49 GMT
Author: btellier
Date: Wed Jun 17 09:03:48 2015
New Revision: 1685957

URL: http://svn.apache.org/r1685957
Log:
MAILBOX-239 Add tests to demonstrate Cassandra backend does not take namespace nor user into
account

Modified:
    james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractMailboxMapperTest.java

Modified: james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractMailboxMapperTest.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractMailboxMapperTest.java?rev=1685957&r1=1685956&r2=1685957&view=diff
==============================================================================
--- james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractMailboxMapperTest.java
(original)
+++ james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractMailboxMapperTest.java
Wed Jun 17 09:03:48 2015
@@ -60,6 +60,8 @@ public abstract class AbstractMailboxMap
     private MailboxPath benwaWorkDonePath;
     private SimpleMailbox<Id> benwaWorkDoneMailbox;
     private MailboxPath bobInboxPath;
+    private SimpleMailbox<Id> bobyMailbox;
+    private MailboxPath bobyMailboxPath;
     private SimpleMailbox<Id> bobInboxMailbox;
     private MailboxPath esnDevGroupInboxPath;
     private SimpleMailbox<Id> esnDevGroupInboxMailbox;
@@ -73,6 +75,8 @@ public abstract class AbstractMailboxMap
     private SimpleMailbox<Id> obmTeamGroupOPushMailbox;
     private MailboxPath obmTeamGroupRoundCubePath;
     private SimpleMailbox<Id> obmTeamGroupRoundCubeMailbox;
+    private MailboxPath bobDifferentNamespacePath;
+    private SimpleMailbox<Id> bobDifferentNamespaceMailbox;
 
     public AbstractMailboxMapperTest(MapperProvider<Id> mapperProvider) {
         this.mapperProvider = mapperProvider;
@@ -83,6 +87,8 @@ public abstract class AbstractMailboxMap
         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");
@@ -102,6 +108,8 @@ public abstract class AbstractMailboxMap
         obmTeamGroupInboxMailbox = createMailbox(obmTeamGroupInboxPath);
         obmTeamGroupOPushMailbox = createMailbox(obmTeamGroupOPushPath);
         obmTeamGroupRoundCubeMailbox = createMailbox(obmTeamGroupRoundCubePath);
+        bobyMailbox = createMailbox(bobyMailboxPath);
+        bobDifferentNamespaceMailbox = createMailbox(bobDifferentNamespacePath);
     }
 
     @Before
@@ -164,6 +172,21 @@ public abstract class AbstractMailboxMap
         assertThat(mailboxMapper.hasChildren(esnDevGroupInboxMailbox, DELIMITER)).isTrue();
     }
 
+    @Ignore("See MAILBOX-11 and JWC-125")
+    @Test
+    public void hasChildrenShouldNotBeAcrossUsersAndNamespace() throws MailboxException {
+        saveAll();
+        assertThat(mailboxMapper.hasChildren(bobInboxMailbox, '.')).isFalse();
+    }
+
+    @Ignore("See MAILBOX-11 and JWC-125")
+    @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 {
@@ -223,6 +246,14 @@ public abstract class AbstractMailboxMap
         MailboxPath regexPath = new MailboxPath(esnDevGroupInboxPath.getNamespace(), esnDevGroupInboxPath.getUser(),
WILDCARD + "X");
         assertThat(mailboxMapper.findMailboxWithPathLike(regexPath)).contains(esnDevGroupInboxMailbox);
     }
+
+    @Ignore("Mailbox name is not escaped")
+    @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);
@@ -230,13 +261,15 @@ public abstract class AbstractMailboxMap
         mailboxMapper.save(benwaWorkTodoMailbox);
         mailboxMapper.save(benwaPersoMailbox);
         mailboxMapper.save(benwaWorkDoneMailbox);
-        mailboxMapper.save(bobInboxMailbox);
         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<Id> createMailbox(MailboxPath mailboxPath) {



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