james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [03/10] james-project git commit: MAILBOX-270: protocol defines the quota, data size of at least 1024 and number of annotations at least 10
Date Thu, 10 Nov 2016 07:34:31 GMT
MAILBOX-270: protocol defines the quota, data size of at least 1024 and number of annotations
at least 10


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/f59434ce
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/f59434ce
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/f59434ce

Branch: refs/heads/master
Commit: f59434ce2bb778b41fc68c97a5af7f3047126823
Parents: af731a6
Author: Quynh Nguyen <qnguyen@linagora.com>
Authored: Mon Sep 12 11:13:33 2016 +0700
Committer: Quynh Nguyen <qnguyen@linagora.com>
Committed: Wed Nov 9 11:39:49 2016 +0700

----------------------------------------------------------------------
 .../james/imap/api/display/HumanReadableText.java   |  2 ++
 .../imap/processor/SetAnnotationProcessor.java      |  4 ++++
 .../imap/processor/SetAnnotationProcessorTest.java  | 16 ++++++++++++++++
 .../processor/base/MailboxEventAnalyserTest.java    |  1 -
 4 files changed, 22 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/f59434ce/protocols/imap/src/main/java/org/apache/james/imap/api/display/HumanReadableText.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/api/display/HumanReadableText.java
b/protocols/imap/src/main/java/org/apache/james/imap/api/display/HumanReadableText.java
index 8ae4cd0..6db33e2 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/api/display/HumanReadableText.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/api/display/HumanReadableText.java
@@ -169,6 +169,8 @@ public class HumanReadableText {
     public static final String UNDEFINED_QUOTA_ROOT_KEY = "org.apache.james.imap.UNDEFINED_QUOTA_ROOT_KEY";
     public static final String UNDEFINED_QUOTA_ROOT_DEFAULT_VALUE = "The Quota Root {0} does
not exist.";
 
+    public static final String MAILBOX_ANNOTATION_KEY = "org.apache.james.imap.ANNOTATION_ERROR_KEY";
+
     private final String defaultValue;
 
     private final String key;

http://git-wip-us.apache.org/repos/asf/james-project/blob/f59434ce/protocols/imap/src/main/java/org/apache/james/imap/processor/SetAnnotationProcessor.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/SetAnnotationProcessor.java
b/protocols/imap/src/main/java/org/apache/james/imap/processor/SetAnnotationProcessor.java
index 4ce0fee..abfb453 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/processor/SetAnnotationProcessor.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/SetAnnotationProcessor.java
@@ -33,6 +33,7 @@ import org.apache.james.imap.main.PathConverter;
 import org.apache.james.imap.message.request.SetAnnotationRequest;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.exception.AnnotationException;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.MailboxNotFoundException;
 import org.apache.james.mailbox.model.MailboxPath;
@@ -63,6 +64,9 @@ public class SetAnnotationProcessor extends AbstractMailboxProcessor<SetAnnotati
         } catch (MailboxNotFoundException e) {
             session.getLog().info(command.getName() + " failed for mailbox " + mailboxName,
e);
             no(command, tag, responder, HumanReadableText.FAILURE_NO_SUCH_MAILBOX, StatusResponse.ResponseCode.tryCreate());
+        } catch (AnnotationException e) {
+            session.getLog().info(command.getName() + " failed for mailbox " + mailboxName,
e);
+            no(command, tag, responder, new HumanReadableText(HumanReadableText.MAILBOX_ANNOTATION_KEY,
e.getMessage()));
         } catch (MailboxException e) {
             session.getLog().info(command.getName() + " failed for mailbox " + mailboxName,
e);
             no(command, tag, responder, HumanReadableText.GENERIC_FAILURE_DURING_PROCESSING);

http://git-wip-us.apache.org/repos/asf/james-project/blob/f59434ce/protocols/imap/src/test/java/org/apache/james/imap/processor/SetAnnotationProcessorTest.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/SetAnnotationProcessorTest.java
b/protocols/imap/src/test/java/org/apache/james/imap/processor/SetAnnotationProcessorTest.java
index 1a76a1e..1d1e3ee 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/processor/SetAnnotationProcessorTest.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/SetAnnotationProcessorTest.java
@@ -43,6 +43,7 @@ import org.apache.james.imap.encode.FakeImapSession;
 import org.apache.james.imap.message.request.SetAnnotationRequest;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.exception.AnnotationException;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.MailboxNotFoundException;
 import org.apache.james.mailbox.mock.MockMailboxSession;
@@ -62,6 +63,7 @@ import com.google.common.collect.ImmutableList;
 public class SetAnnotationProcessorTest {
 
     private static final String TAG = "TAG";
+    private static final int FIRST_ELEMENT_INDEX = 0;
 
     @InjectMocks
     private SetAnnotationProcessor processor;
@@ -158,4 +160,18 @@ public class SetAnnotationProcessorTest {
 
         assertThat(humanTextCaptor.getAllValues()).containsOnly(HumanReadableText.COMPLETED);
     }
+
+    @Test
+    public void processShouldResponseNoWhenManagerThrowsAnnotationException() throws Exception
{
+        when(mockImapSession.getLog()).thenReturn(log);
+
+        doThrow(AnnotationException.class).when(mockMailboxManager).updateAnnotations(eq(inbox),
eq(mockMailboxSession), eq(MAILBOX_ANNOTATIONS));
+
+        processor.process(request, mockResponder, mockImapSession);
+
+        verify(mockStatusResponseFactory, times(1)).taggedNo(any(String.class), any(ImapCommand.class),
humanTextCaptor.capture());
+
+        assertThat(humanTextCaptor.getAllValues().get(FIRST_ELEMENT_INDEX).getKey()).isEqualTo(HumanReadableText.MAILBOX_ANNOTATION_KEY);
+
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/f59434ce/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
index 9b889df..2d9eee6 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
@@ -33,7 +33,6 @@ import java.util.EnumSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Optional;
 import java.util.Set;
 
 import javax.mail.Flags;


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