1 19 20 21 package org.apache.james.mailrepository; 22 23 import org.apache.avalon.framework.configuration.ConfigurationException; 24 import org.apache.avalon.framework.configuration.DefaultConfiguration; 25 import org.apache.avalon.framework.service.DefaultServiceManager; 26 import org.apache.avalon.framework.service.ServiceException; 27 import org.apache.james.mailrepository.filepair.File_Persistent_Object_Repository; 28 import org.apache.james.mailrepository.filepair.File_Persistent_Stream_Repository; 29 import org.apache.james.services.FileSystem; 30 import org.apache.james.services.MailRepository; 31 import org.apache.james.test.mock.avalon.MockLogger; 32 import org.apache.james.test.mock.avalon.MockStore; 33 import org.apache.james.test.mock.james.MockFileSystem; 34 35 public class AvalonMailRepositoryTest extends AbstractMailRepositoryTest { 36 37 43 protected MailRepository getMailRepository() throws ServiceException, ConfigurationException, Exception { 44 DefaultServiceManager serviceManager = new DefaultServiceManager(); 45 serviceManager.put(FileSystem.ROLE, new MockFileSystem()); 46 AvalonMailRepository mr = new AvalonMailRepository(); 47 MockStore mockStore = new MockStore(); 48 File_Persistent_Stream_Repository file_Persistent_Stream_Repository = new File_Persistent_Stream_Repository(); 49 file_Persistent_Stream_Repository.service(serviceManager); 50 file_Persistent_Stream_Repository.enableLogging(new MockLogger()); 51 DefaultConfiguration defaultConfiguration2 = new DefaultConfiguration("conf"); 52 defaultConfiguration2.setAttribute("destinationURL", "file://target/var/mr"); 53 file_Persistent_Stream_Repository.configure(defaultConfiguration2); 54 file_Persistent_Stream_Repository.initialize(); 55 mockStore.add("STREAM.mr", file_Persistent_Stream_Repository); 56 File_Persistent_Object_Repository file_Persistent_Object_Repository = new File_Persistent_Object_Repository(); 57 file_Persistent_Object_Repository.service(serviceManager); 58 file_Persistent_Object_Repository.enableLogging(new MockLogger()); 59 DefaultConfiguration defaultConfiguration22 = new DefaultConfiguration("conf"); 60 defaultConfiguration22.setAttribute("destinationURL", "file://target/var/mr"); 61 file_Persistent_Object_Repository.configure(defaultConfiguration22); 62 file_Persistent_Object_Repository.initialize(); 63 mockStore.add("OBJECT.mr", file_Persistent_Object_Repository); 64 mr.setStore(mockStore); 65 66 mr.enableLogging(new MockLogger()); 67 DefaultConfiguration defaultConfiguration = new DefaultConfiguration("ReposConf"); 68 defaultConfiguration.setAttribute("destinationURL","file://target/var/mr"); 69 defaultConfiguration.setAttribute("type","MAIL"); 70 mr.configure(defaultConfiguration); 71 mr.initialize(); 72 return mr; 73 } 74 75 } 76 77 | Popular Tags |