james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r1157073 [1/2] - in /james/imap/trunk: api/target/ message/src/main/java/org/apache/james/imap/encode/ message/src/main/java/org/apache/james/imap/encode/base/ message/src/test/java/org/apache/james/imap/encode/ message/src/test/java/org/ap...
Date Fri, 12 Aug 2011 12:35:06 GMT
Author: norman
Date: Fri Aug 12 12:35:05 2011
New Revision: 1157073

URL: http://svn.apache.org/viewvc?rev=1157073&view=rev
Log:
Remove response specific methods from ImapComposer. See IMAP-324

Added:
    james/imap/trunk/api/target/
    james/imap/trunk/target/
Removed:
    james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/AbstractTestImapResponseComposer.java
    james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/base/ImapResponseComposerImplTest.java
Modified:
    james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/CapabilityResponseEncoder.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/ExistsResponseEncoder.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/ExpungeResponseEncoder.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/FetchResponseEncoder.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/FlagsResponseEncoder.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/ImapResponseComposer.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/ListingEncodingUtils.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/MailboxStatusResponseEncoder.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/RecentResponseEncoder.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/SearchResponseEncoder.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/StatusResponseEncoder.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/base/ImapResponseComposerImpl.java
    james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/FetchResponseEncoderEnvelopeTest.java
    james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/FetchResponseEncoderNoExtensionsTest.java
    james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/FetchResponseEncoderTest.java
    james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/LSubResponseEncoderTest.java
    james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/ListResponseEncoderTest.java
    james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/ListingEncodingUtilsTest.java
    james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/MailboxStatusResponseEncoderTest.java
    james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/SearchResponseEncoderTest.java
    james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/base/ByteImapResponseWriter.java

Modified: james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/CapabilityResponseEncoder.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/CapabilityResponseEncoder.java?rev=1157073&r1=1157072&r2=1157073&view=diff
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/CapabilityResponseEncoder.java (original)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/CapabilityResponseEncoder.java Fri Aug 12 12:35:05 2011
@@ -19,8 +19,9 @@
 package org.apache.james.imap.encode;
 
 import java.io.IOException;
-import java.util.ArrayList;
+import java.util.Iterator;
 
+import org.apache.james.imap.api.ImapConstants;
 import org.apache.james.imap.api.ImapMessage;
 import org.apache.james.imap.api.process.ImapSession;
 import org.apache.james.imap.encode.base.AbstractChainedImapEncoder;
@@ -48,7 +49,13 @@ public class CapabilityResponseEncoder e
      */
     protected void doEncode(ImapMessage acceptableMessage, ImapResponseComposer composer, ImapSession session) throws IOException {
         final CapabilityResponse response = (CapabilityResponse) acceptableMessage;
-        composer.capabilities(new ArrayList<String>(response.getCapabilities()));
+        Iterator<String> capabilities = response.getCapabilities().iterator();
+        composer.untagged();
+        composer.message(ImapConstants.CAPABILITY_COMMAND_NAME);
+        while(capabilities.hasNext()) {
+        	composer.message(capabilities.next());
+        }
+        composer.end();        
     }
 
     /*

Modified: james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/ExistsResponseEncoder.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/ExistsResponseEncoder.java?rev=1157073&r1=1157072&r2=1157073&view=diff
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/ExistsResponseEncoder.java (original)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/ExistsResponseEncoder.java Fri Aug 12 12:35:05 2011
@@ -27,6 +27,8 @@ import org.apache.james.imap.encode.base
 import org.apache.james.imap.message.response.ExistsResponse;
 
 public class ExistsResponseEncoder extends AbstractChainedImapEncoder {
+   
+	public static final String EXISTS = "EXISTS";
 
     public ExistsResponseEncoder(ImapEncoder next) {
         super(next);
@@ -39,7 +41,8 @@ public class ExistsResponseEncoder exten
     protected void doEncode(ImapMessage acceptableMessage, ImapResponseComposer composer, ImapSession session) throws IOException {
         final ExistsResponse existsResponse = (ExistsResponse) acceptableMessage;
         final long numberOfMessages = existsResponse.getNumberOfMessages();
-        composer.existsResponse(numberOfMessages);
+        
+        composer.untagged().message(numberOfMessages).message(EXISTS).end();
 
     }
 }

Modified: james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/ExpungeResponseEncoder.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/ExpungeResponseEncoder.java?rev=1157073&r1=1157072&r2=1157073&view=diff
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/ExpungeResponseEncoder.java (original)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/ExpungeResponseEncoder.java Fri Aug 12 12:35:05 2011
@@ -27,6 +27,7 @@ import org.apache.james.imap.encode.base
 import org.apache.james.imap.message.response.ExpungeResponse;
 
 public class ExpungeResponseEncoder extends AbstractChainedImapEncoder {
+    public static final String EXPUNGE = "EXPUNGE";
 
     public ExpungeResponseEncoder(final ImapEncoder next) {
         super(next);
@@ -39,6 +40,6 @@ public class ExpungeResponseEncoder exte
     protected void doEncode(ImapMessage acceptableMessage, ImapResponseComposer composer, ImapSession session) throws IOException {
         final ExpungeResponse expungeResponse = (ExpungeResponse) acceptableMessage;
         final int messageSequenceNumber = expungeResponse.getMessageSequenceNumber();
-        composer.expungeResponse(messageSequenceNumber);
+        composer.untagged().message(messageSequenceNumber).message(EXPUNGE).end();
     }
 }

Modified: james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/FetchResponseEncoder.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/FetchResponseEncoder.java?rev=1157073&r1=1157072&r2=1157073&view=diff
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/FetchResponseEncoder.java (original)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/FetchResponseEncoder.java Fri Aug 12 12:35:05 2011
@@ -39,6 +39,7 @@ import org.apache.james.imap.message.res
 import org.slf4j.Logger;
 
 public class FetchResponseEncoder extends AbstractChainedImapEncoder {
+    public static final String ENVELOPE = "ENVELOPE";
 
     /** Disables all optional BODYSTRUCTURE extensions */
     private final boolean neverAddBodyStructureExtensions;
@@ -65,7 +66,10 @@ public class FetchResponseEncoder extend
         if (acceptableMessage instanceof FetchResponse) {
             final FetchResponse fetchResponse = (FetchResponse) acceptableMessage;
             final long messageNumber = fetchResponse.getMessageNumber();
-            composer.openFetchResponse(messageNumber);
+            
+        	composer.untagged().message(messageNumber).message(ImapConstants.FETCH_COMMAND_NAME).openParen();
+
+            
             encodeModSeq(composer, fetchResponse);
             encodeFlags(composer, fetchResponse);
             encodeInternalDate(composer, fetchResponse);
@@ -75,7 +79,8 @@ public class FetchResponseEncoder extend
             encodeBodyStructure(composer, fetchResponse.getBodyStructure(), session);
             encodeUid(composer, fetchResponse);
             encodeBodyElements(composer, fetchResponse.getElements());
-            composer.closeFetchResponse();
+            
+            composer.closeParen().end();
         }
     }
 
@@ -164,8 +169,10 @@ public class FetchResponseEncoder extend
         final String md5 = structure.getMD5();
         final List<String> languages = structure.getLanguages();
         final String location = structure.getLocation();
-        composer.nillableQuote(md5);
-        bodyFldDsp(structure, composer, session).nillableQuotes(languages).nillableQuote(location);
+        nillableQuote(composer, md5);
+        bodyFldDsp(structure, composer, session);
+        nillableQuotes(composer, languages);
+        nillableQuote(composer, location);
     }
 
     private ImapResponseComposer bodyFldDsp(final Structure structure, final ImapResponseComposer composer, ImapSession session) throws IOException {
@@ -213,7 +220,11 @@ public class FetchResponseEncoder extend
         final String description = structure.getDescription();
         final String encoding = structure.getEncoding();
         final long octets = structure.getOctets();
-        composer.openParen().quoteUpperCaseAscii(mediaType).quoteUpperCaseAscii(subType).nillableQuotes(bodyParams).nillableQuote(id).nillableQuote(description).quoteUpperCaseAscii(encoding).message(octets);
+        composer.openParen().quoteUpperCaseAscii(mediaType).quoteUpperCaseAscii(subType);
+        nillableQuotes(composer, bodyParams);
+        nillableQuote(composer, id);
+        nillableQuote(composer, description);
+        composer.quoteUpperCaseAscii(encoding).message(octets);
     }
 
     private void encodeMultipart(ImapResponseComposer composer, Structure structure, final String subType, final boolean includeExtensions, ImapSession session) throws IOException {
@@ -227,8 +238,10 @@ public class FetchResponseEncoder extend
         composer.quoteUpperCaseAscii(subType);
         if (includeExtensions) {
             final List<String> languages = structure.getLanguages();
-            composer.nillableQuotes(structure.getParameters());
-            bodyFldDsp(structure, composer, session).nillableQuotes(languages).nillableQuote(structure.getLocation());
+            nillableQuotes(composer, structure.getParameters());
+            bodyFldDsp(structure, composer, session);
+            nillableQuotes(composer, languages);
+            nillableQuote(composer, structure.getLocation());
         }
         composer.closeParen();
     }
@@ -311,14 +324,22 @@ public class FetchResponseEncoder extend
             final String inReplyTo = envelope.getInReplyTo();
             final String messageId = envelope.getMessageId();
 
-            composer.startEnvelope(date, subject, prefixWithName);
+            if (prefixWithName) {
+            	composer.message(ENVELOPE);
+            }
+            composer.openParen();
+            nillableQuote(composer, date);
+            nillableQuote(composer, subject);
             encodeAddresses(composer, from);
             encodeAddresses(composer, sender);
             encodeAddresses(composer, replyTo);
             encodeAddresses(composer, to);
             encodeAddresses(composer, cc);
             encodeAddresses(composer, bcc);
