📄 baseservicetest.java
字号:
package com.leo.dao;
import java.util.Date;
import junit.framework.TestCase;
import org.apache.log4j.Logger;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import com.leo.service.IUserService;
/**
* @author Superleo
*
*/
public class BaseServiceTest extends TestCase {
/**
* 生成测试工厂
*/
protected static ApplicationContext factory;
protected static String ID; // 在此只是申明 ID 赋值在 oneTimeSetUp() 后,否则报错
protected Logger logger = Logger.getLogger(this.getClass());
private Date date;
private static final String APPLICATION_CONTEXT = "WebRoot\\WEB-INF\\applicationContext.xml";
// private static final String SERVLET_CONTEXT =
// "WebRoot\\WEB-INF\\servletContext.xml";
protected void setUp() throws Exception {
date = new Date();
factory = new FileSystemXmlApplicationContext(
new String[] { APPLICATION_CONTEXT });
logger.info("测试启动开始,当前时间:" + date.toString()
+ "...............................");
}
protected void tearDown() throws Exception {
logger.info("测试正常结束,历时:"
+ (System.currentTimeMillis() - date.getTime())
+ " ms...............................");
}
/** ***************************************************************************** */
public static IUserService getUserService() {
return (IUserService) factory.getBean("userService");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -