1. StrutsTestCase 簡介
	StrutsTestCase 是標(biāo)準(zhǔn) Junit TestCase 的一個擴(kuò)展,為Struts framework提供了方便靈活的測試代碼
	StrutsTestCase 用 ActionServlet controller 進(jìn)行測試,我們可測試Action object, mapping, form bean, forwards
	StrutsTestCase 提供了 Mock Object 和 Cactus 兩種方法來運行Struts ActionServlet,允許在 servlet engine 內(nèi)或外來測試。
	MockStrutsTestCase 使用一系列HttpServlet 模仿對象來模擬容器環(huán)境,CactusStrutsTestCase 使用Cactus testing framework在實際的容器
	中測試
2. 看StrutsTestCase如何工作
	我們用的例子是驗證用戶名和密碼的action,只要接受參數(shù)然后進(jìn)行簡單的邏輯驗證行了,所以我們要做的是:
	(1)建好目錄,準(zhǔn)備必要的jar 文件,struts-config.xml, 資源文件
	(2)action,formbean 的源文件
	(3)test 的源文件
	(4)編寫ant 文件,進(jìn)行測試
	這里我們用MockStrutsTestCase,CactusStrutsTestCase 的用法也是一樣的,只要改一下繼承類行了
	先建立目錄結(jié)構(gòu)
	strutstest
	|-- src
	|-- war
	|-- |-- WEB-INF
	|-- |-- |-- classes
	|-- |-- |-- lib
	把struts 所需要的jarfile 和 strutstest, junit 放入lib
然后寫struts-config.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
	<!DOCTYPE struts-config PUBLIC
	"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
	"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
	<!--
	This is the Struts configuration file for the "Hello!" sample application
	-->
<struts-config>
	<!-- ======== Form Bean Definitions =================================== -->
	<form-beans>
	<form-bean name="LoginForm" type="LoginForm"/>
	</form-beans>
	<!-- ======== Global Forwards ====================================== -->
	<global-forwards>
	<forward name="login" path="/login.jsp"/>
	</global-forwards>
	<!-- ========== Action Mapping Definitions ============================== -->
	<action-mappings>
	<!-- Say Hello! -->
	<action path = "/login"
	type = "LoginAction"
	name = "LoginForm"
	scope = "request"
	validate = "true"
	input = "/login.jsp"
	>
	<forward name="success" path="/hello.jsp" />
	</action>
	</action-mappings>
	
	<!-- ========== Message Resources Definitions =========================== -->
<message-resources parameter="application"/>
</struts-config>
資源文件我們這里只寫一個用于測試的錯誤信息行了, application.properties :
error.password.mismatch=password mismatch
	
	寫LoginForm 來封狀用戶名和密碼:
	import javax.servlet.http.*;
	import org.apache.struts.action.*;
	public class LoginForm extends ActionForm {
	public String username;
	public String password;
	public void setUsername( String username ) {
	this.username = username;
	}
	public String getUsername(){
	return username;
	}
	public void setPassword( String password ) {
	this.password = password;
	}
	public String getPassword(){
	return password;
	}
	}