单元测试与Spring整合的struts2中的action
2014-11-21 15:09
465 查看
环境描述:Struts2 + Spring2.5 + hibernate3 + junit4
目的:对后台Action层的函数进行单元测试
需要的Jar包:junit4.jar(eclipse自带的,在项目路径中导入即可。“properties->Add Library->JUnit->JUnit4”) struts2-junit-plugin-2.1.8.jar spring-test.jar
public class UserAction_Junit extends StrutsSpringTestCase {
protected String getContextLocations() {
return "classpath*:beans*.xml";
}
@Test
public void testGetUsers() throws Exception {
String result = executeAction("/user!getUsers.action");
System.out.println(result);
}
}
目的:对后台Action层的函数进行单元测试
需要的Jar包:junit4.jar(eclipse自带的,在项目路径中导入即可。“properties->Add Library->JUnit->JUnit4”) struts2-junit-plugin-2.1.8.jar spring-test.jar
public class UserAction_Junit extends StrutsSpringTestCase {
protected String getContextLocations() {
return "classpath*:beans*.xml";
}
@Test
public void testGetUsers() throws Exception {
String result = executeAction("/user!getUsers.action");
System.out.println(result);
}
}
相关文章推荐
- spring整合struts2后,struts2的action中调用服务层时,不需要在spring配置文件中去注入
- struts2整合spring出现的Unable to instantiate Action异常
- spring整合SpringMVC Controller 和 Struts2 Action控制层Bean的默认作用域
- Struts2 spring整合 Action 出现java.lang.NoSuchMethodException异常
- spring整合struts2,action里的service注入,空指针异常
- struts2 和 spring整合时的 Action class ... not found 异常
- Struts2整合Spring创建的Action同步问题
- Struts2和Spring3.2 整合时。Struts2 Action 无法通过get,set方式获取前台form传的值
- Struts2与Spring整合.让Spring来管理action
- struts2,spring整合中使用spring 管理struts2的action,springaop 常见问题
- spring 整合struts2 action参数设置不上
- spring-struts2整合 action的管理
- 单元测试Struts2Spring项目的Action和Service(包含源码)
- Struts2和Spring环境下action的单元测试
- SSH整合问题:struts2-spring-plugin自动注入action的属性所产生的问题
- Struts2与Spring整合时Action的创建问题
- 单元测试Struts2Spring项目的Action和Service(包含源码)
- struts2和spring的两种整合方式 action的自动装配
- struts2与spring整合后Action的配置方式
- struts2与spring整合问题,访问struts2链接时,spring会负责创建Action