⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 basetestcase.java

📁 wmoa办公自动化系统 小型的JAVA项目 功能包括审批流 消息发布等
💻 JAVA
字号:
package com.dudu.moa.test;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;

import java.util.*;

/**
 * 注意,此类是JUnit3.8或之前版本的spring测试父类 对于JUnit4,<br/>
 * 推荐使用直接继承spring的AbstractTransactionalJUnit4SpringContextTests
 * @see org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests
 * 
 * @author denglq
 * 
 */
public abstract class BaseTestCase extends
		AbstractTransactionalDataSourceSpringContextTests {
	protected final Log log = LogFactory.getLog(getClass());
	protected ResourceBundle rb;

	protected String[] getConfigLocations() {
		setAutowireMode(AUTOWIRE_BY_NAME);
		return new String[] { "classpath*:spring/*.xml" };
	}

	public BaseTestCase() {
		super.setDefaultRollback(false);
		setAutowireMode(AUTOWIRE_BY_NAME);
		String className = this.getClass().getName();

		try {
			rb = ResourceBundle.getBundle(className);
		} catch (MissingResourceException mre) {
			// log.warn("No resource bundle found for: " + className);
		}
	}

	protected Object populate(Object obj) throws Exception {
		Map<String, String> map = new HashMap<String, String>();

		for (Enumeration<String> keys = rb.getKeys(); keys.hasMoreElements();) {
			String key = keys.nextElement();
			map.put(key, rb.getString(key));
		}

		BeanUtils.copyProperties(map, obj);

		return obj;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -