Author: rdonkin
Date: Fri Aug 10 09:26:12 2007
New Revision: 564652

URL: http://svn.apache.org/viewvc?view=rev&rev=564652
Log:
New messages for server status response.

Added:
    james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/display/
    
james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/display/HumanReadableTextKey.java
    
james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/message/response/imap4rev1/StatusResponse.java
    
james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/message/response/imap4rev1/StatusResponseFactory.java
    james/server/trunk/imap-api/src/test/java/org/
    james/server/trunk/imap-api/src/test/java/org/apache/
    james/server/trunk/imap-api/src/test/java/org/apache/james/
    james/server/trunk/imap-api/src/test/java/org/apache/james/api/
    james/server/trunk/imap-api/src/test/java/org/apache/james/api/imap/
    james/server/trunk/imap-api/src/test/java/org/apache/james/api/imap/message/
    
james/server/trunk/imap-api/src/test/java/org/apache/james/api/imap/message/response/
    
james/server/trunk/imap-api/src/test/java/org/apache/james/api/imap/message/response/imap4rev1/
    
james/server/trunk/imap-api/src/test/java/org/apache/james/api/imap/message/response/imap4rev1/AbstractTestForStatusResponseFactory.java
    
james/server/trunk/imap-api/src/test/java/org/apache/james/api/imap/message/response/imap4rev1/StatusResponseTest.java

Added: 
james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/display/HumanReadableTextKey.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/display/HumanReadableTextKey.java?view=auto&rev=564652
==============================================================================
--- 
james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/display/HumanReadableTextKey.java
 (added)
+++ 
james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/display/HumanReadableTextKey.java
 Fri Aug 10 09:26:12 2007
@@ -0,0 +1,82 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.api.imap.display;
+
+/**
+ * Keys human response text that may be displayed to the user. 
+ */
+public class HumanReadableTextKey {
+
+    public static final HumanReadableTextKey FAILURE_NO_SUCH_MAILBOX 
+        = new 
HumanReadableTextKey("org.apache.james.imap.FAILURE_NO_SUCH_MAILBOX", 
+                "failed. No such mailbox.");
+    
+    private final String defaultValue;
+    private final String key;
+    public HumanReadableTextKey(final String key, final String defaultValue) {
+        super();
+        this.defaultValue = defaultValue;
+        this.key = key;
+    }
+   
+    /**
+     * Gets the default value for this text.
+     * @return default human readable text, not null
+     */
+    public final String getDefaultValue() {
+        return defaultValue;
+    }
+    
+    /**
+     * Gets a unique key that can be used to loopup the text.
+     * How this is performed is implementation independent.
+     * @return key value, not null
+     */
+    public final String getKey() {
+        return key;
+    }
+
+    public int hashCode() {
+        final int PRIME = 31;
+        int result = 1;
+        result = PRIME * result + ((key == null) ? 0 : key.hashCode());
+        return result;
+    }
+
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        final HumanReadableTextKey other = (HumanReadableTextKey) obj;
+        if (key == null) {
+            if (other.key != null)
+                return false;
+        } else if (!key.equals(other.key))
+            return false;
+        return true;
+    }
+    
+    public String toString() {
+        return defaultValue;
+    }
+}

Added: 
james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/message/response/imap4rev1/StatusResponse.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/message/response/imap4rev1/StatusResponse.java?view=auto&rev=564652
==============================================================================
--- 
james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/message/response/imap4rev1/StatusResponse.java
 (added)
+++ 
james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/message/response/imap4rev1/StatusResponse.java
 Fri Aug 10 09:26:12 2007
