1 19 20 21 package org.apache.james.mailrepository; 22 23 import org.apache.avalon.cornerstone.services.datasources.DataSourceSelector; 24 import org.apache.avalon.cornerstone.services.store.Store; 25 import org.apache.avalon.framework.configuration.ConfigurationException; 26 import org.apache.avalon.framework.configuration.DefaultConfiguration; 27 import org.apache.avalon.framework.service.DefaultServiceManager; 28 import org.apache.avalon.framework.service.ServiceException; 29 import org.apache.james.mailrepository.filepair.File_Persistent_Stream_Repository; 30 import org.apache.james.services.FileSystem; 31 import org.apache.james.services.MailRepository; 32 import org.apache.james.test.mock.avalon.MockLogger; 33 import org.apache.james.test.mock.avalon.MockStore; 34 import org.apache.james.test.mock.james.MockFileSystem; 35 import org.apache.james.test.mock.util.AttrValConfiguration; 36 import org.apache.james.test.util.Util; 37 38 public class JDBCMailRepositoryTest extends AbstractMailRepositoryTest { 39 40 46 protected MailRepository getMailRepository() throws ServiceException, ConfigurationException, Exception { 47 DefaultServiceManager serviceManager = new DefaultServiceManager(); 48 serviceManager.put(FileSystem.ROLE, new MockFileSystem()); 49 serviceManager.put(DataSourceSelector.ROLE, Util.getDataSourceSelector()); 50 JDBCMailRepository mr = new JDBCMailRepository(); 51 52 MockStore mockStore = new MockStore(); 54 File_Persistent_Stream_Repository file_Persistent_Stream_Repository = new File_Persistent_Stream_Repository(); 55 file_Persistent_Stream_Repository.service(serviceManager); 56 file_Persistent_Stream_Repository.enableLogging(new MockLogger()); 57 DefaultConfiguration defaultConfiguration2 = new DefaultConfiguration("conf"); 58 defaultConfiguration2.setAttribute("destinationURL", "file://target/var/mr/testrepo"); 59 file_Persistent_Stream_Repository.configure(defaultConfiguration2); 60 file_Persistent_Stream_Repository.initialize(); 61 mockStore.add("STREAM.mr", file_Persistent_Stream_Repository); 62 serviceManager.put(Store.ROLE,mockStore); 63 64 mr.enableLogging(new MockLogger()); 65 DefaultConfiguration defaultConfiguration = new DefaultConfiguration("ReposConf"); 66 defaultConfiguration.setAttribute("destinationURL","db://maildb/mr/testrepo"); 67 defaultConfiguration.addChild(new AttrValConfiguration("sqlFile","file://conf/sqlResources.xml")); 68 defaultConfiguration.setAttribute("type","MAIL"); 69 mr.service(serviceManager); 70 mr.configure(defaultConfiguration); 71 mr.initialize(); 72 return mr; 73 } 74 75 protected String getType() { 76 return "db"; 77 } 78 79 } 80 81 | Popular Tags |