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