JAMES-2242 Memory mail queue should preserve state
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/be236f0d Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/be236f0d Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/be236f0d Branch: refs/heads/master Commit: be236f0da099e37f39f043632981fb7b86ef0657 Parents: 775de66 Author: benwa <btell...@linagora.com> Authored: Wed Nov 29 15:19:20 2017 +0700 Committer: Antoine Duprat <adup...@linagora.com> Committed: Mon Dec 4 14:42:18 2017 +0100 ---------------------------------------------------------------------- .../modules/server/MemoryMailQueueFactory.java | 3 ++- .../james/server/MemoryMailQueueFactoryTest.java | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/be236f0d/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/server/MemoryMailQueueFactory.java ---------------------------------------------------------------------- diff --git a/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/server/MemoryMailQueueFactory.java b/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/server/MemoryMailQueueFactory.java index 8fcc941..5918d5b 100644 --- a/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/server/MemoryMailQueueFactory.java +++ b/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/server/MemoryMailQueueFactory.java @@ -27,10 +27,10 @@ import java.util.concurrent.TimeUnit; import javax.mail.MessagingException; import javax.mail.internet.MimeMessage; -import org.apache.james.server.core.MailImpl; import org.apache.james.queue.api.MailQueue; import org.apache.james.queue.api.MailQueueFactory; import org.apache.james.queue.api.MailQueueItemDecoratorFactory; +import org.apache.james.server.core.MailImpl; import org.apache.mailet.Mail; import com.github.fge.lambdas.Throwing; @@ -88,6 +88,7 @@ public class MemoryMailQueueFactory implements MailQueueFactory { private Mail cloneMail(Mail mail) throws MessagingException { MailImpl mailImpl = MailImpl.duplicate(mail); + mailImpl.setState(mail.getState()); Optional.ofNullable(mail.getMessage()) .ifPresent(Throwing.consumer(message -> mailImpl.setMessage(new MimeMessage(message)))); return mailImpl; http://git-wip-us.apache.org/repos/asf/james-project/blob/be236f0d/server/container/guice/memory-guice/src/test/java/org/apache/james/server/MemoryMailQueueFactoryTest.java ---------------------------------------------------------------------- diff --git a/server/container/guice/memory-guice/src/test/java/org/apache/james/server/MemoryMailQueueFactoryTest.java b/server/container/guice/memory-guice/src/test/java/org/apache/james/server/MemoryMailQueueFactoryTest.java index eaf22b8..62357bb 100644 --- a/server/container/guice/memory-guice/src/test/java/org/apache/james/server/MemoryMailQueueFactoryTest.java +++ b/server/container/guice/memory-guice/src/test/java/org/apache/james/server/MemoryMailQueueFactoryTest.java @@ -97,6 +97,24 @@ public class MemoryMailQueueFactoryTest { } @Test + public void dequeueShouldPreserveState() throws Exception{ + String state = "state"; + Mail mail = FakeMail.builder() + .name(NAME_1) + .state(state) + .build(); + memoryMailQueueFactory.getQueue(KEY).enQueue(mail); + + String newState = memoryMailQueueFactory + .getQueue(KEY) + .deQueue() + .getMail() + .getState(); + + assertThat(newState).isEqualTo(state); + } + + @Test public void dequeueShouldWorkWithMultipleMessages() throws Exception{ Mail mail1 = FakeMail.builder() .name(NAME_1) --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org