james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r591779 [1/2] - in /james/server/trunk: experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/ imap-codec-library/src/main/java/org/apache/james/imapserver/codec/decode/ imap-codec-library/src/main/java/org/apa...
Date Sun, 04 Nov 2007 13:11:13 GMT
Author: rdonkin
Date: Sun Nov  4 05:11:12 2007
New Revision: 591779

URL: http://svn.apache.org/viewvc?rev=591779&view=rev
Log:
Correct locale issues with Append command parsing. Introduce multi-locale functional tests.

Added:
    james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/decode/DecoderUtilsLocaleDateTest.java
Modified:
    james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractAuthenticatedStateTestSuite.java
    james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractProtocolTest.java
    james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractTestFetch.java
    james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractTestForNonAuthenticatedState.java
    james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractTestSelectedInbox.java
    james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractTestSelectedState.java
    james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/SimpleScriptedTestProtocol.java
    james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/decode/DecoderUtils.java
    james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/decode/base/AbstractImapCommandParser.java
    james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/decode/DecoderUtilsTest.java
    james/server/trunk/phoenix-deployment/src/test/org/apache/james/experimental/imapserver/ExperimentalAuthenticatedStateTest.java
    james/server/trunk/phoenix-deployment/src/test/org/apache/james/experimental/imapserver/ExperimentalSelectedStateTest.java

Modified: james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractAuthenticatedStateTestSuite.java
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractAuthenticatedStateTestSuite.java?rev=591779&r1=591778&r2=591779&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractAuthenticatedStateTestSuite.java (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractAuthenticatedStateTestSuite.java Sun Nov  4 05:11:12 2007
@@ -19,6 +19,8 @@
 
 package org.apache.james.test.functional.imap;
 
+import java.util.Locale;
+
 
 abstract public class AbstractAuthenticatedStateTestSuite extends BaseTestForAuthenticatedState {
 
@@ -27,75 +29,222 @@
         super(system);
     }
 
-    public void testNoop() throws Exception {
-        scriptTest("Noop"); 
+    public void testNoopUS() throws Exception {
+        scriptTest("Noop", Locale.US); 
+    }
+    
+    public void testLogoutUS() throws Exception {
+        scriptTest("Logout", Locale.US); 
+    }
+    
+    public void testCapabilityUS() throws Exception {
+        scriptTest("Capability", Locale.US); 
+    }
+    
+    public void testAppendExamineInboxUS() throws Exception {
+        scriptTest("AppendExamineInbox", Locale.US);
+    }
+
+    public void testAppendSelectInboxUS() throws Exception {
+        scriptTest("AppendSelectInbox", Locale.US);
+    }
+    
+    public void testCreateUS() throws Exception {
+        scriptTest("Create", Locale.US); 
+    }
+    
+    public void testExamineEmptyUS() throws Exception {
+        scriptTest("ExamineEmpty", Locale.US); 
+    }
+    
+    public void testSelectEmptyUS() throws Exception {
+        scriptTest("SelectEmpty", Locale.US);
+    }
+        
+    public void testListNamespaceUS() throws Exception {
+        scriptTest("ListNamespace", Locale.US); 
+    }
+    
+    public void testListMailboxesUS() throws Exception {
+        scriptTest("ListMailboxes", Locale.US);
+    }
+    
+    public void testStatusUS() throws Exception {
+        scriptTest("Status", Locale.US); 
+    }
+    
+    public void testSubscribeUS() throws Exception {
+        scriptTest("Subscribe", Locale.US);
+    }
+    
+    public void testDeleteUS() throws Exception {
+        scriptTest("Delete", Locale.US); 
+    }
+    
+    public void testAppendUS() throws Exception {
+        scriptTest("Append", Locale.US);
+    }
+    
+    public void testAppendExpungeUS() throws Exception {
+        scriptTest("AppendExpunge", Locale.US);
+    }
+    
+    public void testSelectAppendUS() throws Exception {
+        scriptTest("SelectAppend", Locale.US);
+    }
+    
+    public void testStringArgsUS() throws Exception {
+        scriptTest("StringArgs", Locale.US);
+    }
+    
+    public void testValidNonAuthenticatedUS() throws Exception {
+        scriptTest("ValidNonAuthenticated", Locale.US);
+    }
+    
+
+    public void testNoopITALY() throws Exception {
+        scriptTest("Noop", Locale.ITALY); 
+    }
+    
+    public void testLogoutITALY() throws Exception {
+        scriptTest("Logout", Locale.ITALY); 
+    }
+    
+    public void testCapabilityITALY() throws Exception {
+        scriptTest("Capability", Locale.ITALY); 
+    }
+    
+    public void testAppendExamineInboxITALY() throws Exception {
+        scriptTest("AppendExamineInbox", Locale.ITALY);
+    }
+
+    public void testAppendSelectInboxITALY() throws Exception {
+        scriptTest("AppendSelectInbox", Locale.ITALY);
+    }
+    
+    public void testCreateITALY() throws Exception {
+        scriptTest("Create", Locale.ITALY); 
+    }
+    
+    public void testExamineEmptyITALY() throws Exception {
+        scriptTest("ExamineEmpty", Locale.ITALY); 
+    }
+    
+    public void testSelectEmptyITALY() throws Exception {
+        scriptTest("SelectEmpty", Locale.ITALY);
+    }
+        
+    public void testListNamespaceITALY() throws Exception {
+        scriptTest("ListNamespace", Locale.ITALY); 
+    }
+    
+    public void testListMailboxesITALY() throws Exception {
+        scriptTest("ListMailboxes", Locale.ITALY);
+    }
+    
+    public void testStatusITALY() throws Exception {
+        scriptTest("Status", Locale.ITALY); 
+    }
+    
+    public void testSubscribeITALY() throws Exception {
+        scriptTest("Subscribe", Locale.ITALY);
+    }
+    
+    public void testDeleteITALY() throws Exception {
+        scriptTest("Delete", Locale.ITALY); 
+    }
+    
+    public void testAppendITALY() throws Exception {
+        scriptTest("Append", Locale.ITALY);
+    }
+    
+    public void testAppendExpungeITALY() throws Exception {
+        scriptTest("AppendExpunge", Locale.ITALY);
+    }
+    
+    public void testSelectAppendITALY() throws Exception {
+        scriptTest("SelectAppend", Locale.ITALY);
+    }
+    
+    public void testStringArgsITALY() throws Exception {
+        scriptTest("StringArgs", Locale.ITALY);
+    }
+    
+    public void testValidNonAuthenticatedITALY() throws Exception {
+        scriptTest("ValidNonAuthenticated", Locale.ITALY);
+    }
+    
+
+    public void testNoopKOREA() throws Exception {
+        scriptTest("Noop", Locale.KOREA); 
     }
     
-    public void testLogout() throws Exception {
-        scriptTest("Logout"); 
+    public void testLogoutKOREA() throws Exception {
+        scriptTest("Logout", Locale.KOREA); 
     }
     
-    public void testCapability() throws Exception {
-        scriptTest("Capability"); 
+    public void testCapabilityKOREA() throws Exception {
+        scriptTest("Capability", Locale.KOREA); 
     }
     
-    public void testAppendExamineInbox() throws Exception {
-        scriptTest("AppendExamineInbox");
+    public void testAppendExamineInboxKOREA() throws Exception {
+        scriptTest("AppendExamineInbox", Locale.KOREA);
     }
 
-    public void testAppendSelectInbox() throws Exception {
-        scriptTest("AppendSelectInbox");
+    public void testAppendSelectInboxKOREA() throws Exception {
+        scriptTest("AppendSelectInbox", Locale.KOREA);
     }
     
-    public void testCreate() throws Exception {
-        scriptTest("Create"); 
+    public void testCreateKOREA() throws Exception {
+        scriptTest("Create", Locale.KOREA); 
     }
     
-    public void testExamineEmpty() throws Exception {
-        scriptTest("ExamineEmpty"); 
+    public void testExamineEmptyKOREA() throws Exception {
+        scriptTest("ExamineEmpty", Locale.KOREA); 
     }
     
-    public void testSelectEmpty() throws Exception {
-        scriptTest("SelectEmpty");
+    public void testSelectEmptyKOREA() throws Exception {
+        scriptTest("SelectEmpty", Locale.KOREA);
     }
         
-    public void testListNamespace() throws Exception {
-        scriptTest("ListNamespace"); 
+    public void testListNamespaceKOREA() throws Exception {
+        scriptTest("ListNamespace", Locale.KOREA); 
     }
     
-    public void testListMailboxes() throws Exception {
-        scriptTest("ListMailboxes");
+    public void testListMailboxesKOREA() throws Exception {
+        scriptTest("ListMailboxes", Locale.KOREA);
     }
     
-    public void testStatus() throws Exception {
-        scriptTest("Status"); 
+    public void testStatusKOREA() throws Exception {
+        scriptTest("Status", Locale.KOREA); 
     }
     
-    public void testSubscribe() throws Exception {
-        scriptTest("Subscribe");
+    public void testSubscribeKOREA() throws Exception {
+        scriptTest("Subscribe", Locale.KOREA);
     }
     
-    public void testDelete() throws Exception {
-        scriptTest("Delete"); 
+    public void testDeleteKOREA() throws Exception {
+        scriptTest("Delete", Locale.KOREA); 
     }
     
-    public void testAppend() throws Exception {
-        scriptTest("Append");
+    public void testAppendKOREA() throws Exception {
+        scriptTest("Append", Locale.KOREA);
     }
     
-    public void testAppendExpunge() throws Exception {
-        scriptTest("AppendExpunge");
+    public void testAppendExpungeKOREA() throws Exception {
+        scriptTest("AppendExpunge", Locale.KOREA);
     }
     
-    public void testSelectAppend() throws Exception {
-        scriptTest("SelectAppend");
+    public void testSelectAppendKOREA() throws Exception {
+        scriptTest("SelectAppend", Locale.KOREA);
     }
     
-    public void testStringArgs() throws Exception {
-        scriptTest("StringArgs");
+    public void testStringArgsKOREA() throws Exception {
+        scriptTest("StringArgs", Locale.KOREA);
     }
     
-    public void testValidNonAuthenticated() throws Exception {
-        scriptTest("ValidNonAuthenticated");
+    public void testValidNonAuthenticatedKOREA() throws Exception {
+        scriptTest("ValidNonAuthenticated", Locale.KOREA);
     }
+    
 }

Modified: james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractProtocolTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractProtocolTest.java?rev=591779&r1=591778&r2=591779&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractProtocolTest.java (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractProtocolTest.java Sun Nov  4 05:11:12 2007
@@ -19,6 +19,8 @@
 
 package org.apache.james.test.functional.imap;
 
+import java.util.Locale;
+
 import junit.framework.TestCase;
 
 
@@ -41,14 +43,14 @@
     protected ProtocolSession testElements = new ProtocolSession();
     /** The Protocol session which is run after the testElements. */
     protected ProtocolSession postElements = new ProtocolSession();
-
+    
     private final HostSystem hostSystem;
     
     public AbstractProtocolTest( HostSystem hostSystem )
     {
         this.hostSystem = hostSystem;
     }
-
+    
     protected void setUp() throws Exception
     {
         super.setUp();

Modified: james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractTestFetch.java
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractTestFetch.java?rev=591779&r1=591778&r2=591779&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractTestFetch.java (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractTestFetch.java Sun Nov  4 05:11:12 2007
@@ -19,17 +19,35 @@
 
 package org.apache.james.test.functional.imap;
 
+import java.util.Locale;
+
 public abstract class AbstractTestFetch extends BaseTestSelectedState {
 
     public AbstractTestFetch(HostSystem system) {
         super(system);
     }
 
-    public void testFetchText() throws Exception {
-        scriptTest("FetchText");
+    public void testFetchTextUS() throws Exception {
+        scriptTest("FetchText", Locale.US);
+    }
+
+    public void testFetchBodyNoSectionUS() throws Exception {
+        scriptTest("FetchBodyNoSection", Locale.US);
+    }
+    
+    public void testFetchTextIT() throws Exception {
+        scriptTest("FetchText", Locale.ITALY);
+    }
+
+    public void testFetchBodyNoSectionIT() throws Exception {
+        scriptTest("FetchBodyNoSection", Locale.ITALY);
+    }
+    
+    public void testFetchTextKOREA() throws Exception {
+        scriptTest("FetchText", Locale.KOREA);
     }
 
-    public void testFetchBodyNoSection() throws Exception {
-        scriptTest("FetchBodyNoSection");
+    public void testFetchBodyNoSectionKOREA() throws Exception {
+        scriptTest("FetchBodyNoSection", Locale.KOREA);
     }
 }

Modified: james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractTestForNonAuthenticatedState.java
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractTestForNonAuthenticatedState.java?rev=591779&r1=591778&r2=591779&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractTestForNonAuthenticatedState.java (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractTestForNonAuthenticatedState.java Sun Nov  4 05:11:12 2007
@@ -19,6 +19,8 @@
 
 package org.apache.james.test.functional.imap;
 
+import java.util.Locale;
+
 public abstract class AbstractTestForNonAuthenticatedState extends
         BaseTestNonAuthenticatedState {
 
@@ -26,31 +28,88 @@
         super(system);
     }
 
-    public void testNoop() throws Exception {
-        scriptTest("Noop");
+    public void testNoopUS() throws Exception {
+        scriptTest("Noop", Locale.US);
+    }
+    
+    public void testLogoutUS() throws Exception {
+        scriptTest("Logout", Locale.US);
+    }
+    
+    public void testCapabilityUS() throws Exception {
+        scriptTest("Capability", Locale.US);
+    }
+    
+    public void testLoginUS() throws Exception {
+        scriptTest("Login", Locale.US);
+    }
+    
+    public void testValidAuthenticatedUS() throws Exception {
+        scriptTest("ValidAuthenticated", Locale.US);
+    }
+    
+    public void testValidSelectedUS() throws Exception {
+        scriptTest("ValidSelected", Locale.US);
+    }
+    
+    public void testAuthenticateUS() throws Exception {
+        scriptTest("Authenticate", Locale.US);
+    }
+    
+
+    public void testNoopITALY() throws Exception {
+        scriptTest("Noop", Locale.ITALY);
+    }
+    
+    public void testLogoutITALY() throws Exception {
+        scriptTest("Logout", Locale.ITALY);
+    }
+    
+    public void testCapabilityITALY() throws Exception {
+        scriptTest("Capability", Locale.ITALY);
+    }
+    
+    public void testLoginITALY() throws Exception {
+        scriptTest("Login", Locale.ITALY);
+    }
+    
+    public void testValidAuthenticatedITALY() throws Exception {
+        scriptTest("ValidAuthenticated", Locale.ITALY);
+    }
+    
+    public void testValidSelectedITALY() throws Exception {
+        scriptTest("ValidSelected", Locale.ITALY);
+    }
+    
+    public void testAuthenticateITALY() throws Exception {
+        scriptTest("Authenticate", Locale.ITALY);
+    }
+    
+    public void testNoopKOREA() throws Exception {
+        scriptTest("Noop", Locale.KOREA);
     }
     
-    public void testLogout() throws Exception {
-        scriptTest("Logout");
+    public void testLogoutKOREA() throws Exception {
+        scriptTest("Logout", Locale.KOREA);
     }
     
-    public void testCapability() throws Exception {
-        scriptTest("Capability");
+    public void testCapabilityKOREA() throws Exception {
+        scriptTest("Capability", Locale.KOREA);
     }
     
-    public void testLogin() throws Exception {
-        scriptTest("Login");
+    public void testLoginKOREA() throws Exception {
+        scriptTest("Login", Locale.KOREA);
     }
     
-    public void testValidAuthenticated() throws Exception {
-        scriptTest("ValidAuthenticated");
+    public void testValidAuthenticatedKOREA() throws Exception {
+        scriptTest("ValidAuthenticated", Locale.KOREA);
     }
     
-    public void testValidSelected() throws Exception {
-        scriptTest("ValidSelected");
+    public void testValidSelectedKOREA() throws Exception {
+        scriptTest("ValidSelected", Locale.KOREA);
     }
     
-    public void testAuthenticate() throws Exception {
-        scriptTest("Authenticate");
+    public void testAuthenticateKOREA() throws Exception {
+        scriptTest("Authenticate", Locale.KOREA);
     }
 }

Modified: james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractTestSelectedInbox.java
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractTestSelectedInbox.java?rev=591779&r1=591778&r2=591779&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractTestSelectedInbox.java (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractTestSelectedInbox.java Sun Nov  4 05:11:12 2007
@@ -19,66 +19,182 @@
 
 package org.apache.james.test.functional.imap;
 
+import java.util.Locale;
+
 public abstract class AbstractTestSelectedInbox extends BaseTestSelectedInbox {
 
     public AbstractTestSelectedInbox(HostSystem system) {
         super(system);
     }
 
-    public void testValidNonAuthenticated() throws Exception {
-        scriptTest("ValidNonAuthenticated");
+    public void testValidNonAuthenticatedUS() throws Exception {
+        scriptTest("ValidNonAuthenticated", Locale.US);
+    }
+    
+    public void testCapabilityUS() throws Exception {
+        scriptTest("Capability", Locale.US);
+    }
+    
+    public void testNoopUS() throws Exception {
+        scriptTest("Noop", Locale.US);
+    }
+    
+    public void testLogoutUS() throws Exception {
+        scriptTest("Logout", Locale.US);
+    }
+    
+    public void testCreateUS() throws Exception {
+        scriptTest("Create", Locale.US);
+    }
+    
+    public void testExamineEmptyUS() throws Exception {
+        scriptTest("ExamineEmpty", Locale.US);
+    }
+    
+    public void testSelectEmptyUS() throws Exception {
+        scriptTest("SelectEmpty", Locale.US);
+    }
+    
+    public void testListNamespaceUS() throws Exception {
+        scriptTest("ListNamespace", Locale.US);
+    }
+    
+    public void testListMailboxesUS() throws Exception {
+        scriptTest("ListMailboxes", Locale.US);
+    }
+    
+    public void testStatusUS() throws Exception {
+        scriptTest("Status", Locale.US);
+    }
+    
+    public void testStringArgsUS() throws Exception {
+        scriptTest("StringArgs", Locale.US);
+    }
+    
+    public void testSubscribeUS() throws Exception {
+        scriptTest("Subscribe", Locale.US);
+    }
+    
+    public void testAppendUS() throws Exception {
+        scriptTest("Append", Locale.US);
+    }
+    
+    public void testDeleteUS() throws Exception {
+        scriptTest("Delete", Locale.US);
+    }
+    
+
+    public void testValidNonAuthenticatedITALY() throws Exception {
+        scriptTest("ValidNonAuthenticated", Locale.ITALY);
+    }
+    
+    public void testCapabilityITALY() throws Exception {
+        scriptTest("Capability", Locale.ITALY);
+    }
+    
+    public void testNoopITALY() throws Exception {
+        scriptTest("Noop", Locale.ITALY);
+    }
+    
+    public void testLogoutITALY() throws Exception {
+        scriptTest("Logout", Locale.ITALY);
+    }
+    
+    public void testCreateITALY() throws Exception {
+        scriptTest("Create", Locale.ITALY);
+    }
+    
+    public void testExamineEmptyITALY() throws Exception {
+        scriptTest("ExamineEmpty", Locale.ITALY);
+    }
+    
+    public void testSelectEmptyITALY() throws Exception {
+        scriptTest("SelectEmpty", Locale.ITALY);
+    }
+    
+    public void testListNamespaceITALY() throws Exception {
+        scriptTest("ListNamespace", Locale.ITALY);
+    }
+    
+    public void testListMailboxesITALY() throws Exception {
+        scriptTest("ListMailboxes", Locale.ITALY);
+    }
+    
+    public void testStatITALYITALY() throws Exception {
+        scriptTest("StatITALY", Locale.ITALY);
+    }
+    
+    public void testStringArgsITALY() throws Exception {
+        scriptTest("StringArgs", Locale.ITALY);
+    }
+    
+    public void testSubscribeITALY() throws Exception {
+        scriptTest("Subscribe", Locale.ITALY);
+    }
+    
+    public void testAppendITALY() throws Exception {
+        scriptTest("Append", Locale.ITALY);
+    }
+    
+    public void testDeleteITALY() throws Exception {
+        scriptTest("Delete", Locale.ITALY);
+    }
+    
+
+    public void testValidNonAuthenticatedKOREA() throws Exception {
+        scriptTest("ValidNonAuthenticated", Locale.KOREA);
     }
     
-    public void testCapability() throws Exception {
-        scriptTest("Capability");
+    public void testCapabilityKOREA() throws Exception {
+        scriptTest("Capability", Locale.KOREA);
     }
     
-    public void testNoop() throws Exception {
-        scriptTest("Noop");
+    public void testNoopKOREA() throws Exception {
+        scriptTest("Noop", Locale.KOREA);
     }
     
-    public void testLogout() throws Exception {
-        scriptTest("Logout");
+    public void testLogoutKOREA() throws Exception {
+        scriptTest("Logout", Locale.KOREA);
     }
     
-    public void testCreate() throws Exception {
-        scriptTest("Create");
+    public void testCreateKOREA() throws Exception {
+        scriptTest("Create", Locale.KOREA);
     }
     
-    public void testExamineEmpty() throws Exception {
-        scriptTest("ExamineEmpty");
+    public void testExamineEmptyKOREA() throws Exception {
+        scriptTest("ExamineEmpty", Locale.KOREA);
     }
     
-    public void testSelectEmpty() throws Exception {
-        scriptTest("SelectEmpty");
+    public void testSelectEmptyKOREA() throws Exception {
+        scriptTest("SelectEmpty", Locale.KOREA);
     }
     
-    public void testListNamespace() throws Exception {
-        scriptTest("ListNamespace");
+    public void testListNamespaceKOREA() throws Exception {
+        scriptTest("ListNamespace", Locale.KOREA);
     }
     
-    public void testListMailboxes() throws Exception {
-        scriptTest("ListMailboxes");
+    public void testListMailboxesKOREA() throws Exception {
+        scriptTest("ListMailboxes", Locale.KOREA);
     }
     
-    public void testStatus() throws Exception {
-        scriptTest("Status");
+    public void testStatKOREAKOREA() throws Exception {
+        scriptTest("StatKOREA", Locale.KOREA);
     }
     
-    public void testStringArgs() throws Exception {
-        scriptTest("StringArgs");
+    public void testStringArgsKOREA() throws Exception {
+        scriptTest("StringArgs", Locale.KOREA);
     }
     
-    public void testSubscribe() throws Exception {
-        scriptTest("Subscribe");
+    public void testSubscribeKOREA() throws Exception {
+        scriptTest("Subscribe", Locale.KOREA);
     }
     
-    public void testAppend() throws Exception {
-        scriptTest("Append");
+    public void testAppendKOREA() throws Exception {
+        scriptTest("Append", Locale.KOREA);
     }
     
-    public void testDelete() throws Exception {
-        scriptTest("Delete");
+    public void testDeleteKOREA() throws Exception {
+        scriptTest("Delete", Locale.KOREA);
     }
     
 }

Modified: james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractTestSelectedState.java
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractTestSelectedState.java?rev=591779&r1=591778&r2=591779&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractTestSelectedState.java (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractTestSelectedState.java Sun Nov  4 05:11:12 2007
@@ -19,45 +19,121 @@
 
 package org.apache.james.test.functional.imap;
 
+import java.util.Locale;
+
 public abstract class AbstractTestSelectedState extends BaseTestSelectedState {
 
     public AbstractTestSelectedState(HostSystem system) {
         super(system);
     }
 
-    public void testCheck() throws Exception {
-        scriptTest("Check");
+    public void testCheckUS() throws Exception {
+        scriptTest("Check", Locale.US);
+    }
+    
+    public void testExpungeUS() throws Exception {
+        scriptTest("Expunge", Locale.US);
+    }
+    
+    public void testSearchUS() throws Exception {
+        scriptTest("Search", Locale.US);
+    }
+    
+    public void testFetchSingleMessageUS() throws Exception {
+        scriptTest("FetchSingleMessage", Locale.US);
+    }
+    
+    public void testFetchMultipleMessagesUS() throws Exception {
+        scriptTest("FetchMultipleMessages", Locale.US);
+    }
+    
+    public void testFetchPeekUS() throws Exception {
+        scriptTest("FetchPeek", Locale.US);
+    }
+    
+    public void testStoreUS() throws Exception {
+        scriptTest("Store", Locale.US);
+    }
+    
+    public void testCopyUS() throws Exception {
+        scriptTest("Copy", Locale.US);
+    }
+    
+    public void testUidUS() throws Exception {
+        scriptTest("Uid", Locale.US);
+    }
+    
+
+    public void testCheckITALY() throws Exception {
+        scriptTest("Check", Locale.ITALY);
+    }
+    
+    public void testExpungeITALY() throws Exception {
+        scriptTest("Expunge", Locale.ITALY);
+    }
+    
+    public void testSearchITALY() throws Exception {
+        scriptTest("Search", Locale.ITALY);
+    }
+    
+    public void testFetchSingleMessageITALY() throws Exception {
+        scriptTest("FetchSingleMessage", Locale.ITALY);
+    }
+    
+    public void testFetchMultipleMessagesITALY() throws Exception {
+        scriptTest("FetchMultipleMessages", Locale.ITALY);
+    }
+    
+    public void testFetchPeekITALY() throws Exception {
+        scriptTest("FetchPeek", Locale.ITALY);
+    }
+    
+    public void testStoreITALY() throws Exception {
+        scriptTest("Store", Locale.ITALY);
+    }
+    
+    public void testCopyITALY() throws Exception {
+        scriptTest("Copy", Locale.ITALY);
+    }
+    
+    public void testUidITALY() throws Exception {
+        scriptTest("Uid", Locale.ITALY);
+    }
+    
+
+    public void testCheckKOREA() throws Exception {
+        scriptTest("Check", Locale.KOREA);
     }
     
-    public void testExpunge() throws Exception {
-        scriptTest("Expunge");
+    public void testExpungeKOREA() throws Exception {
+        scriptTest("Expunge", Locale.KOREA);
     }
     
-    public void testSearch() throws Exception {
-        scriptTest("Search");
+    public void testSearchKOREA() throws Exception {
+        scriptTest("Search", Locale.KOREA);
     }
     
-    public void testFetchSingleMessage() throws Exception {
-        scriptTest("FetchSingleMessage");
+    public void testFetchSingleMessageKOREA() throws Exception {
+        scriptTest("FetchSingleMessage", Locale.KOREA);
     }
     
-    public void testFetchMultipleMessages() throws Exception {
-        scriptTest("FetchMultipleMessages");
+    public void testFetchMultipleMessagesKOREA() throws Exception {
+        scriptTest("FetchMultipleMessages", Locale.KOREA);
     }
     
-    public void testFetchPeek() throws Exception {
-        scriptTest("FetchPeek");
+    public void testFetchPeekKOREA() throws Exception {
+        scriptTest("FetchPeek", Locale.KOREA);
     }
     
-    public void testStore() throws Exception {
-        scriptTest("Store");
+    public void testStoreKOREA() throws Exception {
+        scriptTest("Store", Locale.KOREA);
     }
     
-    public void testCopy() throws Exception {
-        scriptTest("Copy");
+    public void testCopyKOREA() throws Exception {
+        scriptTest("Copy", Locale.KOREA);
     }
     
-    public void testUid() throws Exception {
-        scriptTest("Uid");
+    public void testUidKOREA() throws Exception {
+        scriptTest("Uid", Locale.KOREA);
     }
 }

Modified: james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/SimpleScriptedTestProtocol.java
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/SimpleScriptedTestProtocol.java?rev=591779&r1=591778&r2=591779&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/SimpleScriptedTestProtocol.java (original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/SimpleScriptedTestProtocol.java Sun Nov  4 05:11:12 2007
@@ -21,6 +21,7 @@
 package org.apache.james.test.functional.imap;
 
 import java.io.InputStream;
+import java.util.Locale;
 
 /**
  * A Protocol test which reads the test protocol session from a file. The
@@ -31,10 +32,12 @@
  */
 public class SimpleScriptedTestProtocol
         extends AbstractProtocolTest
-{
+{    
     private FileProtocolSessionBuilder builder =
             new FileProtocolSessionBuilder();
 
+    private static final Locale BASE_DEFAULT_LOCALE = Locale.getDefault();
+    
     /**
      * Sets up a SimpleFileProtocolTest which reads the protocol session from
      * a file of name "<fileName>.test". This file should be available in the classloader
@@ -46,12 +49,21 @@
         super( hostSystem );
     }
 
+    protected void tearDown() throws Exception {
+        Locale.setDefault(BASE_DEFAULT_LOCALE);
+        super.tearDown();
+    }
+
+
+
     /**
      * Reads test elements from the protocol session file and adds them to the
      * {@link #testElements} ProtocolSession. Then calls {@link #runSessions}.
+     * @param locale TODO
      */
-    protected void scriptTest(String fileName) throws Exception
+    protected void scriptTest(String fileName, Locale locale) throws Exception
     {
+        Locale.setDefault(locale);
         addTestFile( fileName + ".test", testElements );
         runSessions();
     }

Modified: james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/decode/DecoderUtils.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/decode/DecoderUtils.java?rev=591779&r1=591778&r2=591779&view=diff
==============================================================================
--- james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/decode/DecoderUtils.java (original)
+++ james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/decode/DecoderUtils.java Sun Nov  4 05:11:12 2007
@@ -19,8 +19,15 @@
 
 package org.apache.james.imapserver.codec.decode;
 
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.Locale;
+import java.util.TimeZone;
+
 import javax.mail.Flags;
 
+import org.apache.james.api.imap.ProtocolException;
 import org.apache.james.api.imap.message.MessageFlags;
 
 /**
@@ -28,6 +35,23 @@
  */
 public final class DecoderUtils {
 
+    private static final int ASCII_ZERO = '0';
+    
+    private static final int JAN_BIT = 0x1;
+    private static final int FEB_BIT = 0x2;
+    private static final int MAR_BIT = 0x4;
+    private static final int APR_BIT = 0x8;
+    private static final int MAY_BIT = 0x10;
+    private static final int JUN_BIT = 0x20;
+    private static final int JUL_BIT = 0x40;
+    private static final int AUG_BIT = 0x80;
+    private static final int SEP_BIT = 0x100;
+    private static final int OCT_BIT = 0x200;
+    private static final int NOV_BIT = 0x400;
+    private static final int DEC_BIT = 0x800;
+    private static final int ALL_MONTH_BITS = JAN_BIT | FEB_BIT | MAR_BIT | APR_BIT | MAY_BIT | JUN_BIT 
+                                        | JUL_BIT | AUG_BIT | SEP_BIT | OCT_BIT | NOV_BIT | DEC_BIT;
+    
     public static void setFlag( final String flagString, final Flags flags )  {
         if ( flagString.equalsIgnoreCase( MessageFlags.ANSWERED ) ) {
             flags.add(Flags.Flag.ANSWERED);
@@ -52,5 +76,327 @@
                 flags.add(flagString);
             }
         }
+    }
+
+    /**
+     * Decodes the given string as a standard IMAP date-time.
+     * @param dateString standard IMAP date-time
+     * @return <code>Date</code> with time component, not null
+     * @throws ProtocolException when this conversion fails
+     */
+    public static final Date decodeDateTime(CharSequence chars) throws ProtocolException {
+        final char dayHigh = chars.charAt(0);
+        final char dayLow = chars.charAt(1);
+        final int day = decodeFixedDay(dayHigh, dayLow);
+        
+        final char monthFirstChar = chars.charAt(3);
+        final char monthSecondChar = chars.charAt(4);
+        final char monthThirdChar = chars.charAt(5);
+        final int month = decodeMonth(monthFirstChar, monthSecondChar, monthThirdChar);
+        
+        final char milleniumChar = chars.charAt(7);
+        final char centuryChar = chars.charAt(8);
+        final char decadeChar = chars.charAt(9);
+        final char yearChar = chars.charAt(10);
+        final int year = decodeYear(milleniumChar, centuryChar, decadeChar, yearChar);
+        
+        final char zoneDeterminent = chars.charAt(21);
+        final char zoneDigitOne = chars.charAt(22);
+        final char zoneDigitTwo = chars.charAt(23);
+        final char zoneDigitThree = chars.charAt(24);
+        final char zoneDigitFour = chars.charAt(25);
+        final int offset = decodeZone(zoneDeterminent, zoneDigitOne, zoneDigitTwo, zoneDigitThree, zoneDigitFour);
+        
+        final char hourHigh = chars.charAt(12);
+        final char hourLow = chars.charAt(13);
+        final int hour = applyHourOffset(offset, decodeNumber(hourHigh, hourLow));
+        
+        final char minuteHigh = chars.charAt(15);
+        final char minuteLow = chars.charAt(16);
+        final int minute = applyMinuteOffset(offset, decodeNumber(minuteHigh, minuteLow));
+        
+        final char secondHigh = chars.charAt(18);
+        final char secondLow = chars.charAt(19);
+        final int second = decodeNumber(secondHigh, secondLow);
+                
+        final GregorianCalendar calendar = new GregorianCalendar(TimeZone.getTimeZone("GMT"), Locale.US);
+        calendar.clear();
+        calendar.set(year, month, day, hour, minute, second);
+        final Date result = calendar.getTime();
+        return result;
+    }
+    
+    private static int applyMinuteOffset(final int offset, final int minutes) {
+        final int result =  minutes - ((Math.abs(offset) % 100) * (int) Math.signum(offset));
+        return result;
+    }
+    
+    private static int applyHourOffset(final int offset, final int hours) {
+        final int result = hours - (offset / 100);
+        return result;
+    }
+    
+    public static int decodeNumber(final char high, final char low) throws ProtocolException {
+        return (10 * decodeDigit(high)) + decodeDigit(low);
+    }
+    
+    public static int decodeZone(char zoneDeterminent, char zoneDigitOne, 
+            char zoneDigitTwo, char zoneDigitThree, char zoneDigitFour) throws ProtocolException {
+        if (isInvalidZone(zoneDeterminent, zoneDigitOne, zoneDigitTwo, 
+                zoneDigitThree, zoneDigitFour)) {
+            throw createTimeZoneException(zoneDeterminent, zoneDigitOne, zoneDigitTwo, zoneDigitThree, zoneDigitFour);
+        }
+        final int sign;
+        if (zoneDeterminent == '+') {
+            sign = 1;
+        } else if (zoneDeterminent == '-') {
+            sign = -1;
+        } else {
+            throw createTimeZoneException(zoneDeterminent, zoneDigitOne, zoneDigitTwo, zoneDigitThree, zoneDigitFour);
+        }
+        final int result = sign * ((1000 * decodeDigit(zoneDigitOne)) +
+                (100 * decodeDigit(zoneDigitTwo)) +
+                (10 * decodeDigit(zoneDigitThree)) +
+                decodeDigit(zoneDigitFour));
+        return result;
+    }
+
+    private static ProtocolException createTimeZoneException(char zoneDeterminent, char zoneDigitOne, char zoneDigitTwo, char zoneDigitThree, char zoneDigitFour) {
+        return new ProtocolException ("Expected time-zone but was " + zoneDeterminent + 
+                zoneDigitOne + zoneDigitTwo + zoneDigitThree + zoneDigitFour);
+    }
+
+    private static boolean isInvalidZone(char zoneDeterminent, char zoneDigitOne, 
+            char zoneDigitTwo, char zoneDigitThree, char zoneDigitFour) {
+        final boolean result;
+        if (zoneDeterminent == '+' || zoneDeterminent == '-') {
+            result = !(isSimpleDigit(zoneDigitOne) && isSimpleDigit(zoneDigitTwo)
+                    && isSimpleDigit(zoneDigitThree) && isSimpleDigit(zoneDigitFour));
+        } else {
+            result = true;
+        }
+        return result;
+    }
+    
+    /**
+     * Is the given character an ASCII digit.
+     * @param character character
+     * @return true if ASCII 0-9, false otherwise
+     */
+    public static boolean isSimpleDigit(char character) {
+        final boolean result = !(character < '0' || character > '9');
+        return result;
+    }
+    
+    /**
+     * Decodes a year.
+     * @param milleniumChar first digit
+     * @param centuryChar second digit
+     * @param decadeChar third digit
+     * @param yearChar forth digit
+     * @return {@link Calendar} year
+     * @throws ProtocolException
+     */
+    public static int decodeYear(final char milleniumChar, final char centuryChar, final char decadeChar, final char yearChar) throws ProtocolException {
+        return (decodeDigit(milleniumChar) * 1000) +
+                        (decodeDigit(centuryChar) * 100) +
+                        (decodeDigit(decadeChar) * 10) +
+                        decodeDigit(yearChar);
+    }
+
+    /**
+     * Decodes asn IMAP <code>date-month</code> to a {@link Calendar} month.
+     * @param monthFirstChar first character in a month triple
+     * @param monthSecondChar second character in a month triple
+     * @param monthThirdChar third character in a month triple
+     * @return {@link Calendar} month (<code>JAN</code>=0)
+     * @throws ProtocolException
+     */
+    public static int decodeMonth(final char monthFirstChar, final char monthSecondChar, final char monthThirdChar) throws ProtocolException {
+        final int result;
+        // Bitwise magic! Eliminate possibility by three switches
+        int possibleMonths = ALL_MONTH_BITS;
+        switch (monthFirstChar) {
+            case 'J':
+            case 'j':
+                possibleMonths &= (JAN_BIT | JUN_BIT | JUL_BIT);
+                break;
+            case 'F':
+            case 'f':
+                possibleMonths &= FEB_BIT;
+                break;
+            case 'M':
+            case 'm':
+                possibleMonths &= (MAR_BIT | MAY_BIT);
+                break;
+            case 'A':
+            case 'a':
+                possibleMonths &= (APR_BIT | AUG_BIT);
+                break;
+            case 'S':
+            case 's':
+                possibleMonths &= SEP_BIT;
+                break;
+            case 'O':
+            case 'o':
+                possibleMonths &= OCT_BIT;
+                break;
+            case 'N':
+            case 'n':
+                possibleMonths &= NOV_BIT;
+                break;
+            case 'D':
+            case 'd':
+                possibleMonths &= DEC_BIT;
+                break;
+            default:
+                possibleMonths = 0;   
+                break;
+        }
+        switch (monthSecondChar) {
+            case 'A':
+            case 'a':
+                possibleMonths &= (JAN_BIT | MAR_BIT | MAY_BIT);
+                break;
+            case 'E':
+            case 'e':
+                possibleMonths &= (FEB_BIT | SEP_BIT | DEC_BIT);
+                break;
+            case 'P':
+            case 'p':
+                possibleMonths &= (APR_BIT);
+                break;
+            case 'U':
+            case 'u':
+                possibleMonths &= (JUN_BIT | JUL_BIT | AUG_BIT);
+                break;
+            case 'C':
+            case 'c':
+                possibleMonths &= OCT_BIT;
+                break;
+            case 'O':
+            case 'o':
+                possibleMonths &= NOV_BIT;
+                break;
+            default:
+                possibleMonths = 0;
+                break;
+        }
+        switch (monthThirdChar) {
+            case 'N':
+            case 'n':
+                possibleMonths &= (JAN_BIT | JUN_BIT);
+                break;
+            case 'B':
+            case 'b':
+                possibleMonths &= FEB_BIT;
+                break;
+            case 'R':
+            case 'r':
+                possibleMonths &= (MAR_BIT | APR_BIT);
+                break;
+            case 'Y':
+            case 'y':
+                possibleMonths &= MAY_BIT;
+                break;
+            case 'L':
+            case 'l':
+                possibleMonths &= JUL_BIT;
+                break;
+            case 'G':
+            case 'g':
+                possibleMonths &= AUG_BIT;
+                break;
+            case 'P':
+            case 'p':
+                possibleMonths &= SEP_BIT;
+                break;
+            case 'T':
+            case 't':
+                possibleMonths &= OCT_BIT;
+                break;
+            case 'V':
+            case 'v':
+                possibleMonths &= NOV_BIT;
+                break;
+            case 'C':
+            case 'c':
+                possibleMonths &= DEC_BIT;
+                break;
+            default:
+                possibleMonths = 0;
+                break;
+        }
+        switch (possibleMonths) {
+            case JAN_BIT:
+                result = Calendar.JANUARY;
+                break;
+            case FEB_BIT:
+                result = Calendar.FEBRUARY;
+                break;
+            case MAR_BIT:
+                result = Calendar.MARCH;
+                break;
+            case APR_BIT:
+                result = Calendar.APRIL;
+                break;
+            case MAY_BIT:
+                result = Calendar.MAY;
+                break;
+            case JUN_BIT:
+                result = Calendar.JUNE;
+                break;
+            case JUL_BIT:
+                result = Calendar.JULY;
+                break;
+            case AUG_BIT:
+                result = Calendar.AUGUST;
+                break;
+            case SEP_BIT:
+                result = Calendar.SEPTEMBER;
+                break;
+            case OCT_BIT:
+                result = Calendar.OCTOBER;
+                break;
+            case NOV_BIT:
+                result = Calendar.NOVEMBER;
+                break;
+            case DEC_BIT:
+                result = Calendar.DECEMBER;
+                break;
+            default:
+                throw new ProtocolException("Expected month name but was " 
+                        + monthFirstChar + monthSecondChar + monthThirdChar);
+        }
+        return result;
+    }
+
+
+    private static int decodeFixedDay(final char dayHigh, final char dayLow) throws ProtocolException {
+        int result = decodeDigit(dayLow);
+        if (dayHigh == '1') {
+            result += 10;
+        } else if (dayHigh == '2') {
+            result += 20;
+        } else if (dayHigh == '3') {
+            result += 30;
+        } else if (dayHigh != ' ') {
+            throw new ProtocolException("Expected SP, 1, 2, or 3 but was " + dayHigh);
+        }
+        return result;
+    }
+    
+    /**
+     * Decodes a number character into a <code>0-9</code> digit.
+     * @param character
+     * @return a digit
+     * @throws ProtocolException if the char is not a digit
+     */
+    public static final int decodeDigit(char character) throws ProtocolException {
+        final int result = character - ASCII_ZERO;
+        if (result < 0 || result > 9) {
+            throw new ProtocolException("Expected a digit but was '" + character + "'");
+        }
+        return result;
     }
 }

Modified: james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/decode/base/AbstractImapCommandParser.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/decode/base/AbstractImapCommandParser.java?rev=591779&r1=591778&r2=591779&view=diff
==============================================================================
--- james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/decode/base/AbstractImapCommandParser.java (original)
+++ james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/decode/base/AbstractImapCommandParser.java Sun Nov  4 05:11:12 2007
@@ -19,9 +19,6 @@
 
 package org.apache.james.imapserver.codec.decode.base;
 
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
 
@@ -202,37 +199,7 @@
             throw new ProtocolException( "DateTime values must be quoted." );
         }
 
-        DateFormat dateFormat = new SimpleDateFormat( "dd-MMM-yyyy hh:mm:ss zzzz" );
-        try {
-            return dateFormat.parse( dateString );
-        }
-        catch ( ParseException e ) {
-            throw new ProtocolException( "Invalid date format.", e);
-        }
-    }
-
-    /**
-     * Reads a "date" argument from the request.
-     * TODO handle timezones properly
-     */
-    public Date date( ImapRequestLineReader request ) throws ProtocolException
-    {
-        char next = request.nextWordChar();
-        String dateString;
-        if ( next == '"' ) {
-            dateString = consumeQuoted( request );
-        }
-        else {
-            dateString = atom( request );
-        }
-
-        DateFormat dateFormat = new SimpleDateFormat( "dd-MMM-yyyy" );
-        try {
-            return dateFormat.parse( dateString );
-        }
-        catch ( ParseException e ) {
-            throw new ProtocolException( "Invalid date format.", e);
-        }
+        return DecoderUtils.decodeDateTime(dateString);
     }
 
     /**

Added: james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/decode/DecoderUtilsLocaleDateTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/decode/DecoderUtilsLocaleDateTest.java?rev=591779&view=auto
==============================================================================
--- james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/decode/DecoderUtilsLocaleDateTest.java (added)
+++ james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/decode/DecoderUtilsLocaleDateTest.java Sun Nov  4 05:11:12 2007
@@ -0,0 +1,191 @@
+/****************************************************************
+ * 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.imapserver.codec.decode;
+
+import java.util.Locale;
+
+import junit.framework.TestCase;
+
+public class DecoderUtilsLocaleDateTest extends TestCase {
+
+    private static final Locale BASE_DEFAULT_LOCALE = Locale.getDefault();
+    
+    protected void setUp() throws Exception {
+        super.setUp();
+    }
+
+    protected void tearDown() throws Exception {
+        Locale.setDefault(BASE_DEFAULT_LOCALE);
+        super.tearDown();
+    }
+    
+    public void testUS() throws Exception {
+        runTests(Locale.US);
+    }
+    
+    public void testITALY() throws Exception {
+        runTests(Locale.ITALY);
+    }
+    
+    public void testTAIWAN() throws Exception {
+        runTests(Locale.TAIWAN);
+    }
+    
+    public void testCHINA() throws Exception {
+        runTests(Locale.CHINA);
+    }
+    
+    public void testKOREA() throws Exception {
+        runTests(Locale.KOREA);
+    }
+    
+    public void testJAPAN() throws Exception {
+        runTests(Locale.JAPAN);
+    }
+    
+    public void testUK() throws Exception {
+        runTests(Locale.UK);
+    }
+    
+    public void testCANADA() throws Exception {
+        runTests(Locale.CANADA);
+    }
+    
+    public void testGERMANY() throws Exception {
+        runTests(Locale.GERMANY);
+    }
+    
+    public void testFRANCH() throws Exception {
+        runTests(Locale.FRANCE);
+    }
+    
+    private void runTests(Locale locale) throws Exception {
+        Locale.setDefault(locale);
+        decodeDateTime();
+    }
+
+    private void decodeDateTime() throws Exception {
+        assertEquals("21 Oct 1972 20:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +0000").toGMTString());
+        assertEquals("21 Oct 1972 19:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +0100").toGMTString());
+        assertEquals("21 Oct 1972 18:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +0200").toGMTString());
+        assertEquals("21 Oct 1972 17:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +0300").toGMTString());
+        assertEquals("21 Oct 1972 16:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +0400").toGMTString());
+        assertEquals("21 Oct 1972 15:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +0500").toGMTString());
+        assertEquals("21 Oct 1972 14:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +0600").toGMTString());
+        assertEquals("21 Oct 1972 13:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +0700").toGMTString());
+        assertEquals("21 Oct 1972 12:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +0800").toGMTString());
+        assertEquals("21 Oct 1972 11:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +0900").toGMTString());
+        assertEquals("21 Oct 1972 10:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +1000").toGMTString());
+        assertEquals("21 Oct 1972 09:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +1100").toGMTString());
+        assertEquals("21 Oct 1972 08:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +1200").toGMTString());        
+        
+        assertEquals("21 Oct 1972 10:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +1000").toGMTString());
+        assertEquals("21 Oct 1972 21:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 -0100").toGMTString());
+        assertEquals("21 Oct 1972 22:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 -0200").toGMTString());
+        assertEquals("21 Oct 1972 23:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 -0300").toGMTString());
+        assertEquals("22 Oct 1972 00:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 -0400").toGMTString());
+        assertEquals("22 Oct 1972 01:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 -0500").toGMTString());
+        assertEquals("22 Oct 1972 02:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 -0600").toGMTString());
+        assertEquals("22 Oct 1972 03:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 -0700").toGMTString());
+        assertEquals("22 Oct 1972 04:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 -0800").toGMTString());
+        assertEquals("22 Oct 1972 05:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 -0900").toGMTString());
+        assertEquals("22 Oct 1972 06:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 -1000").toGMTString());
+        
+        assertEquals("21 Oct 1972 19:30:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +0030").toGMTString());
+        assertEquals("21 Oct 1972 18:30:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +0130").toGMTString());
+        assertEquals("21 Oct 1972 17:30:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +0230").toGMTString());
+        assertEquals("21 Oct 1972 16:30:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +0330").toGMTString());
+        assertEquals("21 Oct 1972 15:30:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +0430").toGMTString());
+        assertEquals("21 Oct 1972 14:30:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +0530").toGMTString());
+        assertEquals("21 Oct 1972 13:30:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +0630").toGMTString());
+        assertEquals("21 Oct 1972 12:30:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +0730").toGMTString());
+        assertEquals("21 Oct 1972 11:30:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +0830").toGMTString());
+        assertEquals("21 Oct 1972 10:30:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +0930").toGMTString());
+        assertEquals("21 Oct 1972 09:30:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +1030").toGMTString());
+        assertEquals("21 Oct 1972 08:30:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +1130").toGMTString());
+        assertEquals("21 Oct 1972 07:30:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +1230").toGMTString());        
+        
+        assertEquals("21 Oct 1972 20:30:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 -0030").toGMTString());
+        assertEquals("21 Oct 1972 21:30:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 -0130").toGMTString());
+        assertEquals("21 Oct 1972 22:30:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 -0230").toGMTString());
+        assertEquals("21 Oct 1972 23:30:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 -0330").toGMTString());
+        assertEquals("22 Oct 1972 00:30:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 -0430").toGMTString());
+        assertEquals("22 Oct 1972 01:30:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 -0530").toGMTString());
+        assertEquals("22 Oct 1972 02:30:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 -0630").toGMTString());
+        assertEquals("22 Oct 1972 03:30:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 -0730").toGMTString());
+        assertEquals("22 Oct 1972 04:30:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 -0830").toGMTString());
+        assertEquals("22 Oct 1972 05:30:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 -0930").toGMTString());
+        assertEquals("22 Oct 1972 06:30:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 -1030").toGMTString());
+        
+        assertEquals("21 Oct 1972 20:16:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 +0000").toGMTString());
+        assertEquals("21 Oct 1972 19:16:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 +0100").toGMTString());
+        assertEquals("21 Oct 1972 18:16:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 +0200").toGMTString());
+        assertEquals("21 Oct 1972 17:16:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 +0300").toGMTString());
+        assertEquals("21 Oct 1972 16:16:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 +0400").toGMTString());
+        assertEquals("21 Oct 1972 15:16:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 +0500").toGMTString());
+        assertEquals("21 Oct 1972 14:16:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 +0600").toGMTString());
+        assertEquals("21 Oct 1972 13:16:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 +0700").toGMTString());
+        assertEquals("21 Oct 1972 12:16:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 +0800").toGMTString());
+        assertEquals("21 Oct 1972 11:16:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 +0900").toGMTString());
+        assertEquals("21 Oct 1972 10:16:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 +1000").toGMTString());
+        assertEquals("21 Oct 1972 09:16:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 +1100").toGMTString());
+        assertEquals("21 Oct 1972 08:16:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 +1200").toGMTString());        
+        
+        assertEquals("21 Oct 1972 20:16:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 -0000").toGMTString());
+        assertEquals("21 Oct 1972 21:16:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 -0100").toGMTString());
+        assertEquals("21 Oct 1972 22:16:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 -0200").toGMTString());
+        assertEquals("21 Oct 1972 23:16:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 -0300").toGMTString());
+        assertEquals("22 Oct 1972 00:16:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 -0400").toGMTString());
+        assertEquals("22 Oct 1972 01:16:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 -0500").toGMTString());
+        assertEquals("22 Oct 1972 02:16:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 -0600").toGMTString());
+        assertEquals("22 Oct 1972 03:16:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 -0700").toGMTString());
+        assertEquals("22 Oct 1972 04:16:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 -0800").toGMTString());
+        assertEquals("22 Oct 1972 05:16:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 -0900").toGMTString());
+        assertEquals("22 Oct 1972 06:16:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 -1000").toGMTString());
+        
+        assertEquals("21 Oct 1972 19:46:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 +0030").toGMTString());
+        assertEquals("21 Oct 1972 18:46:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 +0130").toGMTString());
+        assertEquals("21 Oct 1972 17:46:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 +0230").toGMTString());
+        assertEquals("21 Oct 1972 16:46:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 +0330").toGMTString());
+        assertEquals("21 Oct 1972 15:46:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 +0430").toGMTString());
+        assertEquals("21 Oct 1972 14:46:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 +0530").toGMTString());
+        assertEquals("21 Oct 1972 13:46:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 +0630").toGMTString());
+        assertEquals("21 Oct 1972 12:46:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 +0730").toGMTString());
+        assertEquals("21 Oct 1972 11:46:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 +0830").toGMTString());
+        assertEquals("21 Oct 1972 10:46:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 +0930").toGMTString());
+        assertEquals("21 Oct 1972 09:46:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 +1030").toGMTString());
+        assertEquals("21 Oct 1972 08:46:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 +1130").toGMTString());
+        assertEquals("21 Oct 1972 07:46:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 +1230").toGMTString());        
+        
+        assertEquals("21 Oct 1972 20:46:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 -0030").toGMTString());
+        assertEquals("21 Oct 1972 21:46:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 -0130").toGMTString());
+        assertEquals("21 Oct 1972 22:46:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 -0230").toGMTString());
+        assertEquals("21 Oct 1972 23:46:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 -0330").toGMTString());
+        assertEquals("22 Oct 1972 00:46:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 -0430").toGMTString());
+        assertEquals("22 Oct 1972 01:46:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 -0530").toGMTString());
+        assertEquals("22 Oct 1972 02:46:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 -0630").toGMTString());
+        assertEquals("22 Oct 1972 03:46:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 -0730").toGMTString());
+        assertEquals("22 Oct 1972 04:46:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 -0830").toGMTString());
+        assertEquals("22 Oct 1972 05:46:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 -0930").toGMTString());
+        assertEquals("22 Oct 1972 06:46:27 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:16:27 -1030").toGMTString());
+        
+        
+    }
+}

Modified: james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/decode/DecoderUtilsTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/decode/DecoderUtilsTest.java?rev=591779&r1=591778&r2=591779&view=diff
==============================================================================
--- james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/decode/DecoderUtilsTest.java (original)
+++ james/server/trunk/imap-codec-library/src/test/java/org/apache/james/imapserver/codec/decode/DecoderUtilsTest.java Sun Nov  4 05:11:12 2007
@@ -19,10 +19,18 @@
 
 package org.apache.james.imapserver.codec.decode;
 
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Locale;
+import java.util.TimeZone;
+
 import javax.mail.Flags;
 
 import junit.framework.TestCase;
 
+import org.apache.commons.lang.time.FastDateFormat;
+import org.apache.james.api.imap.ProtocolException;
+
 public class DecoderUtilsTest extends TestCase {
     
     private static final String EXTENSION_FLAG = "\\Extension";
@@ -54,5 +62,361 @@
         Flags flags = new Flags();
         DecoderUtils.setFlag(EXTENSION_FLAG, flags);
         assertTrue("Extension flags should be added", flags.contains(EXTENSION_FLAG));
+    }
+    
+    public void testSimpleDecodeDateTime() throws Exception {
+        assertEquals("21 Oct 1972 20:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +0000").toGMTString());
+        assertEquals("21 Oct 1972 19:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +0100").toGMTString());
+        assertEquals("21 Oct 1972 18:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +0200").toGMTString());
+        assertEquals("21 Oct 1972 17:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +0300").toGMTString());
+        assertEquals("21 Oct 1972 16:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +0400").toGMTString());
+        assertEquals("21 Oct 1972 15:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +0500").toGMTString());
+        assertEquals("21 Oct 1972 14:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +0600").toGMTString());
+        assertEquals("21 Oct 1972 13:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +0700").toGMTString());
+        assertEquals("21 Oct 1972 12:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +0800").toGMTString());
+        assertEquals("21 Oct 1972 11:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +0900").toGMTString());
+        assertEquals("21 Oct 1972 10:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +1000").toGMTString());
+        assertEquals("21 Oct 1972 09:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +1100").toGMTString());
+        assertEquals("21 Oct 1972 08:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +1200").toGMTString());        
+        
+        assertEquals("21 Oct 1972 10:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +1000").toGMTString());
+        assertEquals("21 Oct 1972 21:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 -0100").toGMTString());
+        assertEquals("21 Oct 1972 22:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 -0200").toGMTString());
+        assertEquals("21 Oct 1972 23:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 -0300").toGMTString());
+        assertEquals("22 Oct 1972 00:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 -0400").toGMTString());
+        assertEquals("22 Oct 1972 01:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 -0500").toGMTString());
+        assertEquals("22 Oct 1972 02:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 -0600").toGMTString());
+        assertEquals("22 Oct 1972 03:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 -0700").toGMTString());
+        assertEquals("22 Oct 1972 04:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 -0800").toGMTString());
+        assertEquals("22 Oct 1972 05:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 -0900").toGMTString());
+        assertEquals("22 Oct 1972 06:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 -1000").toGMTString());
+        
+        assertEquals("21 Oct 1972 19:30:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 +0030").toGMTString());
+        assertEquals("21 Oct 1972 20:30:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 -0030").toGMTString());
+
+        assertEquals("22 Oct 1972 06:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 20:00:00 -1000").toGMTString());
+        assertEquals("20 Oct 1972 20:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 06:00:00 +1000").toGMTString());
+        assertEquals("21 Oct 1972 16:00:00 GMT", DecoderUtils.decodeDateTime("21-Oct-1972 06:00:00 -1000").toGMTString());
+    }
+    
+    public void testDecodeDateTime() throws Exception {
+        runTimeZoneTest(TimeZone.getTimeZone("GMT+0"));
+        runTimeZoneTest(TimeZone.getTimeZone("GMT+1"));
+        runTimeZoneTest(TimeZone.getTimeZone("GMT-1"));
+        runTimeZoneTest(TimeZone.getTimeZone("GMT+2"));
+        runTimeZoneTest(TimeZone.getTimeZone("GMT-2"));
+        runTimeZoneTest(TimeZone.getTimeZone("GMT+3"));
+        runTimeZoneTest(TimeZone.getTimeZone("GMT-3"));
+        runTimeZoneTest(TimeZone.getTimeZone("GMT+11"));
+        runTimeZoneTest(TimeZone.getTimeZone("GMT-11"));
+        runTimeZoneTest(TimeZone.getTimeZone("GMT+1030"));
+        runTimeZoneTest(TimeZone.getTimeZone("GMT-1030"));
+        runTimeZoneTest(TimeZone.getTimeZone("GMT+0045"));
+        runTimeZoneTest(TimeZone.getTimeZone("GMT-0045"));
+    }
+    
+    private void runTimeZoneTest(TimeZone zone) throws Exception {
+        runDecodeDateTimeTest(new Date(10000000), zone);
+        runDecodeDateTimeTest(new Date(100000000), zone);
+        runDecodeDateTimeTest(new Date(1000000000), zone);
+        runDecodeDateTimeTest(new Date(10000000000L), zone);
+        runDecodeDateTimeTest(new Date(100000000000L), zone);
+        runDecodeDateTimeTest(new Date(1000000000000L), zone);
+        runDecodeDateTimeTest(new Date(1194168899658L), zone);
+        runDecodeDateTimeTest(new Date(1912093499271L), zone);
+        runDecodeDateTimeTest(new Date(1526720308423L), zone);
+        runDecodeDateTimeTest(new Date(1487487260757L), zone);
+        runDecodeDateTimeTest(new Date(1584040720026L), zone);
+        runDecodeDateTimeTest(new Date(1983293490921L), zone);
+        runDecodeDateTimeTest(new Date(1179806572669L), zone);
+        runDecodeDateTimeTest(new Date(1194038035064L), zone);
+        runDecodeDateTimeTest(new Date(1057865248366L), zone);
+        runDecodeDateTimeTest(new Date(1052797936633L), zone);
+        runDecodeDateTimeTest(new Date(1075268253439L), zone);
+        runDecodeDateTimeTest(new Date(1033938440306L), zone);
+        runDecodeDateTimeTest(new Date(1031614051298L), zone);
+        runDecodeDateTimeTest(new Date(1059929345305L), zone);
+        runDecodeDateTimeTest(new Date(1162582627756L), zone);
+        runDecodeDateTimeTest(new Date(1185747232134L), zone);
+        runDecodeDateTimeTest(new Date(1151301821303L), zone);
+        runDecodeDateTimeTest(new Date(1116091684805L), zone);
+        runDecodeDateTimeTest(new Date(1159599194961L), zone);
+        runDecodeDateTimeTest(new Date(1222523245646L), zone);
+        runDecodeDateTimeTest(new Date(1219556266559L), zone);
+        runDecodeDateTimeTest(new Date(1290015730272L), zone);
+        runDecodeDateTimeTest(new Date(1221694598854L), zone);
+        runDecodeDateTimeTest(new Date(1212132783343L), zone);
+        runDecodeDateTimeTest(new Date(1221761134897L), zone);
+        runDecodeDateTimeTest(new Date(1270941981377L), zone);
+        runDecodeDateTimeTest(new Date(1224491731327L), zone);
+        runDecodeDateTimeTest(new Date(1268571556436L), zone);
+        runDecodeDateTimeTest(new Date(1246838821081L), zone);
+        runDecodeDateTimeTest(new Date(1226795970848L), zone);
+        runDecodeDateTimeTest(new Date(1260254185119L), zone);
+    }
+    
+    private void runDecodeDateTimeTest(Date date, TimeZone zone) throws Exception {
+        dateDecode(formatAsImap(date, zone), zone);
+    }
+    
+    private void dateDecode(String in, TimeZone zone) throws Exception {
+        Date date = DecoderUtils.decodeDateTime(in);
+        String out = formatAsImap(date, zone);
+        System.out.println(out);
+        assertEquals("Round trip", in, out);
+    }
+
+    private String formatAsImap(Date date, TimeZone zone) {
+        assertNotNull(date);
+        FastDateFormat format = FastDateFormat.getInstance("dd-MMM-yyyy hh:mm:ss Z", zone, Locale.US);
+        String out = format.format(date);
+        if (out.charAt(0)=='0') {
+            out = ' ' + out.substring(1, out.length());
+        }
+        return out;
+    }
+    
+    public void testDecodeDigit() throws Exception {
+        assertEquals(0, DecoderUtils.decodeDigit('0'));
+        assertEquals(1, DecoderUtils.decodeDigit('1'));
+        assertEquals(2, DecoderUtils.decodeDigit('2'));
+        assertEquals(3, DecoderUtils.decodeDigit('3'));
+        assertEquals(4, DecoderUtils.decodeDigit('4'));
+        assertEquals(5, DecoderUtils.decodeDigit('5'));
+        assertEquals(6, DecoderUtils.decodeDigit('6'));
+        assertEquals(7, DecoderUtils.decodeDigit('7'));
+        assertEquals(8, DecoderUtils.decodeDigit('8'));
+        assertEquals(9, DecoderUtils.decodeDigit('9'));
+        
+        try {
+            DecoderUtils.decodeDigit('/');
+            fail("/ is not a digit");
+        } catch (ProtocolException e) {
+            // expected
+        }
+        
+        try {
+            DecoderUtils.decodeDigit(':');
+            fail(": is not a digit");
+        } catch (ProtocolException e) {
+            // expected
+        }
+    }
+    
+    public void testDecodeMonth() throws Exception {
+        assertEquals(Calendar.JANUARY, DecoderUtils.decodeMonth('J', 'A', 'N'));
+        assertEquals(Calendar.JANUARY, DecoderUtils.decodeMonth('j', 'a', 'n'));
+        assertEquals(Calendar.FEBRUARY, DecoderUtils.decodeMonth('F', 'E', 'B'));
+        assertEquals(Calendar.FEBRUARY, DecoderUtils.decodeMonth('f', 'e', 'b'));
+        assertEquals(Calendar.MARCH, DecoderUtils.decodeMonth('M', 'A', 'R'));
+        assertEquals(Calendar.MARCH, DecoderUtils.decodeMonth('m', 'a', 'r'));
+        assertEquals(Calendar.APRIL, DecoderUtils.decodeMonth('A', 'P', 'R'));
+        assertEquals(Calendar.APRIL, DecoderUtils.decodeMonth('a', 'p', 'r'));
+        assertEquals(Calendar.MAY, DecoderUtils.decodeMonth('M', 'A', 'Y'));
+        assertEquals(Calendar.MAY, DecoderUtils.decodeMonth('m', 'a', 'y'));
+        assertEquals(Calendar.JUNE, DecoderUtils.decodeMonth('J', 'U', 'N'));
+        assertEquals(Calendar.JUNE, DecoderUtils.decodeMonth('j', 'u', 'n'));
+        assertEquals(Calendar.JULY, DecoderUtils.decodeMonth('J', 'U', 'L'));
+        assertEquals(Calendar.JULY, DecoderUtils.decodeMonth('j', 'u', 'l'));
+        assertEquals(Calendar.AUGUST, DecoderUtils.decodeMonth('A', 'U', 'G'));
+        assertEquals(Calendar.AUGUST, DecoderUtils.decodeMonth('a', 'u', 'g'));
+        assertEquals(Calendar.SEPTEMBER, DecoderUtils.decodeMonth('S', 'E', 'P'));
+        assertEquals(Calendar.SEPTEMBER, DecoderUtils.decodeMonth('s', 'e', 'p'));
+        assertEquals(Calendar.OCTOBER, DecoderUtils.decodeMonth('O', 'C', 'T'));
+        assertEquals(Calendar.OCTOBER, DecoderUtils.decodeMonth('o', 'c', 't'));
+        assertEquals(Calendar.NOVEMBER, DecoderUtils.decodeMonth('N', 'O', 'V'));
+        assertEquals(Calendar.NOVEMBER, DecoderUtils.decodeMonth('n', 'o', 'v'));
+        assertEquals(Calendar.DECEMBER, DecoderUtils.decodeMonth('D', 'E', 'C'));
+        assertEquals(Calendar.DECEMBER, DecoderUtils.decodeMonth('d', 'e', 'c'));
+    }
+    
+    public void testRejectBogusMonths() throws Exception {
+        checkReject('N', 'O', 'C');
+        checkReject('A', 'N', 'T');
+        checkReject('Z', 'Z', 'Z');
+        checkReject('S', 'I', 'P');
+        checkReject('D', 'E', 'P');
+    }
+    
+    private void checkReject(char one, char two, char three) {
+        try {
+            DecoderUtils.decodeMonth(one, two, three);
+            fail(one + two + three + "is not a month"); 
+        } catch (ProtocolException e) {
+            // expected
+        }
+    }
+    
+    public void testDecodeYear() throws Exception {
+        assertEquals(1999, DecoderUtils.decodeYear('1', '9', '9', '9'));
+        assertEquals(747, DecoderUtils.decodeYear('0', '7', '4', '7'));
+        assertEquals(2525, DecoderUtils.decodeYear('2', '5', '2', '5'));
+        assertEquals(5678, DecoderUtils.decodeYear('5', '6', '7', '8'));
+        assertEquals(2453, DecoderUtils.decodeYear('2', '4', '5', '3'));
+        assertEquals(2000, DecoderUtils.decodeYear('2', '0', '0', '0'));
+        assertEquals(2007, DecoderUtils.decodeYear('2', '0', '0', '7'));
+        assertEquals(2008, DecoderUtils.decodeYear('2', '0', '0', '8'));
+        assertEquals(2010, DecoderUtils.decodeYear('2', '0', '1', '0'));
+        assertEquals(2020, DecoderUtils.decodeYear('2', '0', '2', '0'));
+    }
+    
+    public void testRejectBogusYear() throws Exception {
+        checkRejectYear('D', '0', '2', '3');
+        checkRejectYear('1', 'A', '2', '3');
+        checkRejectYear('1', '5', 'B', '3');
+        checkRejectYear('9', '8', '2', 'C');
+        checkRejectYear('S', 'A', 'F', 'd');
+    }
+    
+    
+    private void checkRejectYear(char one, char two, char three, char four) {
+        try {
+            DecoderUtils.decodeYear(one, two, three, four);
+            fail(one + two + three + four + "is not a month"); 
+        } catch (ProtocolException e) {
+            // expected
+        }
+    }
+    
+    public void testDecodeZone() throws Exception {
+        assertEquals(0, DecoderUtils. decodeZone('+', '0', '0', '0', '0'));
+        assertEquals(100, DecoderUtils. decodeZone('+', '0', '1', '0', '0'));
+        assertEquals(200, DecoderUtils. decodeZone('+', '0', '2', '0', '0'));
+        assertEquals(300, DecoderUtils. decodeZone('+', '0', '3', '0', '0'));
+        assertEquals(400, DecoderUtils. decodeZone('+', '0', '4', '0', '0'));
+        assertEquals(500, DecoderUtils. decodeZone('+', '0', '5', '0', '0'));
+        assertEquals(600, DecoderUtils. decodeZone('+', '0', '6', '0', '0'));
+        assertEquals(700, DecoderUtils. decodeZone('+', '0', '7', '0', '0'));
+        assertEquals(800, DecoderUtils. decodeZone('+', '0', '8', '0', '0'));
+        assertEquals(900, DecoderUtils. decodeZone('+', '0', '9', '0', '0'));
+        assertEquals(1000, DecoderUtils. decodeZone('+', '1', '0', '0', '0'));
+        assertEquals(1100, DecoderUtils. decodeZone('+', '1', '1', '0', '0'));
+        assertEquals(1200, DecoderUtils. decodeZone('+', '1', '2', '0', '0'));
+        assertEquals(30, DecoderUtils. decodeZone('+', '0', '0', '3', '0'));
+        assertEquals(130, DecoderUtils. decodeZone('+', '0', '1', '3', '0'));
+        assertEquals(230, DecoderUtils. decodeZone('+', '0', '2', '3', '0'));
+        assertEquals(330, DecoderUtils. decodeZone('+', '0', '3', '3', '0'));
+        assertEquals(430, DecoderUtils. decodeZone('+', '0', '4', '3', '0'));
+        assertEquals(530, DecoderUtils. decodeZone('+', '0', '5', '3', '0'));
+        assertEquals(630, DecoderUtils. decodeZone('+', '0', '6', '3', '0'));
+        assertEquals(730, DecoderUtils. decodeZone('+', '0', '7', '3', '0'));
+        assertEquals(830, DecoderUtils. decodeZone('+', '0', '8', '3', '0'));
+        assertEquals(930, DecoderUtils. decodeZone('+', '0', '9', '3', '0'));
+        assertEquals(1030, DecoderUtils. decodeZone('+', '1', '0', '3', '0'));
+        assertEquals(1130, DecoderUtils. decodeZone('+', '1', '1', '3', '0'));
+        assertEquals(1111, DecoderUtils. decodeZone('+', '1', '1', '1', '1'));
+        assertEquals(0, DecoderUtils. decodeZone('-', '0', '0', '0', '0'));
+        assertEquals(-100, DecoderUtils. decodeZone('-', '0', '1', '0', '0'));
+        assertEquals(-200, DecoderUtils. decodeZone('-', '0', '2', '0', '0'));
+        assertEquals(-300, DecoderUtils. decodeZone('-', '0', '3', '0', '0'));
+        assertEquals(-400, DecoderUtils. decodeZone('-', '0', '4', '0', '0'));
+        assertEquals(-500, DecoderUtils. decodeZone('-', '0', '5', '0', '0'));
+        assertEquals(-600, DecoderUtils. decodeZone('-', '0', '6', '0', '0'));
+        assertEquals(-700, DecoderUtils. decodeZone('-', '0', '7', '0', '0'));
+        assertEquals(-800, DecoderUtils. decodeZone('-', '0', '8', '0', '0'));
+        assertEquals(-900, DecoderUtils. decodeZone('-', '0', '9', '0', '0'));
+        assertEquals(-1000, DecoderUtils. decodeZone('-', '1', '0', '0', '0'));
+        assertEquals(-1100, DecoderUtils. decodeZone('-', '1', '1', '0', '0'));
+        assertEquals(-1200, DecoderUtils. decodeZone('-', '1', '2', '0', '0'));
+        assertEquals(-30, DecoderUtils. decodeZone('-', '0', '0', '3', '0'));
+        assertEquals(-130, DecoderUtils. decodeZone('-', '0', '1', '3', '0'));
+        assertEquals(-230, DecoderUtils. decodeZone('-', '0', '2', '3', '0'));
+        assertEquals(-330, DecoderUtils. decodeZone('-', '0', '3', '3', '0'));
+        assertEquals(-430, DecoderUtils. decodeZone('-', '0', '4', '3', '0'));
+        assertEquals(-530, DecoderUtils. decodeZone('-', '0', '5', '3', '0'));
+        assertEquals(-630, DecoderUtils. decodeZone('-', '0', '6', '3', '0'));
+        assertEquals(-730, DecoderUtils. decodeZone('-', '0', '7', '3', '0'));
+        assertEquals(-830, DecoderUtils. decodeZone('-', '0', '8', '3', '0'));
+        assertEquals(-930, DecoderUtils. decodeZone('-', '0', '9', '3', '0'));
+        assertEquals(-1030, DecoderUtils. decodeZone('-', '1', '0', '3', '0'));
+        assertEquals(-1130, DecoderUtils. decodeZone('-', '1', '1', '3', '0'));
+        assertEquals(-1111, DecoderUtils. decodeZone('-', '1', '1', '1', '1'));
+
+    }
+    
+    public void testBogusZones() throws Exception {
+        checkRejectZone(" 0000");
+        checkRejectZone(" GMT ");
+        checkRejectZone("DANG!");
+        checkRejectZone("+a000");
+        checkRejectZone("+0b00");
+        checkRejectZone("+00c0");
+        checkRejectZone("+000d");
+        checkRejectZone("-a000");
+        checkRejectZone("-0b00");
+        checkRejectZone("-00c0");
+        checkRejectZone("-000d");
+    }
+    
+    private void checkRejectZone(String zone) {
+        try {
+            DecoderUtils.decodeZone(zone.charAt(0), zone.charAt(1), zone.charAt(2), zone.charAt(3), zone.charAt(4));
+            fail(zone + "is not a timezone"); 
+        } catch (ProtocolException e) {
+            // expected
+        }
+    }
+    
+    public void testIsSimpleDigit() throws Exception {
+        assertTrue(DecoderUtils.isSimpleDigit('0'));
+        assertTrue(DecoderUtils.isSimpleDigit('1'));
+        assertTrue(DecoderUtils.isSimpleDigit('2'));
+        assertTrue(DecoderUtils.isSimpleDigit('3'));
+        assertTrue(DecoderUtils.isSimpleDigit('4'));
+        assertTrue(DecoderUtils.isSimpleDigit('5'));
+        assertTrue(DecoderUtils.isSimpleDigit('6'));
+        assertTrue(DecoderUtils.isSimpleDigit('7'));
+        assertTrue(DecoderUtils.isSimpleDigit('8'));
+        assertTrue(DecoderUtils.isSimpleDigit('9'));
+        
+        assertFalse(DecoderUtils.isSimpleDigit('/'));
+        assertFalse(DecoderUtils.isSimpleDigit('.'));
+        assertFalse(DecoderUtils.isSimpleDigit('-'));
+        assertFalse(DecoderUtils.isSimpleDigit('+'));
+        assertFalse(DecoderUtils.isSimpleDigit(','));
+        assertFalse(DecoderUtils.isSimpleDigit('*'));
+        assertFalse(DecoderUtils.isSimpleDigit(':'));
+        assertFalse(DecoderUtils.isSimpleDigit(';'));
+        assertFalse(DecoderUtils.isSimpleDigit('<'));
+        assertFalse(DecoderUtils.isSimpleDigit('='));
+        assertFalse(DecoderUtils.isSimpleDigit('>'));
+        assertFalse(DecoderUtils.isSimpleDigit('A'));
+        assertFalse(DecoderUtils.isSimpleDigit('B'));
+    }
+    
+    public void testDecodeNumber() throws Exception {
+        assertEquals(1, DecoderUtils.decodeNumber('0', '1'));
+        assertEquals(2, DecoderUtils.decodeNumber('0', '2'));
+        assertEquals(3, DecoderUtils.decodeNumber('0', '3'));
+        assertEquals(4, DecoderUtils.decodeNumber('0', '4'));
+        assertEquals(5, DecoderUtils.decodeNumber('0', '5'));
+        assertEquals(6, DecoderUtils.decodeNumber('0', '6'));
+        assertEquals(7, DecoderUtils.decodeNumber('0', '7'));
+        assertEquals(8, DecoderUtils.decodeNumber('0', '8'));
+        assertEquals(9, DecoderUtils.decodeNumber('0', '9'));
+        assertEquals(19, DecoderUtils.decodeNumber('1', '9'));
+        assertEquals(28, DecoderUtils.decodeNumber('2', '8'));
+        assertEquals(37, DecoderUtils.decodeNumber('3', '7'));
+        assertEquals(46, DecoderUtils.decodeNumber('4', '6'));
+        assertEquals(55, DecoderUtils.decodeNumber('5', '5'));
+        assertEquals(64, DecoderUtils.decodeNumber('6', '4'));
+        assertEquals(73, DecoderUtils.decodeNumber('7', '3')); 
+        assertEquals(82, DecoderUtils.decodeNumber('8', '2'));
+        assertEquals(91, DecoderUtils.decodeNumber('9', '1'));
+    }
+    
+    public void testRejectNumber() throws Exception {
+        checkRejectNumber("A1");
+        checkRejectNumber("1A");
+        checkRejectNumber("AA");
+    }
+    
+    private void checkRejectNumber(String number) {
+        try {
+            DecoderUtils.decodeNumber(number.charAt(0), number.charAt(1));
+            fail(number + "is not a number"); 
+        } catch (ProtocolException e) {
+            // expected
+        }
     }
 }



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