1 19 20 package org.apache.james.mailboxmanager; 21 22 import java.util.HashSet ; 23 import java.util.Iterator ; 24 import java.util.Set ; 25 26 import org.apache.james.mailboxmanager.mailbox.GeneralMailboxSession; 27 import org.apache.james.mailboxmanager.manager.MailboxManager; 28 import org.apache.james.mailboxmanager.manager.MailboxManagerProvider; 29 30 import junit.framework.TestCase; 31 32 public abstract class AbstractMailboxManagerSelfTestCase extends TestCase { 33 34 protected MailboxManager mailboxManager; 35 protected MailboxManagerProvider mailboxManagerProvider; 36 37 public void testCreateList() throws MailboxManagerException { 38 ListResult[] listResult; 39 listResult=mailboxManager.list("","*",false); 40 assertNotNull(listResult); 41 assertEquals(0,mailboxManager.list("","*",false).length); 42 Set boxes=new HashSet (); 43 boxes.add("#users.joachim.INBOX"); 44 boxes.add("#users.joachim.INBOX.Drafts"); 45 boxes.add("#users.joachim2.INBOX"); 46 for (Iterator iter = boxes.iterator(); iter.hasNext();) { 47 String box = (String ) iter.next(); 48 mailboxManager.createMailbox(box); 49 } 50 listResult=mailboxManager.list("","*",false); 51 assertEquals(3,listResult.length); 52 for (int i = 0; i < listResult.length; i++) { 53 assertTrue(boxes.contains(listResult[i].getName())); 54 } 55 } 56 57 public void testGetSessionMailboxLife() throws MailboxManagerException { 58 final String folder="#users.joachim3.INBOX"; 59 assertEquals(0, mailboxManagerProvider.getOpenMailboxSessionCountMap().size()); 60 mailboxManager.createMailbox(folder); 61 GeneralMailboxSession sessionMailbox=mailboxManager.getGeneralMailboxSession(folder); 62 assertNotNull(sessionMailbox); 63 assertEquals(1, mailboxManagerProvider.getOpenMailboxSessionCountMap().size()); 64 assertEquals(new Integer (1), mailboxManagerProvider.getOpenMailboxSessionCountMap().get(folder)); 65 sessionMailbox.close(); 66 assertEquals(0, mailboxManagerProvider.getOpenMailboxSessionCountMap().size()); 67 } 68 69 public void testListOne() throws MailboxManagerException { 70 mailboxManager.createMailbox("test1"); 71 mailboxManager.createMailbox("INBOX"); 72 mailboxManager.createMailbox("INBOX2"); 73 74 ListResult[] listResult=mailboxManager.list("","INBOX",false); 75 assertNotNull(listResult); 76 assertEquals(1, listResult.length); 77 assertEquals("INBOX", listResult[0].getName()); 78 } 79 80 } 81 | Popular Tags |