@@ -0,0 +1,203 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.api.imap.message.response.imap4rev1;
+
+import org.apache.james.api.imap.ImapCommand;
+import org.apache.james.api.imap.display.HumanReadableTextKey;
+import org.apache.james.api.imap.message.response.ImapResponseMessage;
+
+/**
+ * <p>
+ * Represents an <code>RFC2060</code> status response.
+ * The five specified status server responses (<code>OK<code>.
+ * <code>NO</code>, <code>BAD</code>, <code>PREAUTH</code>
+ * and <code>BYE</code>) are modeled by this single interface.
+ * They are differentiated by [EMAIL PROTECTED] #getServerResponseType()}
+ * </p>
+ */
+public interface StatusResponse extends ImapResponseMessage {
+    
+    /**
+     * Gets the server response type of this status message.
+     * @return
+     */
+    public Type getServerResponseType();
+    
+    /**
+     * Gets the tag.
+     * @return if tagged response, the tag. Otherwise null.
+     */
+    public String getTag();
+    
+    /**
+     * Gets the command.
+     * @return if tagged response, the command. Otherwise null
+     */
+    public ImapCommand getCommand();
+    
+    /**
+     * Gets the key to the human readable text to be displayed.
+     * Required.
+     * @return key for the text message to be displayed, not null
+     */
+    public HumanReadableTextKey getTextKey();
+    
+    /**
+     * Gets the response code.
+     * Optional.
+     * @return <code>ResponseCode</code>, 
+     * or null if there is no response code
+     */
+    public ResponseCode getResponseCode();
+    
+    /**
+     * Enumerates types of RC2060 status response 
+     */
+    public static final class Type {
+        /** RFC2060 <code>OK</code> server response */
+        public static final Type OK = new Type("OK");
+        /** RFC2060 <code>OK</code> server response */
+        public static final Type NO = new Type("NO");
+        /** RFC2060 <code>BAD</code> server response */
+        public static final Type BAD = new Type("BAD")
+        /** RFC2060 <code>PREAUTH</code> server response */;
+        public static final Type PREAUTH = new Type("PREAUTH");
+        /** RFC2060 <code>BYE</code> server response */
+        public static final Type BYE = new Type("BYE");
+        
+        private final String code;
+
+        private Type(final String code) {
+            super();
+            this.code = code;
+        }
+
+        public int hashCode() {
+            final int PRIME = 31;
+            int result = 1;
+            result = PRIME * result + ((code == null) ? 0 : code.hashCode());
+            return result;
+        }
+        
+        public final String getCode() {
+            return code;
+        }
+
+        public boolean equals(Object obj) {
+            if (this == obj)
+                return true;
+            if (obj == null)
+                return false;
+            if (getClass() != obj.getClass())
+                return false;
+            final ResponseCode other = (ResponseCode) obj;
+            if (code == null) {
+                if (other.code != null)
+                    return false;
+            } else if (!code.equals(other.code))
+                return false;
+            return true;
+        }
+        
+        public String toString() {
+            return code;
+        }
+    }
+    
+    /**
+     * Enumerates response codes.
+     */
+    public static final class ResponseCode {
+        /** RFC2060 <code>ALERT</code> response code */
+        public static final ResponseCode ALERT = new ResponseCode("[ALERT]");
+        /** RFC2060 <code>NEWNAME</code> response code */
+        public static final ResponseCode NEWNAME = new 
ResponseCode("[NEWNAME]");
+        /** RFC2060 <code>PARSE</code> response code */
+        public static final ResponseCode PARSE = new ResponseCode("[PARSE]");
+        /** RFC2060 <code>PERMANENTFLAGS</code> response code */
+        public static final ResponseCode PERMANENTFLAGS = new 
ResponseCode("[PERMANENTFLAGS]");
+        /** RFC2060 <code>READ_ONLY</code> response code */
+        public static final ResponseCode READ_ONLY = new 
ResponseCode("[READ-ONLY]");
+        /** RFC2060 <code>READ_WRITE</code> response code */
+        public static final ResponseCode READ_WRITE = new 
ResponseCode("[READ-WRITE]");
+        /** RFC2060 <code>TRYCREATE</code> response code */
+        public static final ResponseCode TRYCREATE = new 
ResponseCode("[TRYCREATE]");
+        /** RFC2060 <code>UIDVALIDITY</code> response code */
+        public static final ResponseCode UIDVALIDITY = new 
ResponseCode("[UIDVALIDITY]");
+        /** RFC2060 <code>UNSEEN</code> response code */
+        public static final ResponseCode UNSEEN = new ResponseCode("[UNSEEN]");
+        
+        /**
+         * Creates an extension response code.
+         * Names that do not begin with 'X' will have 'X' prepended
+         * @param name extension code, not null
+         * @return <code>ResponseCode</code>, not null
+         */
+        public static ResponseCode createExtension(String name) {
+            StringBuffer buffer = new StringBuffer();
+            buffer.append('[');
+            if (!name.startsWith("X")) {
+                buffer.append('X');
+            }
+            buffer.append(name);
+            buffer.append(']');
+            final ResponseCode result = new ResponseCode(buffer.toString());
+            return result;
+        }
+        
+        private final String code;
+
+        private ResponseCode(final String code) {
+            super();
+            this.code = code;
+        }
+
+        public final String getCode() {
+            return code;
+        }
+
+        public int hashCode() {
+            final int PRIME = 31;
+            int result = 1;
+            result = PRIME * result + ((code == null) ? 0 : code.hashCode());
+            return result;
+        }
+
+        public boolean equals(Object obj) {
+            if (this == obj)
+                return true;
+            if (obj == null)
+                return false;
+            if (getClass() != obj.getClass())
+                return false;
+            final ResponseCode other = (ResponseCode) obj;
+            if (code == null) {
+                if (other.code != null)
+                    return false;
+            } else if (!code.equals(other.code))
+                return false;
+            return true;
+        }
+        
+        public String toString() {
+            return code;
+        }
+    }
+}

