Author: norman Date: Tue Jan 11 07:25:10 2011 New Revision: 1057506 URL: http://svn.apache.org/viewvc?rev=1057506&view=rev Log: Now MaildirStore constructed with %fulluser and %user work like expected. See MAILBOX-32
Modified: james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMailboxMapper.java james/mailbox/trunk/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerTest.java Modified: james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMailboxMapper.java URL: http://svn.apache.org/viewvc/james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMailboxMapper.java?rev=1057506&r1=1057505&r2=1057506&view=diff ============================================================================== --- james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMailboxMapper.java (original) +++ james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMailboxMapper.java Tue Jan 11 07:25:10 2011 @@ -201,9 +201,10 @@ public class MaildirMailboxMapper extend return mailboxList; } - if ((maildirStore.getMaildirLocation().endsWith("/" + MaildirStore.PATH_USER)) && (maildirStore.getMaildirLocation().endsWith("/" + MaildirStore.PATH_FULLUSER))) { + if ((maildirStore.getMaildirLocation().endsWith("/" + MaildirStore.PATH_USER)) || (maildirStore.getMaildirLocation().endsWith("/" + MaildirStore.PATH_FULLUSER))) { File[] users = maildirRoot.listFiles(); visitUsersForMailboxList(null, users, mailboxList); + return mailboxList; } throw new UnsupportedOperationException("The MaildirLocation must end with /%domain/%user, /%user or /%fulluser."); @@ -253,9 +254,16 @@ public class MaildirMailboxMapper extend for (File user: users) { + + if (domain == null) { + userName = user.getName(); + } + else { + userName = user.getName() + "@" + domain.getName(); + } + // Special case for INBOX: Let's use the user's folder. - - MailboxPath inboxMailboxPath = MailboxPath.inbox(user.getName() + "@" + domain.getName()); + MailboxPath inboxMailboxPath = MailboxPath.inbox(userName); mailboxList.add(maildirStore.loadMailbox(inboxMailboxPath)); // List all INBOX sub folders. @@ -267,13 +275,7 @@ public class MaildirMailboxMapper extend }); for (File mailbox: mailboxes) { - - if (domain == null) { - userName = user.getName(); - } - else { - userName = user.getName() + "@" + domain.getName(); - } + MailboxPath mailboxPath = new MailboxPath(MailboxConstants.USER_NAMESPACE, userName, Modified: james/mailbox/trunk/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerTest.java URL: http://svn.apache.org/viewvc/james/mailbox/trunk/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerTest.java?rev=1057506&r1=1057505&r2=1057506&view=diff ============================================================================== --- james/mailbox/trunk/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerTest.java (original) +++ james/mailbox/trunk/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerTest.java Tue Jan 11 07:25:10 2011 @@ -18,6 +18,8 @@ ****************************************************************/ package org.apache.james.mailbox.maildir; +import static org.junit.Assert.*; + import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; @@ -26,12 +28,11 @@ import java.util.Date; import javax.mail.Flags; -import junit.framework.Assert; - import org.apache.commons.io.FileUtils; import org.apache.commons.logging.impl.SimpleLog; import org.apache.james.mailbox.MailboxConstants; import org.apache.james.mailbox.MailboxException; +import org.apache.james.mailbox.MailboxExistsException; import org.apache.james.mailbox.MailboxManagerTest; import org.apache.james.mailbox.MailboxPath; import org.apache.james.mailbox.MailboxSession; @@ -77,12 +78,16 @@ public class MaildirMailboxManagerTest e } else { doTestListWithMaildirStoreConfiguration("/%domain/%user"); - - // TODO Tests fail with /%user configuration - // doTestListWithMaildirStoreConfiguration("/%user"); + // TODO Tests fail with /%user configuration + try { + doTestListWithMaildirStoreConfiguration("/%user"); + fail(); + } catch (MailboxExistsException e) { + // This is expected as the there are many users which have the same localpart + } // TODO Tests fail with /%fulluser configuration - // doTestListWithMaildirStoreConfiguration("/%fulluser"); + doTestListWithMaildirStoreConfiguration("/%fulluser"); } @@ -102,12 +107,15 @@ public class MaildirMailboxManagerTest e MaildirMailboxManager manager = new MaildirMailboxManager(mf, null, store); manager.init(); setMailboxManager(manager); - super.testList(); try { - deleteMaildirTestDirectory(); - } catch (IOException e) { - Assert.fail(); - e.printStackTrace(); + super.testList(); + } finally { + try { + deleteMaildirTestDirectory(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } } @@ -131,7 +139,7 @@ public class MaildirMailboxManagerTest e // See MAILBOX-31 @Test public void testCreateSubFolder() throws MailboxException { - MaildirStore store = new MaildirStore("target/maildir" + "/%domain/%user"); + MaildirStore store = new MaildirStore(MAILDIR_HOME + "/%domain/%user"); MaildirMailboxSessionMapperFactory mf = new MaildirMailboxSessionMapperFactory(store); MaildirMailboxManager manager = new MaildirMailboxManager(mf, null, store); --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org