1 19 20 21 package org.apache.james.mailrepository; 22 23 import java.util.Iterator ; 24 25 import junit.framework.TestCase; 26 27 import org.apache.avalon.framework.configuration.ConfigurationException; 28 import org.apache.avalon.framework.configuration.DefaultConfiguration; 29 import org.apache.avalon.framework.service.ServiceException; 30 import org.apache.james.services.MailRepository; 31 import org.apache.james.test.mock.avalon.MockLogger; 32 33 40 public class MBoxMailRepositoryTest extends TestCase { 41 42 43 protected MailRepository getMailRepository() throws ServiceException, ConfigurationException, Exception { 44 MBoxMailRepository mr = new MBoxMailRepository(); 45 46 mr.enableLogging(new MockLogger()); 47 DefaultConfiguration defaultConfiguration = new DefaultConfiguration("ReposConf"); 48 defaultConfiguration.setAttribute("destinationURL","mbox://src/test/org/apache/james/mailrepository/testdata/Inbox"); 49 defaultConfiguration.setAttribute("type","MAIL"); 50 mr.configure(defaultConfiguration); 51 return mr; 52 } 53 54 public void testReadMboxrdFile() throws ServiceException, ConfigurationException, Exception { 56 MailRepository mr = getMailRepository(); 57 58 Iterator keys = mr.list(); 59 60 assertTrue("Two messages in list", keys.hasNext()); 61 keys.next(); 62 63 assertTrue("One messages in list", keys.hasNext()); 64 keys.next(); 65 66 assertFalse("No messages", keys.hasNext()); 67 } 68 69 76 77 } 78 79 | Popular Tags |