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 da...@apache.org on 2003/11/30 08:03:49 UTC

cvs commit: james-server/proposals/imap2/test/org/apache/james/test AbstractProtocolTest.java

darrell     2003/11/29 23:03:49

  Modified:    proposals/imap2 build-test.xml
               proposals/imap2/java/org/apache/james/imapserver
                        ImapSessionImpl.java ImapSessionMailbox.java
                        JamesImapHost.java
               proposals/imap2/java/org/apache/james/imapserver/commands
                        FetchCommand.java SelectCommand.java
                        StatusCommand.java StoreCommand.java
               proposals/imap2/java/org/apache/james/imapserver/store
                        ImapMailbox.java InMemoryStore.java
                        MailboxListener.java
               proposals/imap2/test/org/apache/james/imapserver Delete.test
                        ImapMailboxTest.java ListMailboxes.test
                        SelectAppend.test SelectInbox.test
                        SelectedStateCleanup.test SelectedStateSetup.test
                        Status.test Subscribe.test
                        TestCommandsInAuthenticatedState.java
                        TestConcurrentSessions.java
                        TestOtherCommandsInSelectedState.java Uid.test
               proposals/imap2/test/org/apache/james/imapserver/concurrent
                        ExistsResponse.test FetchResponse.test
               proposals/imap2/test/org/apache/james/test
                        AbstractProtocolTest.java
  Added:       proposals/imap2/test/org/apache/james/imapserver
                        AppendExamineInbox.test AppendSelectInbox.test
                        InboxAddMessages.test InboxDeleteMessages.test
                        Rename.test
               proposals/imap2/test/org/apache/james/imapserver/concurrent
                        ExpungeResponse.test
  Removed:     proposals/imap2/test/org/apache/james/imapserver
                        ExamineInbox.test
  Log:
  - Copy all messages when inbox is renamed
  - Make sure .SILENT flag doesn't stop concurrent sessions from getting flag updates
  - Send UID in fetch response from UID STORE
  - Try to improve cleanup in protocol tests when errors occur
  
  Revision  Changes    Path
  1.8       +5 -3      james-server/proposals/imap2/build-test.xml
  
  Index: build-test.xml
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/build-test.xml,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- build-test.xml	26 Nov 2003 14:18:37 -0000	1.7
  +++ build-test.xml	30 Nov 2003 07:03:47 -0000	1.8
  @@ -117,7 +117,7 @@
       <!-- Run the full set of Imap tests against local components -->
       <target name="unit-tests" depends="compile"
               description="Run the full set of IMAP tests against local components.">
  -        <junit fork="yes">
  +        <junit fork="yes" failureproperty="unit-test.failed"  >
               <classpath>
                   <pathelement location="${build.test.classes}"/>
                   <path refid="test.class.path"/>
  @@ -135,6 +135,8 @@
               <test name="org.apache.james.imapserver.TestCompound"/>
               <test name="org.apache.james.imapserver.TestConcurrentSessions"/>
           </junit>
  +        
  +        <fail if="unit-test.failed" message="One or more unit-tests failed"/>
       </target>
   
       <!-- Executes tests against a running instance of James -->
  @@ -182,8 +184,8 @@
       </target>
       
       <target name="copytests">
  -        <mkdir dir="${build.dir}/tests"/>
  -        <copy todir="${build.dir}/tests">
  +        <mkdir dir="${build.test.classes}"/>
  +        <copy todir="${build.test.classes}">
               <fileset dir="${test.dir}" includes="**/*.test"/>
           </copy>
       </target>
  
  
  
  1.8       +15 -8     james-server/proposals/imap2/java/org/apache/james/imapserver/ImapSessionImpl.java
  
  Index: ImapSessionImpl.java
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/java/org/apache/james/imapserver/ImapSessionImpl.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ImapSessionImpl.java	26 Nov 2003 14:18:37 -0000	1.7
  +++ ImapSessionImpl.java	30 Nov 2003 07:03:48 -0000	1.8
  @@ -67,6 +67,7 @@
   import javax.mail.Flags;
   import java.util.Map;
   import java.util.Iterator;
  +import java.util.List;
   
   /**
    *
  @@ -115,19 +116,25 @@
           if (selected != null) {
               // New message response
               // TODO: need RECENT...
  -            if (selected._sizeChanged) {
  +            if (selected.isSizeChanged()) {
                   request.existsResponse(selected.getMessageCount());
  -                selected._sizeChanged = false;
  +                request.recentResponse(selected.getRecentCount(true));
  +                selected.setSizeChanged(false);
               }
   
  -            Map flagUpdates = selected.getFlagUpdates();
  -            Iterator iter = flagUpdates.entrySet().iterator();
  +            List flagUpdates = selected.getFlagUpdates();
  +            Iterator iter = flagUpdates.iterator();
               while (iter.hasNext()) {
  -                Map.Entry entry = (Map.Entry) iter.next();
  -                int msn = ((Integer) entry.getKey()).intValue();
  -                Flags updatedFlags = (Flags) entry.getValue();
  +                ImapSessionMailbox.FlagUpdate entry = 
  +                        (ImapSessionMailbox.FlagUpdate) iter.next();
  +                int msn = entry.msn;
  +                Flags updatedFlags = entry.flags;
                   StringBuffer out = new StringBuffer( "FLAGS " );
                   out.append( MessageFlags.format(updatedFlags) );
  +                if (entry.uid != null) {
  +                    out.append(" UID ");
  +                    out.append(entry.uid);
  +                }
                   request.fetchResponse(msn, out.toString());
   
               }
  
  
  
  1.4       +53 -19    james-server/proposals/imap2/java/org/apache/james/imapserver/ImapSessionMailbox.java
  
  Index: ImapSessionMailbox.java
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/java/org/apache/james/imapserver/ImapSessionMailbox.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ImapSessionMailbox.java	21 Jul 2003 23:31:04 -0000	1.3
  +++ ImapSessionMailbox.java	30 Nov 2003 07:03:48 -0000	1.4
  @@ -72,8 +72,7 @@
   public class ImapSessionMailbox implements ImapMailbox, MailboxListener {
       private ImapMailbox _mailbox;
       private boolean _readonly;
  -    // TODO encapsulate
  -    public boolean _sizeChanged;
  +    private boolean _sizeChanged;
       private List _expungedMsns = Collections.synchronizedList(new LinkedList());
       private Map _modifiedFlags = Collections.synchronizedMap(new TreeMap());
   
  @@ -122,32 +121,30 @@
           }
       }
   
  -    public Map getFlagUpdates() throws MailboxException {
  +    public List getFlagUpdates() throws MailboxException {
           if (_modifiedFlags.isEmpty()) {
  -            return Collections.EMPTY_MAP;
  +            return Collections.EMPTY_LIST;
           }
   
  -        TreeMap retVal = new TreeMap();
  -        retVal.putAll(_modifiedFlags);
  +        List retVal = new ArrayList();
  +        retVal.addAll(_modifiedFlags.values());
           _modifiedFlags.clear();
           return retVal;
       }
   
  -    public void expunged(long uid) throws MailboxException {
  +    public void expunged(int msn) {
           synchronized (_expungedMsns) {
  -            int msn = getMsn(uid);
               _expungedMsns.add(new Integer(msn));
           }
       }
   
  -    public void added(long uid) {
  +    public void added(int msn) {
           _sizeChanged = true;
       }
   
  -    public void flagsUpdated(long uid, Flags flags) throws MailboxException {
  +    public void flagsUpdated(int msn, Flags flags, Long uid) {
           // This will overwrite any earlier changes
  -        int msn = getMsn(uid);
  -        _modifiedFlags.put(new Integer(msn), flags);
  +        _modifiedFlags.put(new Integer(msn), new FlagUpdate(msn, uid, flags));
       }
   
       public String getName() {
  @@ -166,8 +163,8 @@
           return _mailbox.getMessageCount();
       }
   
  -    public int getRecentCount() {
  -        return _mailbox.getRecentCount();
  +    public int getRecentCount(boolean reset) {
  +        return _mailbox.getRecentCount(reset);
       }
   
       public long getUidValidity() {
  @@ -175,7 +172,24 @@
       }
   
       public int getFirstUnseen() {
  -        return _mailbox.getFirstUnseen();
  +        return correctForExpungedMessages(_mailbox.getFirstUnseen());
  +    }
  +
  +    /**
  +     * Adjust an actual mailbox msn for the expunged messages in this mailbox that have not
  +     * yet been notified.
  +     * TODO - need a test for this
  +     */ 
  +    private int correctForExpungedMessages(int absoluteMsn) {
  +        int correctedMsn = absoluteMsn;
  +        // Loop throught the expunged list backwards, adjusting the msn as we go.
  +        for (int i = (_expungedMsns.size() - 1); i >= 0; i--) {
  +            Integer expunged = (Integer) _expungedMsns.get(i);
  +            if (expunged.intValue() <= absoluteMsn) {
  +                correctedMsn++;
  +            }
  +        }
  +        return correctedMsn;
       }
   
       public boolean isSelectable() {
  @@ -230,16 +244,36 @@
           return new IdRange[0];  //To change body of created methods use Options | File Templates.
       }
   
  -    public void setFlags(Flags flags, boolean value, long uid, boolean silent) throws MailboxException {
  -        _mailbox.setFlags(flags, value, uid, silent);
  +    public void setFlags(Flags flags, boolean value, long uid, MailboxListener silentListener, boolean addUid) throws MailboxException {
  +        _mailbox.setFlags(flags, value, uid, silentListener, addUid);
       }
   
  -    public void replaceFlags(Flags flags, long uid, boolean silent) throws MailboxException {
  -        _mailbox.replaceFlags(flags, uid, silent);
  +    public void replaceFlags(Flags flags, long uid, MailboxListener silentListener, boolean addUid) throws MailboxException {
  +        _mailbox.replaceFlags(flags, uid, silentListener, addUid);
       }
   
       public void deleteAllMessages() {
           _mailbox.deleteAllMessages();
  +    }
  +
  +    public boolean isSizeChanged() {
  +        return _sizeChanged;
  +    }
  +
  +    public void setSizeChanged(boolean sizeChanged) {
  +        _sizeChanged = sizeChanged;
  +    }
  +    
  +    static final class FlagUpdate {
  +        int msn;
  +        Long uid;
  +        Flags flags;
  +
  +        public FlagUpdate(int msn, Long uid, Flags flags) {
  +            this.msn = msn;
  +            this.uid = uid;
  +            this.flags = flags;
  +        }
       }
   
   }
  
  
  
  1.12      +8 -2      james-server/proposals/imap2/java/org/apache/james/imapserver/JamesImapHost.java
  
  Index: JamesImapHost.java
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/java/org/apache/james/imapserver/JamesImapHost.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- JamesImapHost.java	23 Oct 2003 01:55:12 -0000	1.11
  +++ JamesImapHost.java	30 Nov 2003 07:03:48 -0000	1.12
  @@ -227,8 +227,14 @@
           //            and leave INBOX (with children) intact.
           String userInboxName = getQualifiedMailboxName( user, INBOX_NAME );
           if ( userInboxName.equals( existingMailbox.getFullName() ) ) {
  +            ImapMailbox inbox = existingMailbox;
               ImapMailbox newBox = createMailbox( user, newMailboxName );
  -            // TODO copy all messages from INBOX.
  +            long[] uids = inbox.getMessageUids();
  +            for (int i = 0; i < uids.length; i++) {
  +                long uid = uids[i];
  +                inbox.copyMessage(uid, newBox);
  +            }
  +            inbox.deleteAllMessages();
               return;
           }
   
  
  
  
  1.7       +7 -3      james-server/proposals/imap2/java/org/apache/james/imapserver/commands/FetchCommand.java
  
  Index: FetchCommand.java
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/java/org/apache/james/imapserver/commands/FetchCommand.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- FetchCommand.java	21 Jul 2003 23:31:04 -0000	1.6
  +++ FetchCommand.java	30 Nov 2003 07:03:48 -0000	1.7
  @@ -111,6 +111,10 @@
           IdRange[] idSet = parser.parseIdRange( request );
           FetchRequest fetch = parser.fetchRequest( request );
           parser.endLine( request );
  +        
  +        if (useUids) {
  +            fetch.addElement(FetchElement.UID);
  +        }
   
           ImapMailbox mailbox = session.getSelected();
           long[] uids = mailbox.getMessageUids();
  @@ -125,7 +129,7 @@
                   String msgData = outputMessage( fetch, imapMessage );
                   response.fetchResponse( msn, msgData );
                   if (imapMessage.getFlags().contains(Flags.Flag.RECENT)) {
  -                    mailbox.setFlags(new Flags(Flags.Flag.RECENT), false, uid, true);
  +                    mailbox.setFlags(new Flags(Flags.Flag.RECENT), false, uid, null, false);
                   }
               }
           }
  @@ -140,7 +144,7 @@
       {
   
           StringBuffer response = new StringBuffer();
  -
  +        
           List elements = fetch.getElements();
           for ( int i = 0; i < elements.size(); i++ ) {
               FetchElement fetchElement = ( FetchElement ) elements.get( i );
  
  
  
  1.9       +8 -8      james-server/proposals/imap2/java/org/apache/james/imapserver/commands/SelectCommand.java
  
  Index: SelectCommand.java
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/java/org/apache/james/imapserver/commands/SelectCommand.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SelectCommand.java	21 Jul 2003 23:31:05 -0000	1.8
  +++ SelectCommand.java	30 Nov 2003 07:03:48 -0000	1.9
  @@ -89,19 +89,20 @@
   
           session.deselect();
   
  -        selectMailbox(mailboxName, session);
  +        final boolean isExamine = ( this instanceof ExamineCommand );
  +        selectMailbox(mailboxName, session, isExamine);
   
           ImapSessionMailbox mailbox = session.getSelected();
           response.flagsResponse( mailbox.getPermanentFlags() );
           response.existsResponse( mailbox.getMessageCount() );
  -        response.recentResponse( mailbox.getRecentCount() );
  +        final boolean resetRecent = ! isExamine;
  +        response.recentResponse( mailbox.getRecentCount(resetRecent) );
           response.okResponse( "UIDVALIDITY " + mailbox.getUidValidity(), null );
   
           int firstUnseen = mailbox.getFirstUnseen();
           if ( firstUnseen > 0 ) {
  -            int msnUnseen = mailbox.getMsn( firstUnseen );
  -            response.okResponse( "UNSEEN " + msnUnseen,
  -                                 "Message " + msnUnseen + " is the first unseen" );
  +            response.okResponse( "UNSEEN " + firstUnseen,
  +                                 "Message " + firstUnseen + " is the first unseen" );
           }
           else {
               response.okResponse( null, "No messages unseen" );
  @@ -117,14 +118,13 @@
           }
       }
   
  -    private boolean selectMailbox(String mailboxName, ImapSession session) throws MailboxException {
  +    private boolean selectMailbox(String mailboxName, ImapSession session, boolean readOnly) throws MailboxException {
           ImapMailbox mailbox = getMailbox( mailboxName, session, true );
   
           if ( !mailbox.isSelectable() ) {
               throw new MailboxException( "Nonselectable mailbox." );
           }
   
  -        boolean readOnly = ( this instanceof ExamineCommand );
           session.setSelected( mailbox, readOnly );
           return readOnly;
       }
  
  
  
  1.7       +2 -2      james-server/proposals/imap2/java/org/apache/james/imapserver/commands/StatusCommand.java
  
  Index: StatusCommand.java
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/java/org/apache/james/imapserver/commands/StatusCommand.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- StatusCommand.java	8 Mar 2003 21:13:55 -0000	1.6
  +++ StatusCommand.java	30 Nov 2003 07:03:48 -0000	1.7
  @@ -111,7 +111,7 @@
           if ( statusDataItems.recent ) {
               buffer.append( RECENT );
               buffer.append( SP );
  -            buffer.append( mailbox.getRecentCount() );
  +            buffer.append( mailbox.getRecentCount(false) );
               buffer.append( SP );
           }
   
  
  
  
  1.7       +11 -14    james-server/proposals/imap2/java/org/apache/james/imapserver/commands/StoreCommand.java
  
  Index: StoreCommand.java
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/java/org/apache/james/imapserver/commands/StoreCommand.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- StoreCommand.java	23 Oct 2003 01:55:12 -0000	1.6
  +++ StoreCommand.java	30 Nov 2003 07:03:48 -0000	1.7
  @@ -68,6 +68,7 @@
   import org.apache.james.imapserver.store.MailboxException;
   import org.apache.james.imapserver.store.MessageFlags;
   import org.apache.james.imapserver.store.SimpleImapMessage;
  +import org.apache.james.imapserver.store.MailboxListener;
   
   /**
    * Handles processeing for the STORE imap command.
  @@ -120,6 +121,11 @@
   //            mailbox.replaceFlags(flags, uidSet, directive.isSilent());
   //        }
   
  +        MailboxListener silentListener = null;
  +        if (directive.isSilent()) {
  +            silentListener = mailbox;
  +        }
  +        
           // TODO do this in one hit.
           long[] uids = mailbox.getMessageUids();
           for ( int i = 0; i < uids.length; i++ ) {
  @@ -130,26 +136,17 @@
                    ( !useUids && includes( idSet, msn ) ) )
               {
                   if (directive.getSign() < 0) {
  -                    mailbox.setFlags(flags, false, uid, directive.isSilent());
  +                    mailbox.setFlags(flags, false, uid, silentListener, useUids);
                   }
                   else if (directive.getSign() > 0) {
  -                    mailbox.setFlags(flags, true, uid, directive.isSilent());
  +                    mailbox.setFlags(flags, true, uid, silentListener, useUids);
                   }
                   else {
  -                    mailbox.replaceFlags(flags, uid, directive.isSilent());
  +                    mailbox.replaceFlags(flags, uid, silentListener, useUids);
                   }
  -//                SimpleImapMessage imapMessage = mailbox.getMessage( uid );
  -//                storeFlags( imapMessage, directive, flags );
  -//                mailbox.updateMessage( imapMessage );
  -//
  -//                if ( ! directive.isSilent() ) {
  -//                    StringBuffer out = new StringBuffer( "FLAGS " );
  -//                    out.append( MessageFlags.format(imapMessage.getFlags()) );
  -//                    response.fetchResponse( msn, out.toString() );
  -//                }
               }
           }
  -
  +        
           boolean omitExpunged = (!useUids);
           session.unsolicitedResponses( response, omitExpunged );
           response.commandComplete( this );
  
  
  
  1.12      +4 -4      james-server/proposals/imap2/java/org/apache/james/imapserver/store/ImapMailbox.java
  
  Index: ImapMailbox.java
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/java/org/apache/james/imapserver/store/ImapMailbox.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ImapMailbox.java	23 Oct 2003 01:55:13 -0000	1.11
  +++ ImapMailbox.java	30 Nov 2003 07:03:48 -0000	1.12
  @@ -87,7 +87,7 @@
   
       int getMessageCount();
   
  -    int getRecentCount();
  +    int getRecentCount(boolean reset);
   
       long getUidValidity();
   
  @@ -120,9 +120,9 @@
       void copyMessage( long uid, ImapMailbox toMailbox )
               throws MailboxException;
   
  -    void setFlags(Flags flags, boolean value, long uid, boolean silent) throws MailboxException;
  +    void setFlags(Flags flags, boolean value, long uid, MailboxListener silentListener, boolean addUid) throws MailboxException;
   
  -    void replaceFlags(Flags flags, long uid, boolean silent) throws MailboxException;
  +    void replaceFlags(Flags flags, long uid, MailboxListener silentListener, boolean addUid) throws MailboxException;
   
       int getMsn( long uid ) throws MailboxException;
   
  
  
  
  1.11      +57 -43    james-server/proposals/imap2/java/org/apache/james/imapserver/store/InMemoryStore.java
  
  Index: InMemoryStore.java
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/java/org/apache/james/imapserver/store/InMemoryStore.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- InMemoryStore.java	23 Oct 2003 01:55:13 -0000	1.10
  +++ InMemoryStore.java	30 Nov 2003 07:03:48 -0000	1.11
  @@ -332,6 +332,11 @@
               return count;
           }
   
  +        /**
  +         * Returns the 1-based index of the first unseen message. Unless there are outstanding
  +         * expunge responses in the ImapSessionMailbox, this will correspond to the MSN for
  +         * the first unseen.
  +         */ 
           public int getFirstUnseen()
           {
               for (int i = 0; i < mailMessages.size(); i++) {
  @@ -343,9 +348,19 @@
               return -1;
           }
   
  -        public int getRecentCount()
  +        public int getRecentCount(boolean reset)
           {
  -            return 0;
  +            int count = 0;
  +            for (int i = 0; i < mailMessages.size(); i++) {
  +                SimpleImapMessage message = (SimpleImapMessage) mailMessages.get(i);
  +                if (message.getFlags().contains(Flags.Flag.RECENT)) {
  +                    count++;
  +                    if (reset) {
  +                        message.getFlags().remove(Flags.Flag.RECENT);
  +                    }
  +                }
  +            }
  +            return count;
           }
   
           public int getMsn( long uid ) throws MailboxException
  @@ -379,6 +394,7 @@
   //            flags.setRecent(true);
               SimpleImapMessage imapMessage = new SimpleImapMessage( message, flags,
                                                          internalDate, uid );
  +            imapMessage.getFlags().add(Flags.Flag.RECENT);
               setupLogger( imapMessage );
   
               mailMessages.add(imapMessage);
  @@ -388,55 +404,57 @@
               synchronized (_mailboxListeners) {
                   for (int j = 0; j < _mailboxListeners.size(); j++) {
                       MailboxListener listener = (MailboxListener) _mailboxListeners.get(j);
  -                    listener.added(uid);
  +                    listener.added(newMsn);
                   }
               }
   
               return uid;
           }
   
  -        public void setFlags(Flags flags, boolean value, long uid, boolean silent) throws MailboxException {
  -            SimpleImapMessage message = getMessage(uid);
  -            if (message == null) {
  -                throw new MailboxException( "Message doesn't exist" );
  -            }
  -
  +        public void setFlags(Flags flags, boolean value, long uid, MailboxListener silentListener, boolean addUid) throws MailboxException {
  +            int msn = getMsn(uid);
  +            SimpleImapMessage message = (SimpleImapMessage) mailMessages.get(msn - 1);
  +            
               if (value) {
                   message.getFlags().add(flags);
               } else {
                   message.getFlags().remove(flags);
               }
   
  -            // TODO - this doesn't send silent updates to *any* listeners
  -            // I think "silence" is supposed to be restricted to the session sending the command?.
  -            if (! silent) {
  -                notifyFlagUpdate(uid, message.getFlags());
  +            Long uidNotification = null;
  +            if (addUid) {
  +                uidNotification = new Long(uid);
  +            }
  +            notifyFlagUpdate(msn, message.getFlags(), uidNotification, silentListener);
  +        }
  +        
  +        public void replaceFlags(Flags flags, long uid, MailboxListener silentListener, boolean addUid) throws MailboxException {
  +            int msn = getMsn(uid);
  +            SimpleImapMessage message = (SimpleImapMessage) mailMessages.get(msn - 1);
  +            message.getFlags().remove(MessageFlags.ALL_FLAGS);
  +            message.getFlags().add(flags);
  +
  +            Long uidNotification = null;
  +            if (addUid) {
  +                uidNotification = new Long(uid);
               }
  +            notifyFlagUpdate(msn, message.getFlags(), uidNotification, silentListener);
           }
   
  -        private void notifyFlagUpdate(long uid, Flags flags) throws MailboxException {
  +        private void notifyFlagUpdate(int msn, Flags flags, Long uidNotification, MailboxListener silentListener) {
               synchronized(_mailboxListeners) {
                   for (int i = 0; i < _mailboxListeners.size(); i++) {
                       MailboxListener listener = (MailboxListener) _mailboxListeners.get(i);
  +                    
  +                    if (listener == silentListener) {
  +                        continue;
  +                    }
   
  -                    listener.flagsUpdated(uid, flags);
  +                    listener.flagsUpdated(msn, flags, uidNotification);
                   }
               }
           }
  -
  -        public void replaceFlags(Flags flags, long uid, boolean silent) throws MailboxException {
  -            SimpleImapMessage message = getMessage(uid);
  -            if (message == null) {
  -                throw new MailboxException( "Message doesn't exist" );
  -            }
  -            message.getFlags().remove(MessageFlags.ALL_FLAGS);
  -            message.getFlags().add(flags);
  -
  -            if (! silent) {
  -                notifyFlagUpdate(uid, message.getFlags());
  -            }
  -        }
  -
  +        
           public void deleteAllMessages() {
               mailMessages.clear();
           }
  @@ -460,7 +478,7 @@
               }
               return null;
           }
  -
  +        
           public long[] getMessageUids()
           {
               long[] uids = new long[ mailMessages.size() ];
  @@ -471,10 +489,9 @@
               return uids;
           }
   
  -        private void deleteMessage( long uid )
  +        private void deleteMessage( int msn )
           {
  -            SimpleImapMessage message = getMessage(uid);
  -            mailMessages.remove(message);
  +            mailMessages.remove(msn - 1);
           }
   
           public long[] search(SearchTerm searchTerm) {
  @@ -516,27 +533,24 @@
           }
   
           public void expunge() throws MailboxException {
  -
  -            long[] allUids = getMessageUids();
  -            for (int i = 0; i < allUids.length; i++) {
  -                long uid = allUids[i];
  -                SimpleImapMessage message = getMessage(uid);
  +            for (int i = 0; i < mailMessages.size(); i++) {
  +                SimpleImapMessage message = (SimpleImapMessage) mailMessages.get(i);
                   if (message.getFlags().contains(Flags.Flag.DELETED)) {
  -                    expungeMessage(uid);
  +                    expungeMessage(i + 1);
                   }
               }
           }
   
  -        private void expungeMessage(long uid) throws MailboxException {
  +        private void expungeMessage(int msn) {
               // Notify all the listeners of the pending delete
               synchronized (_mailboxListeners) {
                   for (int j = 0; j < _mailboxListeners.size(); j++) {
                       MailboxListener expungeListener = (MailboxListener) _mailboxListeners.get(j);
  -                    expungeListener.expunged(uid);
  +                    expungeListener.expunged(msn);
                   }
               }
   
  -            deleteMessage(uid);
  +            deleteMessage(msn);
           }
   
           public void addListener(MailboxListener listener) {
  
  
  
  1.3       +3 -3      james-server/proposals/imap2/java/org/apache/james/imapserver/store/MailboxListener.java
  
  Index: MailboxListener.java
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/java/org/apache/james/imapserver/store/MailboxListener.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MailboxListener.java	21 Jul 2003 23:31:06 -0000	1.2
  +++ MailboxListener.java	30 Nov 2003 07:03:48 -0000	1.3
  @@ -61,9 +61,9 @@
   
   public interface MailboxListener {
       // TODO shouldn't have exceptions here
  -    void expunged(long uid) throws MailboxException;
  +    void expunged(int msn);
       
  -    void added(long uid);
  +    void added(int msn);
   
  -    void flagsUpdated(long uid, Flags flags) throws MailboxException;
  +    void flagsUpdated(int msn, Flags flags, Long uid);
   }
  
  
  
  1.3       +8 -8      james-server/proposals/imap2/test/org/apache/james/imapserver/Delete.test
  
  Index: Delete.test
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/test/org/apache/james/imapserver/Delete.test,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Delete.test	3 Dec 2002 14:00:13 -0000	1.2
  +++ Delete.test	30 Nov 2003 07:03:48 -0000	1.3
  @@ -1,21 +1,21 @@
   # Create a few folders
  -C: 10 CREATE test
  +C: 10 CREATE deletetest
   S: 10 OK CREATE completed
  -C: 11 CREATE test.subfolder
  +C: 11 CREATE deletetest.subfolder
   S: 11 OK CREATE completed
  -C: 12 CREATE test1
  +C: 12 CREATE deletetest1
   S: 12 OK CREATE completed
  -C: 13 CREATE test1.subfolder1
  +C: 13 CREATE deletetest1.subfolder1
   S: 13 OK CREATE completed
   
   # Delete subfolder, then folder
  -C: 10 DELETE test.subfolder
  +C: 10 DELETE deletetest.subfolder
   S: 10 OK DELETE completed
  -C: 11 DELETE test
  +C: 11 DELETE deletetest
   S: 11 OK DELETE completed
   
   # Delete folder first, then subfolder.
  -C: 14 DELETE test1.subfolder1
  +C: 14 DELETE deletetest1.subfolder1
   S: 14 OK DELETE completed
  -C: 13 DELETE test1
  +C: 13 DELETE deletetest1
   S: 13 OK DELETE completed
  
  
  
  1.7       +4 -4      james-server/proposals/imap2/test/org/apache/james/imapserver/ImapMailboxTest.java
  
  Index: ImapMailboxTest.java
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/test/org/apache/james/imapserver/ImapMailboxTest.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ImapMailboxTest.java	21 Jul 2003 23:31:06 -0000	1.6
  +++ ImapMailboxTest.java	30 Nov 2003 07:03:48 -0000	1.7
  @@ -188,17 +188,17 @@
           assertEquals(2, mailbox.getUnseenCount());
   
           // Flag the first as seen
  -        mailbox.setFlags(new Flags(Flags.Flag.SEEN), true, uid1, true);
  +        mailbox.setFlags(new Flags(Flags.Flag.SEEN), true, uid1, null, false);
           assertEquals(2, mailbox.getFirstUnseen());
           assertEquals(1, mailbox.getUnseenCount());
   
           // Flag the second as seen
  -        mailbox.setFlags(new Flags(Flags.Flag.SEEN), true, uid2, true);
  +        mailbox.setFlags(new Flags(Flags.Flag.SEEN), true, uid2, null, false);
           assertEquals(-1, mailbox.getFirstUnseen());
           assertEquals(0, mailbox.getUnseenCount());
   
           // Unset the seen flag on the first
  -        mailbox.setFlags(new Flags(Flags.Flag.SEEN), false, uid1, true);
  +        mailbox.setFlags(new Flags(Flags.Flag.SEEN), false, uid1, null, false);
           assertEquals(1, mailbox.getFirstUnseen());
           assertEquals(1, mailbox.getUnseenCount());
       }
  
  
  
  1.3       +24 -24    james-server/proposals/imap2/test/org/apache/james/imapserver/ListMailboxes.test
  
  Index: ListMailboxes.test
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/test/org/apache/james/imapserver/ListMailboxes.test,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ListMailboxes.test	3 Dec 2002 14:00:13 -0000	1.2
  +++ ListMailboxes.test	30 Nov 2003 07:03:48 -0000	1.3
  @@ -1,23 +1,23 @@
   # Create a few folders
  -C: 10 CREATE test
  +C: 10 CREATE listtest
   S: 10 OK CREATE completed
  -C: 11 CREATE test.subfolder
  +C: 11 CREATE listtest.subfolder
   S: 11 OK CREATE completed
  -C: 12 CREATE test1
  +C: 12 CREATE listtest1
   S: 12 OK CREATE completed
  -C: 13 CREATE test1.subfolder1
  +C: 13 CREATE listtest1.subfolder1
   S: 13 OK CREATE completed
   
   # Empty 1st arg searches default context (#mail)
  -C: 10 LIST "" test
  -S: \* LIST \(\) \"\.\" test
  +C: 10 LIST "" listtest
  +S: \* LIST \(\) \"\.\" listtest
   S: 10 OK LIST completed
   
   # % returns all mailboxes matching
   C: a1 LIST "" %
   SUB {
  -S: \* LIST \(\) \"\.\" test
  -S: \* LIST \(\) \"\.\" test1
  +S: \* LIST \(\) \"\.\" listtest
  +S: \* LIST \(\) \"\.\" listtest1
   S: \* LIST \(\) \"\.\" INBOX
   }
   S: a1 OK LIST completed
  @@ -27,10 +27,10 @@
   C: a3 LIST "" I%
   S: \* LIST \(\) \"\.\" INBOX
   S: a3 OK LIST completed
  -C: a4 LIST "" t%
  +C: a4 LIST "" l%
   SUB {
  -S: \* LIST \(\) \"\.\" test
  -S: \* LIST \(\) \"\.\" test1
  +S: \* LIST \(\) \"\.\" listtest
  +S: \* LIST \(\) \"\.\" listtest1
   }
   S: a4 OK LIST completed
   
  @@ -38,10 +38,10 @@
   # * returns all folders and subfolders
   C: b1 LIST "" *
   SUB {
  -S: \* LIST \(\) \"\.\" test
  -S: \* LIST \(\) \"\.\" test1
  -S: \* LIST \(\) \"\.\" test.subfolder
  -S: \* LIST \(\) \"\.\" test1.subfolder1
  +S: \* LIST \(\) \"\.\" listtest
  +S: \* LIST \(\) \"\.\" listtest1
  +S: \* LIST \(\) \"\.\" listtest.subfolder
  +S: \* LIST \(\) \"\.\" listtest1.subfolder1
   S: \* LIST \(\) \"\.\" INBOX
   }
   S: b1 OK LIST completed
  @@ -51,12 +51,12 @@
   C: b3 LIST "" I*
   S: \* LIST \(\) \"\.\" INBOX
   S: b3 OK LIST completed
  -C: b4 LIST "" t*
  +C: b4 LIST "" l*
   SUB {
  -S: \* LIST \(\) \"\.\" test
  -S: \* LIST \(\) \"\.\" test1
  -S: \* LIST \(\) \"\.\" test.subfolder
  -S: \* LIST \(\) \"\.\" test1.subfolder1
  +S: \* LIST \(\) \"\.\" listtest
  +S: \* LIST \(\) \"\.\" listtest1
  +S: \* LIST \(\) \"\.\" listtest.subfolder
  +S: \* LIST \(\) \"\.\" listtest1.subfolder1
   }
   S: b4 OK LIST completed
   
  @@ -67,11 +67,11 @@
   S: a1 OK LIST completed
   
   # Cleanup
  -C: a1 DELETE test1.subfolder1
  +C: a1 DELETE listtest1.subfolder1
   S: a1 OK DELETE completed
  -C: a1 DELETE test1
  +C: a1 DELETE listtest1
   S: a1 OK DELETE completed
  -C: a1 DELETE test.subfolder
  +C: a1 DELETE listtest.subfolder
   S: a1 OK DELETE completed
  -C: a1 DELETE test
  +C: a1 DELETE listtest
   S: a1 OK DELETE completed
  
  
  
  1.2       +3 -1      james-server/proposals/imap2/test/org/apache/james/imapserver/SelectAppend.test
  
  Index: SelectAppend.test
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/test/org/apache/james/imapserver/SelectAppend.test,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SelectAppend.test	13 Jul 2003 06:04:57 -0000	1.1
  +++ SelectAppend.test	30 Nov 2003 07:03:48 -0000	1.2
  @@ -4,7 +4,7 @@
   C: 10 SELECT selectappend
   S: \* FLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)
   S: \* 0 EXISTS
  -S: \* \d+ RECENT
  +S: \* 0 RECENT
   S: \* OK \[UIDVALIDITY \d+\]
   S: \* OK No messages unseen
   S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
  @@ -24,6 +24,7 @@
   C: Hello Joe, could we change that to 4:00pm tomorrow?
   C:
   S: \* 1 EXISTS
  +S: \* 1 RECENT
   S: A003 OK APPEND completed
   
   C: A003 APPEND selectappend {310}
  @@ -40,6 +41,7 @@
   C: Hello Joe, could we change that to 4:00pm tomorrow?
   C:
   S: \* 2 EXISTS
  +S: \* 1 RECENT
   S: A003 OK APPEND completed
   
   C: a1 DELETE selectappend
  
  
  
  1.3       +1 -11     james-server/proposals/imap2/test/org/apache/james/imapserver/SelectInbox.test
  
  Index: SelectInbox.test
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/test/org/apache/james/imapserver/SelectInbox.test,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SelectInbox.test	13 Jul 2003 06:04:57 -0000	1.2
  +++ SelectInbox.test	30 Nov 2003 07:03:48 -0000	1.3
  @@ -3,16 +3,6 @@
   S: \* \d+ EXISTS
   S: \* \d+ RECENT
   S: \* OK \[UIDVALIDITY \d+\]
  -S: (\* OK \[UNSEEN \d+\] \d+ is the first unseen)|(\* OK No messages unseen)
  +S: (\* OK \[UNSEEN 1\] Message 1 is the first unseen)|(\* OK No messages unseen)
   S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
   S: abcd OK \[READ-WRITE\] SELECT completed
  -
  -# Try again to ensure that no changes to flags were made.
  -C: abcd SELECT "INBOX"
  -S: \* FLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)
  -S: \* \d+ EXISTS
  -S: \* \d+ RECENT
  -S: \* OK \[UIDVALIDITY \d+\]
  -S: (\* OK \[UNSEEN \d+\] \d+ is the first unseen)|(\* OK No messages unseen)
  -S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
  -S: abcd OK \[READ-WRITE\] SELECT completed
  \ No newline at end of file
  
  
  
  1.3       +2 -10     james-server/proposals/imap2/test/org/apache/james/imapserver/SelectedStateCleanup.test
  
  Index: SelectedStateCleanup.test
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/test/org/apache/james/imapserver/SelectedStateCleanup.test,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SelectedStateCleanup.test	13 Jul 2003 06:04:57 -0000	1.2
  +++ SelectedStateCleanup.test	30 Nov 2003 07:03:48 -0000	1.3
  @@ -1,14 +1,6 @@
  -C: abcd SELECT inbox
  -S: \* FLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)
  -S: \* \d+ EXISTS
  -S: \* \d+ RECENT
  -S: \* OK \[UIDVALIDITY \d+\]
  -S: (\* OK \[UNSEEN \d+\] \d+ is the first unseen)|(\* OK No messages unseen)
  -S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
  -S: abcd OK \[READ-WRITE\] SELECT completed
  -
  +# try to delete the select mailbox (don't worry about failures
   C: a1 DELETE selected
  -S: a1 OK DELETE completed
  +S: .*
   
   C: a1 SELECT selected
   S: a1 NO SELECT failed. No such mailbox.
  
  
  
  1.3       +1 -1      james-server/proposals/imap2/test/org/apache/james/imapserver/SelectedStateSetup.test
  
  Index: SelectedStateSetup.test
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/test/org/apache/james/imapserver/SelectedStateSetup.test,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SelectedStateSetup.test	13 Jul 2003 06:04:57 -0000	1.2
  +++ SelectedStateSetup.test	30 Nov 2003 07:03:48 -0000	1.3
  @@ -56,7 +56,7 @@
   C: a1 SELECT selected
   S: \* FLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)
   S: \* 4 EXISTS
  -S: \* 0 RECENT
  +S: \* 4 RECENT
   S: \* OK \[UIDVALIDITY \d+\]
   S: \* OK \[UNSEEN 1\] Message 1 is the first unseen
   S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
  
  
  
  1.3       +32 -10    james-server/proposals/imap2/test/org/apache/james/imapserver/Status.test
  
  Index: Status.test
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/test/org/apache/james/imapserver/Status.test,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Status.test	3 Dec 2002 14:00:13 -0000	1.2
  +++ Status.test	30 Nov 2003 07:03:48 -0000	1.3
  @@ -1,23 +1,45 @@
  -C: a1 CREATE test
  +C: a1 CREATE statustest
   S: a1 OK CREATE completed
   
   # Tests for the STATUS command
  -C: a001 STATUS test (MESSAGES)
  -S: \* STATUS test \(MESSAGES \d+\)
  +C: a001 STATUS statustest (MESSAGES)
  +S: \* STATUS statustest \(MESSAGES 0\)
   S: a001 OK STATUS completed
   
  -C: a001 STATUS test (  MESSAGES  )
  -S: \* STATUS test \(MESSAGES \d+\)
  +C: a001 STATUS statustest (  MESSAGES  )
  +S: \* STATUS statustest \(MESSAGES 0\)
   S: a001 OK STATUS completed
   
  -C: a001 STATUS test (MESSAGES RECENT UIDNEXT UIDVALIDITY UNSEEN)
  -S: \* STATUS test \(MESSAGES \d+ RECENT \d+ UIDNEXT \d+ UIDVALIDITY \d+ UNSEEN \d+\)
  +C: a001 STATUS statustest (MESSAGES RECENT UIDNEXT UIDVALIDITY UNSEEN)
  +S: \* STATUS statustest \(MESSAGES 0 RECENT 0 UIDNEXT \d+ UIDVALIDITY \d+ UNSEEN 0\)
   S: a001 OK STATUS completed
   
  -C: a001 STATUS test (UNSEEN RECENT )
  -S: \* STATUS test \(RECENT \d+ UNSEEN \d+\)
  +C: a001 STATUS statustest (UNSEEN RECENT )
  +S: \* STATUS statustest \(RECENT 0 UNSEEN 0\)
  +S: a001 OK STATUS completed
  +
  +C: A003 APPEND statustest {254+}
  +C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
  +C: From: Fred Foobar <fo...@Blurdybloop.COM>
  +C: Subject: Test 01
  +C: To: mooch@owatagu.siam.edu
  +C: Message-Id: <B2...@Blurdybloop.COM>
  +C: MIME-Version: 1.0
  +C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
  +C:
  +C: Test 01
  +C:
  +S: A003 OK APPEND completed
  +
  +C: a001 STATUS statustest (UNSEEN RECENT )
  +S: \* STATUS statustest \(RECENT 1 UNSEEN 1\)
  +S: a001 OK STATUS completed
  +
  +# Make sure that the recent flag isn't unset
  +C: a001 STATUS statustest (UNSEEN RECENT )
  +S: \* STATUS statustest \(RECENT 1 UNSEEN 1\)
   S: a001 OK STATUS completed
   
   # Cleanup
  -C: a1 DELETE test
  +C: a1 DELETE statustest
   S: a1 OK DELETE completed
  
  
  
  1.4       +25 -25    james-server/proposals/imap2/test/org/apache/james/imapserver/Subscribe.test
  
  Index: Subscribe.test
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/test/org/apache/james/imapserver/Subscribe.test,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Subscribe.test	3 Dec 2002 14:00:13 -0000	1.3
  +++ Subscribe.test	30 Nov 2003 07:03:48 -0000	1.4
  @@ -1,73 +1,73 @@
   # Create a few folders
  -C: 10 CREATE test
  +C: 10 CREATE subscribetest
   S: 10 OK CREATE completed
  -C: 11 CREATE test.subfolder
  +C: 11 CREATE subscribetest.subfolder
   S: 11 OK CREATE completed
  -C: 12 CREATE test1
  +C: 12 CREATE subscribetest1
   S: 12 OK CREATE completed
  -C: 13 CREATE test1.subfolder1
  +C: 13 CREATE subscribetest1.subfolder1
   S: 13 OK CREATE completed
   
   C: a01 LSUB "" "*"
   S: a01 OK LSUB completed
   
  -C: a01 SUBSCRIBE test
  +C: a01 SUBSCRIBE subscribetest
   S: a01 OK SUBSCRIBE completed
   
   C: a01 LSUB "" "*"
  -S: \* LSUB \(\) \"\.\" test
  +S: \* LSUB \(\) \"\.\" subscribetest
   S: a01 OK LSUB completed
   
  -C: a01 SUBSCRIBE test.subfolder
  +C: a01 SUBSCRIBE subscribetest.subfolder
   S: a01 OK SUBSCRIBE completed
   
  -C: a01 SUBSCRIBE test1.subfolder1
  +C: a01 SUBSCRIBE subscribetest1.subfolder1
   S: a01 OK SUBSCRIBE completed
   
   # LIST All subscribed
   C: a01 LSUB "" "*"
   SUB {
  -S: \* LSUB \(\) \"\.\" test
  -S: \* LSUB \(\) \"\.\" test\.subfolder
  -S: \* LSUB \(\) \"\.\" test1\.subfolder1
  +S: \* LSUB \(\) \"\.\" subscribetest
  +S: \* LSUB \(\) \"\.\" subscribetest\.subfolder
  +S: \* LSUB \(\) \"\.\" subscribetest1\.subfolder1
   }
   S: a01 OK LSUB completed
   
   # LIST A subset of subscribed
  -C: a01 LSUB "test" "sub*"
  -S: \* LSUB \(\) \"\.\" test\.subfolder
  +C: a01 LSUB "subscribetest" "sub*"
  +S: \* LSUB \(\) \"\.\" subscribetest\.subfolder
   S: a01 OK LSUB completed
   
  -# Unsubscribe from a parent mailbox, make sure that test.subfolder is still subscribed.
  -C: a01 UNSUBSCRIBE test
  +# Unsubscribe from a parent mailbox, make sure that subscribetest.subfolder is still subscribed.
  +C: a01 UNSUBSCRIBE subscribetest
   S: a01 OK UNSUBSCRIBE completed
   
  -C: a01 LSUB "test" "sub*"
  -S: \* LSUB \(\) \"\.\" test\.subfolder
  +C: a01 LSUB "subscribetest" "sub*"
  +S: \* LSUB \(\) \"\.\" subscribetest\.subfolder
   S: a01 OK LSUB completed
   
   
   # Attempt to unsubscribe from a mailbox that isn't subscribed
  -C: a01 UNSUBSCRIBE test1
  +C: a01 UNSUBSCRIBE subscribetest1
   S: a01 OK UNSUBSCRIBE completed
   
  -C: a01 UNSUBSCRIBE test.subfolder
  +C: a01 UNSUBSCRIBE subscribetest.subfolder
   S: a01 OK UNSUBSCRIBE completed
   
   # LIST All subscribed
   C: a01 LSUB "" "*"
  -S: \* LSUB \(\) \"\.\" test1\.subfolder1
  +S: \* LSUB \(\) \"\.\" subscribetest1\.subfolder1
   S: a01 OK LSUB completed
   
   # Cleanup
  -C: a01 UNSUBSCRIBE test1.subfolder1
  +C: a01 UNSUBSCRIBE subscribetest1.subfolder1
   S: a01 OK UNSUBSCRIBE completed
   
  -C: a1 DELETE test1.subfolder1
  +C: a1 DELETE subscribetest1.subfolder1
   S: a1 OK DELETE completed
  -C: a1 DELETE test1
  +C: a1 DELETE subscribetest1
   S: a1 OK DELETE completed
  -C: a1 DELETE test.subfolder
  +C: a1 DELETE subscribetest.subfolder
   S: a1 OK DELETE completed
  -C: a1 DELETE test
  +C: a1 DELETE subscribetest
   S: a1 OK DELETE completed
  
  
  
  1.4       +2 -3      james-server/proposals/imap2/test/org/apache/james/imapserver/TestCommandsInAuthenticatedState.java
  
  Index: TestCommandsInAuthenticatedState.java
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/test/org/apache/james/imapserver/TestCommandsInAuthenticatedState.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestCommandsInAuthenticatedState.java	8 Mar 2003 21:13:57 -0000	1.3
  +++ TestCommandsInAuthenticatedState.java	30 Nov 2003 07:03:48 -0000	1.4
  @@ -109,8 +109,8 @@
           suite.addTest( new TestCommandsInAuthenticatedState( "Logout" ) );
   
           // Valid in authenticated state
  -        suite.addTest( new TestCommandsInAuthenticatedState( "ExamineInbox" ) );
  -        suite.addTest( new TestCommandsInAuthenticatedState( "SelectInbox" ) );
  +        suite.addTest( new TestCommandsInAuthenticatedState( "AppendExamineInbox" ) );
  +        suite.addTest( new TestCommandsInAuthenticatedState( "AppendSelectInbox" ) );
           suite.addTest( new TestCommandsInAuthenticatedState( "Create" ) );
           suite.addTest( new TestCommandsInAuthenticatedState( "ExamineEmpty" ) );
           suite.addTest( new TestCommandsInAuthenticatedState( "SelectEmpty" ) );
  @@ -123,5 +123,4 @@
   
           return suite;
       }
  -
   }
  
  
  
  1.2       +2 -1      james-server/proposals/imap2/test/org/apache/james/imapserver/TestConcurrentSessions.java
  
  Index: TestConcurrentSessions.java
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/test/org/apache/james/imapserver/TestConcurrentSessions.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestConcurrentSessions.java	26 Nov 2003 14:18:38 -0000	1.1
  +++ TestConcurrentSessions.java	30 Nov 2003 07:03:48 -0000	1.2
  @@ -31,6 +31,7 @@
           // Not valid in this state
           suite.addTest( new TestConcurrentSessions( "concurrent/FetchResponse" ) );
           suite.addTest( new TestConcurrentSessions( "concurrent/ExistsResponse" ) );
  +        suite.addTest( new TestConcurrentSessions( "concurrent/ExpungeResponse" ) );
   
           return suite;
       }
  
  
  
  1.4       +7 -1      james-server/proposals/imap2/test/org/apache/james/imapserver/TestOtherCommandsInSelectedState.java
  
  Index: TestOtherCommandsInSelectedState.java
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/test/org/apache/james/imapserver/TestOtherCommandsInSelectedState.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestOtherCommandsInSelectedState.java	8 Mar 2003 21:13:57 -0000	1.3
  +++ TestOtherCommandsInSelectedState.java	30 Nov 2003 07:03:48 -0000	1.4
  @@ -89,6 +89,12 @@
           addTestFile( "SelectInbox.test", preElements );
       }
   
  +    protected void addCloseInbox()
  +    {
  +        postElements.CL( "a CLOSE");
  +        postElements.SL( ".*", "TestOtherCommandsInSelectedState.java:96");
  +    }
  +    
       /**
        * Provides all tests which should be run in the selected state. Each test name
        * corresponds to a protocol session file.
  
  
  
  1.3       +21 -16    james-server/proposals/imap2/test/org/apache/james/imapserver/Uid.test
  
  Index: Uid.test
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/test/org/apache/james/imapserver/Uid.test,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Uid.test	13 Jul 2003 06:04:57 -0000	1.2
  +++ Uid.test	30 Nov 2003 07:03:48 -0000	1.3
  @@ -1,30 +1,35 @@
  +#Delete the first message, so that UIDs don't match MSNs
  +C: a STORE 1 +FLAGS (\Deleted)
  +S: \* 1 FETCH \(FLAGS \(\\Deleted\)
  +S: a OK STORE completed
  +C: a EXPUNGE
  +S: \* 1 EXPUNGE
  +S: a OK EXPUNGE completed
  +
   #Regular fetch
  -C: a FETCH 1:10 (UID)
  -S: \* 1 FETCH \(UID 1\)
  -S: \* 2 FETCH \(UID 2\)
  -S: \* 3 FETCH \(UID 3\)
  -S: \* 4 FETCH \(UID 4\)
  +C: a FETCH 1:3 (UID)
  +S: \* 1 FETCH \(UID 2\)
  +S: \* 2 FETCH \(UID 3\)
  +S: \* 3 FETCH \(UID 4\)
   S: a OK FETCH completed
   
   #UID fetch
  -C: a UID FETCH 1:3 (UID)
  -S: \* 1 FETCH \(UID 1\)
  -S: \* 2 FETCH \(UID 2\)
  -S: \* 3 FETCH \(UID 3\)
  +C: a UID FETCH 1:3 (INTERNALDATE)
  +S: \* 1 FETCH \(INTERNALDATE "[^"]*" UID 2\)
  +S: \* 2 FETCH \(INTERNALDATE ".*" UID 3\)
   S: a OK FETCH completed
   
   #UID store
   C: a UID STORE 2:3 +FLAGS (\Deleted)
  -S: \* 2 FETCH \(FLAGS \(\\Deleted\)\)
  -S: \* 3 FETCH \(FLAGS \(\\Deleted\)\)
  +S: \* 1 FETCH \(FLAGS \(\\Deleted\) UID 2\)
  +S: \* 2 FETCH \(FLAGS \(\\Deleted\) UID 3\)
   S: a OK STORE completed
   
   # Regular fetch
   C: a FETCH 1:100 (FLAGS UID)
  -S: \* 1 FETCH \(FLAGS \(\) UID 1\)
  -S: \* 2 FETCH \(FLAGS \(\\Deleted\) UID 2\)
  -S: \* 3 FETCH \(FLAGS \(\\Deleted\) UID 3\)
  -S: \* 4 FETCH \(FLAGS \(\) UID 4\)
  +S: \* 1 FETCH \(FLAGS \(\\Deleted\) UID 2\)
  +S: \* 2 FETCH \(FLAGS \(\\Deleted\) UID 3\)
  +S: \* 3 FETCH \(FLAGS \(\) UID 4\)
   S: a OK FETCH completed
   
   # CREATE and do a UID COPY
  @@ -40,7 +45,7 @@
   
   # Do a UID SEARCH
   C: a UID SEARCH FLAGGED
  -S: \* SEARCH 1 2 3 4
  +S: \* SEARCH 2 3 4
   S: a OK SEARCH completed
   
   # Cleanup
  
  
  
  1.1                  james-server/proposals/imap2/test/org/apache/james/imapserver/AppendExamineInbox.test
  
  Index: AppendExamineInbox.test
  ===================================================================
  # Create a couple of messages to retrieve
  C: A003 APPEND inbox {254+}
  C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
  C: From: Fred Foobar <fo...@Blurdybloop.COM>
  C: Subject: Test 01
  C: To: mooch@owatagu.siam.edu
  C: Message-Id: <B2...@Blurdybloop.COM>
  C: MIME-Version: 1.0
  C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
  C:
  C: Test 01
  C:
  S: A003 OK APPEND completed
  
  C: A003 APPEND inbox {254+}
  C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
  C: From: Fred Foobar <fo...@Blurdybloop.COM>
  C: Subject: Test 02
  C: To: mooch@owatagu.siam.edu
  C: Message-Id: <B2...@Blurdybloop.COM>
  C: MIME-Version: 1.0
  C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
  C:
  C: Test 02
  C:
  S: A003 OK APPEND completed
  
  C: abcd EXAMINE inbox
  S: \* FLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)
  S: \* 2 EXISTS
  S: \* 2 RECENT
  S: \* OK \[UIDVALIDITY \d+\]
  S: (\* OK \[UNSEEN 1\] Message 1 is the first unseen)|(\* OK No messages unseen)
  S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
  S: abcd OK \[READ-ONLY\] EXAMINE completed
  
  # Try again to ensure that no changes to flags were made.
  C: abcd EXAMINE inbox
  S: \* FLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)
  S: \* 2 EXISTS
  S: \* 2 RECENT
  S: \* OK \[UIDVALIDITY \d+\]
  S: (\* OK \[UNSEEN 1\] Message 1 is the first unseen)|(\* OK No messages unseen)
  S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
  S: abcd OK \[READ-ONLY\] EXAMINE completed
  
  # Rename the INBOX - this copies all of the messages out
  C: a RENAME INBOX tobedeleted
  S: a OK RENAME completed
  
  C: a DELETE tobedeleted
  S: OK DELETE completed
  
  
  1.1                  james-server/proposals/imap2/test/org/apache/james/imapserver/AppendSelectInbox.test
  
  Index: AppendSelectInbox.test
  ===================================================================
  # Create a couple of messages to retrieve
  C: A003 APPEND inbox {254+}
  C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
  C: From: Fred Foobar <fo...@Blurdybloop.COM>
  C: Subject: Test 01
  C: To: mooch@owatagu.siam.edu
  C: Message-Id: <B2...@Blurdybloop.COM>
  C: MIME-Version: 1.0
  C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
  C:
  C: Test 01
  C:
  S: A003 OK APPEND completed
  
  C: A003 APPEND inbox {254+}
  C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
  C: From: Fred Foobar <fo...@Blurdybloop.COM>
  C: Subject: Test 02
  C: To: mooch@owatagu.siam.edu
  C: Message-Id: <B2...@Blurdybloop.COM>
  C: MIME-Version: 1.0
  C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
  C:
  C: Test 02
  C:
  S: A003 OK APPEND completed
  
  C: abcd SELECT inbox
  S: \* FLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)
  S: \* 2 EXISTS
  S: \* 2 RECENT
  S: \* OK \[UIDVALIDITY \d+\]
  S: (\* OK \[UNSEEN 1\] Message 1 is the first unseen)|(\* OK No messages unseen)
  S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
  S: abcd OK \[READ-WRITE\] SELECT completed
  
  # Try again to ensure that no changes to flags were made.
  C: abcd SELECT "INBOX"
  S: \* FLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)
  S: \* 2 EXISTS
  S: \* 0 RECENT
  S: \* OK \[UIDVALIDITY \d+\]
  S: (\* OK \[UNSEEN 1\] Message 1 is the first unseen)|(\* OK No messages unseen)
  S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
  S: abcd OK \[READ-WRITE\] SELECT completed
  
  # Closing the inbox will cause the messages to be silently expunged
  C: abcd CLOSE
  S: abcd OK CLOSE completed
  
  
  1.1                  james-server/proposals/imap2/test/org/apache/james/imapserver/InboxAddMessages.test
  
  Index: InboxAddMessages.test
  ===================================================================
  C: A003 APPEND inbox {254+}
  C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
  C: From: Fred Foobar <fo...@Blurdybloop.COM>
  C: Subject: Test 01
  C: To: mooch@owatagu.siam.edu
  C: Message-Id: <B2...@Blurdybloop.COM>
  C: MIME-Version: 1.0
  C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
  C:
  C: Test 01
  C:
  S: A003 OK APPEND completed
  
  C: A003 APPEND inbox {254+}
  C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
  C: From: Fred Foobar <fo...@Blurdybloop.COM>
  C: Subject: Test 02
  C: To: mooch@owatagu.siam.edu
  C: Message-Id: <B2...@Blurdybloop.COM>
  C: MIME-Version: 1.0
  C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
  C:
  C: Test 02
  C:
  S: A003 OK APPEND completed
  
  
  
  1.1                  james-server/proposals/imap2/test/org/apache/james/imapserver/InboxDeleteMessages.test
  
  Index: InboxDeleteMessages.test
  ===================================================================
  # Rename the INBOX - this copied all of the messages out
  C: a RENAME INBOX tobedeleted
  S: a OK RENAME completed
  
  C: a DELETE tobedeleted
  S: OK DELETE completed
  
  
  1.1                  james-server/proposals/imap2/test/org/apache/james/imapserver/Rename.test
  
  Index: Rename.test
  ===================================================================
  # TODO - this test
  
  
  1.2       +54 -11    james-server/proposals/imap2/test/org/apache/james/imapserver/concurrent/ExistsResponse.test
  
  Index: ExistsResponse.test
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/test/org/apache/james/imapserver/concurrent/ExistsResponse.test,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ExistsResponse.test	26 Nov 2003 14:18:38 -0000	1.1
  +++ ExistsResponse.test	30 Nov 2003 07:03:49 -0000	1.2
  @@ -1,12 +1,5 @@
   # Tests that appending a message from one session triggers an EXISTS response
   # in a concurrent session on the same mailbox
  -
  -# TODO: 
  -# a) Check sending of EXISTS response when using other selected state commands.
  -#            eg FETCH, STORE, COPY...
  -# b) Check sending of EXISTS response when using other non-selected state commands 
  -#            eg CREATE, APPEND...
  -# c) Get RECENT working
   SESSION: 1
   C: 1a CREATE existsresponse
   S: 1a OK CREATE completed.
  @@ -25,8 +18,28 @@
   S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
   S: 2a OK \[READ-WRITE\] SELECT completed
   
  +SESSION: 3
  +C: 3a SELECT existsresponse
  +S: \* FLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)
  +S: \* 0 EXISTS
  +S: \* 0 RECENT
  +S: \* OK \[UIDVALIDITY \d+\]
  +S: \* OK No messages unseen
  +S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
  +S: 3a OK \[READ-WRITE\] SELECT completed
  +
  +SESSION: 4
  +C: 4a SELECT existsresponse
  +S: \* FLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)
  +S: \* 0 EXISTS
  +S: \* 0 RECENT
  +S: \* OK \[UIDVALIDITY \d+\]
  +S: \* OK No messages unseen
  +S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
  +S: 4a OK \[READ-WRITE\] SELECT completed
  +
   SESSION: 1
  -C: 1c APPEND existsresponse (\Deleted) {310+}
  +C: 1c APPEND existsresponse {310+}
   C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
   C: From: Fred Foobar <fo...@Blurdybloop.COM>
   C: Subject: afternoon meeting
  @@ -39,11 +52,41 @@
   C:
   S: 1c OK APPEND completed
   
  +C: 1b STATUS existsresponse (MESSAGES RECENT)
  +S: \* STATUS existsresponse \(MESSAGES 1 RECENT 1\)
  +S: 1b OK STATUS completed
  +
  +# EXISTS response on NOOP
   SESSION: 2
   C: 2b NOOP
   S: \* 1 EXISTS
  -#S: \* 1 RECENT
  +S: \* 1 RECENT
   S: 2b OK NOOP completed
   
  -C: 2c DELETE existsresponse
  -S: 2c OK DELETE completed
  +C: 2c CLOSE
  +S: 2c OK CLOSE completed
  +
  +# EXISTS response on STORE
  +SESSION: 3
  +C: 3b STORE 1 +FLAGS.SILENT (\Flagged)
  +S: \* 1 EXISTS
  +S: \* 0 RECENT
  +S: 3b OK STORE completed
  +
  +C: 3c CLOSE
  +S: 3c OK CLOSE completed
  +
  +# EXISTS response on CREATE
  +SESSION: 4
  +C: 4b CREATE another
  +S: \* 1 EXISTS
  +S: \* 0 RECENT
  +S: \* 1 FETCH \(FLAGS \(\\Flagged\)
  +S: 4b OK CREATE completed
  +
  +C: 4c DELETE another
  +S: 4c OK DELETE completed
  +
  +C: 4c DELETE existsresponse
  +S: 4c OK DELETE completed
  +
  
  
  
  1.2       +83 -10    james-server/proposals/imap2/test/org/apache/james/imapserver/concurrent/FetchResponse.test
  
  Index: FetchResponse.test
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/test/org/apache/james/imapserver/concurrent/FetchResponse.test,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FetchResponse.test	26 Nov 2003 14:18:38 -0000	1.1
  +++ FetchResponse.test	30 Nov 2003 07:03:49 -0000	1.2
  @@ -3,6 +3,7 @@
   
   # TODO: Check sending of fetch responses when using other selected state commands.
   #            eg FETCH, STORE, COPY...
  +# TODO: make sure SILENT is only effective on calling mailbox (not other listeners)
   SESSION: 1
   C: 1a CREATE multibox
   S: 1a OK CREATE completed.
  @@ -11,7 +12,7 @@
   S: \* STATUS multibox \(MESSAGES 0\)
   S: 1b OK STATUS completed
   
  -C: 1c APPEND multibox (\Deleted) {310+}
  +C: 1c APPEND multibox {310+}
   C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
   C: From: Fred Foobar <fo...@Blurdybloop.COM>
   C: Subject: afternoon meeting
  @@ -24,10 +25,23 @@
   C:
   S: 1c OK APPEND completed
   
  +C: 1c APPEND multibox {312+}
  +C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
  +C: From: Fred Foobar <fo...@Blurdybloop.COM>
  +C: Subject: afternoon meeting 2
  +C: To: mooch@owatagu.siam.edu
  +C: Message-Id: <B2...@Blurdybloop.COM>
  +C: MIME-Version: 1.0
  +C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
  +C:
  +C: Hello Joe, do you think we can meet at 3:30 tomorrow?
  +C:
  +S: 1c OK APPEND completed
  +
   C: 1d SELECT multibox
   S: \* FLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)
  -S: \* 1 EXISTS
  -S: \* \d+ RECENT
  +S: \* 2 EXISTS
  +S: \* 2 RECENT
   S: \* OK \[UIDVALIDITY \d+\]
   S: \* OK \[UNSEEN 1\] Message 1 is the first unseen
   S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
  @@ -36,30 +50,89 @@
   SESSION: 2
   C: 2a SELECT multibox
   S: \* FLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)
  -S: \* 1 EXISTS
  -S: \* \d+ RECENT
  +S: \* 2 EXISTS
  +S: \* 0 RECENT
   S: \* OK \[UIDVALIDITY \d+\]
   S: \* OK \[UNSEEN 1\] Message 1 is the first unseen
   S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
   S: 2a OK \[READ-WRITE\] SELECT completed
   
  +SESSION: 3
  +C: 3a SELECT multibox
  +S: \* FLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)
  +S: \* 2 EXISTS
  +S: \* 0 RECENT
  +S: \* OK \[UIDVALIDITY \d+\]
  +S: \* OK \[UNSEEN 1\] Message 1 is the first unseen
  +S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
  +S: 3a OK \[READ-WRITE\] SELECT completed
  +
  +SESSION: 4
  +C: 4a SELECT multibox
  +S: \* FLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)
  +S: \* 2 EXISTS
  +S: \* 0 RECENT
  +S: \* OK \[UIDVALIDITY \d+\]
  +S: \* OK \[UNSEEN 1\] Message 1 is the first unseen
  +S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
  +S: 4a OK \[READ-WRITE\] SELECT completed
  +
   SESSION: 1
  -C: 1e STORE 1 FLAGS (\Deleted)
  -S: \* 1 FETCH \(FLAGS \(\\Deleted\)\)
  +C: 1e STORE 1 FLAGS (\Flagged)
  +S: \* 1 FETCH \(FLAGS \(\\Flagged\)\)
   S: 1e OK STORE completed
   
   # On NOOP, we get the Fetch Response from the Session1 update.
   SESSION: 2
   C: 2b NOOP
  -S: \* 1 FETCH \(FLAGS \(\\Deleted\)\)
  +S: \* 1 FETCH \(FLAGS \(\\Flagged\)\)
   S: 2b OK NOOP completed
   
  -C: 2c CLOSE
  -S: 2c OK CLOSE completed
  +# On STORE, we get the Fetch Response from the Session1 update.
  +SESSION: 3
  +C: 3b COPY 2 inbox
  +S: \* 1 FETCH \(FLAGS \(\\Flagged\)\)
  +S: 3b OK COPY completed
  +
  +# Update another flag, this time SILENT 
  +# Still get notifications on *other* sessions, but not this one.
  +SESSION: 1
  +C: 1e STORE 2 FLAGS.SILENT (\Flagged)
  +S: 1e OK STORE completed
  +
  +# We should only get one flag notification on SESSION 2,
  +# but 2 notifications on SESSION 4.
  +SESSION: 2
  +C: 2b NOOP
  +S: \* 2 FETCH \(FLAGS \(\\Flagged\)\)
  +S: 2b OK NOOP completed
  +
  +# On CREATE, we get the Fetch Response from both of the Session1 updates.
  +SESSION: 4
  +C: 4b CREATE another
  +S: \* 1 FETCH \(FLAGS \(\\Flagged\)\)
  +S: \* 2 FETCH \(FLAGS \(\\Flagged\)\)
  +S: 4b OK CREATE completed
  +
  +C: 4c DELETE another
  +S: 4c OK DELETE completed
   
   SESSION: 1
   C: 1f CLOSE
   S: 1f OK CLOSE completed
   
  +SESSION: 2
  +C: 2c CLOSE
  +S: 2c OK CLOSE completed
  +
  +SESSION: 3
  +C: 3c CLOSE
  +S: 3c OK CLOSE completed
  +
  +SESSION: 4
  +C: 4c CLOSE
  +S: 4c OK CLOSE completed
  +
  +SESSION: 1
   C: 1g DELETE multibox
   S: 1g OK DELETE completed
  
  
  
  1.1                  james-server/proposals/imap2/test/org/apache/james/imapserver/concurrent/ExpungeResponse.test
  
  Index: ExpungeResponse.test
  ===================================================================
  SESSION: 1
  C: 1a CREATE expungeresponse
  S: 1a OK CREATE completed
  
  C: 1b APPEND expungeresponse (\Deleted) {254+}
  C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
  C: From: Fred Foobar <fo...@Blurdybloop.COM>
  C: Subject: Test 01
  C: To: mooch@owatagu.siam.edu
  C: Message-Id: <B2...@Blurdybloop.COM>
  C: MIME-Version: 1.0
  C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
  C:
  C: Test 01
  C:
  S: 1b OK APPEND completed
  
  C: 1b APPEND expungeresponse {254+}
  C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
  C: From: Fred Foobar <fo...@Blurdybloop.COM>
  C: Subject: Test 02
  C: To: mooch@owatagu.siam.edu
  C: Message-Id: <B2...@Blurdybloop.COM>
  C: MIME-Version: 1.0
  C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
  C:
  C: Test 02
  C:
  S: 1b OK APPEND completed
  
  C: 1c APPEND expungeresponse (\Deleted) {254+}
  C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
  C: From: Fred Foobar <fo...@Blurdybloop.COM>
  C: Subject: Test 03
  C: To: mooch@owatagu.siam.edu
  C: Message-Id: <B2...@Blurdybloop.COM>
  C: MIME-Version: 1.0
  C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
  C:
  C: Test 03
  C:
  S: 1c OK APPEND completed
  
  C: 1d APPEND expungeresponse {254+}
  C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
  C: From: Fred Foobar <fo...@Blurdybloop.COM>
  C: Subject: Test 04
  C: To: mooch@owatagu.siam.edu
  C: Message-Id: <B2...@Blurdybloop.COM>
  C: MIME-Version: 1.0
  C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
  C:
  C: Test 04
  C:
  S: 1d OK APPEND completed
  
  C: 1e SELECT expungeresponse
  S: \* FLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)
  S: \* 4 EXISTS
  S: \* 4 RECENT
  S: \* OK \[UIDVALIDITY \d+\]
  S: \* OK \[UNSEEN 1\] Message 1 is the first unseen
  S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
  S: 1e OK \[READ-WRITE\] SELECT completed
  
  SESSION: 2
  C: 2a SELECT expungeresponse
  S: \* FLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)
  S: \* 4 EXISTS
  S: \* 0 RECENT
  S: \* OK \[UIDVALIDITY \d+\]
  S: \* OK \[UNSEEN 1\] Message 1 is the first unseen
  S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
  S: 2a OK \[READ-WRITE\] SELECT completed
  
  SESSION: 3
  C: 3a SELECT expungeresponse
  S: \* FLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)
  S: \* 4 EXISTS
  S: \* 0 RECENT
  S: \* OK \[UIDVALIDITY \d+\]
  S: \* OK \[UNSEEN 1\] Message 1 is the first unseen
  S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
  S: 3a OK \[READ-WRITE\] SELECT completed
  
  # Do an expunge with session 1
  SESSION: 1
  C: 1f EXPUNGE
  S: \* 1 EXPUNGE
  S: \* 2 EXPUNGE
  S: 1f OK EXPUNGE completed
  
  # Make sure session 2 gets expunge responses
  SESSION: 2
  C: 2b NOOP
  S: \* 1 EXPUNGE
  S: \* 2 EXPUNGE
  S: 2b OK NOOP completed
  
  # Now select with a new session - we have sessions 2,3 and 4 in different states
  SESSION: 4
  C: 4a SELECT expungeresponse
  S: \* FLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)
  S: \* 2 EXISTS
  S: \* 0 RECENT
  S: \* OK \[UIDVALIDITY \d+\]
  S: \* OK \[UNSEEN 1\] Message 1 is the first unseen
  S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
  S: 4a OK \[READ-WRITE\] SELECT completed
  
  SESSION: 1
  C: 1g STORE 1 FLAGS (\Deleted)
  S: \* 1 FETCH \(FLAGS \(\\Deleted\)\)
  S: 1g OK STORE completed
  C: 1h EXPUNGE
  S: \* 1 EXPUNGE
  S: 1h OK EXPUNGE completed
  
  SESSION: 2
  C: 2c NOOP
  S: \* 1 FETCH \(FLAGS \(\\Deleted\)\)
  S: \* 1 EXPUNGE
  S: 2c OK NOOP completed
  
  SESSION: 3
  C: 3b NOOP
  S: \* 1 FETCH \(FLAGS \(\\Deleted\)\)
  S: \* 1 EXPUNGE
  S: \* 2 EXPUNGE
  S: \* 1 EXPUNGE
  S: 3b OK NOOP completed
  
  SESSION: 4
  C: 4b NOOP
  S: \* 1 FETCH \(FLAGS \(\\Deleted\)\)
  S: \* 1 EXPUNGE
  S: 4b OK NOOP completed
  
  
  
  
  
  
  
  1.9       +47 -15    james-server/proposals/imap2/test/org/apache/james/test/AbstractProtocolTest.java
  
  Index: AbstractProtocolTest.java
  ===================================================================
  RCS file: /home/cvs/james-server/proposals/imap2/test/org/apache/james/test/AbstractProtocolTest.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- AbstractProtocolTest.java	26 Nov 2003 14:18:38 -0000	1.8
  +++ AbstractProtocolTest.java	30 Nov 2003 07:03:49 -0000	1.9
  @@ -117,9 +117,9 @@
       protected int timeout = TIMEOUT;
   
       /** A UsersRepository which all tests share. */
  -    private UsersRepository users;
  +    private static UsersRepository users;
       /** An ImapHost instance which all tests share. */
  -    private ImapHost imapHost;
  +    private static ImapHost imapHost;
   
       public AbstractProtocolTest( String s )
       {
  @@ -154,8 +154,7 @@
        * is parsed to determine if the actual response matches that expected.
        */
       private void runSocketProtocolSessions()
  -            throws Exception
  -    {
  +            throws Exception {
           Socket[] socket = new Socket[testElements.getSessionCount()];
           PrintWriter[] out = new PrintWriter[socket.length];
           BufferedReader[] in = new BufferedReader[socket.length];
  @@ -167,21 +166,34 @@
               in[i] = new BufferedReader(new InputStreamReader(socket[i].getInputStream()));
           }
   
  +        Exception failure = null;
           try {
  -             preElements.runLiveSession( out, in );
  -             testElements.runLiveSession( out, in );
  -             postElements.runLiveSession( out, in );
  -         }
  -         catch ( ProtocolSession.InvalidServerResponseException e ) {
  -             fail( e.getMessage() );
  -         }
  +            preElements.runLiveSession(out, in);
  +            testElements.runLiveSession(out, in);
  +        } catch (ProtocolSession.InvalidServerResponseException e) {
  +            failure = e;
  +        } finally {
  +            // Try our best to do cleanup.
  +            try {
  +                postElements.runLiveSession(out, in);
  +            } catch (ProtocolSession.InvalidServerResponseException e) {
  +                // Don't overwrite real error with error on cleanup.
  +                if (failure == null) {
  +                    failure = e;
  +                }
  +            }
  +        }
  +        
  +        if (failure != null) {
  +            fail(failure.getMessage());
  +        }
   
           for (int i = 0; i < socket.length; i++) {
               out[i].close();
               in[i].close();
               socket[i].close();
           }
  -     }
  +    }
   
       /**
        * Runs the pre,test and post protocol sessions against a local copy of the ImapServer.
  @@ -206,15 +218,35 @@
               socket[i].start();
           }
   
  +        Exception failure = null;
           try {
                preElements.runLiveSession( out, in );
                testElements.runLiveSession( out, in );
  -             postElements.runLiveSession( out, in );
  +        } catch (ProtocolSession.InvalidServerResponseException e) {
  +             failure = e;
  +             // Try our best to do cleanup.
  +               for (int i = 0; i < in.length; i++) {
  +                   BufferedReader reader = in[i];
  +                   while (reader.ready()) {
  +                       reader.read();
  +                   }
  +               }
  +         } finally {
  +             try {
  +                 postElements.runLiveSession(out, in);
  +             } catch (ProtocolSession.InvalidServerResponseException e) {
  +                 // Don't overwrite real error with error on cleanup.
  +                 if (failure == null) {
  +                     failure = e;
  +                 }
  +             }
            }
  -         catch ( ProtocolSession.InvalidServerResponseException e ) {
  -             fail( e.getMessage() );
  +        
  +         if (failure != null) {
  +             fail(failure.getMessage());
            }
   
  + 
           for (int i = 0; i < socket.length; i++) {
               out[i].close();
               in[i].close();
  
  
  

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