package org.appfuse.persistence;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import junit.framework.TestCase;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class BaseDAOTestCase extends TestCase {
protected Log log = LogFactory.getLog(BaseDAOTestCase.class);
ClassPathXmlApplicationContext ctx = null;
protected Object conn = null;
protected ResourceBundle rb = null;
public BaseDAOTestCase() {
ctx = new ClassPathXmlApplicationContext("/applicationContext.xml");
String className = this.getClass().getName();
try {
rb = ResourceBundle.getBundle(className);
} catch (MissingResourceException mre) {
}
}
protected Object populate(Object obj) throws Exception {
Map map = new HashMap();
for (Enumeration keys = rb.getKeys(); keys.hasMoreElements();) {
String key = (String) keys.nextElement();
map.put(key, rb.getString(key));
}
BeanUtils.copyProperties(obj, map);
return obj;
}
}