Repository: james-project Updated Branches: refs/heads/master ca25b8226 -> 00678d881
JAMES-1691 Move MailSpool to jmap.send package Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/66579d71 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/66579d71 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/66579d71 Branch: refs/heads/master Commit: 66579d716ce074f3ecca68ce8adbd6ea47ae8c5c Parents: 813af4a Author: Raphael Ouazana <[email protected]> Authored: Wed Feb 24 15:00:46 2016 +0100 Committer: Raphael Ouazana <[email protected]> Committed: Wed Feb 24 15:00:46 2016 +0100 ---------------------------------------------------------------------- .../org/apache/james/jmap/JMAPCommonModule.java | 2 +- .../org/apache/james/jmap/send/MailSpool.java | 43 ++++++++ .../org/apache/james/jmap/utils/MailSpool.java | 43 -------- .../apache/james/jmap/send/MailSpoolTest.java | 106 +++++++++++++++++++ .../apache/james/jmap/utils/MailSpoolTest.java | 106 ------------------- 5 files changed, 150 insertions(+), 150 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/66579d71/server/container/cassandra-guice/src/main/java/org/apache/james/jmap/JMAPCommonModule.java ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/jmap/JMAPCommonModule.java b/server/container/cassandra-guice/src/main/java/org/apache/james/jmap/JMAPCommonModule.java index 3d8854a..14c2d9f 100644 --- a/server/container/cassandra-guice/src/main/java/org/apache/james/jmap/JMAPCommonModule.java +++ b/server/container/cassandra-guice/src/main/java/org/apache/james/jmap/JMAPCommonModule.java @@ -29,8 +29,8 @@ import org.apache.james.jmap.crypto.JamesSignatureHandler; import org.apache.james.jmap.crypto.SignatureHandler; import org.apache.james.jmap.crypto.SignedContinuationTokenManager; import org.apache.james.jmap.memory.access.MemoryAccessTokenRepository; +import org.apache.james.jmap.send.MailSpool; import org.apache.james.jmap.utils.DefaultZonedDateTimeProvider; -import org.apache.james.jmap.utils.MailSpool; import org.apache.james.jmap.utils.ZonedDateTimeProvider; import com.google.common.collect.ImmutableList; http://git-wip-us.apache.org/repos/asf/james-project/blob/66579d71/server/protocols/jmap/src/main/java/org/apache/james/jmap/send/MailSpool.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/send/MailSpool.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/send/MailSpool.java new file mode 100644 index 0000000..6267890 --- /dev/null +++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/send/MailSpool.java @@ -0,0 +1,43 @@ +/**************************************************************** + * 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.jmap.send; + +import javax.inject.Inject; + +import org.apache.james.queue.api.MailQueue; +import org.apache.james.queue.api.MailQueue.MailQueueException; +import org.apache.james.queue.api.MailQueueFactory; +import org.apache.mailet.Mail; + +import com.google.common.annotations.VisibleForTesting; + +public class MailSpool { + + private final MailQueue queue; + + @Inject + @VisibleForTesting MailSpool(MailQueueFactory queueFactory) { + queue = queueFactory.getQueue(MailQueueFactory.SPOOL); + } + + public void send(Mail mail) throws MailQueueException { + queue.enQueue(mail); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/66579d71/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/MailSpool.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/MailSpool.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/MailSpool.java deleted file mode 100644 index 340d188..0000000 --- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/MailSpool.java +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************** - * 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.jmap.utils; - -import javax.inject.Inject; - -import org.apache.james.queue.api.MailQueue; -import org.apache.james.queue.api.MailQueue.MailQueueException; -import org.apache.james.queue.api.MailQueueFactory; -import org.apache.mailet.Mail; - -import com.google.common.annotations.VisibleForTesting; - -public class MailSpool { - - private final MailQueue queue; - - @Inject - @VisibleForTesting MailSpool(MailQueueFactory queueFactory) { - queue = queueFactory.getQueue(MailQueueFactory.SPOOL); - } - - public void send(Mail mail) throws MailQueueException { - queue.enQueue(mail); - } -} http://git-wip-us.apache.org/repos/asf/james-project/blob/66579d71/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 new file mode 100644 index 0000000..3687138 --- /dev/null +++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/MailSpoolTest.java @@ -0,0 +1,106 @@ +/**************************************************************** + * 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.jmap.send; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.TimeUnit; + +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.james.queue.api.MailQueueFactory; +import org.apache.mailet.Mail; +import org.apache.mailet.base.test.FakeMail; +import org.junit.Before; +import org.junit.Test; + +public class MailSpoolTest { + + private MailSpool mailSpool; + private MailQueue myQueue; + + @Before + public void setup() { + myQueue = new MyQueue(); + + mailSpool = new MailSpool(new MailQueueFactory() { + + @Override + public MailQueue getQueue(String name) { + return myQueue; + } + }); + } + + @Test + public void sendShouldEnQueueTheMail() throws Exception { + FakeMail mail = new FakeMail(); + + mailSpool.send(mail); + + assertThat(myQueue.deQueue()) + .isNotNull() + .extracting(MailQueueItem::getMail) + .containsExactly(mail); + } + + private static class MyQueue implements MailQueue { + + private ConcurrentLinkedQueue<Mail> queue; + + public MyQueue() { + queue = new ConcurrentLinkedQueue<Mail>(); + } + + @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()); + } + } + + 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 { + } + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/66579d71/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/MailSpoolTest.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/MailSpoolTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/MailSpoolTest.java deleted file mode 100644 index 359e649..0000000 --- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/MailSpoolTest.java +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************** - * 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.jmap.utils; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.TimeUnit; - -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.james.queue.api.MailQueueFactory; -import org.apache.mailet.Mail; -import org.apache.mailet.base.test.FakeMail; -import org.junit.Before; -import org.junit.Test; - -public class MailSpoolTest { - - private MailSpool mailSpool; - private MailQueue myQueue; - - @Before - public void setup() { - myQueue = new MyQueue(); - - mailSpool = new MailSpool(new MailQueueFactory() { - - @Override - public MailQueue getQueue(String name) { - return myQueue; - } - }); - } - - @Test - public void sendShouldEnQueueTheMail() throws Exception { - FakeMail mail = new FakeMail(); - - mailSpool.send(mail); - - assertThat(myQueue.deQueue()) - .isNotNull() - .extracting(MailQueueItem::getMail) - .containsExactly(mail); - } - - private static class MyQueue implements MailQueue { - - private ConcurrentLinkedQueue<Mail> queue; - - public MyQueue() { - queue = new ConcurrentLinkedQueue<Mail>(); - } - - @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()); - } - } - - 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: [email protected] For additional commands, e-mail: [email protected]
