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 2010/12/21 11:11:37 UTC

svn commit: r1051443 - /james/mailbox/trunk/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java

Author: eric
Date: Tue Dec 21 10:11:36 2010
New Revision: 1051443

URL: http://svn.apache.org/viewvc?rev=1051443&view=rev
Log:
Test list() with 3 level folders to have representative data for maildir impl.

Modified:
    james/mailbox/trunk/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java

Modified: james/mailbox/trunk/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java?rev=1051443&r1=1051442&r2=1051443&view=diff
==============================================================================
--- james/mailbox/trunk/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java (original)
+++ james/mailbox/trunk/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java Tue Dec 21 10:11:36 2010
@@ -53,16 +53,23 @@ public abstract class MailboxManagerTest
     private static MailboxManager mailboxManager;
     
     /**
-     * Number of Mailboxes to be created in the Mailbox Manager.
+     * Number of Users (with INBOX) to be created in the Mailbox Manager.
      */
-    private static final int MAILBOX_COUNT = 10;
+    private static final int USER_COUNT = 5;
+    
+    /**
+     * Number of Sub Mailboxes (mailbox in another mailbox) to be created in the Mailbox Manager.
+     */
+    private static final int SUB_MAILBOXES_COUNT = 5;
     
     /**
      * Number of Messages per Mailbox to be created in the Mailbox Manager.
      */
-    private static final int MESSAGE_PER_MAILBOX_COUNT = 10;
+    private static final int MESSAGE_PER_MAILBOX_COUNT = 5;
     
     /**
+     * Create some INBOXes and their sub mailboxes and assert list() method.
+     * 
      * @throws UnsupportedEncodingException 
      * @throws MailboxException 
      */
@@ -73,7 +80,10 @@ public abstract class MailboxManagerTest
 
         MailboxSession mailboxSession = getMailboxManager().createSystemSession("manager", new SimpleLog("testList"));
         getMailboxManager().startProcessingRequest(mailboxSession);
-        Assert.assertEquals(getMailboxManager().list(mailboxSession).size(), MAILBOX_COUNT);
+        Assert.assertEquals(USER_COUNT + // INBOX
+                USER_COUNT * MESSAGE_PER_MAILBOX_COUNT + // INBOX.SUB_FOLDER
+                USER_COUNT * MESSAGE_PER_MAILBOX_COUNT * MESSAGE_PER_MAILBOX_COUNT,  // INBOX.SUB_FOLDER.SUBSUB_FOLDER
+                getMailboxManager().list(mailboxSession).size());
 
     }
     
@@ -86,26 +96,25 @@ public abstract class MailboxManagerTest
      */
     private void feedMailboxManager() throws MailboxException, UnsupportedEncodingException {
 
-        MessageManager messageManager = null;
         MailboxPath mailboxPath = null;
         
-        for (int i=0; i < MAILBOX_COUNT; i++) {
+        for (int i=0; i < USER_COUNT; i++) {
 
-            MailboxSession mailboxSession = getMailboxManager().createSystemSession("user" + i, new SimpleLog("testList-feeder"));        
-
-            getMailboxManager().startProcessingRequest(mailboxSession);
+            MailboxSession mailboxSession = getMailboxManager().createSystemSession("user" + i, new SimpleLog("mailboxmanager-test"));        
             mailboxPath = new MailboxPath("#private", "user" + i, "INBOX");
-            getMailboxManager().createMailbox(mailboxPath, mailboxSession);
-            messageManager = getMailboxManager().getMailbox(mailboxPath, mailboxSession);
-            for (int j=0; j < MESSAGE_PER_MAILBOX_COUNT; j++) {
-                messageManager.appendMessage(new ByteArrayInputStream(MockMail.MAIL_TEXT_PLAIN.getBytes("UTF-8")), 
-                        Calendar.getInstance().getTime(), 
-                        mailboxSession, 
-                        true, 
-                        new Flags(Flags.Flag.RECENT));
+            createMailbox(mailboxSession, mailboxPath);
+            
+            for (int j=0; j < SUB_MAILBOXES_COUNT; j++) {
+                mailboxPath = new MailboxPath("#private", "user" + i, "INBOX.SUB_FOLDER_" + j);
+                createMailbox(mailboxSession, mailboxPath);
+                
+                for (int k=0; k < SUB_MAILBOXES_COUNT; k++) {
+                    mailboxPath = new MailboxPath("#private", "user" + i, "INBOX.SUB_FOLDER_" + j + ".SUBSUB_FOLDER_" + k);
+                    createMailbox(mailboxSession, mailboxPath);
+                }
+                    
             }
             
-            getMailboxManager().endProcessingRequest(mailboxSession);
             getMailboxManager().logout(mailboxSession, true);
         
         }
@@ -113,6 +122,26 @@ public abstract class MailboxManagerTest
     }
     
     /**
+     * 
+     * @param mailboxPath
+     * @throws MailboxException
+     * @throws UnsupportedEncodingException 
+     */
+    private void createMailbox(MailboxSession mailboxSession, MailboxPath mailboxPath) throws MailboxException, UnsupportedEncodingException {
+        getMailboxManager().startProcessingRequest(mailboxSession);
+        getMailboxManager().createMailbox(mailboxPath, mailboxSession);
+        MessageManager messageManager = getMailboxManager().getMailbox(mailboxPath, mailboxSession);
+        for (int j=0; j < MESSAGE_PER_MAILBOX_COUNT; j++) {
+            messageManager.appendMessage(new ByteArrayInputStream(MockMail.MAIL_TEXT_PLAIN.getBytes("UTF-8")), 
+                    Calendar.getInstance().getTime(), 
+                    mailboxSession, 
+                    true, 
+                    new Flags(Flags.Flag.RECENT));
+        }
+        getMailboxManager().endProcessingRequest(mailboxSession);
+    }
+    
+    /**
      * Setter to inject the mailboxManager.
      */
     protected static void setMailboxManager(MailboxManager mailboxManager) {



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