Next step is to create a component for the current functionality of SpringTestCase and to use that instead of SpringTestCase.
package org.wamblee.usermgt.hibernate;
import java.io.IOException;
+import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.TreeMap;
import org.springframework.core.io.ClassPathResource;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.transaction.PlatformTransactionManager;
+import org.wamblee.persistence.hibernate.HibernateMappingFiles;
import org.wamblee.system.core.DefaultProvidedInterface;
import org.wamblee.system.core.DefaultRequiredInterface;
import org.wamblee.system.core.ProvidedInterface;
}
private static Map<RequiredInterface, String> createRequired() {
- Map<RequiredInterface,String> required = new TreeMap<RequiredInterface, String>();
- required.put(new DefaultRequiredInterface("datasource", DataSource.class), "datasource");
+ Map<RequiredInterface,String> required = new HashMap<RequiredInterface, String>();
+ required.put(new DefaultRequiredInterface("datasource", DataSource.class), "dataSource");
+ required.put(new DefaultRequiredInterface("mappingFiles", HibernateMappingFiles.class),
+ "hibernateMappingFiles");
return required;
}
private static Map<String, ProvidedInterface> createProvided() {
- Map<String,ProvidedInterface> provided = new TreeMap<String,ProvidedInterface>();
+ Map<String,ProvidedInterface> provided = new HashMap<String,ProvidedInterface>();
provided.put("transactionManager", new DefaultProvidedInterface(
"transactionMgr", PlatformTransactionManager.class));
private DefaultContainer _container;
private Scope _scope;
- private DataSource _datasource;
+ private DataSource _datasource;
+ private UserSet _userset;
+ private GroupSet _groupset;
/* (non-Javadoc)
* @see org.wamblee.usermgt.InMemoryUserSetTest#setUp()
super.setUp();
_container = new DefaultContainer("top");
- Component ds = new ExternalDatasourceComponent("datasource");
- _container.addComponent(ds);
+ _container.addComponent(new ExternalDatasourceComponent("datasource"));
+ _container.addComponent("mappingFiles", new UsermgtHibernateMappingFiles());
+ _container.addComponent(new HibernateComponent("hibernate"));
+ _container.addComponent(new UserGroupRepositoryComponent("usersgroups"));
ObjectConfiguration config = new ObjectConfiguration(HibernateUserSetTest.class);
- config.getSetterConfig().clear().add("datasource");
+ config.getSetterConfig().clear().add("datasource").add("userset").add("groupset");
_container.addComponent("testcase", this, config);
- _scope = _container.start();
- Object my = _scope.getInterfaceImplementation(ds.getProvidedInterfaces()[0], Object.class);
+ _scope = _container.start();
clearUserCache();
}
_datasource = aDatasource;
}
+ public void setUserset(UserSet aUserset) {
+ _userset = aUserset;
+ }
+
+ public void setGroupset(GroupSet aGroupset) {
+ _groupset = aGroupset;
+ }
@Override
protected void tearDown() throws Exception {
*/
package org.wamblee.usermgt.hibernate;
+import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
+import net.sf.ehcache.Ehcache;
+
import org.hibernate.SessionFactory;
+import org.wamblee.cache.EhCache;
import org.wamblee.system.core.DefaultProvidedInterface;
import org.wamblee.system.core.DefaultRequiredInterface;
import org.wamblee.system.core.ProvidedInterface;
}
private static Map<RequiredInterface, String> createRequired() {
- Map<RequiredInterface, String> required = new TreeMap<RequiredInterface, String>();
+ Map<RequiredInterface, String> required = new HashMap<RequiredInterface, String>();
required.put(new DefaultRequiredInterface("sessionFactory", SessionFactory.class), "sessionFactory");
return required;
}
private static Map<String, ProvidedInterface> createProvided() {
- Map<String,ProvidedInterface> provided = new TreeMap<String,ProvidedInterface>();
+ Map<String,ProvidedInterface> provided = new HashMap<String,ProvidedInterface>();
+ provided.put("userCache", new DefaultProvidedInterface("cache", EhCache.class));
provided.put(UserSet.class.getName(), new DefaultProvidedInterface("userset", UserSet.class));
provided.put(GroupSet.class.getName(), new DefaultProvidedInterface("groupset", GroupSet.class));
return provided;