1 19 20 package org.apache.james.imapserver.handler.session; 21 22 import java.io.IOException ; 23 24 import javax.mail.Flags ; 25 import javax.mail.MessagingException ; 26 import javax.mail.internet.MimeMessage ; 27 28 import org.apache.james.imapserver.ProtocolException; 29 import org.apache.james.imapserver.client.LoginCommand; 30 import org.apache.james.imapserver.client.SelectCommand; 31 import org.apache.james.imapserver.client.StatusClientCommand; 32 import org.apache.james.imapserver.store.MailboxException; 33 import org.apache.james.imapserver.util.MessageGenerator; 34 import org.apache.james.mailboxmanager.MailboxManagerException; 35 36 public class StatusSessionTest extends AbstractSessionTest { 37 38 String [] folders = {USER_INBOX,USER_MAILBOX_ROOT+".f2"}; 39 MimeMessage [] f2_msgs= null; 40 MimeMessage [] inbox_msgs= new MimeMessage [0]; 41 42 boolean setup=false; 43 private long f2_uidV; 44 private long f2_uidNext; 45 46 public void setUp() throws MailboxManagerException, MailboxException, MessagingException , IOException { 47 super.setUp(); 48 f2_msgs=MessageGenerator.generateSimpleMessages(4); 49 createFolders(folders); 50 appendMessagesClosed(folders[1], new MimeMessage []{f2_msgs[0]}); 51 f2_msgs[1].setFlag(Flags.Flag.SEEN, true); 52 f2_msgs[2].setFlag(Flags.Flag.SEEN, true); 53 addUIDMessagesOpen(folders[1], new MimeMessage []{f2_msgs[1],f2_msgs[2],f2_msgs[3]}); 54 f2_uidV = getUidValidity(folders[1]); 55 f2_uidNext = getUidNext(folders[1]); 56 } 57 58 protected void doTestStatus() throws MessagingException , ProtocolException, IOException { 59 StatusClientCommand statusCommand; 60 61 statusCommand = new StatusClientCommand(folders[1],f2_msgs,f2_uidNext,f2_uidV); 63 verifyCommand(statusCommand); 64 65 statusCommand = new StatusClientCommand(folders[1],f2_msgs,f2_uidNext,f2_uidV); 67 statusCommand.setStatusMessages(true); 68 verifyCommand(statusCommand); 69 70 statusCommand = new StatusClientCommand(folders[1],f2_msgs,f2_uidNext,f2_uidV); 72 statusCommand.setStatusMessages(true); 73 statusCommand.setStatusUidNext(true); 74 verifyCommand(statusCommand); 75 76 statusCommand = new StatusClientCommand(folders[1],f2_msgs,f2_uidNext,f2_uidV); 78 statusCommand.setStatusMessages(true); 79 statusCommand.setStatusRecent(true); 80 statusCommand.setStatusUidNext(true); 81 statusCommand.setStatusUidValidity(true); 82 statusCommand.setStatusUnseen(true); 83 verifyCommand(statusCommand); 84 } 85 86 87 public void testStatusAuthState() throws ProtocolException, IOException , MessagingException { 88 verifyCommand(new LoginCommand(USER_NAME,USER_PASSWORD)); 89 doTestStatus(); 90 } 91 92 93 public void testStatusSelectedState() throws ProtocolException, IOException , MessagingException { 94 verifyCommand(new LoginCommand(USER_NAME,USER_PASSWORD)); 95 verifyCommand(new SelectCommand("INBOX", inbox_msgs, getUidValidity(USER_INBOX))); 96 doTestStatus(); 97 } 98 99 100 } 101 | Popular Tags |