james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r591949 - in /james/server/trunk: experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/ imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/ imap-codec-library/src/test/java/org/apache...
Date Mon, 05 Nov 2007 10:22:48 GMT
Author: rdonkin
Date: Mon Nov  5 02:22:47 2007
New Revision: 591949

URL: http://svn.apache.org/viewvc?rev=591949&view=rev
Log:
Factored out interface for composer. Design seems a little overengineered now but an interface
makes mocking easier.

Added:
    james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/ImapResponseComposerImpl.java
      - copied, changed from r591931, james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/ImapResponseComposer.java
Modified:
    james/server/trunk/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/ImapHandler.java
    james/server/trunk/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/ImapRequestHandler.java
    james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/ImapResponseComposer.java
    james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/encode/ImapResponseCommandTest.java
    james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/encode/ImapResponseTest.java
    james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/encode/imap4rev1/StatusResponseEncoderTest.java
    james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/encode/imap4rev1/legacy/BadResponseEncodeTest.java
    james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/encode/imap4rev1/legacy/CommandFailedResponseEncoderTest.java
    james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/encode/imap4rev1/legacy/ErrorResponseMessageTest.java

Modified: james/server/trunk/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/ImapHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/ImapHandler.java?rev=591949&r1=591948&r2=591949&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/ImapHandler.java
(original)
+++ james/server/trunk/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/ImapHandler.java
Mon Nov  5 02:22:47 2007
@@ -35,6 +35,7 @@
 import org.apache.james.imapserver.codec.decode.ImapDecoder;
 import org.apache.james.imapserver.codec.encode.ImapEncoder;
 import org.apache.james.imapserver.codec.encode.ImapResponseComposer;