-            composer.endEnvelope(inReplyTo, messageId);
+            
+            nillableQuote(composer, inReplyTo);
+            nillableQuote(composer, messageId);
+            composer.closeParen();
         }
     }
 
@@ -326,13 +347,13 @@ public class FetchResponseEncoder extend
         if (addresses == null || addresses.length == 0) {
             composer.nil();
         } else {
-            composer.startAddresses();
+            composer.openParen();
             final int length = addresses.length;
             for (int i = 0; i < length; i++) {
                 final FetchResponse.Envelope.Address address = addresses[i];
                 encodeAddress(composer, address);
             }
-            composer.endAddresses();
+            composer.closeParen();
         }
     }
 
@@ -341,6 +362,36 @@ public class FetchResponseEncoder extend
         final String domainList = address.getAtDomainList();
         final String mailbox = address.getMailboxName();
         final String host = address.getHostName();
-        composer.address(name, domainList, mailbox, host);
+        composer.skipNextSpace().openParen();
+        nillableQuote(composer, name);
+        nillableQuote(composer, domainList);
+        nillableQuote(composer, mailbox);
+        nillableQuote(composer,host).closeParen();
+    }
+    
+
+
+    private ImapResponseComposer nillableQuote(ImapResponseComposer composer, String message) throws IOException {
+        if (message == null) {
+        	composer.nil();
+        } else {
+        	composer.quote(message);
+        }
+        return composer;
     }
+
+
+    private ImapResponseComposer nillableQuotes(ImapResponseComposer composer, List<String> quotes) throws IOException {
+        if (quotes == null || quotes.size() == 0) {
+        	composer.nil();
+        } else {
+        	composer.openParen();
+            for (final String string : quotes) {
+            	nillableQuote(composer,string);
+            }
+            composer.closeParen();
+        }
+        return composer;
+    }
+
 }

Modified: james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/FlagsResponseEncoder.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/FlagsResponseEncoder.java?rev=1157073&r1=1157072&r2=1157073&view=diff
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/FlagsResponseEncoder.java (original)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/FlagsResponseEncoder.java Fri Aug 12 12:35:05 2011
@@ -41,6 +41,6 @@ public class FlagsResponseEncoder extend
     protected void doEncode(ImapMessage acceptableMessage, ImapResponseComposer composer, ImapSession session) throws IOException {
         final FlagsResponse flagsResponse = (FlagsResponse) acceptableMessage;
         final Flags flags = flagsResponse.getFlags();
-        composer.flagsResponse(flags);
+        composer.untagged().flags(flags).end();
     }
 }

Modified: james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/ImapResponseComposer.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/ImapResponseComposer.java?rev=1157073&r1=1157072&r2=1157073&view=diff
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/ImapResponseComposer.java (original)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/ImapResponseComposer.java Fri Aug 12 12:35:05 2011
@@ -20,8 +20,6 @@
 package org.apache.james.imap.encode;
 
 import java.io.IOException;
-import java.util.Collection;
-import java.util.List;
 
 import javax.mail.Flags;
 
@@ -50,239 +48,138 @@ public interface ImapResponseComposer {
      */
     public ImapResponseComposer flags(Flags flags) throws IOException;
 
-    /**
-     * Compose a complete FLAGS response.
-     * 
-     * @param flags
-     *            <code>Flags</code>, not null
-     */
-    public ImapResponseComposer flagsResponse(Flags flags) throws IOException;
 
     /**
-     * Compose a complete EXISTS response
-     * 
-     * @param count the message count that exists
-     * @return self
-     * @throws IOException
-     */
-    public ImapResponseComposer existsResponse(long count) throws IOException;
-
-    /**
-     * Compose a RECENT response
+     * Composes a <code>NIL</code>.
      * 
-     * @param count the message count which is marked as recent
-     * @return self
      * @throws IOException
      */
-    public ImapResponseComposer recentResponse(long count) throws IOException;
+    public ImapResponseComposer nil() throws IOException;
 
     /**
-     * Compose a EXPUNGE response
+     * Compose a response which contains the {@link ImapCommand} to which the response belongs
      * 
-     * @param msn the MSN which where expunged
+     * @param command
+     * @param message
      * @return self
      * @throws IOException
      */
-    public ImapResponseComposer expungeResponse(long msn) throws IOException;
+    public ImapResponseComposer commandResponse(ImapCommand command, String message) throws IOException;
 
+  
     /**
-     * Compose a SEARCH response
+     * Writes the message provided to the client, prepended with the request
+     * tag.
      * 
-     * @param ids the MSN or UID which were found
-     * @return  self
-     * @throws IOException
-     * @{@link Deprecated} use {@link #searchResponse(long[], Long)}
+     * @param message
+     *            The message to write to the client.
      */
-    @Deprecated
-    public ImapResponseComposer searchResponse(long[] ids) throws IOException;
-
+    public ImapResponseComposer taggedResponse(String message, String tag) throws IOException;
 
     /**
-     * Compose a SEARCH response
-     * 
-     * @param ids the MSN or UID which were found
-     * @param highestModSeq the highest mod-sequence which matched or null 
-     * @return self
-     * @throws IOException
-     */
-    public ImapResponseComposer searchResponse(long[] ids, Long highestModSeq) throws IOException;
-    
-    /**
-     * Starts a FETCH response by writing the opening star-FETCH-number-paren
-     * sequence.
+     * Writes the message provided to the client, prepended with the untagged
+     * marker "*".
      * 
-     * @param msn
-     *            message number
-     * @see #closeFetchResponse()
-     */
-    public ImapResponseComposer openFetchResponse(long msn) throws IOException;
-
-    /**
-     * Ends a FETCH response by writing the closing paren-crlf sequence.
+     * @param message
+     *            The message to write to the client.
      */
-    public ImapResponseComposer closeFetchResponse() throws IOException;
+    public ImapResponseComposer untaggedResponse(String message) throws IOException;
 
-    /**
-     * Starts a <code>FETCH ENVELOPE</code> production.
-     * 
-     * @param date
-     *            envelope date, or null for <code>NIL</code>
-     * @param subject
-     *            envelope subject, or null for <code>NIL</code>
-     * @param prefixWithName
-     *            whether <code>ENVELOPE</code> should be prefixed
-     * @throws IOException
-     * @see {@link #endEnvelope(String, String)} must be called
-     */
-    public ImapResponseComposer startEnvelope(String date, String subject, boolean prefixWithName) throws IOException;
 
     /**
-     * Starts a list of addresses.
+     * Write a '*' 
      * 
+     * @return composer
      * @throws IOException
      */
-    public ImapResponseComposer startAddresses() throws IOException;
+    public ImapResponseComposer untagged() throws IOException;
 
     /**
-     * Composes an address.
      * 
      * @param name
-     *            personal name, or null for <code>NIL</code>
-     * @param domainList
-     *            route address list, or null for <code>NIL</code>
-     * @param mailbox
-     *            mailbox name, or null for <code>NIL</code>
-     * @param host
-     *            host name, or null for <code>NIL</code>
+     * @return
      * @throws IOException
      */
-    public ImapResponseComposer address(String name, String domainList, String mailbox, String host) throws IOException;
+    public ImapResponseComposer commandName(final String name) throws IOException;
 
     /**
-     * Ends a list of addresses.
+     * Write the message of type <code>String</code>
      * 
+     * @param message
+     * @return composer
      * @throws IOException
      */
-    public ImapResponseComposer endAddresses() throws IOException;
+    public ImapResponseComposer message(final String message) throws IOException;
 
     /**
-     * Ends a <code>FETCH ENVELOPE</code> production.
+     * Write the message of type <code>Long</code>
      * 
-     * @param inReplyTo
-     *            envelope in-reply-to, or null for <code>NIL</code>
-     * @param messageId
-     *            envelope message-id, or null for <code>NIL</code>
+     * @param number
+     * @return composer
      * @throws IOException
      */
-    public ImapResponseComposer endEnvelope(String inReplyTo, String messageId) throws IOException;
+    public ImapResponseComposer message(final long number) throws IOException;
 
     /**
-     * Composes a <code>NIL</code>.
+     * Write the given sequence-set
      * 
+     * @param ranges
+     * @return composer
      * @throws IOException
      */
-    public ImapResponseComposer nil() throws IOException;
+    public ImapResponseComposer sequenceSet(final IdRange[] ranges) throws IOException;
 
     /**
-     * Compose a response which contains the {@link ImapCommand} to which the response belongs
+     * Write a CRLF and flush the composer which will write the content of it to the socket
      * 
-     * @param command
-     * @param message
-     * @return self
+     * @return composer
      * @throws IOException
      */
-    public ImapResponseComposer commandResponse(ImapCommand command, String message) throws IOException;
-
-    /**
-     * Writes a list response
-     * 
-     * @param typeName
-     *            <code>LIST</code> or <code>LSUB</code>.
-     * @param attributes
-     *            name attributes, or null if there are no attributes
-     * @param hierarchyDelimiter
-     *            hierarchy delimiter, or null if delimiter is <code>NIL</code>
-     * @param name
-     *            mailbox name
-     */
-    public ImapResponseComposer listResponse(String typeName, List<String> attributes, char hierarchyDelimiter, String name) throws IOException;
-
-    /**
-     * Writes the message provided to the client, prepended with the request
-     * tag.
-     * 
-     * @param message
-     *            The message to write to the client.
-     */
-    public ImapResponseComposer taggedResponse(String message, String tag) throws IOException;
+    public ImapResponseComposer end() throws IOException;
 
     /**
-     * Writes the message provided to the client, prepended with the untagged
-     * marker "*".
+     * Write a tag
      * 
-     * @param message
-     *            The message to write to the client.
+     * @param tag
+     * @return composer
+     * @throws IOException
      */
-    public ImapResponseComposer untaggedResponse(String message) throws IOException;
+    public ImapResponseComposer tag(String tag) throws IOException;
 
     /**
-     * Compose a BYE response
+     * Write a quoted message
      * 
      * @param message
-     * @return self
+     * @return composer
      * @throws IOException
      */
-    public ImapResponseComposer byeResponse(String message) throws IOException;
+    public ImapResponseComposer quote(String message) throws IOException;
 
     /**
-     * Compose a HELLO response
+     * Compose a {@link Literal} and write it to the socket. Everything which was buffered before will
+     * get written too
      * 
-     * @param message
+     * @param literal
      * @return self
      * @throws IOException
      */
-    public ImapResponseComposer hello(String message) throws IOException;
-
-    public ImapResponseComposer untagged() throws IOException;
-
-    public ImapResponseComposer commandName(final String name) throws IOException;
-
-    public ImapResponseComposer message(final String message) throws IOException;
-
-    public ImapResponseComposer message(final long number) throws IOException;
-
-    public ImapResponseComposer sequenceSet(final IdRange[] ranges) throws IOException;
+    public ImapResponseComposer literal(Literal literal) throws IOException;
 
+    
     /**
-     * Write a CRLF and flush the composer which will write the content of it to the socket
+     * Write a '('
      * 
      * @return composer
      * @throws IOException
      */
-    public ImapResponseComposer end() throws IOException;
-
-    public ImapResponseComposer tag(String tag) throws IOException;
-
-    public ImapResponseComposer statusResponse(String tag, ImapCommand command, String type, String responseCode, Collection<String> parameters, boolean useParens, long number, String text) throws IOException;
-
-    @Deprecated
-    public ImapResponseComposer statusResponse(Long messages, Long recent, Long uidNext, Long uidValidity, Long unseen, String mailboxName) throws IOException;
-    public ImapResponseComposer statusResponse(Long messages, Long recent, Long uidNext, Long highestModSeq, Long uidValidity, Long unseen, String mailboxName) throws IOException;
-
-    public ImapResponseComposer quote(String message) throws IOException;
+    public ImapResponseComposer openParen() throws IOException;
 
     /**
-     * Compose a {@link Literal} and write it to the socket. Everything which was buffered before will
-     * get written too
+     * Write a ')'
      * 
-     * @param literal
-     * @return self
+     * @return composer
      * @throws IOException
      */
-    public ImapResponseComposer literal(Literal literal) throws IOException;
-
-    public ImapResponseComposer openParen() throws IOException;
-
     public ImapResponseComposer closeParen() throws IOException;
 
     /**
@@ -309,70 +206,39 @@ public interface ImapResponseComposer {
      */
     public ImapResponseComposer quoteUpperCaseAscii(final String message) throws IOException;
 
-    /**
-     * Appends the given message after appropriate quoting (when not null) or
-     * <code>NIL</code> (when null).
-     * 
-     * @param message
-     *            possibly null
-     * @return self, not null
-     * @throws IOException
-     */
-    public ImapResponseComposer nillableQuote(String message) throws IOException;
 
     /**
-     * Composes a sequence of nillables quotes. When messages are null, a single
-     * <code>NIL</code> is appended. Otherwise, each element is appended in
-     * sequence as per {@link #nillableQuote(String)}.
+     * Tell the {@link ImapResponseComposer} to skip the next written space
      * 
-     * @param quotes
-     *            messages, possibly null
-     * @return self, not null
+     * @return composer
      * @throws IOException
      */
-    public ImapResponseComposer nillableQuotes(List<String> quotes) throws IOException;
+    public ImapResponseComposer skipNextSpace() throws IOException;
 
-    /**
-     * Composes a nillable composition. When the master quote is null,
-     * <code>NIL</code> is appended. Otherwise, a parenthesized list is created
-     * starting with the master quote. When the quotes are null,
-     * <code>NIL</code> is appended only. Otherwise, each element is appended in
-     * sequence as per {@link #nillableQuote(String)}
-     * 
-     * @param quote
-     *            master, possibly null
-     * @param quotes
-     *            quotes, possibly null
-     * @return self, not null
-     * @throws IOException
-     */
-    public ImapResponseComposer nillableComposition(String masterQuote, List<String> quotes) throws IOException;
 
     /**
-     * Tell the {@link ImapResponseComposer} to skip the next written space
+     * Writes a continuation response.
      * 
-     * @return composer
-     * @throws IOException
+     * @param message
+     *            message for display, not null
      */
-    public ImapResponseComposer skipNextSpace() throws IOException;
+    public ImapResponseComposer continuationResponse(String message) throws IOException;
+    
 
     /**
-     * Composes a <code>CAPABILITY</code> response. See <code>7.2.1</code> of <a
-     * href='http://james.apache.org/server/rfclist/imap4/rfc2060.txt'
-     * rel='tag'>RFC2060</a>.
+     * Write a '}'
      * 
-     * @param capabilities
-     *            not null
+     * @return composer
      * @throws IOException
      */
-    public ImapResponseComposer capabilities(List<String> capabilities) throws IOException;
+    public ImapResponseComposer closeSquareBracket() throws IOException;
 
     /**
-     * Writes a continuation response.
+     * Write a '{'
      * 
-     * @param message
-     *            message for display, not null
+     * @return composer
+     * @throws IOException
      */
-    public ImapResponseComposer continuationResponse(String message) throws IOException;
+    public ImapResponseComposer openSquareBracket() throws IOException;
 
 }