Added: 
james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/message/response/imap4rev1/StatusResponseFactory.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/message/response/imap4rev1/StatusResponseFactory.java?view=auto&rev=564652
==============================================================================
--- 
james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/message/response/imap4rev1/StatusResponseFactory.java
 (added)
+++ 
james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/message/response/imap4rev1/StatusResponseFactory.java
 Fri Aug 10 09:26:12 2007
@@ -0,0 +1,167 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.api.imap.message.response.imap4rev1;
+
+import org.apache.james.api.imap.ImapCommand;
+import org.apache.james.api.imap.display.HumanReadableTextKey;
+
+/**
+ * Constructs [EMAIL PROTECTED] StatusResponse} instances.
+ * This interface enforces RFC2060 rules.
+ */
+public interface StatusResponseFactory {
+
+    /**
+     * Creates a tagged OK status response.
+     * @param tag operation tag, not null
+     * @param command <code>ImapCommand</code>, not null
+     * @param displayTextKey key to the human readable code to be displayed
+     * @param code <code>ResponseCode</code>, not null
+     * @return <code>StatusResponse</code>, not null
+     */
+    public StatusResponse taggedOk(String tag, ImapCommand command, 
HumanReadableTextKey displayTextKey, StatusResponse.ResponseCode code);
+    
+    /**
+     * Creates a tagged NO status response.
+     * @param tag <code>CharSequence</code>, not null
+     * @param command <code>ImapCommand</code>, not null
+     * @param displayTextKey key to the human readable code to be displayed
+     * @param code <code>ResponseCode</code>, not null
+     * @return <code>StatusResponse</code>, not null
+     */
+    public StatusResponse taggedNo(String tag, ImapCommand command, 
HumanReadableTextKey displayTextKey, StatusResponse.ResponseCode code);
+    
+    /**
+     * Creates a tagged BAD status response.
+     * @param tag <code>CharSequence</code>, not null
+     * @param command <code>ImapCommand</code>, not null
+     * @param displayTextKey key to the human readable code to be displayed
+     * @param code <code>ResponseCode</code>, not null
+     * @return <code>StatusResponse</code>, not null
+     */
+    public StatusResponse taggedBad(String tag, ImapCommand command, 
HumanReadableTextKey displayTextKey, StatusResponse.ResponseCode code);
+
+    /**
+     * Creates a untagged OK status response.
+     * @param displayTextKey key to the human readable code to be displayed
+     * @param code <code>ResponseCode</code>, not null
+     * @return <code>StatusResponse</code>, not null
+     */
+    public StatusResponse untaggedOk(HumanReadableTextKey displayTextKey, 
StatusResponse.ResponseCode code);
+
+    /**
+     * Creates a untagged NO status response.
+     * @param displayTextKey key to the human readable code to be displayed
+     * @param code <code>ResponseCode</code>, not null
+     * @return <code>StatusResponse</code>, not null
+     */
+    public StatusResponse untaggedNo(HumanReadableTextKey displayTextKey, 
StatusResponse.ResponseCode code);
+
+    /**
+     * Creates a untagged BAD status response.
+     * @param displayTextKey key to the human readable code to be displayed
+     * @param code <code>ResponseCode</code>, not null
+     * @return <code>StatusResponse</code>, not null
+     */
+    public StatusResponse untaggedBad(HumanReadableTextKey displayTextKey, 
StatusResponse.ResponseCode code);
+
+    /**
+     * Creates a PREAUTH status response.
+     * These are always untagged.
+     * @param displayTextKey key to the human readable code to be displayed
+     * @param code <code>ResponseCode</code>, not null
+     * @return <code>StatusResponse</code>, not null
+     */
+    public StatusResponse preauth(HumanReadableTextKey displayTextKey, 
StatusResponse.ResponseCode code);
+
+    /**
+     * Creates a BYE status response.
+     * These are always untagged.
+     * @param displayTextKey key to the human readable code to be displayed
+     * @param code <code>ResponseCode</code>, not null
+     * @return <code>StatusResponse</code>, not null
+     */
+    public StatusResponse bye(HumanReadableTextKey displayTextKey, 
StatusResponse.ResponseCode code);
+
+    /**
+     * Creates a tagged OK status response.
+     * @param tag <code>CharSequence</code>, not null
+     * @param command <code>ImapCommand</code>, not null
+     * @param displayTextKey key to the human readable code to be displayed
+     * @return <code>StatusResponse</code>, not null
+     */
+    public StatusResponse taggedOk(String tag, ImapCommand command, 
HumanReadableTextKey displayTextKey);
+    
+    /**
+     * Creates a tagged NO status response.
+     * @param tag <code>CharSequence</code>, not null
+     * @param command <code>ImapCommand</code>, not null
+     * @param displayTextKey key to the human readable code to be displayed
+     * @return <code>StatusResponse</code>, not null
+     */
+    public StatusResponse taggedNo(String tag, ImapCommand command, 
HumanReadableTextKey displayTextKey);
+    
+    /**
+     * Creates a tagged BAD status response.
+     * @param tag <code>CharSequence</code>, not null
+     * @param command <code>ImapCommand</code>, not null
+     * @param displayTextKey key to the human readable code to be displayed
+     * @return <code>StatusResponse</code>, not null
+     */
+    public StatusResponse taggedBad(String tag, ImapCommand command, 
HumanReadableTextKey displayTextKey);
+
+    /**
+     * Creates a untagged OK status response.
+     * @param displayTextKey key to the human readable code to be displayed
+     * @return <code>StatusResponse</code>, not null
+     */
+    public StatusResponse untaggedOk(HumanReadableTextKey displayTextKey);
+
+    /**
+     * Creates a untagged NO status response.
+     * @param displayTextKey key to the human readable code to be displayed
+     * @return <code>StatusResponse</code>, not null
+     */
+    public StatusResponse untaggedNo(HumanReadableTextKey displayTextKey);
+
+    /**
+     * Creates a untagged BAD status response.
+     * @param displayTextKey key to the human readable code to be displayed
+     * @return <code>StatusResponse</code>, not null
+     */
+    public StatusResponse untaggedBad(HumanReadableTextKey displayTextKey);
+
+    /**
+     * Creates a PREAUTH status response.
+     * These are always untagged.
+     * @param displayTextKey key to the human readable code to be displayed
+     * @return <code>StatusResponse</code>, not null
+     */
+    public StatusResponse preauth(HumanReadableTextKey displayTextKey);
+
+    /**
+     * Creates a BYE status response.
+     * These are always untagged.
+     * @param displayTextKey key to the human readable code to be displayed
+     * @return <code>StatusResponse</code>, not null
+     */
+    public StatusResponse bye(HumanReadableTextKey displayTextKey);
+
+}