+import org.apache.james.imapserver.codec.encode.ImapResponseComposerImpl;
 
 /**
  * The handler class for IMAP connections.
@@ -84,7 +85,7 @@
     public void forceConnectionClose(final String message) {
         getLogger().debug("forceConnectionClose: "+message);
         final OutputStreamImapResponseWriter writer = new OutputStreamImapResponseWriter(outs);
-        ImapResponseComposer response = new ImapResponseComposer(writer);
+        ImapResponseComposer response = new ImapResponseComposerImpl(writer);
         response.byeResponse(message);
         endSession();
     }
@@ -143,7 +144,7 @@
     protected void handleProtocol() throws IOException {
         try {
             final OutputStreamImapResponseWriter writer = new OutputStreamImapResponseWriter(
outs );
-            ImapResponseComposer response = new ImapResponseComposer( writer);
+            ImapResponseComposer response = new ImapResponseComposerImpl( writer);
 
             // Write welcome message
                  

Modified: james/server/trunk/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/ImapRequestHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/ImapRequestHandler.java?rev=591949&r1=591948&r2=591949&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/ImapRequestHandler.java
(original)
+++ james/server/trunk/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/ImapRequestHandler.java
Mon Nov  5 02:22:47 2007
@@ -36,6 +36,7 @@
 import org.apache.james.imapserver.codec.decode.ImapRequestLineReader;
 import org.apache.james.imapserver.codec.encode.ImapEncoder;
 import org.apache.james.imapserver.codec.encode.ImapResponseComposer;
+import org.apache.james.imapserver.codec.encode.ImapResponseComposerImpl;
 
 /**
  * @version $Revision: 109034 $
@@ -87,7 +88,7 @@
             return false;
         }
 
-        ImapResponseComposer response = new ImapResponseComposer( new OutputStreamImapResponseWriter(
output ));
+        ImapResponseComposerImpl response = new ImapResponseComposerImpl( new OutputStreamImapResponseWriter(
output ));
         response.enableLogging(getLogger()); 
 
         doProcessRequest( request, response, session );

Modified: james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/ImapResponseComposer.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/ImapResponseComposer.java?rev=591949&r1=591948&r2=591949&view=diff
==============================================================================
--- james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/ImapResponseComposer.java
(original)
+++ james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/ImapResponseComposer.java
Mon Nov  5 02:22:47 2007
@@ -21,36 +21,9 @@
 
 import javax.mail.Flags;
 
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.avalon.framework.logger.Logger;
 import org.apache.james.api.imap.ImapCommand;
-import org.apache.james.api.imap.ImapConstants;
-import org.apache.james.api.imap.message.MessageFlags;
 
-/**
- * Class providing methods to send response messages from the server to the
- * client.
- */
-public class ImapResponseComposer extends AbstractLogEnabled implements
-        ImapConstants, ImapResponseWriter {
-
-    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.";
-
-    private final ImapResponseWriter writer;
-
-    public ImapResponseComposer(final ImapResponseWriter writer) {
-        this.writer = writer;
-    }
+public interface ImapResponseComposer {
 
     /**
      * Writes a standard tagged OK response on completion of a command. Response
@@ -63,9 +36,8 @@
      * @param command
      *                The ImapCommand which was completed.
      */
-    public void commandComplete(final ImapCommand command, final String tag) {
-        commandComplete(command, null, tag);
-    }
+    public abstract void commandComplete(final ImapCommand command,
+            final String tag);
 
     /**
      * Writes a standard tagged OK response on completion of a command, with a
@@ -80,15 +52,8 @@
      * @param responseCode
      *                A string response code to send to the client.
      */
-    public void commandComplete(final ImapCommand command,
-            final String responseCode, final String tag) {
-        tag(tag);
-        message(OK);
-        responseCode(responseCode);
-        commandName(command);
-        message("completed.");
-        end();
-    }
+    public abstract void commandComplete(final ImapCommand command,
+            final String responseCode, final String tag);
 
     /**
      * Writes a standard NO response on command failure, together with a
@@ -103,10 +68,8 @@
      * @param reason
      *                A message describing why the command failed.
      */
-    public void commandFailed(final ImapCommand command, final String reason,
-            final String tag) {
-        commandFailed(command, null, reason, tag);
-    }
+    public abstract void commandFailed(final ImapCommand command,
+            final String reason, final String tag);
 
     /**
      * Writes a standard NO response on command failure, together with a
@@ -123,20 +86,8 @@
      * @param reason
      *                A message describing why the command failed.
      */
-    public void commandFailed(ImapCommand command, String responseCode,
-            String reason, final String tag) {
-        tag(tag);
-        message(NO);
-        responseCode(responseCode);
-        commandName(command);
-        message(FAILED);
-        message(reason);
-        end();
-        final Logger logger = getLogger();
-        if (logger != null && logger.isInfoEnabled()) {
-            logger.info("COMMAND FAILED [" + responseCode + "] - " + reason);
-        }
-    }
+    public abstract void commandFailed(ImapCommand command,
+            String responseCode, String reason, final String tag);
 
     /**
      * Writes a standard BAD response on command error, together with a
@@ -149,46 +100,19 @@
      * @param message
      *                The descriptive error message.
      */
-    public void commandError(final String message, final String tag) {
-        tag(tag);
-        message(BAD);
-        message(message);
-        end();
-        final Logger logger = getLogger();
-        if (logger != null && logger.isInfoEnabled()) {
-            logger.info("ERROR - " + message);
-        }
-    }
+    public abstract void commandError(final String message, final String tag);
 
     /**
      * Writes a standard untagged BAD response, together with a descriptive
      * message.
      */
-    public void badResponse(String message) {
-        untagged();
-        message(BAD);
-        message(message);
-        end();
-        final Logger logger = getLogger();
-        if (logger != null && logger.isInfoEnabled()) {
-            logger.info("BAD - " + message);
-        }
-    }
+    public abstract void badResponse(String message);
 
     /**
      * Writes a standard untagged BAD response, together with a descriptive
      * message.
      */
-    public void badResponse(String message, String tag) {
-        tag(tag);
-        message(BAD);
-        message(message);
-        end();
-        final Logger logger = getLogger();
-        if (logger != null && logger.isInfoEnabled()) {
-            logger.info("BAD - " + message);
-        }
-    }
+    public abstract void badResponse(String message, String tag);
 
     /**
      * Writes an untagged OK response, with the supplied response code, and an
@@ -199,13 +123,7 @@
      * @param message
      *                The message to follow the []
      */
-    public void okResponse(String responseCode, String message) {
-        untagged();
-        message(OK);
-        responseCode(responseCode);
-        message(message);
-        end();
-    }
+    public abstract void okResponse(String responseCode, String message);
 
     /**
      * Writes an untagged NO response. Indicates that a warning. The command may
@@ -216,56 +134,20 @@
      * @param responseCode
      *                response code or null when there is no response code
      */
-    public void untaggedNoResponse(String displayMessage, String responseCode) {
-        untagged();
-        message(NO);
-        responseCode(responseCode);
-        message(displayMessage);
-        end();
-    }
-
-    public void flagsResponse(Flags flags) {
-        untagged();
-        message(FLAGS);
-        message(MessageFlags.format(flags));
-        end();
-    }
-
-    public void existsResponse(int count) {
-        untagged();
-        message(count);
-        message(EXISTS);
-        end();
-    }
-
-    public void recentResponse(int count) {
-        untagged();
-        message(count);
-        message(RECENT);
-        end();
-    }
-
-    public void expungeResponse(int msn) {
-        untagged();
-        message(msn);
-        message(EXPUNGE);
-        end();
-    }
-
-    public void fetchResponse(int msn, String msgData) {
-        untagged();
-        message(msn);
-        message(FETCH);
-        message("(" + msgData + ")");
-        end();
-    }
-
-    public void commandResponse(ImapCommand command, String message) {
-        untagged();
-        commandName(command);
-        message(message);
-        end();
-    }
+    public abstract void untaggedNoResponse(String displayMessage,
+            String responseCode);
+
+    public abstract void flagsResponse(Flags flags);
+
+    public abstract void existsResponse(int count);
+
+    public abstract void recentResponse(int count);
+
+    public abstract void expungeResponse(int msn);
+
+    public abstract void fetchResponse(int msn, String msgData);
+
+    public abstract void commandResponse(ImapCommand command, String message);
 
     /**
      * Writes the message provided to the client, prepended with the request
@@ -274,11 +156,7 @@
      * @param message
      *                The message to write to the client.
      */
-    public void taggedResponse(String message, String tag) {
-        tag(tag);
-        message(message);
-        end();
-    }
+    public abstract void taggedResponse(String message, String tag);
 
     /**
      * Writes the message provided to the client, prepended with the untagged
@@ -287,79 +165,27 @@
      * @param message
      *                The message to write to the client.
      */
-    public void untaggedResponse(String message) {
-        untagged();
-        message(message);
-        end();
-    }
-
-    public void byeResponse(String message) {
-        untaggedResponse(BYE + SP + message);
-    }
-
-    public void untagged() {
-        writer.untagged();
-    }
-
-    private void commandName(final ImapCommand command) {
-        final String name = command.getName();
-        commandName(name);
-    }
-
-    public void commandName(final String name) {
-        writer.commandName(name);
-    }
-
-    public void message(final String message) {
-        if (message != null) {
-            // TODO: consider message normalisation
-            // TODO: CR/NFs in message must be replaced
-            // TODO: probably best done in the writer
-            writer.message(message);
-        }
-    }
-
-    public void message(final int number) {
-        writer.message(number);
-    }
-
-    public void responseCode(final String responseCode) {
-        if (responseCode != null) {
-            writer.responseCode(responseCode);
-        }
-    }
-
-    public void end() {
-        writer.end();
-    }
-
-    public void permanentFlagsResponse(Flags flags) {
-        untagged();
-        message(OK);
-        responseCode("PERMANENTFLAGS " + MessageFlags.format(flags));
-        end();
-    }
-
-    public void tag(String tag) {
-        writer.tag(tag);
-    }
-    
-    public void statusResponse(String tag, ImapCommand command, String type, String responseCode,
String text) {
-        if (tag == null) {
-            untagged();
-        } else {
-            tag(tag);
-        }
-        message(type);
-        if (responseCode != null) {
-            message(responseCode);
-        }
-        if (command != null) {
-            commandName(command);
-        }
-        if (text != null) {
-            message(text);
-        }
-        end();
-    }
-}
+    public abstract void untaggedResponse(String message);
+
+    public abstract void byeResponse(String message);
+
+    public abstract void untagged();
+
+    public abstract void commandName(final String name);
+
+    public abstract void message(final String message);
+
+    public abstract void message(final int number);
+
+    public abstract void responseCode(final String responseCode);
+
+    public abstract void end();
+
+    public abstract void permanentFlagsResponse(Flags flags);
+
+    public abstract void tag(String tag);
+
+    public abstract void statusResponse(String tag, ImapCommand command,
+            String type, String responseCode, String text);
+
+}
\ No newline at end of file

