james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r1052361 - 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 Thu, 23 Dec 2010 19:17:00 GMT
Author: norman
Date: Thu Dec 23 19:16:59 2010
New Revision: 1052361

URL: http://svn.apache.org/viewvc?rev=1052361&view=rev
Log:
More MailQueue tests

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=1052361&r1=1052360&r2=1052361&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:16:59 2010
@@ -18,10 +18,14 @@
  ****************************************************************/
 package org.apache.james.queue.activemq;
 
+import java.util.Arrays;
+
 import javax.jms.ConnectionFactory;
 
 import org.apache.activemq.broker.BrokerPlugin;
 import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.broker.region.policy.PolicyEntry;
+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.jms.JMSMailQueue;
@@ -33,7 +37,18 @@ public class ActiveMQMailQueueTest exten
     @Override
     protected BrokerService createBroker() throws Exception {
         BrokerService broker =  super.createBroker();
+        // Enable statistics
         broker.setPlugins(new BrokerPlugin[] {new StatisticsBrokerPlugin()});
+        broker.setEnableStatistics(true);
+        
+        // Enable priority support
+        PolicyMap pMap = new PolicyMap();
+        PolicyEntry entry = new PolicyEntry();
+        entry.setPrioritizedMessages(true);
+        entry.setQueue("test");
+        pMap.setPolicyEntries(Arrays.asList(entry));
+        broker.setDestinationPolicy(pMap);
+        
         return broker;
     }
 

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=1052361&r1=1052360&r2=1052361&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:16:59 2010
@@ -35,6 +35,7 @@ import org.apache.activemq.ActiveMQConne
 import org.apache.activemq.broker.BrokerService;
 import org.apache.commons.logging.impl.SimpleLog;
 import org.apache.james.core.MailImpl;
+import org.apache.james.queue.api.ManageableMailQueue;
 import org.apache.james.queue.api.MailQueue.MailQueueItem;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
@@ -126,7 +127,87 @@ public class JMSMailQueueTest extends Te
         assertEquals(0, queue.getSize());
     }
     
-    private Mail createMail() throws MessagingException {
+    public void testRemoveWithRecipient() throws MessagingException, InterruptedException
{
+        assertEquals(0, queue.getSize());
+
+        Mail mail = createMail();
+        mail.setRecipients(Arrays.asList(new MailAddress("remove@me1")));
+
+        Mail mail2 =createMail();
+        mail2.setRecipients(Arrays.asList(new MailAddress("remove@me2")));
+        
+
+        queue.enQueue(mail);
+        queue.enQueue(mail2);
+        
+        Thread.sleep(200);
+        
+        assertEquals(2, queue.getSize());
+        assertEquals(1,queue.remove(ManageableMailQueue.Type.Recipient, "remove@me1"));
+        
+        Thread.sleep(200);
+        assertEquals(1, queue.getSize());
+        
+        assertEquals(1,queue.remove(ManageableMailQueue.Type.Recipient, "remove@me2"));
+        assertEquals(0, queue.getSize());
+
+
+    }
+    public void testRemoveWithSender() throws MessagingException, InterruptedException {
+        assertEquals(0, queue.getSize());
+
+        MailImpl mail = createMail();
+        mail.setSender(new MailAddress("remove@me1"));
+
+        MailImpl mail2 =createMail();
+        mail2.setSender(new MailAddress("remove@me2"));
+        
+
+        queue.enQueue(mail);
+        queue.enQueue(mail2);
+        
+        Thread.sleep(200);
+        
+        assertEquals(2, queue.getSize());
+        assertEquals(1,queue.remove(ManageableMailQueue.Type.Sender, "remove@me1"));
+        
+        Thread.sleep(200);
+        assertEquals(1, queue.getSize());
+        
+        assertEquals(1,queue.remove(ManageableMailQueue.Type.Sender, "remove@me2"));
+        assertEquals(0, queue.getSize());
+
+
+    }
+     
+    public void testRemoveWithName() throws MessagingException, InterruptedException {
+        assertEquals(0, queue.getSize());
+
+        MailImpl mail = createMail();
+        mail.setName("remove@me1");
+
+        MailImpl mail2 =createMail();
+        mail2.setName("remove@me2");
+        
+
+        queue.enQueue(mail);
+        queue.enQueue(mail2);
+        
+        Thread.sleep(200);
+        
+        assertEquals(2, queue.getSize());
+        assertEquals(1,queue.remove(ManageableMailQueue.Type.Name, "remove@me1"));
+        
+        Thread.sleep(200);
+        assertEquals(1, queue.getSize());
+        
+        assertEquals(1,queue.remove(ManageableMailQueue.Type.Name, "remove@me2"));
+        assertEquals(0, queue.getSize());
+
+
+    }
+    
+    private MailImpl createMail() throws MessagingException {
         MailImpl mail = new MailImpl();
         mail.setName("" + System.currentTimeMillis());
         mail.setAttribute("test1", System.currentTimeMillis());



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