锘??xml version="1.0" encoding="utf-8" standalone="yes"?>综合偷自拍亚洲乱中文字幕,亚洲国产成人久久77,亚洲国产精品一区二区三区久久
http://m.tkk7.com/Good-Game/category/23016.htmlzh-cnThu, 06 Mar 2008 07:59:02 GMTThu, 06 Mar 2008 07:59:02 GMT60- httpUnit 涔嬩嬌鐢ㄥ叾浠杦eb璧勬簮http://m.tkk7.com/Good-Game/archive/2008/01/29/178388.htmlG_GG_GTue, 29 Jan 2008 09:25:00 GMThttp://m.tkk7.com/Good-Game/archive/2008/01/29/178388.htmlhttp://m.tkk7.com/Good-Game/comments/178388.htmlhttp://m.tkk7.com/Good-Game/archive/2008/01/29/178388.html#Feedback0http://m.tkk7.com/Good-Game/comments/commentRss/178388.htmlhttp://m.tkk7.com/Good-Game/services/trackbacks/178388.htmlhttpUnit
package聽httpUnit;
import聽com.meterware.httpunit.GetMethodWebRequest;
import聽com.meterware.httpunit.WebConversation;
import聽com.meterware.httpunit.WebForm;
import聽com.meterware.httpunit.WebRequest;
import聽com.meterware.httpunit.WebResponse;
import聽junit.framework.TestCase;
public聽class聽HttpTest聽extends聽TestCase聽{
聽聽聽聽public聽void聽testT()聽throws聽Exception聽{
聽聽聽聽聽聽聽聽WebConversation聽wc聽=聽new聽WebConversation();
聽聽聽聽聽聽聽聽WebRequest聽聽聽聽聽req聽=聽new聽GetMethodWebRequest(聽"http://www.baidu.com"聽);
聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽WebResponse聽聽聽resp聽=聽wc.getResponse(聽req聽);
聽聽聽聽聽聽聽聽//<input聽type=submit聽value=鐧懼害涓涓嬄爄d=sb>
聽聽聽聽聽聽聽聽//<input聽type=text聽name=wd聽id=kw聽size=36聽maxlength=100>
聽聽聽聽聽聽聽聽WebForm聽form聽=聽resp.getForms()[0];聽聽聽聽聽聽//聽select聽the聽first聽form聽in聽the聽page
聽聽聽聽聽聽聽聽form.setParameter(聽"wd",聽"Italian"聽);聽聽聽
聽聽聽聽聽聽聽聽resp.getForms()[0].getSubmitButtonWithID("sb").click();
聽聽聽聽聽聽聽聽System.out.println(聽wc.getCurrentPage().getText()聽);
聽聽聽聽}
}

]]> - 涓嶄嬌鐢ㄥ鍣?榪涜 嫻嬭瘯 jsp http://m.tkk7.com/Good-Game/archive/2007/11/02/157794.htmlG_GG_GFri, 02 Nov 2007 09:11:00 GMThttp://m.tkk7.com/Good-Game/archive/2007/11/02/157794.htmlhttp://m.tkk7.com/Good-Game/comments/157794.htmlhttp://m.tkk7.com/Good-Game/archive/2007/11/02/157794.html#Feedback0http://m.tkk7.com/Good-Game/comments/commentRss/157794.htmlhttp://m.tkk7.com/Good-Game/services/trackbacks/157794.html瀹瑰櫒澶栫殑JSP欏甸潰嫻嬭瘯鎶鏈?/a>
鐢變簬涓婇潰緇欏嚭渚?澶嶆潅 銆備竴鑸漢寰堥毦鐞嗚В銆傛垜涔熸槸 ^_^
浣嗕粩緇嗙湅鎴戣繕鏄嚜宸卞啓鍑轟竴涓瘮杈冪畝鍗曠殑錛屾湜澶у涓璧瘋璁恒?br />
琚祴璇昷sp
<%@聽taglib聽prefix="html"聽uri="/WEB-INF/struts-html.tld"聽%>
<%@聽taglib聽prefix="c"聽uri="/WEB-INF/c-1_0-rt.tld"聽%>
<html:html>
聽聽聽聽<c:if聽test="${name聽!=聽pass}">
聽聽聽聽聽聽聽${name}聽聽<br>
聽聽聽聽聽聽聽${pass}聽<br>
聽聽聽 聽聽 <!-- <html:text property="in" ></html:text> -->
聽聽聽聽</c:if>
</html:html>
ant鐩存帴鎶婁粬鏀懼湪 eclipes 宸ョ▼鐨勬牴鐩綍涓?build.xml
聽聽聽 浣嗘湁鏈?涓弬鏁拌璁劇疆 tomcat.home聽 Tomcat 鐨勫湴鍧
聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 webapp.path 宸ョ▼涓殑鏍圭洰褰曪紝涓嬮潰鏈塛EB-INF
聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 src 鍘熶唬鐮?錛堝埌鏃跺檍sp浼氱炕璇戞垚.java
聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 鍒拌繖涓洰褰曠殑 org.apache.jsp.jsp 涓嬶級
<project聽name="Webapp聽Precompilation"聽default="all"聽basedir=".">聽
聽聽<!--聽tomcat聽dir聽-->
聽聽<property聽name="tomcat.home"聽value="D:\Tomcat聽5.0"/>
聽聽
聽聽<!--聽this=..//WEB-INF聽(in聽eclipes)聽聽-->
聽聽<property聽name="webapp.path"聽value=".\WebRoot"/>
聽聽<!--聽src聽(in聽eclipes)聽-->
聽聽<property聽name="src"聽value="./src"/>
聽聽<target聽name="jspc">聽
聽聽聽聽<taskdef聽classname="org.apache.jasper.JspC"聽name="jasper2"聽>聽
聽聽聽聽聽聽<classpath聽id="jspc.classpath">聽
聽聽聽聽聽聽聽聽<pathelement聽location="${java.home}/../lib/tools.jar"/>聽
聽聽聽聽聽聽聽聽<fileset聽dir="${tomcat.home}/bin">聽
聽聽聽聽聽聽聽聽聽聽<include聽name="*.jar"/>聽
聽聽聽聽聽聽聽聽</fileset>聽
聽聽聽聽聽聽聽聽<fileset聽dir="${tomcat.home}/server/lib">聽
聽聽聽聽聽聽聽聽聽聽<include聽name="*.jar"/>聽
聽聽聽聽聽聽聽聽</fileset>聽
聽聽聽聽聽聽聽聽<fileset聽dir="${tomcat.home}/common/lib">聽
聽聽聽聽聽聽聽聽聽聽<include聽name="*.jar"/>聽
聽聽聽聽聽聽聽聽</fileset>聽
聽聽聽聽聽聽</classpath>聽
聽聽聽聽</taskdef>聽
聽聽聽聽<jasper2聽
聽聽聽聽聽聽聽聽聽聽聽聽聽validateXml="false"聽
聽聽聽聽聽聽聽聽聽聽聽聽聽uriroot="${webapp.path}"聽
聽聽聽聽聽聽聽聽聽聽聽聽聽webXmlFragment="${webapp.path}/WEB-INF/generated_web.xml"聽
聽聽聽聽聽聽聽聽聽聽聽聽聽outputDir="${src}"聽/>聽
聽聽</target>
聽聽<target聽name="compile">
聽聽聽聽<mkdir聽dir="${webapp.path}/WEB-INF/classes"/>
聽聽聽聽<mkdir聽dir="${webapp.path}/WEB-INF/lib"/>
聽聽聽聽<javac聽destdir="${webapp.path}/WEB-INF/classes"
聽聽聽聽聽聽聽聽聽聽聽optimize="off"
聽聽聽聽聽聽聽聽聽聽聽debug="on"聽failonerror="false"
聽聽聽聽聽聽聽聽聽聽聽srcdir="${src}"聽
聽聽聽聽聽聽聽excludes="**/*.smap">
聽聽聽聽聽聽<classpath>
聽聽聽聽聽聽聽聽<pathelement聽location="${webapp.path}/WEB-INF/classes"/>
聽聽聽聽聽聽聽聽<fileset聽dir="${webapp.path}/WEB-INF/lib">
聽聽聽聽聽聽聽聽聽聽<include聽name="*.jar"/>
聽聽聽聽聽聽聽聽</fileset>
聽聽聽聽聽聽聽聽<pathelement聽location="${tomcat.home}/common/classes"/>
聽聽聽聽聽聽聽聽<fileset聽dir="${tomcat.home}/common/lib">
聽聽聽聽聽聽聽聽聽聽<include聽name="*.jar"/>
聽聽聽聽聽聽聽聽</fileset>
聽聽聽聽聽聽聽聽<pathelement聽location="${tomcat.home}/shared/classes"/>
聽聽聽聽聽聽聽聽<fileset聽dir="${tomcat.home}/shared/lib">
聽聽聽聽聽聽聽聽聽聽<include聽name="*.jar"/>
聽聽聽聽聽聽聽聽</fileset>
聽聽聽聽聽聽聽聽<fileset聽dir="${tomcat.home}/bin">聽
聽聽聽聽聽聽聽聽聽聽<include聽name="*.jar"/>聽
聽聽聽聽聽聽聽聽</fileset>聽
聽聽聽聽聽聽</classpath>
聽聽聽聽聽聽<include聽name="**"聽/>
聽聽聽聽聽聽<exclude聽name="tags/**"聽/>
聽聽聽聽</javac>
聽聽</target>
聽聽<target聽name="all"聽depends="jspc,compile">
聽聽</target>
聽聽<target聽name="cleanup">
聽聽聽聽聽聽<delete>
聽聽聽聽聽聽聽聽<fileset聽dir="${webapp.path}/WEB-INF/src"/>
聽聽聽聽聽聽聽聽<fileset聽dir="${webapp.path}/WEB-INF/classes/org/apache/jsp"/>
聽聽聽聽聽聽</delete>
聽聽</target>
</project>
TEST
package聽jetty.test.supper;
import聽javax.servlet.http.HttpServletRequest;
import聽javax.servlet.http.HttpServletResponse;
import聽org.apache.jsp.jsp.MyJsp_jsp;
import聽com.meterware.httpunit.GetMethodWebRequest;
import聽com.meterware.httpunit.WebRequest;
import聽com.meterware.httpunit.WebResponse;
import聽com.meterware.servletunit.InvocationContext;
import聽com.meterware.servletunit.ServletRunner;
import聽com.meterware.servletunit.ServletUnitClient;
import聽junit.framework.TestCase;
public聽class聽JSPCTest聽extends聽TestCase{
聽聽聽聽private聽InvocationContext聽ic聽=聽null聽;
聽聽聽聽protected聽void聽setUp()聽throws聽Exception聽{
聽聽聽聽聽聽聽聽ServletRunner聽sr聽=聽new聽ServletRunner();
聽聽聽聽聽聽聽聽聽聽聽//聽鍚戠幆澧冧腑娉ㄥ唽 jsp
聽聽聽聽聽聽聽聽sr.registerServlet("HelloWorld",聽MyJsp_jsp.class.getName());
聽聽聽聽聽聽聽聽ServletUnitClient聽聽sc聽=聽sr.newClient();
聽聽聽聽聽聽聽聽WebRequest聽request聽=聽new聽GetMethodWebRequest("http://localhost/HelloWorld");
聽聽聽聽聽聽聽聽聽ic聽=聽sc.newInvocation(request);
聽聽聽聽}
聽聽聽聽
聽聽聽聽public聽void聽testJspC()聽throws聽Exception{
聽聽聽聽聽聽聽聽HttpServletRequest聽re聽=聽聽ic聽.getRequest();
聽聽聽聽聽聽聽聽HttpServletResponse聽rq聽=聽聽ic.getResponse();
聽聽聽聽聽聽聽聽re.setAttribute("name","liukaiyi");
聽聽聽聽聽聽聽聽re.setAttribute("pass","123456");
聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽MyJsp_jsp聽is聽=聽(MyJsp_jsp)聽ic.getServlet();
聽聽聽聽聽聽聽聽is._jspService(re,rq);
聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽WebResponse聽response聽=聽ic.getServletResponse();
// 杈撳嚭
聽聽聽聽聽聽聽聽System.out.println(聽response.getText()聽);
聽聽聽聽聽聽聽聽
聽聽聽聽}
}
緇撴灉鏄?br /><html>
聽聽聽聽
聽聽聽聽聽聽聽liukaiyi聽聽<br>
聽聽聽聽聽聽聽123456聽<br>
聽聽聽聽
聽聽聽聽
</html>
鍚庨潰鐢?HttpUnit 鍜?HtmlUnit 嫻嬭瘯灝變笉鐢ㄦ垜璇翠簡鎶?緗戜笂涓澶ф妸銆?/font>

]]> - 嫻嬭瘯 WEBhttp://m.tkk7.com/Good-Game/archive/2007/11/02/157726.htmlG_GG_GFri, 02 Nov 2007 04:44:00 GMThttp://m.tkk7.com/Good-Game/archive/2007/11/02/157726.htmlhttp://m.tkk7.com/Good-Game/comments/157726.htmlhttp://m.tkk7.com/Good-Game/archive/2007/11/02/157726.html#Feedback0http://m.tkk7.com/Good-Game/comments/commentRss/157726.htmlhttp://m.tkk7.com/Good-Game/services/trackbacks/157726.html
瀛︿範嫻嬭瘯鐣欎釜鍗?br />
嫻嬭瘯 Servlet 浣跨敤:
package
聽jetty.test.supper;
import
聽java.io.File;
import
聽javax.servlet.http.HttpServletRequest;
import
聽jetty.LoginServlet;
import
聽com.meterware.httpunit.GetMethodWebRequest;
import
聽com.meterware.httpunit.WebConversation;
import
聽com.meterware.httpunit.WebRequest;
import
聽com.meterware.httpunit.WebResponse;
import
聽com.meterware.servletunit.InvocationContext;
import
聽com.meterware.servletunit.ServletRunner;
import
聽com.meterware.servletunit.ServletUnitClient;
import
聽junit.framework.TestCase;
public
聽
class
聽HttpUnitTest聽
extends
聽TestCase聽{
聽聽聽聽
public
聽
void
聽ctestUrl()
throws
聽Exception{
聽聽聽聽聽聽聽聽System.out.println(
"
鐩存帴鑾峰彇緗戦〉鍐呭錛?/span>
"
);
聽聽聽聽聽聽聽聽WebConversation聽wc聽
=
聽
new
聽WebConversation();
聽聽聽聽聽聽聽聽WebResponse聽wr聽
=
聽wc.getResponse(聽
"
http://www.google.com
"
聽);
聽聽聽聽聽聽聽聽System.out.println(聽wr.getText()聽);
聽聽聽聽}
聽聽聽聽
聽聽聽聽
public
聽
void
聽testRun1()
throws
聽Exception{
聽聽聽聽聽聽聽聽System.out.println(
"
鏃犲弬鏁版祴璇曪細
"
);
聽聽聽聽聽聽聽聽
//
寤虹珛鏈嶅姟鍣?/span>
聽聽聽聽聽聽聽聽ServletRunner聽sr聽
=
聽
new
聽ServletRunner(
new
聽File(
"
WebRoot\\WEB-INF\\test.xml
"
));
聽聽聽聽聽聽聽聽
//
妯℃嫙瀹㈡埛绔?/span>
聽聽聽聽聽聽聽聽ServletUnitClient聽sc聽
=
聽sr.newClient();
聽聽聽聽聽聽聽聽
//
URL聽瀹氫綅
聽聽聽聽聽聽聽聽WebRequest聽request聽聽聽
=
聽
new
聽GetMethodWebRequest(聽
"
http://localhost:7000/cactusDemo
"
聽);
聽聽聽聽聽聽聽聽WebResponse聽response聽
=
聽sc.getResponse(聽request聽);
聽聽聽聽聽聽聽聽
//
榪愯
聽聽聽聽聽聽聽聽System.out.println(response.getText()
+
"
\n
"
);
聽聽聽聽}
聽聽聽聽
聽聽聽聽
public
聽
void
聽testRun2()
throws
聽Exception{
聽聽聽聽聽聽聽聽System.out.println(
"
Session聽鍜屄爎equest聽嫻嬭瘯錛?/span>
"
);
聽聽聽聽聽聽聽聽ServletRunner聽sr聽
=
聽
new
聽ServletRunner(
new
聽File(
"
WebRoot\\WEB-INF\\test.xml
"
));
聽聽聽聽聽聽聽聽ServletUnitClient聽sc聽
=
聽sr.newClient();
聽聽聽聽聽聽聽聽WebRequest聽request聽聽聽
=
聽
new
聽GetMethodWebRequest(聽
"
http://localhost/cactusDemo
"
聽);
聽聽聽聽聽聽聽聽
//
Parameter聽鍔犲弬聽use聽
聽聽聽聽聽聽聽聽request.setParameter(
"
use
"
,
"
web
"
);
聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽
//
鍙栧嚭聽Servlet聽:聽LoginServlet聽鏂規硶鍑嗗鎵ц
聽聽聽聽聽聽聽聽InvocationContext聽ic聽
=
聽sc.newInvocation(聽request聽);
聽聽聽聽聽聽聽聽LoginServlet聽se聽
=
聽(LoginServlet)ic.getServlet();
聽聽聽聽聽聽聽聽HttpServletRequest聽re聽
=
聽ic.getRequest()聽;
聽聽聽聽聽聽聽聽
//
request聽session聽聽鍔犲弬聽use聽
聽聽聽聽聽聽聽聽re.setAttribute(
"
use
"
,
"
re
"
);
聽聽聽聽聽聽聽聽re.getSession(
true
).setAttribute(
"
use
"
,
"
re
"
);
聽聽聽聽聽聽聽聽se.doGet(re,ic.getResponse());
//
鍏抽敭錛氳繍琛屾祴璇曟柟娉?br />聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽
//
鑾峰彇聽out
聽聽聽聽聽聽聽聽WebResponse聽response聽
=
聽ic.getServletResponse();
聽聽聽聽聽聽聽聽System.out.println(response.getText());
聽聽聽聽}
}
test.xml
<?
xml聽version="1.0"聽encoding="UTF-8"
?>
<
web-app聽
xmlns
="http://java.sun.com/xml/ns/j2ee"
聽xmlns:xsi
="http://www.w3.org/2001/XMLSchema-instance"
聽version
="2.4"
聽xsi:schemaLocation
="http://java.sun.com/xml/ns/j2ee聽聽聽http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
>
聽聽
<
servlet
>
聽聽聽聽
<
servlet-name
>
cactusDemo
</
servlet-name
>
聽聽聽聽
<
servlet-class
>
jetty.LoginServlet
</
servlet-class
>
聽聽
</
servlet
>
聽聽
<
servlet-mapping
>
聽聽聽聽
<
servlet-name
>
cactusDemo
</
servlet-name
>
聽聽聽聽
<
url-pattern
>
/cactusDemo
</
url-pattern
>
聽聽
</
servlet-mapping
>
</
web-app
>
嫻嬭瘯 JSP:
Cookbook
鍙傝?/font>聽
涓嶄嬌鐢ㄥ鍣?榪涜 嫻嬭瘯 jsp
嫻嬭瘯Struts:
StrutsTestCase
鍙傝?/font>聽

]]>- 嫻嬭瘯 servlet(杞?http://m.tkk7.com/Good-Game/archive/2007/10/31/157141.htmlG_GG_GWed, 31 Oct 2007 03:11:00 GMThttp://m.tkk7.com/Good-Game/archive/2007/10/31/157141.htmlhttp://m.tkk7.com/Good-Game/comments/157141.htmlhttp://m.tkk7.com/Good-Game/archive/2007/10/31/157141.html#Feedback2http://m.tkk7.com/Good-Game/comments/commentRss/157141.htmlhttp://m.tkk7.com/Good-Game/services/trackbacks/157141.html
1>servlet鍙互鑴辯瀹瑰櫒錛屽鏄撴妸璇ユ祴璇曞啓鍏nt鎴杕aven鑴氭湰錛岃嫻嬭瘯榪涜銆?br />2>httpunit鍦ㄦ祴璇晄ervlet琛屼負鏃訛紝閲囩敤鐨勬槸瀹屽叏妯℃嫙嫻忚鍣紝鏈夋椂嫻嬭瘯姣旇緝闅懼啓銆?/font>
package聽Cactus.test.support;
import聽junit.framework.TestCase;
import聽Cactus.HelloWorld;
import聽com.meterware.httpunit.GetMethodWebRequest;
import聽com.meterware.httpunit.WebRequest;
import聽com.meterware.httpunit.WebResponse;
import聽com.meterware.servletunit.InvocationContext;
import聽com.meterware.servletunit.ServletRunner;
import聽com.meterware.servletunit.ServletUnitClient;
import聽junit.framework.Assert;
聽
public聽class聽HttpUnitTestHelloWorld聽extends聽TestCase聽{
聽
聽protected聽void聽setUp()聽throws聽Exception聽{
聽聽super.setUp();
聽}
聽
聽protected聽void聽tearDown()聽throws聽Exception聽{
聽聽super.tearDown();
聽}
聽
聽public聽void聽testHelloWorld()聽{
聽聽
聽聽try聽{
聽聽聽//聽鍒涘緩Servlet鐨勮繍琛岀幆澧?/span>
聽聽聽ServletRunner聽sr聽=聽new聽ServletRunner();
聽聽聽//聽鍚戠幆澧冧腑娉ㄥ唽Servlet
聽聽聽sr.registerServlet("HelloWorld",聽HelloWorld.class.getName());
聽
聽聽聽//聽鍒涘緩璁塊棶Servlet鐨勫鎴風
聽聽聽ServletUnitClient聽sc聽=聽sr.newClient();
聽聽聽//聽鍙戦佽姹?/span>
聽聽聽WebRequest聽request聽=聽new聽GetMethodWebRequest("http://localhost/HelloWorld");
聽聽聽request.setParameter("username",聽"testuser");
聽聽聽
聽聽聽//鐢ㄥ鎵樺姞杞鉸爄s
聽聽聽InvocationContext聽ic聽=聽sc.newInvocation(request);
聽聽聽HelloWorld聽is聽=聽(HelloWorld)聽ic.getServlet();
聽
聽聽聽//聽嫻嬭瘯servlet鐨勬煇涓柟娉?/span>
聽聽聽Assert.assertTrue(is.authenticate());
聽聽聽//聽鑾峰緱妯℃嫙鏈嶅姟鍣ㄧ殑淇℃伅
聽聽聽WebResponse聽response聽=聽sc.getResponse(request);
聽聽聽//聽鏂█
聽聽聽Assert.assertTrue(response.getText().equals("testuser:Hello聽World!"));
聽聽}聽catch聽(Exception聽e)聽{
聽聽聽e.printStackTrace();
聽聽}
聽}
聽
}
Jetty
package聽Cactus.test.support;
import聽org.mortbay.jetty.Connector;
import聽org.mortbay.jetty.Server;
import聽org.mortbay.jetty.bio.SocketConnector;
import聽org.mortbay.jetty.servlet.ServletHandler;
聽
import聽com.meterware.httpunit.WebConversation;
import聽com.meterware.httpunit.WebResponse;
聽
import聽junit.framework.Assert;
import聽junit.framework.TestCase;
聽
public聽class聽JettySampleTest聽extends聽TestCase聽{
聽
聽Server聽server;
聽protected聽void聽setUp()聽throws聽Exception聽{
聽聽聽聽聽聽//閫氳繃浠g爜璁劇疆騫跺惎鍔ㄤ竴涓湇鍔″櫒錛岃鏈嶅姟鍣ㄦ槸servlet鐨勬祴璇曞鍣?/span>
聽聽聽聽聽聽super.setUp();
聽聽聽聽聽聽server聽=聽new聽Server();
聽聽聽聽聽聽Connector聽connector=new聽SocketConnector();
聽聽聽聽聽聽connector.setPort(80);
聽聽聽聽聽聽server.setConnectors(new聽Connector[]{connector});
聽聽聽聽聽聽ServletHandler聽handler=new聽ServletHandler();
聽聽聽聽聽聽server.setHandler(handler);
聽聽聽聽聽聽handler.addServletWithMapping("Cactus.HelloWorld",聽"/");
聽聽聽聽聽聽server.start();
聽}
聽
聽protected聽void聽tearDown()聽throws聽Exception聽{
聽聽super.tearDown();
聽聽server.stop();
聽}
聽
聽public聽void聽testHellWorld()聽{
聽聽try聽{
聽聽聽WebConversation聽wc聽=聽new聽WebConversation();
聽聽聽WebResponse聽web聽=聽wc.getResponse("http://127.0.0.1/HelloWorld");
聽聽聽String聽result=web.getText();
聽聽聽Assert.assertEquals(result,"null:Hello聽World!");
聽聽
聽聽}聽catch聽(Exception聽e)聽{
聽聽聽e.printStackTrace();
聽聽}
聽}
}

]]> - junit 絎旇http://m.tkk7.com/Good-Game/archive/2007/10/30/157007.htmlG_GG_GTue, 30 Oct 2007 09:59:00 GMThttp://m.tkk7.com/Good-Game/archive/2007/10/30/157007.htmlhttp://m.tkk7.com/Good-Game/comments/157007.htmlhttp://m.tkk7.com/Good-Game/archive/2007/10/30/157007.html#Feedback0http://m.tkk7.com/Good-Game/comments/commentRss/157007.htmlhttp://m.tkk7.com/Good-Game/services/trackbacks/157007.html
1. TestSuite
聽 public static Test suite() {
聽聽聽聽 TestSuite suite = new TestSuite(MathTool.class);
聽聽聽聽 suite.addTest(new MathToolTest("testGcd"));
聽 }
2.鍏ㄥ眬灞炴?br /> protected void setUp() throws Exception {
super.setUp();
arr = new ............;
}
protected void tearDown() throws Exception {
super.tearDown();
arr = null;
}
3. Cactus
web璁劇疆
http://caterpillar.onlyfun.net/GossipCN/JUnit/FirstCactusWithTomcat.htm
http://caterpillar.onlyfun.net/GossipCN/JUnit/FirstCactusWithJetty.htm

]]> - 鍦↗unit涓祴璇曠鏈夊嚱鏁扮殑鏂規硶錛坖unit, private, method) 錛堣漿錛?/title>http://m.tkk7.com/Good-Game/archive/2007/10/23/155223.htmlG_GG_GTue, 23 Oct 2007 03:11:00 GMThttp://m.tkk7.com/Good-Game/archive/2007/10/23/155223.htmlhttp://m.tkk7.com/Good-Game/comments/155223.htmlhttp://m.tkk7.com/Good-Game/archive/2007/10/23/155223.html#Feedback0http://m.tkk7.com/Good-Game/comments/commentRss/155223.htmlhttp://m.tkk7.com/Good-Game/services/trackbacks/155223.htmleclipse涓浣曞啓涓涓祴璇曠鏈夋柟娉曠殑junit錛?br />鍋囪綾籗ummer瀹氫箟濡備笅錛?br />public class Summer{
聽聽聽private int methodone(String argsone){
聽聽聽聽聽聽//method code
聽聽聽聽聽聽.......
聽聽聽聽聽聽return聽4;
聽聽聽}
}
嫻嬭瘯濡備笅錛?br />public class SummerTest extends TestCase {
聽聽聽public void testMethodone(){
聽聽聽聽聽聽Object rightResult = xxxxx;
聽聽聽聽聽聽Summer聽example =聽new Summer.newInstance();
聽聽聽聽聽聽Method m =聽example .getClass().getDeclaredMethod("methodone",new Class[]{String.class});
聽聽聽聽聽聽m.setAccessible(true);
聽聽聽聽聽聽Object result = m.invoke(example ,new聽Object[]聽{new String(xxxx)});
聽聽聽聽聽聽m.setAccessible(false);
聽聽聽聽聽聽if (result.equals(rightResult)){
聽聽聽聽聽聽聽聽聽//your code
聽聽聽聽聽聽聽聽聽......
聽聽聽聽聽聽}
聽聽聽}
}

]]> - StrutsTestCase 涓嶉渶瑕?鍐?classpath 鏂規硶 ^_^http://m.tkk7.com/Good-Game/archive/2007/04/16/110991.htmlG_GG_GMon, 16 Apr 2007 08:01:00 GMThttp://m.tkk7.com/Good-Game/archive/2007/04/16/110991.htmlhttp://m.tkk7.com/Good-Game/comments/110991.htmlhttp://m.tkk7.com/Good-Game/archive/2007/04/16/110991.html#Feedback4http://m.tkk7.com/Good-Game/comments/commentRss/110991.htmlhttp://m.tkk7.com/Good-Game/services/trackbacks/110991.html 涓嬭澆http://sourceforge.net/projects/strutstestcase/
struts-config.xml
<?
xml聽version
=
"
1.0
"
聽encoding
=
"
UTF-8
"
?>
<!
DOCTYPE聽struts
-
config聽PUBLIC聽
"
-//Apache聽Software聽Foundation//DTD聽Struts聽Configuration聽1.1//EN
"
聽
"
http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd
"
>
<
struts
-
config
>
聽聽
<
data
-
sources聽
/>
聽聽
<
form
-
beans聽
>
聽聽聽聽
<
form
-
bean聽name
=
"
loginForm
"
聽type
=
"
com.yourcompany.struts.form.LoginForm
"
聽
/>
聽聽
</
form
-
beans
>
聽聽
<
global
-
exceptions聽
/>
聽聽
<
global
-
forwards聽
/>
聽聽
<
action
-
mappings聽
>
聽聽聽聽
<
action
聽聽聽聽聽聽name
=
"
loginForm
"
聽聽聽聽聽聽path
=
"
/login
"
聽聽聽聽聽聽scope
=
"
request
"
聽聽聽聽聽聽type
=
"
com.yourcompany.struts.action.LoginAction
"
>
聽聽聽聽聽聽
<
forward
聽聽聽聽聽聽聽聽name
=
"
ok
"
聽聽聽聽聽聽聽聽path
=
"
/form/suss.jsp
"
/>
聽聽聽聽聽聽
<
forward
聽聽聽聽聽聽聽聽name
=
"
error
"
聽聽聽聽聽聽聽聽path
=
"
/form/login.jsp
"
/>
聽聽聽聽聽聽聽聽聽
聽聽聽聽
</
action
>
聽聽
</
action
-
mappings
>
聽聽
<
message
-
resources聽parameter
=
"
com.yourcompany.struts.ApplicationResources
"
聽
/>
</
struts
-
config
>
Action
//Created聽by聽MyEclipse聽Struts
//聽XSL聽source聽(default):聽platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_4.0.1/xslt/JavaClass.xsl
package聽com.yourcompany.struts.action;
import聽javax.servlet.http.HttpServletRequest;
import聽javax.servlet.http.HttpServletResponse;
import聽org.apache.struts.action.Action;
import聽org.apache.struts.action.ActionForm;
import聽org.apache.struts.action.ActionForward;
import聽org.apache.struts.action.ActionMapping;
import聽com.yourcompany.struts.form.LoginForm;
/**聽
聽*聽MyEclipse聽Struts
聽*聽Creation聽date:聽04-16-2007
聽*聽
聽*聽XDoclet聽definition:
聽*聽@struts.action聽path="/login"聽name="loginForm"聽input="/form/login.jsp"聽scope="request"聽validate="true"
聽*聽@struts.action-forward聽name="Myjsp"聽path="/WEB-INF/"
聽*/
public聽class聽LoginAction聽extends聽Action聽{
聽聽聽聽//聽---------------------------------------------------------聽Instance聽Variables
聽聽聽聽//聽---------------------------------------------------------聽Methods
聽聽聽聽/**聽
聽聽聽聽聽*聽Method聽execute
聽聽聽聽聽*聽@param聽mapping
聽聽聽聽聽*聽@param聽form
聽聽聽聽聽*聽@param聽request
聽聽聽聽聽*聽@param聽response
聽聽聽聽聽*聽@return聽ActionForward
聽聽聽聽聽*/
聽聽聽聽public聽ActionForward聽execute(
聽聽聽聽聽聽聽聽ActionMapping聽mapping,
聽聽聽聽聽聽聽聽ActionForm聽form,
聽聽聽聽聽聽聽聽HttpServletRequest聽request,
聽聽聽聽聽聽聽聽HttpServletResponse聽response)聽{
聽聽聽聽聽聽聽聽LoginForm聽loginForm聽=聽(LoginForm)聽form;
聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽String聽name聽=聽loginForm.getName()聽;
聽聽聽聽聽聽聽聽String聽pass聽=聽loginForm.getPass()聽;
聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽if(name.equals(pass)){
聽聽聽聽聽聽聽聽聽聽聽聽聽return聽mapping.findForward("login");
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽return聽mapping.findForward("ok");
聽聽聽聽聽聽聽聽聽
聽聽聽聽}
}
Form
package聽com.yourcompany.struts.form;
import聽org.apache.struts.action.ActionErrors;
import聽org.apache.struts.action.ActionForm;
public聽class聽LoginForm聽extends聽ActionForm聽{
聽聽聽聽private聽String聽name聽;
聽聽聽聽private聽String聽pass聽;
聽聽聽聽
聽聽聽聽public聽void聽setName(String聽name){
聽聽聽聽聽聽聽聽this.name聽=聽name聽;
聽聽聽聽}
聽聽聽聽public聽String聽getName(){
聽聽聽聽聽聽聽聽return聽this.name聽;
聽聽聽聽}
聽聽聽聽public聽void聽setPass(String聽pass){
聽聽聽聽聽聽聽聽this.pass聽=聽pass聽;
聽聽聽聽}
聽聽聽聽public聽String聽getPass(){
聽聽聽聽聽聽聽聽return聽this.pass聽;
聽聽聽聽}
}
鍏抽敭鐨勬潵浜?----
package聽test;
import聽java.io.File;
import聽servletunit.struts.MockStrutsTestCase;
import聽junit.framework.TestCase;
//
public聽class聽StrutsTest聽extends聽MockStrutsTestCase聽{
聽聽聽聽public聽StrutsTest(String聽testName){
聽聽聽聽聽聽聽聽super(testName);
聽聽聽聽}
聽聽聽聽public聽void聽setUp()throws聽Exception{
聽聽聽聽聽聽聽聽super.setUp();
聽聽聽聽聽聽聽聽聽聽File聽web聽=聽new聽File("E:/src/StrutsTestCase/WebRoot/");
聽聽聽聽聽聽聽聽this.setContextDirectory(web);
聽聽聽聽聽聽聽聽setConfigFile("E:/src/StrutsTestCase/WebRoot/WEB-INF/web.xml");
聽聽聽聽聽聽聽聽setConfigFile("E:/src/StrutsTestCase/WebRoot/WEB-INF/struts-config.xml");
聽
聽聽聽聽}
聽聽聽聽
聽聽聽聽public聽void聽testAction()聽{
聽聽聽 聽聽聽 setRequestPathInfo("/login");
聽聽聽聽聽聽聽聽this.addRequestParameter("name","liu");
聽聽聽聽聽聽聽聽this.addRequestParameter("pass","123");
聽聽聽聽聽聽聽聽actionPerform();
聽聽聽聽聽聽聽聽this.verifyForward("ok");
聽聽聽聽}
}
涓嶉渶瑕?鍐?classpath 鍝堝搱

]]>
主站蜘蛛池模板:
亚洲AV无码不卡在线观看下载|
国产又粗又猛又爽又黄的免费视频|
亚洲资源在线视频|
中文在线观看永久免费|
亚洲一区二区三区香蕉|
成人免费777777被爆出|
国产精品亚洲高清一区二区|
黄色视频在线免费观看|
久久影院亚洲一区|
鲁大师在线影院免费观看|
亚洲卡一卡二卡乱码新区|
亚洲国产精品日韩|
久久国产精品萌白酱免费|
亚洲午夜久久久精品电影院|
国产美女无遮挡免费网站|
GOGOGO免费观看国语|
亚洲男女性高爱潮网站|
好男人视频在线观看免费看片|
亚洲日产乱码一二三区别|
亚洲男人av香蕉爽爽爽爽|
91av视频免费在线观看|
亚洲国产精品久久久久秋霞小|
国产成人精品日本亚洲专区61|
91精品国产免费|
妇女自拍偷自拍亚洲精品|
久久夜色精品国产嚕嚕亚洲av|
好先生在线观看免费播放|
国产精品九九久久免费视频|
亚洲国产亚洲片在线观看播放|
免费久久精品国产片香蕉|
91精品导航在线网址免费|
国产成人综合亚洲一区|
亚洲一卡2卡三卡4卡有限公司|
国产免费私拍一区二区三区|
香港a毛片免费观看
|
亚洲av成人无码久久精品|
免费国产成人高清在线观看麻豆|
国产桃色在线成免费视频|
日本片免费观看一区二区|
久久免费区一区二区三波多野|
国产高潮流白浆喷水免费A片 |