【Java开源代码栏目提醒】:网学会员,鉴于大家对Java开源代码十分关注,论文会员在此为大家搜集整理了“BaseManagerTestCase.java”一文,供大家参考学习!
package com.welshow.hbp.service;
import java.util.Map;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.welshow.hbp.util.ConvertUtil;
import org.jmock.MockObjectTestCase;
public abstract class BaseManagerTestCase extends MockObjectTestCase {
//~ Static fields/initializers =============================================
protected final Log log = LogFactory.getLog(getClass());
protected ResourceBundle rb;
//~ Constructors ===========================================================
public BaseManagerTestCase() {
// Since a ResourceBundle is not required for each class, just
// do a simple check to see if one exists
String className = this.getClass().getName();
try {
rb = ResourceBundle.getBundle(className);
} catch (MissingResourceException mre) {
//log.warn("No resource bundle found for: " + className);
}
}
//~ Methods ================================================================
/**
* Utility method to populate a javabean-style object with values
* from a Properties file
*
* @param obj
* @return
* @throws Exception
*/
protected Object populate(Object obj) throws Exception {
// loop through all the beans methods and set its properties from
// its .properties file
Map map = ConvertUtil.convertBundleToMap(rb);
BeanUtils.copyProperties(obj, map);
return obj;
}
}
上一篇:
BaseManager.java
下一篇:
月入5000,你有什么资格谈生活