1 19 20 package org.apache.james.userrepository; 21 22 import org.apache.avalon.cornerstone.blocks.datasources.DefaultDataSourceSelector; 23 import org.apache.avalon.framework.configuration.ConfigurationException; 24 import org.apache.avalon.framework.configuration.DefaultConfiguration; 25 import org.apache.avalon.framework.container.ContainerUtil; 26 import org.apache.avalon.framework.logger.ConsoleLogger; 27 import org.apache.james.services.UsersRepository; 28 import org.apache.james.test.mock.james.MockFileSystem; 29 import org.apache.james.test.mock.util.AttrValConfiguration; 30 import org.apache.james.test.util.Util; 31 32 import java.util.Iterator ; 33 34 37 public class DefaultUsersJdbcRepositoryTest extends MockUsersRepositoryTest { 38 39 45 protected UsersRepository getUsersRepository() throws Exception { 46 DefaultUsersJdbcRepository res = new DefaultUsersJdbcRepository(); 47 String tableString = "defusers"; 48 configureAbstractJdbcUsersRepository(res, tableString); 49 return res; 50 } 51 52 58 protected void configureAbstractJdbcUsersRepository(AbstractJdbcUsersRepository res, String tableString) throws Exception , ConfigurationException { 59 res.setFileSystem(new MockFileSystem()); 60 DefaultDataSourceSelector dataSourceSelector = Util.getDataSourceSelector(); 61 62 res.setDatasources(dataSourceSelector ); 63 64 DefaultConfiguration configuration = new DefaultConfiguration("test"); 65 configuration.setAttribute("destinationURL", "db://maildb/"+tableString); 66 configuration.addChild(new AttrValConfiguration("sqlFile","file://conf/sqlResources.xml")); 67 res.enableLogging(new ConsoleLogger()); 68 res.configure(configuration ); 69 res.initialize(); 70 } 71 72 75 protected boolean getCheckCase() { 76 return true; 77 } 78 79 protected void disposeUsersRepository() { 80 Iterator i = this.usersRepository.list(); 81 while (i.hasNext()) { 82 this.usersRepository.removeUser((String ) i.next()); 83 } 84 ContainerUtil.dispose(this.usersRepository); 85 } 86 87 } 88 | Popular Tags |