Modified: james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/ListingEncodingUtils.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/ListingEncodingUtils.java?rev=1157073&r1=1157072&r2=1157073&view=diff
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/ListingEncodingUtils.java (original)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/ListingEncodingUtils.java Fri Aug 12 12:35:05 2011
@@ -21,6 +21,7 @@ package org.apache.james.imap.encode;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 
 import org.apache.james.imap.api.ImapConstants;
@@ -36,8 +37,27 @@ public class ListingEncodingUtils {
         final List<String> attributes = getNameAttributes(response);
 
         final String name = response.getName();
+        final char hierarchyDelimiter = response.getHierarchyDelimiter();
+                
+        composer.untagged();
+        composer.message(responseTypeName);
+        composer.openParen();
+        if (attributes != null) {
+            for (Iterator<String> it = attributes.iterator(); it.hasNext();) {
+                final String attribute = it.next();
+                composer.message(attribute);
+            }
+        }
+        composer.closeParen();
+
+        if (hierarchyDelimiter == Character.UNASSIGNED) {
+        	composer.nil();
+        } else {
+        	composer.quote(Character.toString(hierarchyDelimiter));
+        }
+        composer.quote(name);
 
-        composer.listResponse(responseTypeName, attributes, response.getHierarchyDelimiter(), name);
+        composer.end();
     }
 
     private static List<String> getNameAttributes(final AbstractListingResponse response) {

Modified: james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/MailboxStatusResponseEncoder.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/MailboxStatusResponseEncoder.java?rev=1157073&r1=1157072&r2=1157073&view=diff
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/MailboxStatusResponseEncoder.java (original)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/MailboxStatusResponseEncoder.java Fri Aug 12 12:35:05 2011
@@ -21,6 +21,7 @@ package org.apache.james.imap.encode;
 
 import java.io.IOException;
 
+import org.apache.james.imap.api.ImapConstants;
 import org.apache.james.imap.api.ImapMessage;
 import org.apache.james.imap.api.process.ImapSession;
 import org.apache.james.imap.encode.base.AbstractChainedImapEncoder;
@@ -29,7 +30,7 @@ import org.apache.james.imap.message.res
 /**
  * Encodes <code>STATUS</code> responses.
  */
-public class MailboxStatusResponseEncoder extends AbstractChainedImapEncoder {
+public class MailboxStatusResponseEncoder extends AbstractChainedImapEncoder implements ImapConstants {
 
     public MailboxStatusResponseEncoder(ImapEncoder next) {
         super(next);
@@ -37,8 +38,56 @@ public class MailboxStatusResponseEncode
 
     protected void doEncode(ImapMessage acceptableMessage, ImapResponseComposer composer, ImapSession session) throws IOException {
         MailboxStatusResponse response = (MailboxStatusResponse) acceptableMessage;
-        composer.statusResponse(response.getMessages(), response.getRecent(), response.getUidNext(), response.getHighestModSeq(), response.getUidValidity(), response.getUnseen(), response.getMailbox());
+        Long messages = response.getMessages();
+        Long recent = response.getRecent();
+        Long uidNext = response.getUidNext();
+        Long highestModSeq = response.getHighestModSeq();
+        Long uidValidity = response.getUidValidity();
+        Long unseen = response.getUnseen();
+        String mailboxName = response.getMailbox();
+
+        composer.untagged();
+        composer.message(STATUS_COMMAND_NAME);
+        composer.quote(mailboxName);
+        composer.openParen();
+
+        if (messages != null) {
+        	composer.message(STATUS_MESSAGES);
+            final long messagesValue = messages.longValue();
+            composer.message(messagesValue);
+        }
+
+        if (recent != null) {
+        	composer.message(STATUS_RECENT);
+            final long recentValue = recent.longValue();
+            composer.message(recentValue);
+        }
+
+        if (uidNext != null) {
+        	composer.message(STATUS_UIDNEXT);
+            final long uidNextValue = uidNext.longValue();
+            composer.message(uidNextValue);
+        }
+        
+        if (highestModSeq != null) {
+        	composer.message(STATUS_HIGHESTMODSEQ);
+        	composer.message(highestModSeq);
+        }
+
+        if (uidValidity != null) {
+        	composer.message(STATUS_UIDVALIDITY);
+            final long uidValidityValue = uidValidity.longValue();
+            composer.message(uidValidityValue);
+        }
+
+        if (unseen != null) {
+        	composer.message(STATUS_UNSEEN);
+            final long unseenValue = unseen.longValue();
+            composer.message(unseenValue);
+        }
 
+        composer.closeParen();
+        composer.end();
     }
 
     protected boolean isAcceptable(ImapMessage message) {

Modified: james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/RecentResponseEncoder.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/RecentResponseEncoder.java?rev=1157073&r1=1157072&r2=1157073&view=diff
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/RecentResponseEncoder.java (original)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/RecentResponseEncoder.java Fri Aug 12 12:35:05 2011
@@ -27,6 +27,7 @@ import org.apache.james.imap.encode.base
 import org.apache.james.imap.message.response.RecentResponse;
 
 public class RecentResponseEncoder extends AbstractChainedImapEncoder {
+    public static final String RECENT = "RECENT";
 
     public RecentResponseEncoder(ImapEncoder next) {
         super(next);
@@ -36,12 +37,10 @@ public class RecentResponseEncoder exten
         return (message instanceof RecentResponse);
     }
 
-    protected void doEncode(ImapMessage acceptableMessage, ImapResponseComposer composer, ImapSession session) throws IOException { // TODO
-        // Auto-generated
-        // method stub
+    protected void doEncode(ImapMessage acceptableMessage, ImapResponseComposer composer, ImapSession session) throws IOException {
         final RecentResponse recentResponse = (RecentResponse) acceptableMessage;
         final int numberFlaggedRecent = recentResponse.getNumberFlaggedRecent();
-        composer.recentResponse(numberFlaggedRecent);
+        composer.untagged().message(numberFlaggedRecent).message(RECENT).end();
     }
 
 }

Modified: james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/SearchResponseEncoder.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/SearchResponseEncoder.java?rev=1157073&r1=1157072&r2=1157073&view=diff
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/SearchResponseEncoder.java (original)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/SearchResponseEncoder.java Fri Aug 12 12:35:05 2011
@@ -20,6 +20,7 @@ package org.apache.james.imap.encode;
 
 import java.io.IOException;
 
+import org.apache.james.imap.api.ImapConstants;
 import org.apache.james.imap.api.ImapMessage;
 import org.apache.james.imap.api.process.ImapSession;
 import org.apache.james.imap.encode.base.AbstractChainedImapEncoder;
@@ -37,7 +38,25 @@ public class SearchResponseEncoder exten
     protected void doEncode(ImapMessage acceptableMessage, ImapResponseComposer composer, ImapSession session) throws IOException {
         SearchResponse response = (SearchResponse) acceptableMessage;
         final long[] ids = response.getIds();
-        composer.searchResponse(ids);
+        Long highestModSeq = response.getHighestModSeq();
+        composer.untagged();
+        composer.message(ImapConstants.SEARCH_RESPONSE_NAME);
+        if (ids != null) {
+            final int length = ids.length;
+            for (int i = 0; i < length; i++) {
+                final long id = ids[i];
+                composer.message(id);
+            }
+        }
+        
+        // add MODSEQ
+        if (highestModSeq != null) {
+        	composer.openParen();
+        	composer.message("MODSEQ");
+        	composer.message(highestModSeq);
+        	composer.closeParen();
+        }
+        composer.end();
     }
 
     protected boolean isAcceptable(ImapMessage message) {

Modified: james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/StatusResponseEncoder.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/StatusResponseEncoder.java?rev=1157073&r1=1157072&r2=1157073&view=diff
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/StatusResponseEncoder.java (original)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/StatusResponseEncoder.java Fri Aug 12 12:35:05 2011
@@ -22,6 +22,7 @@ package org.apache.james.imap.encode;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Iterator;
 import java.util.Locale;
 
 import org.apache.james.imap.api.ImapCommand;
@@ -66,7 +67,39 @@ public class StatusResponseEncoder exten
             number = responseCode.getNumber();
             useParens = responseCode.useParens();
         }
-        composer.statusResponse(tag, command, type, code, parameters, useParens, number, text);
+        //composer.statusResponse(tag, command, type, code, parameters, useParens, number, text);
+        
+        if (tag == null) {
+        	composer.untagged();
+        } else {
+        	composer.tag(tag);
+        }
+        composer.message(type);
+        if (responseCode != null) {
+        	composer.openSquareBracket();
+        	composer.message(code);
+            if (number > -1) {
+            	composer.message(number);
+            }
+            if (parameters != null && !parameters.isEmpty()) {
+                if (useParens)
+                	composer.openParen();
+                for (Iterator<String> it = parameters.iterator(); it.hasNext();) {
+                    final String parameter = it.next();
+                    composer.message(parameter);
+                }
+                if (useParens)
+                	composer.closeParen();
+            }
+            composer.closeSquareBracket();
+        }
+        if (command != null) {
+        	composer.commandName(command.getName());
+        }
+        if (text != null && !"".equals(text)) {
+        	composer.message(text);
+        }
+        composer.end();
     }
 
     private String asString(HumanReadableText text, ImapSession session) {

Modified: james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/base/ImapResponseComposerImpl.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/base/ImapResponseComposerImpl.java?rev=1157073&r1=1157072&r2=1157073&view=diff
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/base/ImapResponseComposerImpl.java (original)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/base/ImapResponseComposerImpl.java Fri Aug 12 12:35:05 2011
@@ -22,9 +22,6 @@ package org.apache.james.imap.encode.bas
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.charset.Charset;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
 
 import javax.mail.Flags;
 
@@ -42,16 +39,6 @@ import org.apache.james.imap.message.res
  */
 public class ImapResponseComposerImpl implements ImapConstants, ImapResponseComposer {
 
-    public static final String ENVELOPE = "ENVELOPE";
-
-    public static final String FETCH = "FETCH";
-
-    public static final String EXPUNGE = "EXPUNGE";
-
-    public static final String RECENT = "RECENT";
-
-    public static final String EXISTS = "EXISTS";
-
     public static final String FLAGS = "FLAGS";
 
     public static final String FAILED = "failed.";
@@ -101,61 +88,7 @@ public class ImapResponseComposerImpl im
         return this;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.apache.james.imap.encode.ImapResponseComposer#flagsResponse(javax
-     * .mail.Flags)
-     */
-    public ImapResponseComposer flagsResponse(Flags flags) throws IOException {
-        untagged();
-        flags(flags);
-        end();
-        return this;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.apache.james.imap.encode.ImapResponseComposer#existsResponse(long)
-     */
-    public ImapResponseComposer existsResponse(long count) throws IOException {
-        untagged();
-        message(count);
-        message(EXISTS);
-        end();
-        return this;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.apache.james.imap.encode.ImapResponseComposer#recentResponse(long)
-     */
-    public ImapResponseComposer recentResponse(long count) throws IOException {
-        untagged();
-        message(count);
-        message(RECENT);
-        end();
-        return this;
-    }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.apache.james.imap.encode.ImapResponseComposer#expungeResponse(long)
-     */
-    public ImapResponseComposer expungeResponse(long msn) throws IOException {
-        untagged();
-        message(msn);
-        message(EXPUNGE);
-        end();
-        return this;
-    }
 
     /*
      * (non-Javadoc)
@@ -200,29 +133,7 @@ public class ImapResponseComposerImpl im
         return this;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.apache.james.imap.encode.ImapResponseComposer#byeResponse(java.lang
-     * .String)
-     */
-    public ImapResponseComposer byeResponse(String message) throws IOException {
-        untaggedResponse(BYE + SP + message);
-        return this;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.apache.james.imap.encode.ImapResponseComposer#hello(java.lang.String)
-     */
-    public ImapResponseComposer hello(String message) throws IOException {
-        untaggedResponse(OK + SP + message);
-        return this;
-    }
-
+   
     /*
      * (non-Javadoc)
      * 
@@ -286,91 +197,6 @@ public class ImapResponseComposerImpl im
     /*
      * (non-Javadoc)
      * 
-     * @see
-     * org.apache.james.imap.encode.ImapResponseComposer#statusResponse(java
-     * .lang.String, org.apache.james.imap.api.ImapCommand, java.lang.String,
-     * java.lang.String, java.util.Collection, boolean, long, java.lang.String)
-     */
-    public ImapResponseComposer statusResponse(String tag, ImapCommand command, String type, String responseCode, Collection<String> parameters, boolean useParens, long number, String text) throws IOException {
-        if (tag == null) {
-            untagged();
-        } else {
-            tag(tag);
-        }
-        message(type);
-        if (responseCode != null) {
-            openSquareBracket();
-            message(responseCode);
-            if (number > -1) {
-                message(number);
-            }
-            if (parameters != null && !parameters.isEmpty()) {
-                if (useParens)
-                    openParen();
-                for (Iterator<String> it = parameters.iterator(); it.hasNext();) {
-                    final String parameter = it.next();
-                    message(parameter);
-                }
-                if (useParens)
-                    closeParen();
-            }
-            closeSquareBracket();
-        }
-        if (command != null) {
-            commandName(command.getName());
-        }
-        if (text != null && !"".equals(text)) {
-            message(text);
-        }
-        end();
-        return this;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.apache.james.imap.encode.ImapResponseComposer#statusResponse(java
-     * .lang.Long, java.lang.Long, java.lang.Long, java.lang.Long,
-     * java.lang.Long, java.lang.String)
-     */
-    public ImapResponseComposer statusResponse(Long messages, Long recent, Long uidNext, Long uidValidity, Long unseen, String mailboxName) throws IOException {
-        return statusResponse(messages, recent, uidNext, null, uidValidity, unseen, mailboxName);
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.apache.james.imap.encode.ImapResponseComposer#listResponse(java.lang
-     * .String, java.util.List, java.lang.String, java.lang.String)
-     */
-    public ImapResponseComposer listResponse(String typeName, List<String> attributes, char hierarchyDelimiter, String name) throws IOException {
-        untagged();
-        message(typeName);
-        openParen();
-        if (attributes != null) {
-            for (Iterator<String> it = attributes.iterator(); it.hasNext();) {
-                final String attribute = it.next();
-                message(attribute);
-            }
-        }
-        closeParen();
-
-        if (hierarchyDelimiter == Character.UNASSIGNED) {
-            message(NIL);
-        } else {
-            quote(Character.toString(hierarchyDelimiter));
-        }
-        quote(name);
-
-        end();
-        return this;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
      * @see org.apache.james.imap.encode.ImapResponseComposer#closeParen()
      */
     public ImapResponseComposer closeParen() throws IOException {
@@ -388,35 +214,7 @@ public class ImapResponseComposerImpl im
         return this;
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.apache.james.imap.encode.ImapResponseComposer#searchResponse(long[], java.lang.Long)
-     */
-    public ImapResponseComposer searchResponse(long[] ids, Long highestModSeq) throws IOException {
-        untagged();
-        message(ImapConstants.SEARCH_RESPONSE_NAME);
-        message(ids);
-        
-        // add MODSEQ
-        if (highestModSeq != null) {
-            openParen();
-            message("MODSEQ");
-            message(highestModSeq);
-            closeParen();
-        }
-        end();
-        return this;
-    }
 
-    private void message(long[] ids) throws IOException {
-        if (ids != null) {
-            final int length = ids.length;
-            for (int i = 0; i < length; i++) {
-                final long id = ids[i];
-                message(id);
-            }
-        }
-    }
 
     /*
      * (non-Javadoc)
@@ -454,73 +252,8 @@ public class ImapResponseComposerImpl im
         return this;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.apache.james.imap.encode.ImapResponseComposer#closeFetchResponse()
-     */
-    public ImapResponseComposer closeFetchResponse() throws IOException {
-        closeParen();
-        end();
-        return this;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.apache.james.imap.encode.ImapResponseComposer#openFetchResponse(long)
-     */
-    public ImapResponseComposer openFetchResponse(long msn) throws IOException {
-        untagged();
-        message(msn);
-        message(FETCH);
-        openParen();
-        return this;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.apache.james.imap.encode.ImapResponseComposer#address(java.lang.String
-     * , java.lang.String, java.lang.String, java.lang.String)
-     */
-    public ImapResponseComposer address(String name, String domainList, String mailbox, String host) throws IOException {
-        skipNextSpace();
-        openParen();
-        nillableQuote(name);
-        nillableQuote(domainList);
-        nillableQuote(mailbox);
-        nillableQuote(host);
-        closeParen();
-        return this;
-    }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.james.imap.encode.ImapResponseComposer#endAddresses()
-     */
-    public ImapResponseComposer endAddresses() throws IOException {
-        closeParen();
-        return this;
-    }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.apache.james.imap.encode.ImapResponseComposer#endEnvelope(java.lang
-     * .String, java.lang.String)
-     */
-    public ImapResponseComposer endEnvelope(String inReplyTo, String messageId) throws IOException {
-        nillableQuote(inReplyTo);
-        nillableQuote(messageId);
-        closeParen();
-        return this;
-    }
 
     /*
      * (non-Javadoc)
@@ -532,87 +265,7 @@ public class ImapResponseComposerImpl im
         return this;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.james.imap.encode.ImapResponseComposer#startAddresses()
-     */
-    public ImapResponseComposer startAddresses() throws IOException {
-        openParen();
-        return this;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.apache.james.imap.encode.ImapResponseComposer#startEnvelope(java.
-     * lang.String, java.lang.String, boolean)
-     */
-    public ImapResponseComposer startEnvelope(String date, String subject, boolean prefixWithName) throws IOException {
-        if (prefixWithName) {
-            message(ENVELOPE);
-        }
-        openParen();
-        nillableQuote(date);
-        nillableQuote(subject);
-        return this;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.apache.james.imap.encode.ImapResponseComposer#nillableQuote(java.
-     * lang.String)
-     */
-    public ImapResponseComposer nillableQuote(String message) throws IOException {
-        if (message == null) {
-            nil();
-        } else {
-            quote(message);
-        }
-        return this;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.apache.james.imap.encode.ImapResponseComposer#nillableComposition
-     * (java.lang.String, java.util.List)
-     */
-    public ImapResponseComposer nillableComposition(String masterQuote, List<String> quotes) throws IOException {
-        if (masterQuote == null) {
-            nil();
-        } else {
-            openParen();
-            quote(masterQuote);
-            nillableQuotes(quotes);
-            closeParen();
-        }
-        return this;
-    }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.apache.james.imap.encode.ImapResponseComposer#nillableQuotes(java
-     * .util.List)
-     */
-    public ImapResponseComposer nillableQuotes(List<String> quotes) throws IOException {
-        if (quotes == null || quotes.size() == 0) {
-            nil();
-        } else {
-            openParen();
-            for (final String string : quotes) {
-                nillableQuote(string);
-            }
-            closeParen();
-        }
-        return this;
-    }
 
     /*
      * (non-Javadoc)
@@ -646,22 +299,6 @@ public class ImapResponseComposerImpl im
         return this;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.apache.james.imap.encode.ImapResponseComposer#capabilities(java.util
-     * .List)
-     */
-    public ImapResponseComposer capabilities(List<String> capabilities) throws IOException {
-        untagged();
-        message(CAPABILITY_COMMAND_NAME);
-        for (String capability : capabilities) {
-            message(capability);
-        }
-        end();
-        return this;
-    }
 
     private void writeASCII(final String string) throws IOException {
         buffer.write(string.getBytes(usAscii));
@@ -772,12 +409,14 @@ public class ImapResponseComposerImpl im
         return this;
     }
 
-    private void closeSquareBracket() throws IOException {
+    public ImapResponseComposer closeSquareBracket() throws IOException {
         closeBracket(BYTE_CLOSE_SQUARE_BRACKET);
+        return this;
     }
 
-    private void openSquareBracket() throws IOException {
+    public ImapResponseComposer openSquareBracket() throws IOException {
         openBracket(BYTE_OPEN_SQUARE_BRACKET);
+        return this;
     }
 
     private void upperCaseAscii(String message, boolean quote) throws IOException {
@@ -815,59 +454,5 @@ public class ImapResponseComposerImpl im
         return message(sb.toString());
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.apache.james.imap.encode.ImapResponseComposer#searchResponse(long[])
-     */
-    public ImapResponseComposer searchResponse(long[] ids) throws IOException {
-        return searchResponse(ids, null);
-    }
-
-    @Override
-    public ImapResponseComposer statusResponse(Long messages, Long recent, Long uidNext, Long highestModSeq, Long uidValidity, Long unseen, String mailboxName) throws IOException {
-        untagged();
-        message(STATUS_COMMAND_NAME);
-        quote(mailboxName);
-        openParen();
-
-        if (messages != null) {
-            message(STATUS_MESSAGES);
-            final long messagesValue = messages.longValue();
-            message(messagesValue);
-        }
-
-        if (recent != null) {
-            message(STATUS_RECENT);
-            final long recentValue = recent.longValue();
-            message(recentValue);
-        }
-
-        if (uidNext != null) {
-            message(STATUS_UIDNEXT);
-            final long uidNextValue = uidNext.longValue();
-            message(uidNextValue);
-        }
-        
-        if (highestModSeq != null) {
-            message(STATUS_HIGHESTMODSEQ);
-            message(highestModSeq);
-        }
-
-        if (uidValidity != null) {
-            message(STATUS_UIDVALIDITY);
-            final long uidValidityValue = uidValidity.longValue();
-            message(uidValidityValue);
-        }
-
-        if (unseen != null) {
-            message(STATUS_UNSEEN);
-            final long unseenValue = unseen.longValue();
-            message(unseenValue);
-        }
-
-        closeParen();
-        end();
-        return this;
-    }
 
 }

Modified: james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/FetchResponseEncoderEnvelopeTest.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/FetchResponseEncoderEnvelopeTest.java?rev=1157073&r1=1157072&r2=1157073&view=diff
==============================================================================
--- james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/FetchResponseEncoderEnvelopeTest.java (original)
+++ james/imap/trunk/message/src/test/java/org/apache/james/imap/encode/FetchResponseEncoderEnvelopeTest.java Fri Aug 12 12:35:05 2011
@@ -19,17 +19,14 @@
 
 package org.apache.james.imap.encode;
 
-import javax.mail.Flags;
+import junit.framework.Assert;
 
-import org.apache.james.imap.api.ImapCommand;
-import org.apache.james.imap.encode.FetchResponseEncoder;
-import org.apache.james.imap.encode.ImapEncoder;
-import org.apache.james.imap.encode.ImapResponseComposer;
+import org.apache.james.imap.encode.base.ByteImapResponseWriter;
+import org.apache.james.imap.encode.base.ImapResponseComposerImpl;
 import org.apache.james.imap.message.response.FetchResponse;
 import org.apache.james.imap.message.response.FetchResponse.Envelope.Address;
 import org.jmock.Expectations;
 import org.jmock.Mockery;
-import org.jmock.Sequence;
 import org.jmock.integration.junit4.JMock;
 import org.jmock.integration.junit4.JUnit4Mockery;
 import org.junit.Before;
@@ -59,40 +56,39 @@ public class FetchResponseEncoderEnvelop
 
     private Mockery context = new JUnit4Mockery();
     
-    Flags flags;
 
-    ImapResponseComposer composer;
+    private ImapEncoder mockNextEncoder;
 
-    ImapEncoder mockNextEncoder;
+    private FetchResponseEncoder encoder;
 
-    FetchResponseEncoder encoder;
+    private FetchResponse message;
 
-    ImapCommand stubCommand;
+    private FetchResponse.Envelope envelope;
 
-    FetchResponse message;
+    private Address[] bcc;
 
-    FetchResponse.Envelope envelope;
+    private Address[] cc;
 
-    Address[] bcc;
+    private String date;
 
-    Address[] cc;
+    private Address[] from;
 
-    String date;
+    private String inReplyTo;
 
-    Address[] from;
+    private String messageId;
 
-    String inReplyTo;
+    private Address[] replyTo;
 
-    String messageId;
+    private Address[] sender;
 
-    Address[] replyTo;
-
-    Address[] sender;
-
-    String subject;
-
-    Address[] to;
+    private String subject;
 
+    private Address[] to;
+    
+    private ByteImapResponseWriter writer = new ByteImapResponseWriter();
+    private ImapResponseComposer composer = new ImapResponseComposerImpl(writer); 
+    
+    
     @Before
     public void setUp() throws Exception {
         envelope = context.mock(FetchResponse.Envelope.class);
@@ -109,11 +105,8 @@ public class FetchResponseEncoderEnvelop
         to = null;
 
         message = new FetchResponse(MSN, null, null, null, null, null, envelope, null, null, null);
-        composer = context.mock(ImapResponseComposer.class);
         mockNextEncoder = context.mock(ImapEncoder.class);
         encoder = new FetchResponseEncoder(mockNextEncoder, false);
-        stubCommand = ImapCommand.anyStateCommand("COMMAND");
-        flags = new Flags(Flags.Flag.DELETED);
     }
 
     private Address[] mockOneAddress() {
@@ -161,175 +154,88 @@ public class FetchResponseEncoderEnvelop
     @Test
     public void testShouldNilAllNullProperties() throws Exception {
         envelopExpects();
-        context.checking(new Expectations() {{
-            final Sequence composition = context.sequence("composition");
-            oneOf(composer).openFetchResponse(with(equal((long) MSN))); inSequence(composition);
-            oneOf(composer).startEnvelope(with(aNull(String.class)), with(aNull(String.class)), with(equal(true))); inSequence(composition);
-            exactly(6).of(composer).nil(); inSequence(composition);
-            oneOf(composer).endEnvelope(null, null); inSequence(composition);
-            oneOf(composer).closeFetchResponse();inSequence(composition);
-        }});
         encoder.doEncode(message, composer, new FakeImapSession());
+        
+        Assert.assertEquals("* 100 FETCH (ENVELOPE (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL))\r\n", writer.getString());
     }
 
     @Test
     public void testShouldComposeDate() throws Exception {
         date = "a date";
         envelopExpects();
-        context.checking(new Expectations() {{
-            final Sequence composition = context.sequence("composition");
-            oneOf(composer).openFetchResponse(with(equal((long) MSN))); inSequence(composition);
-            oneOf(composer).startEnvelope(with(date), with(aNull(String.class)), with(equal(true))); inSequence(composition);
-            exactly(6).of(composer).nil(); inSequence(composition);
-            oneOf(composer).endEnvelope(null, null); inSequence(composition);
-            oneOf(composer).closeFetchResponse();inSequence(composition);
-        }});
+        
+        
         encoder.doEncode(message, composer, new FakeImapSession());
+        Assert.assertEquals("* 100 FETCH (ENVELOPE (\"a date\" NIL NIL NIL NIL NIL NIL NIL NIL NIL))\r\n",writer.getString());
+
     }
     
     @Test
     public void testShouldComposeSubject() throws Exception {
         subject = "some subject";
         envelopExpects();
-        context.checking(new Expectations() {{
-            final Sequence composition = context.sequence("composition");
-            oneOf(composer).openFetchResponse(with(equal((long) MSN))); inSequence(composition);
-            oneOf(composer).startEnvelope(with(aNull(String.class)), with(equal(subject)), with(equal(true))); inSequence(composition);
-            exactly(6).of(composer).nil(); inSequence(composition);
-            oneOf(composer).endEnvelope(null, null); inSequence(composition);
-            oneOf(composer).closeFetchResponse();inSequence(composition);
-        }});
+        
         encoder.doEncode(message, composer, new FakeImapSession());
+        Assert.assertEquals("* 100 FETCH (ENVELOPE (NIL \"some subject\" NIL NIL NIL NIL NIL NIL NIL NIL))\r\n", writer.getString());
+
     }
 
     @Test
     public void testShouldComposeInReplyTo() throws Exception {
         inReplyTo = "some reply to";
         envelopExpects();
-        context.checking(new Expectations() {{
-            final Sequence composition = context.sequence("composition");
-            oneOf(composer).openFetchResponse(with(equal((long) MSN))); inSequence(composition);
-            oneOf(composer).startEnvelope(with(aNull(String.class)), with(aNull(String.class)), with(equal(true))); inSequence(composition);
-            exactly(6).of(composer).nil(); inSequence(composition);
-            oneOf(composer).endEnvelope(with(equal(inReplyTo)), with(aNull(String.class))); inSequence(composition);
-            oneOf(composer).closeFetchResponse();inSequence(composition);
-        }});
+       
         encoder.doEncode(message, composer, new FakeImapSession());
+        Assert.assertEquals("* 100 FETCH (ENVELOPE (NIL NIL NIL NIL NIL NIL NIL NIL \"some reply to\" NIL))\r\n", writer.getString());
     }
 
     @Test
     public void testShouldComposeMessageId() throws Exception {
         messageId = "some message id";
         envelopExpects();
-        context.checking(new Expectations() {{
-            final Sequence composition = context.sequence("composition");
-            oneOf(composer).openFetchResponse(with(equal((long) MSN))); inSequence(composition);
-            oneOf(composer).startEnvelope(with(aNull(String.class)), with(aNull(String.class)), with(equal(true))); inSequence(composition);
-            exactly(6).of(composer).nil(); inSequence(composition);
-            oneOf(composer).endEnvelope(with(aNull(String.class)), with(equal(messageId))); inSequence(composition);
-            oneOf(composer).closeFetchResponse();inSequence(composition);
-        }});
+        
         encoder.doEncode(message, composer, new FakeImapSession());
+        Assert.assertEquals("* 100 FETCH (ENVELOPE (NIL NIL NIL NIL NIL NIL NIL NIL NIL \"some message id\"))\r\n", writer.getString());
+
     }
 
     @Test
     public void testShouldComposeOneFromAddress() throws Exception {
         from = mockOneAddress();
         envelopExpects();
-        context.checking(new Expectations() {{
-            final Sequence composition = context.sequence("composition");
-            oneOf(composer).openFetchResponse(with(equal((long) MSN))); inSequence(composition);
-            oneOf(composer).startEnvelope(with(aNull(String.class)), with(aNull(String.class)), with(equal(true))); inSequence(composition);
-            oneOf(composer).startAddresses(); inSequence(composition);
-            oneOf(composer).address(
-                    with(equal(ADDRESS_ONE_NAME)), 
-                    with(equal(ADDRESS_ONE_DOMAIN_LIST)),
-                    with(equal(ADDRESS_ONE_MAILBOX)), 
-                    with(equal(ADDRESS_ONE_HOST))); inSequence(composition);
-            oneOf(composer).endAddresses(); inSequence(composition);        
-            exactly(5).of(composer).nil(); inSequence(composition);
-            oneOf(composer).endEnvelope(with(aNull(String.class)), with(equal(messageId))); inSequence(composition);
-            oneOf(composer).closeFetchResponse();inSequence(composition);
-        }});
         encoder.doEncode(message, composer, new FakeImapSession());
+        Assert.assertEquals("* 100 FETCH (ENVELOPE (NIL NIL ((\"NAME\" \"DOMAIN LIST\" \"MAILBOX\" \"HOST\")) NIL NIL NIL NIL NIL NIL NIL))\r\n", writer.getString());
+
     }
 
     @Test
     public void testShouldComposeManyFromAddress() throws Exception {
         from = mockManyAddresses();
         envelopExpects();
-        context.checking(new Expectations() {{
-            final Sequence composition = context.sequence("composition");
-            oneOf(composer).openFetchResponse(with(equal((long) MSN))); inSequence(composition);
-            oneOf(composer).startEnvelope(with(aNull(String.class)), with(aNull(String.class)), with(equal(true))); inSequence(composition);
-            oneOf(composer).startAddresses(); inSequence(composition);
-            oneOf(composer).address(
-                    with(equal(ADDRESS_ONE_NAME)), 
-                    with(equal(ADDRESS_ONE_DOMAIN_LIST)),
-                    with(equal(ADDRESS_ONE_MAILBOX)), 
-                    with(equal(ADDRESS_ONE_HOST))); inSequence(composition);
-            oneOf(composer).address(
-                    with(equal(ADDRESS_TWO_NAME)), 
-                    with(equal(ADDRESS_TWO_DOMAIN_LIST)),
-                    with(equal(ADDRESS_TWO_MAILBOX)), 
-                    with(equal(ADDRESS_TWO_HOST))); inSequence(composition);
-            oneOf(composer).endAddresses(); inSequence(composition);        
-            exactly(5).of(composer).nil(); inSequence(composition);
-            oneOf(composer).endEnvelope(with(aNull(String.class)), with(equal(messageId))); inSequence(composition);
-            oneOf(composer).closeFetchResponse();inSequence(composition);
-        }});
+        
         encoder.doEncode(message, composer, new FakeImapSession());
+        Assert.assertEquals("* 100 FETCH (ENVELOPE (NIL NIL ((\"NAME\" \"DOMAIN LIST\" \"MAILBOX\" \"HOST\")(\"2NAME\" \"2DOMAIN LIST\" \"2MAILBOX\" \"2HOST\")) NIL NIL NIL NIL NIL NIL NIL))\r\n", writer.getString());
+
     }
 
     @Test
     public void testShouldComposeOneSenderAddress() throws Exception {
         sender = mockOneAddress();
         envelopExpects();
-        context.checking(new Expectations() {{
-            final Sequence composition = context.sequence("composition");
-            oneOf(composer).openFetchResponse(with(equal((long) MSN))); inSequence(composition);
-            oneOf(composer).startEnvelope(with(aNull(String.class)), with(aNull(String.class)), with(equal(true))); inSequence(composition);
-            exactly(1).of(composer).nil(); inSequence(composition);
-            oneOf(composer).startAddresses(); inSequence(composition);
-            oneOf(composer).address(
-                    with(equal(ADDRESS_ONE_NAME)), 
-                    with(equal(ADDRESS_ONE_DOMAIN_LIST)),
-                    with(equal(ADDRESS_ONE_MAILBOX)), 
-                    with(equal(ADDRESS_ONE_HOST))); inSequence(composition);
-            oneOf(composer).endAddresses(); inSequence(composition);        
-            exactly(4).of(composer).nil(); inSequence(composition);
-            oneOf(composer).endEnvelope(with(aNull(String.class)), with(equal(messageId))); inSequence(composition);
-            oneOf(composer).closeFetchResponse();inSequence(composition);
-        }});
+     
         encoder.doEncode(message, composer, new FakeImapSession());
+        Assert.assertEquals("* 100 FETCH (ENVELOPE (NIL NIL NIL ((\"NAME\" \"DOMAIN LIST\" \"MAILBOX\" \"HOST\")) NIL NIL NIL NIL NIL NIL))\r\n", writer.getString());
+
     }
 
     @Test
     public void testShouldComposeManySenderAddress() throws Exception {
         sender = mockManyAddresses();
         envelopExpects();
-        context.checking(new Expectations() {{
-            final Sequence composition = context.sequence("composition");
-            oneOf(composer).openFetchResponse(with(equal((long) MSN))); inSequence(composition);
-            oneOf(composer).startEnvelope(with(aNull(String.class)), with(aNull(String.class)), with(equal(true))); inSequence(composition);
-            exactly(1).of(composer).nil(); inSequence(composition);
-            oneOf(composer).startAddresses(); inSequence(composition);
-            oneOf(composer).address(
-                    with(equal(ADDRESS_ONE_NAME)), 
-                    with(equal(ADDRESS_ONE_DOMAIN_LIST)),
-                    with(equal(ADDRESS_ONE_MAILBOX)), 
-                    with(equal(ADDRESS_ONE_HOST))); inSequence(composition);
-            oneOf(composer).address(
-                    with(equal(ADDRESS_TWO_NAME)), 
-                    with(equal(ADDRESS_TWO_DOMAIN_LIST)),
-                    with(equal(ADDRESS_TWO_MAILBOX)), 
-                    with(equal(ADDRESS_TWO_HOST))); inSequence(composition);
-            oneOf(composer).endAddresses(); inSequence(composition);        
-            exactly(4).of(composer).nil(); inSequence(composition);
-            oneOf(composer).endEnvelope(with(aNull(String.class)), with(equal(messageId))); inSequence(composition);
-            oneOf(composer).closeFetchResponse();inSequence(composition);
-        }});
+     
         encoder.doEncode(message, composer, new FakeImapSession());
+        Assert.assertEquals("* 100 FETCH (ENVELOPE (NIL NIL NIL ((\"NAME\" \"DOMAIN LIST\" \"MAILBOX\" \"HOST\")(\"2NAME\" \"2DOMAIN LIST\" \"2MAILBOX\" \"2HOST\")) NIL NIL NIL NIL NIL NIL))\r\n", writer.getString());
+
     }
     
 
@@ -337,201 +243,79 @@ public class FetchResponseEncoderEnvelop
     public void testShouldComposeOneReplyToAddress() throws Exception {
         replyTo = mockOneAddress();
         envelopExpects();
-        context.checking(new Expectations() {{
-            final Sequence composition = context.sequence("composition");
-            oneOf(composer).openFetchResponse(with(equal((long) MSN))); inSequence(composition);
-            oneOf(composer).startEnvelope(with(aNull(String.class)), with(aNull(String.class)), with(equal(true))); inSequence(composition);
-            exactly(2).of(composer).nil(); inSequence(composition);
-            oneOf(composer).startAddresses(); inSequence(composition);
-            oneOf(composer).address(
-                    with(equal(ADDRESS_ONE_NAME)), 
-                    with(equal(ADDRESS_ONE_DOMAIN_LIST)),
-                    with(equal(ADDRESS_ONE_MAILBOX)), 
-                    with(equal(ADDRESS_ONE_HOST))); inSequence(composition);
-            oneOf(composer).endAddresses(); inSequence(composition);        
-            exactly(3).of(composer).nil(); inSequence(composition);
-            oneOf(composer).endEnvelope(with(aNull(String.class)), with(equal(messageId))); inSequence(composition);
-            oneOf(composer).closeFetchResponse();inSequence(composition);
-        }});
+       
         encoder.doEncode(message, composer, new FakeImapSession());
+        Assert.assertEquals("* 100 FETCH (ENVELOPE (NIL NIL NIL NIL ((\"NAME\" \"DOMAIN LIST\" \"MAILBOX\" \"HOST\")) NIL NIL NIL NIL NIL))\r\n", writer.getString());
+
     }
 
     @Test
     public void testShouldComposeManyReplyToAddress() throws Exception {
         replyTo = mockManyAddresses();
         envelopExpects();
-        context.checking(new Expectations() {{
-            final Sequence composition = context.sequence("composition");
-            oneOf(composer).openFetchResponse(with(equal((long) MSN))); inSequence(composition);
-            oneOf(composer).startEnvelope(with(aNull(String.class)), with(aNull(String.class)), with(equal(true))); inSequence(composition);
-            exactly(2).of(composer).nil(); inSequence(composition);
-            oneOf(composer).startAddresses(); inSequence(composition);
-            oneOf(composer).address(
-                    with(equal(ADDRESS_ONE_NAME)), 
-                    with(equal(ADDRESS_ONE_DOMAIN_LIST)),
-                    with(equal(ADDRESS_ONE_MAILBOX)), 
-                    with(equal(ADDRESS_ONE_HOST))); inSequence(composition);
-            oneOf(composer).address(
-                    with(equal(ADDRESS_TWO_NAME)), 
-                    with(equal(ADDRESS_TWO_DOMAIN_LIST)),
-                    with(equal(ADDRESS_TWO_MAILBOX)), 
-                    with(equal(ADDRESS_TWO_HOST))); inSequence(composition);
-            oneOf(composer).endAddresses(); inSequence(composition);        
-            exactly(3).of(composer).nil(); inSequence(composition);
-            oneOf(composer).endEnvelope(with(aNull(String.class)), with(equal(messageId))); inSequence(composition);
-            oneOf(composer).closeFetchResponse();inSequence(composition);
-        }});
+       
         encoder.doEncode(message, composer, new FakeImapSession());
+        Assert.assertEquals("* 100 FETCH (ENVELOPE (NIL NIL NIL NIL ((\"NAME\" \"DOMAIN LIST\" \"MAILBOX\" \"HOST\")(\"2NAME\" \"2DOMAIN LIST\" \"2MAILBOX\" \"2HOST\")) NIL NIL NIL NIL NIL))\r\n", writer.getString());
+
     }
 
     @Test
     public void testShouldComposeOneToAddress() throws Exception {
         to = mockOneAddress();
         envelopExpects();
-        context.checking(new Expectations() {{
-            final Sequence composition = context.sequence("composition");
-            oneOf(composer).openFetchResponse(with(equal((long) MSN))); inSequence(composition);
-            oneOf(composer).startEnvelope(with(aNull(String.class)), with(aNull(String.class)), with(equal(true))); inSequence(composition);
-            exactly(3).of(composer).nil(); inSequence(composition);
-            oneOf(composer).startAddresses(); inSequence(composition);
-            oneOf(composer).address(
-                    with(equal(ADDRESS_ONE_NAME)), 
-                    with(equal(ADDRESS_ONE_DOMAIN_LIST)),
-                    with(equal(ADDRESS_ONE_MAILBOX)), 
-                    with(equal(ADDRESS_ONE_HOST))); inSequence(composition);
-            oneOf(composer).endAddresses(); inSequence(composition);        
-            exactly(2).of(composer).nil(); inSequence(composition);
-            oneOf(composer).endEnvelope(with(aNull(String.class)), with(equal(messageId))); inSequence(composition);
-            oneOf(composer).closeFetchResponse();inSequence(composition);
-        }});
+       
         encoder.doEncode(message, composer, new FakeImapSession());
+        Assert.assertEquals("* 100 FETCH (ENVELOPE (NIL NIL NIL NIL NIL ((\"NAME\" \"DOMAIN LIST\" \"MAILBOX\" \"HOST\")) NIL NIL NIL NIL))\r\n",writer.getString());
+
     }
 
     @Test
     public void testShouldComposeManyToAddress() throws Exception {
         to = mockManyAddresses();
         envelopExpects();
-        context.checking(new Expectations() {{
-            final Sequence composition = context.sequence("composition");
-            oneOf(composer).openFetchResponse(with(equal((long) MSN))); inSequence(composition);
-            oneOf(composer).startEnvelope(with(aNull(String.class)), with(aNull(String.class)), with(equal(true))); inSequence(composition);
-            exactly(3).of(composer).nil(); inSequence(composition);
-            oneOf(composer).startAddresses(); inSequence(composition);
-            oneOf(composer).address(
-                    with(equal(ADDRESS_ONE_NAME)), 
-                    with(equal(ADDRESS_ONE_DOMAIN_LIST)),
-                    with(equal(ADDRESS_ONE_MAILBOX)), 
-                    with(equal(ADDRESS_ONE_HOST))); inSequence(composition);
-            oneOf(composer).address(
-                    with(equal(ADDRESS_TWO_NAME)), 
-                    with(equal(ADDRESS_TWO_DOMAIN_LIST)),
-                    with(equal(ADDRESS_TWO_MAILBOX)), 
-                    with(equal(ADDRESS_TWO_HOST))); inSequence(composition);
-            oneOf(composer).endAddresses(); inSequence(composition);        
-            exactly(2).of(composer).nil(); inSequence(composition);
-            oneOf(composer).endEnvelope(with(aNull(String.class)), with(equal(messageId))); inSequence(composition);
-            oneOf(composer).closeFetchResponse();inSequence(composition);
-        }});
+       
         encoder.doEncode(message, composer, new FakeImapSession());
+        Assert.assertEquals("* 100 FETCH (ENVELOPE (NIL NIL NIL NIL NIL ((\"NAME\" \"DOMAIN LIST\" \"MAILBOX\" \"HOST\")(\"2NAME\" \"2DOMAIN LIST\" \"2MAILBOX\" \"2HOST\")) NIL NIL NIL NIL))\r\n",writer.getString());
+
     }
 
     @Test
     public void testShouldComposeOneCcAddress() throws Exception {
         cc = mockOneAddress();
         envelopExpects();
-        context.checking(new Expectations() {{
-            final Sequence composition = context.sequence("composition");
-            oneOf(composer).openFetchResponse(with(equal((long) MSN))); inSequence(composition);
-            oneOf(composer).startEnvelope(with(aNull(String.class)), with(aNull(String.class)), with(equal(true))); inSequence(composition);
-            exactly(4).of(composer).nil(); inSequence(composition);
-            oneOf(composer).startAddresses(); inSequence(composition);
-            oneOf(composer).address(
-                    with(equal(ADDRESS_ONE_NAME)), 
-                    with(equal(ADDRESS_ONE_DOMAIN_LIST)),
-                    with(equal(ADDRESS_ONE_MAILBOX)), 
-                    with(equal(ADDRESS_ONE_HOST))); inSequence(composition);
-            oneOf(composer).endAddresses(); inSequence(composition);        
-            exactly(1).of(composer).nil(); inSequence(composition);
-            oneOf(composer).endEnvelope(with(aNull(String.class)), with(equal(messageId))); inSequence(composition);
-            oneOf(composer).closeFetchResponse();inSequence(composition);
-        }});
+
         encoder.doEncode(message, composer, new FakeImapSession());
+        Assert.assertEquals("* 100 FETCH (ENVELOPE (NIL NIL NIL NIL NIL NIL ((\"NAME\" \"DOMAIN LIST\" \"MAILBOX\" \"HOST\")) NIL NIL NIL))\r\n",writer.getString());
+
     }
 
     @Test
     public void testShouldComposeManyCcAddress() throws Exception {
         cc = mockManyAddresses();
         envelopExpects();
-        context.checking(new Expectations() {{
-            final Sequence composition = context.sequence("composition");
-            oneOf(composer).openFetchResponse(with(equal((long) MSN))); inSequence(composition);
-            oneOf(composer).startEnvelope(with(aNull(String.class)), with(aNull(String.class)), with(equal(true))); inSequence(composition);
-            exactly(4).of(composer).nil(); inSequence(composition);
-            oneOf(composer).startAddresses(); inSequence(composition);
-            oneOf(composer).address(
-                    with(equal(ADDRESS_ONE_NAME)), 
-                    with(equal(ADDRESS_ONE_DOMAIN_LIST)),
-                    with(equal(ADDRESS_ONE_MAILBOX)), 
-                    with(equal(ADDRESS_ONE_HOST))); inSequence(composition);
-            oneOf(composer).address(
-                    with(equal(ADDRESS_TWO_NAME)), 
-                    with(equal(ADDRESS_TWO_DOMAIN_LIST)),
-                    with(equal(ADDRESS_TWO_MAILBOX)), 
-                    with(equal(ADDRESS_TWO_HOST))); inSequence(composition);
-            oneOf(composer).endAddresses(); inSequence(composition);        
-            exactly(1).of(composer).nil(); inSequence(composition);
-            oneOf(composer).endEnvelope(with(aNull(String.class)), with(equal(messageId))); inSequence(composition);
-            oneOf(composer).closeFetchResponse();inSequence(composition);
-        }});
+       
         encoder.doEncode(message, composer, new FakeImapSession());
+        Assert.assertEquals("* 100 FETCH (ENVELOPE (NIL NIL NIL NIL NIL NIL ((\"NAME\" \"DOMAIN LIST\" \"MAILBOX\" \"HOST\")(\"2NAME\" \"2DOMAIN LIST\" \"2MAILBOX\" \"2HOST\")) NIL NIL NIL))\r\n",writer.getString());
+
     }
     
     @Test
     public void testShouldComposeOneBccAddress() throws Exception {
         bcc = mockOneAddress();
         envelopExpects();
-        context.checking(new Expectations() {{
-            final Sequence composition = context.sequence("composition");
-            oneOf(composer).openFetchResponse(with(equal((long) MSN))); inSequence(composition);
-            oneOf(composer).startEnvelope(with(aNull(String.class)), with(aNull(String.class)), with(equal(true))); inSequence(composition);
-            exactly(5).of(composer).nil(); inSequence(composition);
-            oneOf(composer).startAddresses(); inSequence(composition);
-            oneOf(composer).address(
-                    with(equal(ADDRESS_ONE_NAME)), 
-                    with(equal(ADDRESS_ONE_DOMAIN_LIST)),
-                    with(equal(ADDRESS_ONE_MAILBOX)), 
-                    with(equal(ADDRESS_ONE_HOST))); inSequence(composition);
-            oneOf(composer).endAddresses(); inSequence(composition);        
-            oneOf(composer).endEnvelope(with(aNull(String.class)), with(equal(messageId))); inSequence(composition);
-            oneOf(composer).closeFetchResponse();inSequence(composition);
-        }});
+       
         encoder.doEncode(message, composer, new FakeImapSession());
+        Assert.assertEquals("* 100 FETCH (ENVELOPE (NIL NIL NIL NIL NIL NIL NIL ((\"NAME\" \"DOMAIN LIST\" \"MAILBOX\" \"HOST\")) NIL NIL))\r\n",writer.getString());
+
     }
 
     @Test
     public void testShouldComposeManyBccAddress() throws Exception {
         bcc = mockManyAddresses();
         envelopExpects();
-        context.checking(new Expectations() {{
-            final Sequence composition = context.sequence("composition");
-            oneOf(composer).openFetchResponse(with(equal((long) MSN))); inSequence(composition);
-            oneOf(composer).startEnvelope(with(aNull(String.class)), with(aNull(String.class)), with(equal(true))); inSequence(composition);
-            exactly(5).of(composer).nil(); inSequence(composition);
-            oneOf(composer).startAddresses(); inSequence(composition);
-            oneOf(composer).address(
-                    with(equal(ADDRESS_ONE_NAME)), 
-                    with(equal(ADDRESS_ONE_DOMAIN_LIST)),
-                    with(equal(ADDRESS_ONE_MAILBOX)), 
-                    with(equal(ADDRESS_ONE_HOST))); inSequence(composition);
-            oneOf(composer).address(
-                    with(equal(ADDRESS_TWO_NAME)), 
-                    with(equal(ADDRESS_TWO_DOMAIN_LIST)),
-                    with(equal(ADDRESS_TWO_MAILBOX)), 
-                    with(equal(ADDRESS_TWO_HOST))); inSequence(composition);
-            oneOf(composer).endAddresses(); inSequence(composition);        
-            oneOf(composer).endEnvelope(with(aNull(String.class)), with(equal(messageId))); inSequence(composition);
-            oneOf(composer).closeFetchResponse();inSequence(composition);
-        }});
+       
         encoder.doEncode(message, composer, new FakeImapSession());
+        Assert.assertEquals("* 100 FETCH (ENVELOPE (NIL NIL NIL NIL NIL NIL NIL ((\"NAME\" \"DOMAIN LIST\" \"MAILBOX\" \"HOST\")(\"2NAME\" \"2DOMAIN LIST\" \"2MAILBOX\" \"2HOST\")) NIL NIL))\r\n",writer.getString());
+
     }
 }



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


Mime
View raw message