锘??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 GMT60httpUnit 涔嬩嬌鐢ㄥ叾浠杦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;

publicclass聽HttpTest聽extends聽TestCase聽{
聽聽聽聽
publicvoid聽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()聽);
聽聽聽聽}
}



G_G 2008-01-29 17:25 鍙戣〃璇勮
]]>
涓嶄嬌鐢ㄥ鍣?榪涜 嫻嬭瘯 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;

publicclass聽JSPCTest聽extends聽TestCase{
聽聽聽聽
private聽InvocationContext聽ic聽=null聽;

聽聽聽聽
protectedvoid聽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);

聽聽聽聽}
聽聽聽聽
聽聽聽聽
publicvoid聽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>






G_G 2007-11-02 17:11 鍙戣〃璇勮
]]>
嫻嬭瘯 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>聽



G_G 2007-11-02 12:44 鍙戣〃璇勮
]]>
嫻嬭瘯 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;

publicclass聽HttpUnitTestHelloWorld聽extends聽TestCase聽{

protectedvoid聽setUp()聽throws聽Exception聽{
聽聽
super.setUp();
聽}

protectedvoid聽tearDown()聽throws聽Exception聽{
聽聽
super.tearDown();
聽}

publicvoid聽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;

publicclass聽JettySampleTest聽extends聽TestCase聽{

聽Server聽server;
protectedvoid聽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();
聽}

protectedvoid聽tearDown()聽throws聽Exception聽{
聽聽
super.tearDown();
聽聽server.stop();
聽}

publicvoid聽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();
聽聽}
聽}
}



G_G 2007-10-31 11:11 鍙戣〃璇勮
]]>
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







G_G 2007-10-30 17:59 鍙戣〃璇勮
]]>
鍦↗unit涓祴璇曠鏈夊嚱鏁扮殑鏂規硶錛坖unit, private, method) 錛堣漿錛?/title><link>http://m.tkk7.com/Good-Game/archive/2007/10/23/155223.html</link><dc:creator>G_G</dc:creator><author>G_G</author><pubDate>Tue, 23 Oct 2007 03:11:00 GMT</pubDate><guid>http://m.tkk7.com/Good-Game/archive/2007/10/23/155223.html</guid><wfw:comment>http://m.tkk7.com/Good-Game/comments/155223.html</wfw:comment><comments>http://m.tkk7.com/Good-Game/archive/2007/10/23/155223.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/Good-Game/comments/commentRss/155223.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/Good-Game/services/trackbacks/155223.html</trackback:ping><description><![CDATA[ <span id="LblContent">eclipse涓浣曞啓涓涓祴璇曠鏈夋柟娉曠殑junit錛?br />鍋囪綾籗ummer瀹氫箟濡備笅錛?br /></span>public class Summer{<br />聽聽聽private int <font color="#0000ff"><strong>methodone</strong></font>(<font color="#ff6600"><strong>String</strong></font> argsone){<br />聽聽聽聽聽聽//method code<br />聽聽聽聽聽聽.......<br />聽聽聽聽聽聽return聽4;<br />聽聽聽}<br />}<br /><br />嫻嬭瘯濡備笅錛?br />public class SummerTest extends TestCase {<br />聽聽聽public void testMethodone(){<br />聽聽聽聽聽聽Object rightResult = xxxxx;<br />聽聽聽聽聽聽Summer聽example =聽new Summer.newInstance();<br />聽聽聽聽聽聽Method m =聽example .getClass()<font color="#ff0000">.getDeclaredMethod</font>("<font color="#0000ff">methodone</font>",new Class[]{<font color="#ff6600">String.class</font>});<br />聽聽聽聽聽聽<font color="#ff0000">m.setAccessible(true);</font><br />聽聽聽聽聽聽Object result = m.invoke(example ,new聽Object[]聽{new String(xxxx)});<br />聽聽聽聽聽聽m.setAccessible(false);<br />聽聽聽聽聽聽if (result.equals(rightResult)){<br />聽聽聽聽聽聽聽聽聽//your code<br />聽聽聽聽聽聽聽聽聽......<br />聽聽聽聽聽聽}<br />聽聽聽}<br />}<img alt="" src="/oceanqtt/aggbug/13798.html" height="1" width="1" /><img src ="http://m.tkk7.com/Good-Game/aggbug/155223.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/Good-Game/" target="_blank">G_G</a> 2007-10-23 11:11 <a href="http://m.tkk7.com/Good-Game/archive/2007/10/23/155223.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>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/"
*/
publicclass聽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;

publicclass聽LoginForm聽extends聽ActionForm聽{
聽聽聽聽
private聽String聽name聽;
聽聽聽聽
private聽String聽pass聽;
聽聽聽聽
聽聽聽聽
publicvoid聽setName(String聽name){
聽聽聽聽聽聽聽聽
this.name聽=聽name聽;
聽聽聽聽}
聽聽聽聽
public聽String聽getName(){
聽聽聽聽聽聽聽聽
returnthis.name聽;
聽聽聽聽}
聽聽聽聽
publicvoid聽setPass(String聽pass){
聽聽聽聽聽聽聽聽
this.pass聽=聽pass聽;
聽聽聽聽}
聽聽聽聽
public聽String聽getPass(){
聽聽聽聽聽聽聽聽
returnthis.pass聽;
聽聽聽聽}
}

鍏抽敭鐨勬潵浜?----
package聽test;

import聽java.io.File;

import聽servletunit.struts.MockStrutsTestCase;
import聽junit.framework.TestCase;
//
publicclass聽StrutsTest聽extends聽MockStrutsTestCase聽{

聽聽聽聽
public聽StrutsTest(String聽testName){
聽聽聽聽聽聽聽聽
super(testName);
聽聽聽聽}
聽聽聽聽
publicvoid聽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");

聽聽聽聽}
聽聽聽聽
聽聽聽聽
publicvoid聽testAction()聽{
聽聽聽 聽聽聽
setRequestPathInfo("/login");
聽聽聽聽聽聽聽聽this.addRequestParameter("name","liu");
聽聽聽聽聽聽聽聽
this.addRequestParameter("pass","123");
聽聽聽聽聽聽聽聽actionPerform();
聽聽聽聽聽聽聽聽
this.verifyForward("ok");
聽聽聽聽}
}

涓嶉渶瑕?鍐?classpath 鍝堝搱


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