You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2018/01/18 02:49:15 UTC
[07/10] james-project git commit: JAMES-2285 MailSpoolTest should
rely on MemoryMailQueue
JAMES-2285 MailSpoolTest should rely on MemoryMailQueue
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/92da7418
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/92da7418
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/92da7418
Branch: refs/heads/master
Commit: 92da741851771b0e535295af335977f4b78e7a6c
Parents: ad7e51d
Author: benwa <bt...@linagora.com>
Authored: Thu Jan 11 14:30:17 2018 +0700
Committer: benwa <bt...@linagora.com>
Committed: Thu Jan 18 09:48:49 2018 +0700
----------------------------------------------------------------------
server/protocols/jmap/pom.xml | 5 ++
.../apache/james/jmap/send/MailSpoolTest.java | 76 +++++++-------------
2 files changed, 31 insertions(+), 50 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/92da7418/server/protocols/jmap/pom.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/pom.xml b/server/protocols/jmap/pom.xml
index d51f2ba..7ac74f2 100644
--- a/server/protocols/jmap/pom.xml
+++ b/server/protocols/jmap/pom.xml
@@ -121,6 +121,11 @@
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
+ <artifactId>james-server-queue-memory</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
<artifactId>james-server-util</artifactId>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/james-project/blob/92da7418/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/MailSpoolTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/MailSpoolTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/MailSpoolTest.java
index 69b25d9..3bc50b0 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/MailSpoolTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/MailSpoolTest.java
@@ -21,80 +21,56 @@ package org.apache.james.jmap.send;
import static org.assertj.core.api.Assertions.assertThat;
-import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.TimeUnit;
-
import org.apache.james.mailbox.model.TestMessageId;
import org.apache.james.queue.api.MailQueue;
-import org.apache.james.queue.api.MailQueue.MailQueueException;
import org.apache.james.queue.api.MailQueue.MailQueueItem;
-import org.apache.mailet.Mail;
+import org.apache.james.queue.api.MailQueueFactory;
+import org.apache.james.queue.api.RawMailQueueItemDecoratorFactory;
+import org.apache.james.queue.memory.MemoryMailQueueFactory;
import org.apache.mailet.base.test.FakeMail;
import org.junit.Before;
import org.junit.Test;
public class MailSpoolTest {
+ private static final String USERNAME = "user";
+ private static final TestMessageId MESSAGE_ID = TestMessageId.of(1);
+ private static final String NAME = "Name";
private MailSpool mailSpool;
private MailQueue myQueue;
@Before
public void setup() {
- myQueue = new MyQueue();
+ myQueue = new MemoryMailQueueFactory.MemoryMailQueue(MailQueueFactory.SPOOL, new RawMailQueueItemDecoratorFactory());
mailSpool = new MailSpool(name -> myQueue);
}
@Test
public void sendShouldEnQueueTheMail() throws Exception {
- FakeMail mail = FakeMail.defaultFakeMail();
+ FakeMail mail = FakeMail.builder()
+ .name(NAME)
+ .build();
- mailSpool.send(mail, new MailMetadata(TestMessageId.of(1), "user"));
+ mailSpool.send(mail, new MailMetadata(MESSAGE_ID, USERNAME));
- assertThat(myQueue.deQueue())
- .isNotNull()
- .extracting(MailQueueItem::getMail)
- .containsExactly(mail);
+ MailQueueItem actual = myQueue.deQueue();
+ assertThat(actual.getMail().getName()).isEqualTo(NAME);
}
- private static class MyQueue implements MailQueue {
-
- private ConcurrentLinkedQueue<Mail> queue;
-
- public MyQueue() {
- queue = new ConcurrentLinkedQueue<>();
- }
-
- @Override
- public void enQueue(Mail mail) throws MailQueueException {
- queue.add(mail);
- }
-
- @Override
- public void enQueue(Mail mail, long delay, TimeUnit unit) throws MailQueueException {
- }
-
- @Override
- public MailQueueItem deQueue() throws MailQueueException {
- return new MyMailQueueItem(queue.poll());
- }
+ @Test
+ public void sendShouldPositionJMAPRelatedMetadata() throws Exception {
+ FakeMail mail = FakeMail.builder()
+ .name(NAME)
+ .build();
+
+ mailSpool.send(mail, new MailMetadata(MESSAGE_ID, USERNAME));
+
+ MailQueueItem actual = myQueue.deQueue();
+ assertThat(actual.getMail().getAttribute(MailMetadata.MAIL_METADATA_USERNAME_ATTRIBUTE))
+ .isEqualTo(USERNAME);
+ assertThat(actual.getMail().getAttribute(MailMetadata.MAIL_METADATA_MESSAGE_ID_ATTRIBUTE))
+ .isEqualTo(MESSAGE_ID.serialize());
}
- private static class MyMailQueueItem implements MailQueueItem {
-
- private final Mail mail;
-
- public MyMailQueueItem(Mail mail) {
- this.mail = mail;
- }
-
- @Override
- public Mail getMail() {
- return mail;
- }
-
- @Override
- public void done(boolean success) throws MailQueueException {
- }
- }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org