james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Charles <e...@apache.org>
Subject Re: svn commit: r1052367 - in /james/server/trunk: queue-activemq/src/test/java/org/apache/james/queue/activemq/ActiveMQMailQueueTest.java queue-jms/src/test/java/org/apache/james/queue/jms/JMSMailQueueTest.java
Date Fri, 24 Dec 2010 14:42:59 GMT
Hi,
JMSMailQueueTest in queue-jms uses the AMQ Broker.
Would it be possible to mock the broker (get rid of amq dependencies) in 
queue-jms?

Tks,
Eric

On 23/12/2010 20:45, norman@apache.org wrote:
> Author: norman
> Date: Thu Dec 23 19:45:09 2010
> New Revision: 1052367
>
> URL: http://svn.apache.org/viewvc?rev=1052367&view=rev
> Log:
> Add tests for mail priority support. I think all functions of our MailQueue implementations
are now tested
>
> Modified:
>      james/server/trunk/queue-activemq/src/test/java/org/apache/james/queue/activemq/ActiveMQMailQueueTest.java
>      james/server/trunk/queue-jms/src/test/java/org/apache/james/queue/jms/JMSMailQueueTest.java
>
> Modified: james/server/trunk/queue-activemq/src/test/java/org/apache/james/queue/activemq/ActiveMQMailQueueTest.java
> URL: http://svn.apache.org/viewvc/james/server/trunk/queue-activemq/src/test/java/org/apache/james/queue/activemq/ActiveMQMailQueueTest.java?rev=1052367&r1=1052366&r2=1052367&view=diff
> ==============================================================================
> --- james/server/trunk/queue-activemq/src/test/java/org/apache/james/queue/activemq/ActiveMQMailQueueTest.java
(original)
> +++ james/server/trunk/queue-activemq/src/test/java/org/apache/james/queue/activemq/ActiveMQMailQueueTest.java
Thu Dec 23 19:45:09 2010
> @@ -18,9 +18,11 @@
>    ****************************************************************/
>   package org.apache.james.queue.activemq;
>
> +import java.io.IOException;
>   import java.util.Arrays;
>
>   import javax.jms.ConnectionFactory;
> +import javax.mail.MessagingException;
>
>   import org.apache.activemq.broker.BrokerPlugin;
>   import org.apache.activemq.broker.BrokerService;
> @@ -28,8 +30,10 @@ import org.apache.activemq.broker.region
>   import org.apache.activemq.broker.region.policy.PolicyMap;
>   import org.apache.activemq.plugin.StatisticsBrokerPlugin;
>   import org.apache.commons.logging.impl.SimpleLog;
> +import org.apache.james.queue.api.MailQueue.MailQueueItem;
>   import org.apache.james.queue.jms.JMSMailQueue;
>   import org.apache.james.queue.jms.JMSMailQueueTest;
> +import org.apache.mailet.Mail;
>
>   public class ActiveMQMailQueueTest extends JMSMailQueueTest{
>
> @@ -59,5 +63,43 @@ public class ActiveMQMailQueueTest exten
>           ActiveMQMailQueue queue = new ActiveMQMailQueue(factory, "test", false,log);
>           return queue;
>       }
> +
> +    public void testPrioritySupport() throws InterruptedException, MessagingException,
IOException {
> +            // should be empty
> +            assertEquals(0, queue.getSize());
> +
> +            Mail mail = createMail();
> +            Mail mail2 =createMail();
> +            mail2.setAttribute(ActiveMQMailQueue.MAIL_PRIORITY, ActiveMQMailQueue.HIGH_PRIORITY);
> +
> +            queue.enQueue(mail);
> +            queue.enQueue(mail2);
> +
> +            Thread.sleep(200);
> +
> +            assertEquals(2, queue.getSize());
> +
> +
> +            // we should get mail2 first as it has a higher priority set
> +            assertEquals(2, queue.getSize());
> +            MailQueueItem item2 = queue.deQueue();
> +            checkMail(mail2, item2.getMail());
> +            item2.done(true);
> +
> +            Thread.sleep(200);
> +
> +
> +
> +            assertEquals(1, queue.getSize());
> +            MailQueueItem item3 = queue.deQueue();
> +            checkMail(mail, item3.getMail());
> +            item3.done(true);
> +
> +            Thread.sleep(200);
> +
> +            // should be empty
> +            assertEquals(0, queue.getSize());
> +        }
> +
>
>   }
>
> Modified: james/server/trunk/queue-jms/src/test/java/org/apache/james/queue/jms/JMSMailQueueTest.java
> URL: http://svn.apache.org/viewvc/james/server/trunk/queue-jms/src/test/java/org/apache/james/queue/jms/JMSMailQueueTest.java?rev=1052367&r1=1052366&r2=1052367&view=diff
> ==============================================================================
> --- james/server/trunk/queue-jms/src/test/java/org/apache/james/queue/jms/JMSMailQueueTest.java
(original)
> +++ james/server/trunk/queue-jms/src/test/java/org/apache/james/queue/jms/JMSMailQueueTest.java
Thu Dec 23 19:45:09 2010
> @@ -44,7 +44,7 @@ import org.apache.mailet.MailAddress;
>   import junit.framework.TestCase;
>
>   public class JMSMailQueueTest extends TestCase{
> -    private JMSMailQueue queue;
> +    protected JMSMailQueue queue;
>       private BrokerService broker;
>
>       public void setUp() throws Exception{
> @@ -288,7 +288,7 @@ public class JMSMailQueueTest extends Te
>
>       }
>
> -    private MailImpl createMail() throws MessagingException {
> +    protected MailImpl createMail() throws MessagingException {
>           MailImpl mail = new MailImpl();
>           mail.setName("" + System.currentTimeMillis());
>           mail.setAttribute("test1", System.currentTimeMillis());
> @@ -306,7 +306,7 @@ public class JMSMailQueueTest extends Te
>
>       }
>       @SuppressWarnings("unchecked")
> -    private void checkMail(Mail enqueuedMail, Mail dequeuedMail) throws MessagingException,
IOException {
> +    protected void checkMail(Mail enqueuedMail, Mail dequeuedMail) throws MessagingException,
IOException {
>           assertEquals(enqueuedMail.getErrorMessage(), dequeuedMail.getErrorMessage());
>           assertEquals(enqueuedMail.getMessageSize(), dequeuedMail.getMessageSize());
>           assertEquals(enqueuedMail.getName(), dequeuedMail.getName());
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
> For additional commands, e-mail: server-dev-help@james.apache.org
>


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