1 19 20 package org.apache.james.imapserver.handler.session; 21 22 import java.io.IOException ; 23 24 import javax.mail.MessagingException ; 25 import javax.mail.internet.MimeMessage ; 26 27 import org.apache.james.imapserver.ProtocolException; 28 import org.apache.james.imapserver.client.LoginCommand; 29 import org.apache.james.imapserver.client.LogoutClientCommand; 30 import org.apache.james.imapserver.client.RenameClientCommand; 31 import org.apache.james.imapserver.store.MailboxException; 32 import org.apache.james.imapserver.util.MessageGenerator; 33 import org.apache.james.mailboxmanager.MailboxManagerException; 34 35 public class RenameSessionTest extends AbstractSessionTest { 36 37 String [] folders = { USER_MAILBOX_ROOT + ".INBOX", 38 USER_MAILBOX_ROOT + ".test", USER_MAILBOX_ROOT + ".test1", 39 USER_MAILBOX_ROOT + ".test1.test1a", 40 USER_MAILBOX_ROOT + ".test1.test1b", 41 USER_MAILBOX_ROOT + ".test2.test2a", 42 USER_MAILBOX_ROOT + ".test2.test2b" }; 43 44 MimeMessage [] msgs = null; 45 46 public void setUp() throws MailboxException, MessagingException , 47 IOException , MailboxManagerException { 48 super.setUp(); 49 msgs = MessageGenerator.generateSimpleMessages(2); 50 createFolders(folders); 51 for (int i = 0; i < folders.length; i++) { 52 appendMessagesClosed(folders[i], msgs); 53 } 54 } 55 56 public void tearDown() throws Exception { 57 super.tearDown(); 58 for (int i = 0; i < folders.length; i++) { 59 assertFalse(folders[i] + " is still in use!", isOpen(folders[i])); 60 } 61 } 62 63 public void testRenameSubfolder() throws ProtocolException, IOException , 64 MessagingException , MailboxManagerException { 65 verifyCommand(new LoginCommand(USER_NAME, USER_PASSWORD)); 66 67 verifyCommand(new RenameClientCommand("test1.test1a", "test1.test1neu")); 68 69 String [] expected = { USER_MAILBOX_ROOT + ".INBOX", 70 USER_MAILBOX_ROOT + ".test", USER_MAILBOX_ROOT + ".test1", 71 USER_MAILBOX_ROOT + ".test1.test1neu", 72 USER_MAILBOX_ROOT + ".test1.test1b", 73 USER_MAILBOX_ROOT + ".test2.test2a", 74 USER_MAILBOX_ROOT + ".test2.test2b" }; 75 verifyFolderList(expected, getFolderNames()); 76 77 verifyCommand(new LogoutClientCommand()); 78 } 79 80 public void testRenameParentfolder() throws ProtocolException, IOException , 81 MessagingException , MailboxManagerException { 82 verifyCommand(new LoginCommand(USER_NAME, USER_PASSWORD)); 83 84 verifyCommand(new RenameClientCommand("test1", "test2")); 85 86 String [] expected = { USER_MAILBOX_ROOT + ".INBOX", 87 USER_MAILBOX_ROOT + ".test", USER_MAILBOX_ROOT + ".test2", 88 USER_MAILBOX_ROOT + ".test2.test1a", 89 USER_MAILBOX_ROOT + ".test2.test1b", 90 USER_MAILBOX_ROOT + ".test2.test2a", 91 USER_MAILBOX_ROOT + ".test2.test2b" }; 92 verifyFolderList(expected, getFolderNames()); 93 94 verifyCommand(new LogoutClientCommand()); 95 } 96 97 } 98 | Popular Tags |