import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
public class BaseTest extends
AbstractDependencyInjectionSpringContextTests {
/**
* load spring configuration file
*/
public String[] getConfigLocations() {
String[] configLocations = { "file:src/main/webapp/WEB-INF/config/applicationContext.xml" };
return configLocations;
}
/**
* public String[] getConfigLocations() {
String[] configLocations = { "applicationContext.xml","hibernate-context.xml" };
return configLocations;
}
*/
}
public class ContentModuleControllerTest extends BaseTest{
ContentModuleService contentModuleService ;
public void setContentModuleService(ContentModuleService contentModuleService)
{
this.contentModuleService = contentModuleService;
}
public void testGetProduct() {
assertEquals("Eric test mock",contentModuleService.forTest("Eric test mock"));
}
public void testGetArticleByDate() {
// MockHttpServletRequest request = new MockHttpServletRequest("GET", "/web/modules/articles/date");
// request.addParameter("debug", "true");
}
}
[b]
MockHttpServletRequest是模拟http请求,不是HttpClient类型的直接调用,MockHttpServletRequest 不需要服务器启动,单纯模拟,根据你自己的实际情况,选择你需要的访问请求模式。HttpClient用在需要response返回值比较的junit环境。[/b]