Author: rdonkin
Date: Wed May 13 08:17:54 2009
New Revision: 774250
URL: http://svn.apache.org/viewvc?rev=774250&view=rev
Log:
Added missing functional tests and added support for missing feature. IMAP-83
https://issues.apache.org/jira/browse/IMAP-83
Modified:
james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/Mailbox.java
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AppendProcessor.java
james/imap/trunk/seda/src/test/java/org/apache/james/imap/functional/suite/ConcurrentSessions.java
james/imap/trunk/seda/src/test/resources/org/apache/james/imap/scripts/ConcurrentExpungeResponse.test
james/imap/trunk/seda/src/test/resources/org/apache/james/imap/scripts/ConcurrentRenameSelected.test
james/imap/trunk/seda/src/test/resources/org/apache/james/imap/scripts/ConcurrentRenameSelectedSub.test
james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMailbox.java
james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailbox.java
Modified:
james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/Mailbox.java
URL:
http://svn.apache.org/viewvc/james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/Mailbox.java?rev=774250&r1=774249&r2=774250&view=diff
==============================================================================
---
james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/Mailbox.java
(original)
+++
james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/Mailbox.java
Wed May 13 08:17:54 2009
@@ -82,11 +82,13 @@
* @param mailboxSession not null
* @param isRecent true when the message should be marked recent,
* false otherwise
+ * @param flags optionally set these flags on created message,
+ * or null when no additional flags should be set
* @return uid for the newly added message
* @throws MailboxException when message cannot be appended
*/
long appendMessage(byte[] message, Date internalDate, MailboxSession
mailboxSession,
- boolean isRecent) throws MailboxException;
+ boolean isRecent, Flags flags) throws MailboxException;
/**
* Gets messages in the given range.
Modified:
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AppendProcessor.java
URL:
http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AppendProcessor.java?rev=774250&r1=774249&r2=774250&view=diff
==============================================================================
---
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AppendProcessor.java
(original)
+++
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AppendProcessor.java
Wed May 13 08:17:54 2009
@@ -21,6 +21,8 @@
import java.util.Date;
+import javax.mail.Flags;
+
import org.apache.commons.logging.Log;
import org.apache.james.imap.api.ImapCommand;
import org.apache.james.imap.api.ImapMessage;
@@ -60,15 +62,14 @@
final String mailboxName = request.getMailboxName();
final byte[] messageBytes = request.getMessage();
final Date datetime = request.getDatetime();
- // TODO: Flags are ignore: check whether the specification says that
- // they should be processed
+ final Flags flags = request.getFlags();
try {
final String fullMailboxName = buildFullName(session, mailboxName);
final MailboxManager mailboxManager = getMailboxManager();
final Mailbox mailbox = mailboxManager.getMailbox(fullMailboxName,
ImapSessionUtils.getMailboxSession(session));
- appendToMailbox(messageBytes, datetime, session, tag, command,
- mailbox, responder, fullMailboxName);
+ appendToMailbox(messageBytes, datetime, flags, session, tag,
+ command, mailbox, responder, fullMailboxName);
} catch (MailboxException mme) {
// Mailbox API does not provide facilities for diagnosing the
@@ -91,8 +92,8 @@
}
private void appendToMailbox(final byte[] message, final Date datetime,
- final ImapSession session, final String tag, final ImapCommand
command,
- final Mailbox mailbox, Responder responder, final String
fullMailboxName) {
+ final Flags flagsToBeSet, final ImapSession session, final String
tag,
+ final ImapCommand command, final Mailbox mailbox, Responder
responder, final String fullMailboxName) {
try {
final MailboxSession mailboxSession = ImapSessionUtils
.getMailboxSession(session);
@@ -100,7 +101,7 @@
final boolean isSelectedMailbox = selectedMailbox != null
&& fullMailboxName.equals(selectedMailbox.getName());
final long uid = mailbox.appendMessage(message, datetime,
mailboxSession,
- !isSelectedMailbox);
+ !isSelectedMailbox, flagsToBeSet);
if (isSelectedMailbox) {
selectedMailbox.addRecent(uid);
}
Modified:
james/imap/trunk/seda/src/test/java/org/apache/james/imap/functional/suite/ConcurrentSessions.java
URL:
http://svn.apache.org/viewvc/james/imap/trunk/seda/src/test/java/org/apache/james/imap/functional/suite/ConcurrentSessions.java?rev=774250&r1=774249&r2=774250&view=diff
==============================================================================
---
james/imap/trunk/seda/src/test/java/org/apache/james/imap/functional/suite/ConcurrentSessions.java
(original)
+++
james/imap/trunk/seda/src/test/java/org/apache/james/imap/functional/suite/ConcurrentSessions.java
Wed May 13 08:17:54 2009
@@ -30,6 +30,18 @@
super(system);
}
+ public void testConcurrentExpungeResponseUS() throws Exception {
+ scriptTest("ConcurrentExpungeResponse", Locale.US);
+ }
+
+ public void testConcurrentExpungeResponseITALY() throws Exception {
+ scriptTest("ConcurrentExpungeResponse", Locale.ITALY);
+ }
+
+ public void testConcurrentExpungeResponseKOREA() throws Exception {
+ scriptTest("ConcurrentExpungeResponse", Locale.KOREA);
+ }
+
public void testConcurrentCrossExpungeUS() throws Exception {
scriptTest("ConcurrentCrossExpunge", Locale.US);
}
Modified:
james/imap/trunk/seda/src/test/resources/org/apache/james/imap/scripts/ConcurrentExpungeResponse.test
URL:
http://svn.apache.org/viewvc/james/imap/trunk/seda/src/test/resources/org/apache/james/imap/scripts/ConcurrentExpungeResponse.test?rev=774250&r1=774249&r2=774250&view=diff
==============================================================================
---
james/imap/trunk/seda/src/test/resources/org/apache/james/imap/scripts/ConcurrentExpungeResponse.test
(original)
+++
james/imap/trunk/seda/src/test/resources/org/apache/james/imap/scripts/ConcurrentExpungeResponse.test
Wed May 13 08:17:54 2009
@@ -18,7 +18,7 @@
################################################################
SESSION: 1
C: 1a CREATE expungeresponse
-S: 1a OK CREATE completed
+S: 1a OK CREATE completed.
C: 1b APPEND expungeresponse (\Deleted) {254+}
C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
@@ -31,7 +31,7 @@
C:
C: Test 01
C:
-S: 1b OK APPEND completed
+S: 1b OK APPEND completed.
C: 1b APPEND expungeresponse {254+}
C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
@@ -44,7 +44,7 @@
C:
C: Test 02
C:
-S: 1b OK APPEND completed
+S: 1b OK APPEND completed.
C: 1c APPEND expungeresponse (\Deleted) {254+}
C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
@@ -57,7 +57,7 @@
C:
C: Test 03
C:
-S: 1c OK APPEND completed
+S: 1c OK APPEND completed.
C: 1d APPEND expungeresponse {254+}
C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
@@ -70,17 +70,17 @@
C:
C: Test 04
C:
-S: 1d OK APPEND completed
+S: 1d OK APPEND completed.
C: 1e SELECT expungeresponse
S: \* FLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)
S: \* 4 EXISTS
S: \* 4 RECENT
S: \* OK \[UIDVALIDITY \d+\]
-S: \* OK \[UNSEEN 1\] Message 1 is the first unseen
+S: \* OK \[UNSEEN 1\]
S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
S: \* OK \[UIDNEXT 5\]
-S: 1e OK \[READ-WRITE\] SELECT completed
+S: 1e OK \[READ-WRITE\] SELECT completed.
SESSION: 2
C: 2a SELECT expungeresponse
@@ -88,10 +88,10 @@
S: \* 4 EXISTS
S: \* 0 RECENT
S: \* OK \[UIDVALIDITY \d+\]
-S: \* OK \[UNSEEN 1\] Message 1 is the first unseen
+S: \* OK \[UNSEEN 1\]
S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
S: \* OK \[UIDNEXT 5\]
-S: 2a OK \[READ-WRITE\] SELECT completed
+S: 2a OK \[READ-WRITE\] SELECT completed.
SESSION: 3
C: 3a SELECT expungeresponse
@@ -99,24 +99,25 @@
S: \* 4 EXISTS
S: \* 0 RECENT
S: \* OK \[UIDVALIDITY \d+\]
-S: \* OK \[UNSEEN 1\] Message 1 is the first unseen
+S: \* OK \[UNSEEN 1\]
S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
S: \* OK \[UIDNEXT 5\]
-S: 3a OK \[READ-WRITE\] SELECT completed
+S: 3a OK \[READ-WRITE\] SELECT completed.
# Do an expunge with session 1
SESSION: 1
C: 1f EXPUNGE
S: \* 1 EXPUNGE
S: \* 2 EXPUNGE
-S: 1f OK EXPUNGE completed
+S: \* 2 RECENT
+S: 1f OK EXPUNGE completed.
# Make sure session 2 gets expunge responses
SESSION: 2
C: 2b NOOP
S: \* 1 EXPUNGE
S: \* 2 EXPUNGE
-S: 2b OK NOOP completed
+S: 2b OK NOOP completed.
# Now select with a new session - we have sessions 2,3 and 4 in different
states
SESSION: 4
@@ -125,38 +126,38 @@
S: \* 2 EXISTS
S: \* 0 RECENT
S: \* OK \[UIDVALIDITY \d+\]
-S: \* OK \[UNSEEN 1\] Message 1 is the first unseen
+S: \* OK \[UNSEEN 1\]
S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)\]
-S: 4a OK \[READ-WRITE\] SELECT completed
+S: \* OK \[UIDNEXT 5\]
+S: 4a OK \[READ-WRITE\] SELECT completed.
SESSION: 1
C: 1g STORE 1 FLAGS (\Deleted)
-S: \* 1 FETCH \(FLAGS \(\\Deleted\)\)
-S: 1g OK STORE completed
+S: \* 1 FETCH \(FLAGS \(\\Deleted \\Recent\)\)
+S: 1g OK STORE completed.
C: 1h EXPUNGE
S: \* 1 EXPUNGE
-S: 1h OK EXPUNGE completed
+S: \* 1 RECENT
+S: 1h OK EXPUNGE completed.
SESSION: 2
C: 2c NOOP
-S: \* 1 FETCH \(FLAGS \(\\Deleted\)\)
S: \* 1 EXPUNGE
-S: 2c OK NOOP completed
+S: 2c OK NOOP completed.
SESSION: 3
C: 3b NOOP
-S: \* 1 FETCH \(FLAGS \(\\Deleted\)\)
S: \* 1 EXPUNGE
-S: \* 2 EXPUNGE
S: \* 1 EXPUNGE
-S: 3b OK NOOP completed
+S: \* 1 EXPUNGE
+S: 3b OK NOOP completed.
SESSION: 4
C: 4b NOOP
-S: \* 1 FETCH \(FLAGS \(\\Deleted\)\)
S: \* 1 EXPUNGE
-S: 4b OK NOOP completed
-
+S: 4b OK NOOP completed.
+C: A150 DELETE expungeresponse
+S: A150 OK DELETE completed\.
Modified:
james/imap/trunk/seda/src/test/resources/org/apache/james/imap/scripts/ConcurrentRenameSelected.test
URL:
http://svn.apache.org/viewvc/james/imap/trunk/seda/src/test/resources/org/apache/james/imap/scripts/ConcurrentRenameSelected.test?rev=774250&r1=774249&r2=774250&view=diff
==============================================================================
---
james/imap/trunk/seda/src/test/resources/org/apache/james/imap/scripts/ConcurrentRenameSelected.test
(original)
+++
james/imap/trunk/seda/src/test/resources/org/apache/james/imap/scripts/ConcurrentRenameSelected.test
Wed May 13 08:17:54 2009
@@ -57,7 +57,7 @@
# Client #1 is still able to do operations that do not reference the mailbox
name.
SESSION: 1
C: 1d FETCH 1:* (FLAGS)
-S: \* 1 FETCH \(FLAGS \(\\Recent\)\)
+S: \* 1 FETCH \(FLAGS \(\\Deleted \\Recent\)\)
S: 1d OK FETCH completed.
# Client #1 is not able to do operations that reference the mailbox name.
@@ -73,3 +73,6 @@
C: Test 03
C:
S: 1e NO \[TRYCREATE\] APPEND failed. No such mailbox.
+
+C: A150 DELETE renamed
+S: A150 OK DELETE completed\.
\ No newline at end of file
Modified:
james/imap/trunk/seda/src/test/resources/org/apache/james/imap/scripts/ConcurrentRenameSelectedSub.test
URL:
http://svn.apache.org/viewvc/james/imap/trunk/seda/src/test/resources/org/apache/james/imap/scripts/ConcurrentRenameSelectedSub.test?rev=774250&r1=774249&r2=774250&view=diff
==============================================================================
---
james/imap/trunk/seda/src/test/resources/org/apache/james/imap/scripts/ConcurrentRenameSelectedSub.test
(original)
+++
james/imap/trunk/seda/src/test/resources/org/apache/james/imap/scripts/ConcurrentRenameSelectedSub.test
Wed May 13 08:17:54 2009
@@ -59,7 +59,7 @@
# Client #1 is still able to do operations that do not reference the mailbox
name.
SESSION: 1
C: 1d FETCH 1:* (FLAGS)
-S: \* 1 FETCH \(FLAGS \(\\Recent\)\)
+S: \* 1 FETCH \(FLAGS \(\\Deleted \\Recent\)\)
S: 1d OK FETCH completed.
# Client #1 is not able to do operations that reference the mailbox name.
Modified:
james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMailbox.java
URL:
http://svn.apache.org/viewvc/james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMailbox.java?rev=774250&r1=774249&r2=774250&view=diff
==============================================================================
---
james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMailbox.java
(original)
+++
james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMailbox.java
Wed May 13 08:17:54 2009
@@ -91,7 +91,7 @@
}
public long appendMessage(byte[] messageBytes, Date internalDate,
- MailboxSession mailboxSession, boolean isRecent)
+ MailboxSession mailboxSession, boolean isRecent, Flags
flagsToBeSet)
throws MailboxException {
final Mailbox mailbox = reserveNextUid();
@@ -188,7 +188,12 @@
propertyBuilder.setTextualLineCount(lines);
}
- final Flags flags = new Flags();
+ final Flags flags;
+ if (flagsToBeSet == null) {
+ flags = new Flags();
+ } else {
+ flags = flagsToBeSet;
+ }
if (isRecent) {
flags.add(Flags.Flag.RECENT);
}
Modified:
james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailbox.java
URL:
http://svn.apache.org/viewvc/james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailbox.java?rev=774250&r1=774249&r2=774250&view=diff
==============================================================================
---
james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailbox.java
(original)
+++
james/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/TorqueMailbox.java
Wed May 13 08:17:54 2009
@@ -118,7 +118,7 @@
}
public long appendMessage(byte[] message, Date internalDate,
- MailboxSession mailboxSession, boolean isRecent)
+ MailboxSession mailboxSession, boolean isRecent, Flags flags)
throws MailboxException {
try {
@@ -147,6 +147,11 @@
if (isRecent) {
mimeMessage.setFlag(Flags.Flag.RECENT, true);
}
+ if (flags != null) {
+ for (final Flags.Flag flag:flags.getSystemFlags()) {
+ mimeMessage.setFlag(flag, true);
+ }
+ }
final int size = size(mimeMessage);
messageRow.setSize(size);
populateFlags(mimeMessage, messageRow);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]