Copied: james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/ImapResponseComposerImpl.java
(from r591931, james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/ImapResponseComposer.java)
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/ImapResponseComposerImpl.java?p2=james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/ImapResponseComposerImpl.java&p1=james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/ImapResponseComposer.java&r1=591931&r2=591949&rev=591949&view=diff
==============================================================================
--- james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/ImapResponseComposer.java
(original)
+++ james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/encode/ImapResponseComposerImpl.java
Mon Nov  5 02:22:47 2007
@@ -31,8 +31,8 @@
  * Class providing methods to send response messages from the server to the
  * client.
  */
-public class ImapResponseComposer extends AbstractLogEnabled implements
-        ImapConstants, ImapResponseWriter {
+public class ImapResponseComposerImpl extends AbstractLogEnabled implements
+        ImapConstants, ImapResponseWriter, ImapResponseComposer {
 
     public static final String FETCH = "FETCH";
 
@@ -48,37 +48,19 @@
 
     private final ImapResponseWriter writer;
 
-    public ImapResponseComposer(final ImapResponseWriter writer) {
+    public ImapResponseComposerImpl(final ImapResponseWriter writer) {
         this.writer = writer;
     }
 
     /**
-     * Writes a standard tagged OK response on completion of a command. Response
-     * is writen as:
-     * 
-     * <pre>
-     *      a01 OK COMMAND_NAME completed.
-     * </pre>
-     * 
-     * @param command
-     *                The ImapCommand which was completed.
+     * @see org.apache.james.imapserver.codec.encode.ImapResponseComposer#commandComplete(org.apache.james.api.imap.ImapCommand,
java.lang.String)
      */
     public void commandComplete(final ImapCommand command, final String tag) {
         commandComplete(command, null, tag);
     }
 
     /**
-     * Writes a standard tagged OK response on completion of a command, with a
-     * response code (eg READ-WRITE) Response is writen as:
-     * 
-     * <pre>
-     *      a01 OK [responseCode] COMMAND_NAME completed.
-     * </pre>
-     * 
-     * @param command
-     *                The ImapCommand which was completed.
-     * @param responseCode
-     *                A string response code to send to the client.
+     * @see org.apache.james.imapserver.codec.encode.ImapResponseComposer#commandComplete(org.apache.james.api.imap.ImapCommand,
java.lang.String, java.lang.String)
      */
     public void commandComplete(final ImapCommand command,
             final String responseCode, final String tag) {
@@ -91,17 +73,7 @@
     }
 
     /**
-     * Writes a standard NO response on command failure, together with a
-     * descriptive message. Response is writen as:
-     * 
-     * <pre>
-     *      a01 NO COMMAND_NAME failed. &lt;reason&gt;
-     * </pre>
-     * 
-     * @param command
-     *                The ImapCommand which failed.
-     * @param reason
-     *                A message describing why the command failed.
+     * @see org.apache.james.imapserver.codec.encode.ImapResponseComposer#commandFailed(org.apache.james.api.imap.ImapCommand,
java.lang.String, java.lang.String)
      */
     public void commandFailed(final ImapCommand command, final String reason,
             final String tag) {
@@ -109,19 +81,7 @@
     }
 
     /**
-     * Writes a standard NO response on command failure, together with a
-     * descriptive message. Response is writen as:
-     * 
-     * <pre>
-     *      a01 NO [responseCode] COMMAND_NAME failed. &lt;reason&gt;
-     * </pre>
-     * 
-     * @param command
-     *                The ImapCommand which failed.
-     * @param responseCode
-     *                The Imap response code to send.
-     * @param reason
-     *                A message describing why the command failed.
+     * @see org.apache.james.imapserver.codec.encode.ImapResponseComposer#commandFailed(org.apache.james.api.imap.ImapCommand,
java.lang.String, java.lang.String, java.lang.String)
      */
     public void commandFailed(ImapCommand command, String responseCode,
             String reason, final String tag) {
@@ -139,15 +99,7 @@
     }
 
     /**
-     * Writes a standard BAD response on command error, together with a
-     * descriptive message. Response is writen as:
-     * 
-     * <pre>
-     *      a01 BAD &lt;message&gt;
-     * </pre>
-     * 
-     * @param message
-     *                The descriptive error message.
+     * @see org.apache.james.imapserver.codec.encode.ImapResponseComposer#commandError(java.lang.String,
java.lang.String)
      */
     public void commandError(final String message, final String tag) {
         tag(tag);
@@ -161,8 +113,7 @@
     }
 
     /**
-     * Writes a standard untagged BAD response, together with a descriptive
-     * message.
+     * @see org.apache.james.imapserver.codec.encode.ImapResponseComposer#badResponse(java.lang.String)
      */
     public void badResponse(String message) {
         untagged();
@@ -176,8 +127,7 @@
     }
 
     /**
-     * Writes a standard untagged BAD response, together with a descriptive
-     * message.
+     * @see org.apache.james.imapserver.codec.encode.ImapResponseComposer#badResponse(java.lang.String,
java.lang.String)
      */
     public void badResponse(String message, String tag) {
         tag(tag);
@@ -191,13 +141,7 @@
     }
 
     /**
-     * Writes an untagged OK response, with the supplied response code, and an
-     * optional message.
-     * 
-     * @param responseCode
-     *                The response code, included in [].
-     * @param message
-     *                The message to follow the []
+     * @see org.apache.james.imapserver.codec.encode.ImapResponseComposer#okResponse(java.lang.String,
java.lang.String)
      */
     public void okResponse(String responseCode, String message) {
         untagged();
@@ -208,13 +152,7 @@
     }
 
     /**
-     * Writes an untagged NO response. Indicates that a warning. The command may
-     * still complete sucessfully.
-     * 
-     * @param displayMessage
-     *                message for display, not null
-     * @param responseCode
-     *                response code or null when there is no response code
+     * @see org.apache.james.imapserver.codec.encode.ImapResponseComposer#untaggedNoResponse(java.lang.String,
java.lang.String)
      */
     public void untaggedNoResponse(String displayMessage, String responseCode) {
         untagged();
@@ -224,6 +162,9 @@
         end();
     }
 
+    /**
+     * @see org.apache.james.imapserver.codec.encode.ImapResponseComposer#flagsResponse(javax.mail.Flags)
+     */
     public void flagsResponse(Flags flags) {
         untagged();
         message(FLAGS);
@@ -231,6 +172,9 @@
         end();
     }
 
+    /**
+     * @see org.apache.james.imapserver.codec.encode.ImapResponseComposer#existsResponse(int)
+     */
     public void existsResponse(int count) {
         untagged();
         message(count);
@@ -238,6 +182,9 @@
         end();
     }
 
+    /**
+     * @see org.apache.james.imapserver.codec.encode.ImapResponseComposer#recentResponse(int)
+     */
     public void recentResponse(int count) {
         untagged();
         message(count);
@@ -245,6 +192,9 @@
         end();
     }
 
+    /**
+     * @see org.apache.james.imapserver.codec.encode.ImapResponseComposer#expungeResponse(int)
+     */
     public void expungeResponse(int msn) {
         untagged();
         message(msn);
@@ -252,6 +202,9 @@
         end();
     }
 
+    /**
+     * @see org.apache.james.imapserver.codec.encode.ImapResponseComposer#fetchResponse(int,
java.lang.String)
+     */
     public void fetchResponse(int msn, String msgData) {
         untagged();
         message(msn);
@@ -260,6 +213,9 @@
         end();
     }
 
+    /**
+     * @see org.apache.james.imapserver.codec.encode.ImapResponseComposer#commandResponse(org.apache.james.api.imap.ImapCommand,
java.lang.String)
+     */
     public void commandResponse(ImapCommand command, String message) {
         untagged();
         commandName(command);
@@ -268,11 +224,7 @@
     }
 
     /**
-     * Writes the message provided to the client, prepended with the request
-     * tag.
-     * 
-     * @param message
-     *                The message to write to the client.
+     * @see org.apache.james.imapserver.codec.encode.ImapResponseComposer#taggedResponse(java.lang.String,
java.lang.String)
      */
     public void taggedResponse(String message, String tag) {
         tag(tag);
@@ -281,11 +233,7 @@
     }
 
     /**
-     * Writes the message provided to the client, prepended with the untagged
-     * marker "*".
-     * 
-     * @param message
-     *                The message to write to the client.
+     * @see org.apache.james.imapserver.codec.encode.ImapResponseComposer#untaggedResponse(java.lang.String)
      */
     public void untaggedResponse(String message) {
         untagged();
@@ -293,10 +241,16 @@
         end();
     }
 
+    /**
+     * @see org.apache.james.imapserver.codec.encode.ImapResponseComposer#byeResponse(java.lang.String)
+     */
     public void byeResponse(String message) {
         untaggedResponse(BYE + SP + message);
     }
 
+    /**
+     * @see org.apache.james.imapserver.codec.encode.ImapResponseComposer#untagged()
+     */
     public void untagged() {
         writer.untagged();
     }
@@ -306,10 +260,16 @@
         commandName(name);
     }
 
+    /**
+     * @see org.apache.james.imapserver.codec.encode.ImapResponseComposer#commandName(java.lang.String)
+     */
     public void commandName(final String name) {
         writer.commandName(name);
     }
 
+    /**
+     * @see org.apache.james.imapserver.codec.encode.ImapResponseComposer#message(java.lang.String)
+     */
     public void message(final String message) {
         if (message != null) {
             // TODO: consider message normalisation
@@ -319,20 +279,32 @@
         }
     }
 
+    /**
+     * @see org.apache.james.imapserver.codec.encode.ImapResponseComposer#message(int)
+     */
     public void message(final int number) {
         writer.message(number);
     }
 
+    /**
+     * @see org.apache.james.imapserver.codec.encode.ImapResponseComposer#responseCode(java.lang.String)
+     */
     public void responseCode(final String responseCode) {
         if (responseCode != null) {
             writer.responseCode(responseCode);
         }
     }
 
+    /**
+     * @see org.apache.james.imapserver.codec.encode.ImapResponseComposer#end()
+     */
     public void end() {
         writer.end();
     }
 
+    /**
+     * @see org.apache.james.imapserver.codec.encode.ImapResponseComposer#permanentFlagsResponse(javax.mail.Flags)
+     */
     public void permanentFlagsResponse(Flags flags) {
         untagged();
         message(OK);
@@ -340,10 +312,16 @@
         end();
     }
 
+    /**
+     * @see org.apache.james.imapserver.codec.encode.ImapResponseComposer#tag(java.lang.String)
+     */
     public void tag(String tag) {
         writer.tag(tag);
     }
     
+    /**
+     * @see org.apache.james.imapserver.codec.encode.ImapResponseComposer#statusResponse(java.lang.String,
org.apache.james.api.imap.ImapCommand, java.lang.String, java.lang.String, java.lang.String)
+     */
     public void statusResponse(String tag, ImapCommand command, String type, String responseCode,
String text) {
         if (tag == null) {
             untagged();

Modified: james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/encode/ImapResponseCommandTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/encode/ImapResponseCommandTest.java?rev=591949&r1=591948&r2=591949&view=diff
==============================================================================
--- james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/encode/ImapResponseCommandTest.java
(original)
+++ james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/encode/ImapResponseCommandTest.java
Mon Nov  5 02:22:47 2007
@@ -41,7 +41,7 @@
         mockCommand.expects(atLeastOnce()).method("getName").will(returnValue(NAME));
         command = (ImapCommand) mockCommand.proxy();
         writer = new MockImapResponseWriter();
-        response = new ImapResponseComposer(writer);;
+        response = new ImapResponseComposerImpl(writer);;
     }
 
     protected void tearDown() throws Exception {
@@ -88,7 +88,7 @@
                 writer.operations.get(1));
         assertEquals(new MockImapResponseWriter.CommandNameOperation(NAME),
                 writer.operations.get(2));
-        assertEquals(new MockImapResponseWriter.TextMessageOperation(ImapResponseComposer.FAILED),
+        assertEquals(new MockImapResponseWriter.TextMessageOperation(ImapResponseComposerImpl.FAILED),
                 writer.operations.get(3));
         assertEquals(new MockImapResponseWriter.TextMessageOperation(reason), 
                 writer.operations.get(4));
@@ -108,7 +108,7 @@
                 writer.operations.get(2));
         assertEquals(new MockImapResponseWriter.CommandNameOperation(NAME),
                 writer.operations.get(3));
-        assertEquals(new MockImapResponseWriter.TextMessageOperation(ImapResponseComposer.FAILED),
+        assertEquals(new MockImapResponseWriter.TextMessageOperation(ImapResponseComposerImpl.FAILED),
                 writer.operations.get(4));
         assertEquals(new MockImapResponseWriter.TextMessageOperation(reason), 
                 writer.operations.get(5));

Modified: james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/encode/ImapResponseTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/encode/ImapResponseTest.java?rev=591949&r1=591948&r2=591949&view=diff
==============================================================================
--- james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/encode/ImapResponseTest.java
(original)
+++ james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/encode/ImapResponseTest.java
Mon Nov  5 02:22:47 2007
@@ -36,7 +36,7 @@
     protected void setUp() throws Exception {
         super.setUp();
         writer = new MockImapResponseWriter();
-        response = new ImapResponseComposer(writer);;
+        response = new ImapResponseComposerImpl(writer);;
     }
 
     protected void tearDown() throws Exception {
@@ -91,7 +91,7 @@
         response.flagsResponse(flags);
         assertEquals(4, writer.operations.size());
         assertEquals(new MockImapResponseWriter.UntaggedOperation(), writer.operations.get(0));
-        assertEquals(new MockImapResponseWriter.TextMessageOperation(ImapResponseComposer.FLAGS),

+        assertEquals(new MockImapResponseWriter.TextMessageOperation(ImapResponseComposerImpl.FLAGS),

                 writer.operations.get(1));
         assertEquals(new MockImapResponseWriter.TextMessageOperation(MessageFlags.format(flags)),
                 writer.operations.get(2));
@@ -106,7 +106,7 @@
         assertEquals(new MockImapResponseWriter.UntaggedOperation(), writer.operations.get(0));
         assertEquals(new MockImapResponseWriter.NumericMessageOperation(count), 
                 writer.operations.get(1));
-        assertEquals(new MockImapResponseWriter.TextMessageOperation(ImapResponseComposer.EXISTS),
+        assertEquals(new MockImapResponseWriter.TextMessageOperation(ImapResponseComposerImpl.EXISTS),
                 writer.operations.get(2));
         assertEquals(new MockImapResponseWriter.EndOperation(), 
                 writer.operations.get(3));
@@ -119,7 +119,7 @@
         assertEquals(new MockImapResponseWriter.UntaggedOperation(), writer.operations.get(0));
         assertEquals(new MockImapResponseWriter.NumericMessageOperation(count), 
                 writer.operations.get(1));
-        assertEquals(new MockImapResponseWriter.TextMessageOperation(ImapResponseComposer.RECENT),
+        assertEquals(new MockImapResponseWriter.TextMessageOperation(ImapResponseComposerImpl.RECENT),
                 writer.operations.get(2));
         assertEquals(new MockImapResponseWriter.EndOperation(), 
                 writer.operations.get(3));
@@ -132,7 +132,7 @@
         assertEquals(new MockImapResponseWriter.UntaggedOperation(), writer.operations.get(0));
         assertEquals(new MockImapResponseWriter.NumericMessageOperation(count), 
                 writer.operations.get(1));
-        assertEquals(new MockImapResponseWriter.TextMessageOperation(ImapResponseComposer.EXPUNGE),
+        assertEquals(new MockImapResponseWriter.TextMessageOperation(ImapResponseComposerImpl.EXPUNGE),
                 writer.operations.get(2));
         assertEquals(new MockImapResponseWriter.EndOperation(), 
                 writer.operations.get(3));
@@ -146,7 +146,7 @@
         assertEquals(new MockImapResponseWriter.UntaggedOperation(), writer.operations.get(0));
         assertEquals(new MockImapResponseWriter.NumericMessageOperation(count), 
                 writer.operations.get(1));
-        assertEquals(new MockImapResponseWriter.TextMessageOperation(ImapResponseComposer.FETCH),
+        assertEquals(new MockImapResponseWriter.TextMessageOperation(ImapResponseComposerImpl.FETCH),
                 writer.operations.get(2));
         assertEquals(new MockImapResponseWriter.TextMessageOperation("(" + data + ")"),
                 writer.operations.get(3));
@@ -182,7 +182,7 @@
         response.byeResponse(message);
         assertEquals(3, writer.operations.size());
         assertEquals(new MockImapResponseWriter.UntaggedOperation(), writer.operations.get(0));
-        assertEquals(new MockImapResponseWriter.TextMessageOperation(ImapResponseComposer.BYE
+ ImapResponseComposer.SP + message),
+        assertEquals(new MockImapResponseWriter.TextMessageOperation(ImapResponseComposerImpl.BYE
+ ImapResponseComposerImpl.SP + message),
                 writer.operations.get(1));
         assertEquals(new MockImapResponseWriter.EndOperation(), 
                 writer.operations.get(2));
@@ -193,7 +193,7 @@
         response.permanentFlagsResponse(flags);
         assertEquals(4, writer.operations.size());
         assertEquals(new MockImapResponseWriter.UntaggedOperation(), writer.operations.get(0));
-        assertEquals(new MockImapResponseWriter.TextMessageOperation(ImapResponseComposer.OK),
+        assertEquals(new MockImapResponseWriter.TextMessageOperation(ImapResponseComposerImpl.OK),
                 writer.operations.get(1));
         assertEquals(new MockImapResponseWriter.ResponseCodeOperation("PERMANENTFLAGS " +
MessageFlags.format(flags)),
                 writer.operations.get(2));

Modified: james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/encode/imap4rev1/StatusResponseEncoderTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/encode/imap4rev1/StatusResponseEncoderTest.java?rev=591949&r1=591948&r2=591949&view=diff
==============================================================================
--- james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/encode/imap4rev1/StatusResponseEncoderTest.java
(original)
+++ james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/encode/imap4rev1/StatusResponseEncoderTest.java
Mon Nov  5 02:22:47 2007
@@ -26,6 +26,7 @@
 import org.apache.james.api.imap.message.response.imap4rev1.StatusResponse;
 import org.apache.james.imapserver.codec.encode.ImapEncoder;
 import org.apache.james.imapserver.codec.encode.ImapResponseComposer;
+import org.apache.james.imapserver.codec.encode.ImapResponseComposerImpl;
 import org.apache.james.imapserver.codec.encode.imap4rev1.legacy.MockImapResponseWriter;
 import org.jmock.Mock;
 import org.jmock.MockObjectTestCase;
@@ -46,7 +47,7 @@
     protected void setUp() throws Exception {
         super.setUp();
         writer = new MockImapResponseWriter();
-        response = new ImapResponseComposer(writer);
+        response = new ImapResponseComposerImpl(writer);
         mockNextEncoder = mock(ImapEncoder.class);
         mockStatusResponse = mock(StatusResponse.class);
         encoder = new StatusResponseEncoder((ImapEncoder) mockNextEncoder.proxy());

Modified: james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/encode/imap4rev1/legacy/BadResponseEncodeTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/encode/imap4rev1/legacy/BadResponseEncodeTest.java?rev=591949&r1=591948&r2=591949&view=diff
==============================================================================
--- james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/encode/imap4rev1/legacy/BadResponseEncodeTest.java
(original)
+++ james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/encode/imap4rev1/legacy/BadResponseEncodeTest.java
Mon Nov  5 02:22:47 2007
@@ -24,6 +24,7 @@
 import org.apache.james.imap.message.response.imap4rev1.legacy.BadResponse;
 import org.apache.james.imapserver.codec.encode.ImapEncoder;
 import org.apache.james.imapserver.codec.encode.ImapResponseComposer;
+import org.apache.james.imapserver.codec.encode.ImapResponseComposerImpl;
 import org.jmock.Mock;
 
 public class BadResponseEncodeTest extends TestCase {
@@ -41,7 +42,7 @@
         mockNextEncoder = new Mock(ImapEncoder.class);
         encoder = new BadResponseEncoder((ImapEncoder) mockNextEncoder.proxy());
         writer = new MockImapResponseWriter();
-        response = new ImapResponseComposer(writer);
+        response = new ImapResponseComposerImpl(writer);
         message = new BadResponse(MESSAGE);
     }
 

Modified: james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/encode/imap4rev1/legacy/CommandFailedResponseEncoderTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/encode/imap4rev1/legacy/CommandFailedResponseEncoderTest.java?rev=591949&r1=591948&r2=591949&view=diff
==============================================================================
--- james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/encode/imap4rev1/legacy/CommandFailedResponseEncoderTest.java
(original)
+++ james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/encode/imap4rev1/legacy/CommandFailedResponseEncoderTest.java
Mon Nov  5 02:22:47 2007
@@ -24,6 +24,7 @@
 import org.apache.james.imap.message.response.imap4rev1.legacy.CommandFailedResponse;
 import org.apache.james.imapserver.codec.encode.ImapEncoder;
 import org.apache.james.imapserver.codec.encode.ImapResponseComposer;
+import org.apache.james.imapserver.codec.encode.ImapResponseComposerImpl;
 import org.jmock.Mock;
 import org.jmock.MockObjectTestCase;
 
@@ -44,7 +45,7 @@
         writer = new MockImapResponseWriter();
         mockNextEncoder = mock(ImapEncoder.class);
         encoder = new CommandFailedResponseEncoder((ImapEncoder) mockNextEncoder.proxy());
-        response = new ImapResponseComposer(writer);
+        response = new ImapResponseComposerImpl(writer);
         command = mock(ImapCommand.class);
         command.expects(atLeastOnce()).method("getName").will(returnValue(NAME));
     }
@@ -67,7 +68,7 @@
                 writer.operations.get(2));
         assertEquals(new MockImapResponseWriter.CommandNameOperation(NAME),
                 writer.operations.get(3));
-        assertEquals(new MockImapResponseWriter.TextMessageOperation(ImapResponseComposer.FAILED),
+        assertEquals(new MockImapResponseWriter.TextMessageOperation(ImapResponseComposerImpl.FAILED),
                 writer.operations.get(4));
         assertEquals(new MockImapResponseWriter.TextMessageOperation(message), 
                 writer.operations.get(5));
@@ -86,7 +87,7 @@
                 writer.operations.get(1));
         assertEquals(new MockImapResponseWriter.CommandNameOperation(NAME),
                 writer.operations.get(2));
-        assertEquals(new MockImapResponseWriter.TextMessageOperation(ImapResponseComposer.FAILED),
+        assertEquals(new MockImapResponseWriter.TextMessageOperation(ImapResponseComposerImpl.FAILED),
                 writer.operations.get(3));
         assertEquals(new MockImapResponseWriter.TextMessageOperation(message), 
                 writer.operations.get(4));

Modified: james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/encode/imap4rev1/legacy/ErrorResponseMessageTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/encode/imap4rev1/legacy/ErrorResponseMessageTest.java?rev=591949&r1=591948&r2=591949&view=diff
==============================================================================
--- james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/encode/imap4rev1/legacy/ErrorResponseMessageTest.java
(original)
+++ james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/encode/imap4rev1/legacy/ErrorResponseMessageTest.java
Mon Nov  5 02:22:47 2007
@@ -25,6 +25,7 @@
 import org.apache.james.imap.message.response.imap4rev1.legacy.ErrorResponse;
 import org.apache.james.imapserver.codec.encode.ImapEncoder;
 import org.apache.james.imapserver.codec.encode.ImapResponseComposer;
+import org.apache.james.imapserver.codec.encode.ImapResponseComposerImpl;
 import org.jmock.Mock;
 
 public class ErrorResponseMessageTest extends TestCase {
@@ -43,7 +44,7 @@
         writer = new MockImapResponseWriter();
         mockNextEncoder = new Mock(ImapEncoder.class);
         encoder = new ErrorResponseEncoder((ImapEncoder) mockNextEncoder.proxy());
-        response = new ImapResponseComposer(writer);
+        response = new ImapResponseComposerImpl(writer);
         message = new ErrorResponse(ERROR, TAG);
     }
 



---------------------------------------------------------------------
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