import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import org.apache.struts2.StrutsSpringJUnit4TestCase;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.opensymphony.xwork2.ActionProxy;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
public class TestActionJUnit4Test extends StrutsSpringJUnit4TestCase<TestAction> {
@Override
protected String getConfigPath() {
return "struts-plugin.xml";
}
@Test
public void testExecute() throws Exception {
ActionProxy proxy = getActionProxy("/test/test.action");
String result = proxy.execute();
assertEquals("success", result);
assertEquals("Test by Linus", ((TestAction) proxy.getAction()).getMessage());
executeAction("/test/test");
assertFalse(getAction().hasFieldErrors());
assertEquals("Test by Linus", findValueAfterExecute("message"));
}
}
分享到:
相关推荐
Struts2 Spring 框架整合 单元测试 Action和Service http://blog.csdn.net/fansunion/
Struts2+Spring+hibernate中对action的单元测试环境搭建[总结].pdf
7.Spring+Junit4单元测试,优点:不会破坏数据库现场,等等。 2)Demo 导入说明: 1.Eclipse Encoding:GBK 2.Eclipse 导入后可能需要在 Xml Catalog 手动添加:ehcache-spring-1.2.xsd(ehcache-spring-annotations...
11.6.4 配置Struts文档struts-config.xml 11.6.5 配置web.xml 11.6.6 启动Tomcat运行示例 11.4 整合Spring和Struts 11.4.1 Spring和Struts的整合方式 11.4.2 编写实现登录的页面regedit.jsp 11.4.3 编写存储登录用户...
11.6.4 配置Struts文档struts-config.xml 11.6.5 配置web.xml 11.6.6 启动Tomcat运行示例 11.4 整合Spring和Struts 11.4.1 Spring和Struts的整合方式 11.4.2 编写实现登录的页面regedit.jsp 11.4.3 编写存储登录用户...
11.6.4 配置Struts文档struts-config.xml 11.6.5 配置web.xml 11.6.6 启动Tomcat运行示例 11.4 整合Spring和Struts 11.4.1 Spring和Struts的整合方式 11.4.2 编写实现登录的页面regedit.jsp 11.4.3 编写存储登录用户...
第3章 使用Struts 2动作 36 3.1 Struts 2动作简介 36 3.2 打包动作 39 3.2.1 Struts 2公文包示例应用程序 39 3.2.2 组织你的包 39 3.2.3 使用struts-default包中的组件 41 3.3 实现动作 43 3.3.1 可选的Action接口 ...
16.2 协同使用Spring和WebWork 2/Struts 2 16.3 集成Spring和Tapestry 16.3.1 集成Spring和Tapestry 3 16.3.2 集成Spring和Tapestry 4 16.4 协同使用Spring和JSF 16.4.1 解析JSF管理的属性 16.4.2 解析Spring...
16.2 协同使用Spring和WebWork 2/Struts 2 16.3 集成Spring和Tapestry 16.3.1 集成Spring和Tapestry 3 16.3.2 集成Spring和Tapestry 4 16.4 协同使用Spring和JSF 16.4.1 解析JSF管理的属性 16.4.2 解析Spring...
16.2协同使用spring和webwork2/struts2 16.3集成spring和tapestry 16.3.1集成spring和tapestry3 16.3.2集成spring和tapestry4 16.4协同使用spring和jsf 16.4.1解析jsf管理的属性 16.4.2解析springbean 16.4.3...
11.Struts2自动查询目录下的action 35 12.一个Action处理多个业务 method 35 13.使用校验模板校验 35 14.校验模板 35 15.文件上传 36 Struts2 UI tabbed pane tab pane datetime tree 37 SSH Struts+Spring+...
AngularJS.in.Action jquery in action中文版 JUnit in Action中文版 LuceneInAction Maven in action Redis in Action SPRING in action Struts2 in action 等等
* cn.itcast.crm.web.action:struts2的action * cn.itcast.crm.web.form:封装页面数据的javaBean * junit:开发人员测试用的 * 搭建hibernate层 * 定义需求:部门信息的页面数据要插入到数据库中 * 定义...
struts2.1 spring2.5 hibernate3.2 很好的集成实例代码,Hibernate配置文件采用POjo注解的形势,spring管理action和BPO、DAO等 用MySQL数据库,用TestServer做JUnit测试时,会自动创建所需要的表
第一部份:介绍实例架构 结合实例讲解Web项目总体结构 分析多层结构优点 具体讲解每个层次的实现技巧 第二部分:介绍组织层次关联利器(Spring) 快速入门 ...借助Junit的单元测试 借助Ant的自动部署
struts2:使用struts2的jar包 * 项目体系分层: cn.itcast.elec.containner:自定义的spring容器,用于在控制层调用操作业务层 cn.itcast.elec.dao:项目的dao层,负责连接数据库的操作 cn.itcast.elec.daomain:...
客户关系管理系统框架搭建: crm项目的架构 * 创建web工程 * 引入jar包 ... * cn.itcast.crm.web.action:struts2的action * cn.itcast.crm.web.form:封装页面数据的javaBean * junit:开发人员测试用的
11.6.4 配置Struts文档struts-config.xml 11.6.5 配置web.xml 11.6.6 启动Tomcat运行示例 11.4 整合Spring和Struts 11.4.1 Spring和Struts的整合方式 11.4.2 编写实现登录的页面regedit.jsp 11.4.3 编写存储登录用户...
以及基于这些技术的商业化应用程序的开发技巧,在讲解过程中以目前最为流行的开发工具MyEclipse为载体,全面系统地介绍了如何在MyEclipse中开发基于Struts、Hibernate、Spring等主流框架的各种Java应用程序。...
\contentsline {chapter}{Contents}{2}{section*.1} {1}Java基础}{17}{chapter.1} {1.1}基本语法}{17}{section.1.1} {1.2}数字表达方式}{17}{section.1.2} {1.3}补码}{19}{section.1.3} {1.3.1}总结}{23}{...