Added: 
james/server/trunk/imap-api/src/test/java/org/apache/james/api/imap/message/response/imap4rev1/AbstractTestForStatusResponseFactory.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/imap-api/src/test/java/org/apache/james/api/imap/message/response/imap4rev1/AbstractTestForStatusResponseFactory.java?view=auto&rev=564652
==============================================================================
--- 
james/server/trunk/imap-api/src/test/java/org/apache/james/api/imap/message/response/imap4rev1/AbstractTestForStatusResponseFactory.java
 (added)
+++ 
james/server/trunk/imap-api/src/test/java/org/apache/james/api/imap/message/response/imap4rev1/AbstractTestForStatusResponseFactory.java
 Fri Aug 10 09:26:12 2007
@@ -0,0 +1,184 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.api.imap.message.response.imap4rev1;
+
+import org.apache.james.api.imap.ImapCommand;
+import org.apache.james.api.imap.display.HumanReadableTextKey;
+import org.jmock.MockObjectTestCase;
+
+abstract public class AbstractTestForStatusResponseFactory extends 
MockObjectTestCase {
+
+    private static final String TAG = "ATAG";
+    private static final HumanReadableTextKey KEY = new 
HumanReadableTextKey("KEY", "TEXT");
+    private static final StatusResponse.ResponseCode CODE = 
StatusResponse.ResponseCode.ALERT;
+    
+    private ImapCommand command;
+    
+    StatusResponseFactory factory;
+    
+    abstract protected StatusResponseFactory createInstance();
+    
+    protected void setUp() throws Exception {
+        super.setUp();
+        factory = createInstance();
+        command = (ImapCommand) mock(ImapCommand.class).proxy();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    public void testTaggedOk() {
+        StatusResponse response = factory.taggedOk(TAG, command, KEY);
+        assertNotNull(response);
+        assertEquals(StatusResponse.Type.OK, response.getServerResponseType());
+        assertEquals(TAG, response.getTag());
+        assertEquals(KEY, response.getTextKey());
+        assertEquals(command, response.getCommand());
+        assertNull(response.getResponseCode());
+        response = factory.taggedOk(TAG, command, KEY, CODE);
+        assertNotNull(response);
+        assertEquals(StatusResponse.Type.OK, response.getServerResponseType());
+        assertEquals(TAG, response.getTag());
+        assertEquals(KEY, response.getTextKey());
+        assertEquals(CODE, response.getResponseCode());
+        assertEquals(command, response.getCommand());
+    }
+
+    public void testTaggedNo() {
+        StatusResponse response = factory.taggedNo(TAG, command, KEY);
+        assertNotNull(response);
+        assertEquals(StatusResponse.Type.NO, response.getServerResponseType());
+        assertEquals(TAG, response.getTag());
+        assertEquals(KEY, response.getTextKey());
+        assertEquals(command, response.getCommand());
+        assertNull(response.getResponseCode());
+        response = factory.taggedNo(TAG, command, KEY, CODE);
+        assertNotNull(response);
+        assertEquals(StatusResponse.Type.NO, response.getServerResponseType());
+        assertEquals(TAG, response.getTag());
+        assertEquals(KEY, response.getTextKey());
+        assertEquals(CODE, response.getResponseCode());
+        assertEquals(command, response.getCommand());
+    }
+
+    public void testTaggedBad() {
+        StatusResponse response = factory.taggedBad(TAG, command, KEY);
+        assertNotNull(response);
+        assertEquals(StatusResponse.Type.BAD, 
response.getServerResponseType());
+        assertEquals(TAG, response.getTag());
+        assertEquals(KEY, response.getTextKey());
+        assertNull(response.getResponseCode());
+        assertEquals(command, response.getCommand());
+        response = factory.taggedBad(TAG, command, KEY, CODE);
+        assertNotNull(response);
+        assertEquals(StatusResponse.Type.BAD, 
response.getServerResponseType());
+        assertEquals(TAG, response.getTag());
+        assertEquals(KEY, response.getTextKey());
+        assertEquals(CODE, response.getResponseCode());
+        assertEquals(command, response.getCommand());
+    }
+
+    public void testUntaggedOk() {
+        StatusResponse response = factory.untaggedOk(KEY);
+        assertNotNull(response);
+        assertEquals(StatusResponse.Type.OK, response.getServerResponseType());
+        assertEquals(null, response.getTag());
+        assertEquals(KEY, response.getTextKey());
+        assertNull(response.getResponseCode());
+        assertNull(response.getCommand());
+        response = factory.untaggedOk(KEY, CODE);
+        assertNotNull(response);
+        assertEquals(StatusResponse.Type.OK, response.getServerResponseType());
+        assertEquals(null, response.getTag());
+        assertEquals(KEY, response.getTextKey());
+        assertEquals(CODE, response.getResponseCode());
+        assertNull(response.getCommand());
+    }
+
+    public void testUntaggedNo() {
+        StatusResponse response = factory.untaggedNo(KEY);
+        assertNotNull(response);
+        assertEquals(StatusResponse.Type.NO, response.getServerResponseType());
+        assertEquals(null, response.getTag());
+        assertEquals(KEY, response.getTextKey());
+        assertNull(response.getResponseCode());
+        assertNull(response.getCommand());
+        response = factory.untaggedNo(KEY, CODE);
+        assertNotNull(response);
+        assertEquals(StatusResponse.Type.NO, response.getServerResponseType());
+        assertEquals(null, response.getTag());
+        assertEquals(KEY, response.getTextKey());
+        assertEquals(CODE, response.getResponseCode());
+        assertNull(response.getCommand());
+    }
+
+    public void testUntaggedBad() {
+        StatusResponse response = factory.untaggedBad(KEY);
+        assertNotNull(response);
+        assertEquals(StatusResponse.Type.BAD, 
response.getServerResponseType());
+        assertEquals(null, response.getTag());
+        assertEquals(KEY, response.getTextKey());
+        assertNull(response.getResponseCode());
+        assertNull(response.getCommand());
+        response = factory.untaggedBad(KEY, CODE);
+        assertNotNull(response);
+        assertEquals(StatusResponse.Type.BAD, 
response.getServerResponseType());
+        assertEquals(null, response.getTag());
+        assertEquals(KEY, response.getTextKey());
+        assertEquals(CODE, response.getResponseCode());
+        assertNull(response.getCommand());
+    }
+
+    public void testPreauth() {
+        StatusResponse response = factory.preauth(KEY);
+        assertNotNull(response);
+        assertEquals(StatusResponse.Type.PREAUTH, 
response.getServerResponseType());
+        assertEquals(null, response.getTag());
+        assertEquals(KEY, response.getTextKey());
+        assertNull(response.getResponseCode());
+        assertNull(response.getCommand());
+        response = factory.preauth(KEY, CODE);
+        assertNotNull(response);
+        assertEquals(StatusResponse.Type.PREAUTH, 
response.getServerResponseType());
+        assertEquals(null, response.getTag());
+        assertEquals(KEY, response.getTextKey());
+        assertEquals(CODE, response.getResponseCode());
+        assertNull(response.getCommand());
+    }
+
+    public void testBye() {
+        StatusResponse response = factory.bye(KEY);
+        assertNotNull(response);
+        assertEquals(StatusResponse.Type.BYE, 
response.getServerResponseType());
+        assertEquals(null, response.getTag());
+        assertEquals(KEY, response.getTextKey());
+        assertNull(response.getResponseCode());
+        assertNull(response.getCommand());
+        response = factory.bye(KEY, CODE);
+        assertNotNull(response);
+        assertEquals(StatusResponse.Type.BYE, 
response.getServerResponseType());
+        assertEquals(null, response.getTag());
+        assertEquals(KEY, response.getTextKey());
+        assertEquals(CODE, response.getResponseCode());
+        assertNull(response.getCommand());
+    }
+
+}

Added: 
james/server/trunk/imap-api/src/test/java/org/apache/james/api/imap/message/response/imap4rev1/StatusResponseTest.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/imap-api/src/test/java/org/apache/james/api/imap/message/response/imap4rev1/StatusResponseTest.java?view=auto&rev=564652
==============================================================================
--- 
james/server/trunk/imap-api/src/test/java/org/apache/james/api/imap/message/response/imap4rev1/StatusResponseTest.java
 (added)
+++ 
james/server/trunk/imap-api/src/test/java/org/apache/james/api/imap/message/response/imap4rev1/StatusResponseTest.java
 Fri Aug 10 09:26:12 2007
@@ -0,0 +1,36 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.api.imap.message.response.imap4rev1;
+
+import junit.framework.TestCase;
+
+public class StatusResponseTest extends TestCase {
+
+    protected void setUp() throws Exception {
+    }
+
+    protected void tearDown() throws Exception {
+    }
+
+    public void testResponseCodeExtension() throws Exception {
+        assertEquals("Preserve names beginning with X", "[XEXTENSION]", 
StatusResponse.ResponseCode.createExtension("XEXTENSION").getCode());
+        assertEquals("Correct other names", "[XEXTENSION]", 
StatusResponse.ResponseCode.createExtension("EXTENSION").getCode());
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to