Re: Problems in Starting up with ServletUnit
Laxman Kumar <[email protected]> Sun, 16 Jan 2011 20:24:36 +0800
| Newsgroups | gmane.comp.web.httpunit.devel |
|---|---|
| Message-ID | <[email protected]> |
--===============2787654178962282681== Content-Type: multipart/alternative; boundary="_732069fe-bf36-4126-8b13-975ed41326a1_" --_732069fe-bf36-4126-8b13-975ed41326a1_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi Narindar Kumar=2C This is Kishan from hyd=2Cindia. I would like to know about httpunit. Could you please tell me will it work for testing any type of web sites (i= e. banking / finance / commerial / entertainment / gov. / public services a= nd moreover with https protocol ) also ? Because I tried to connect to my gmail account & my internet banking for= my account.=2C its not loading home package even since Some scriptlet engi= ne error coming while loading home pages itself. But through htmlunit I'm u= nable to access any of web site with having any issue. Can you please tel m= e what could be the issue I just downloaded httpunit jar & other dependenci= es jars also from sourceforge.net link only. But its unable to access all = web sites whatever we want to connect & access for testing. Please help me out what to do to access all require web sites by using t= his httpunit ..! I'm eagerly waiting for your reply soon. Thank you & regards=2C Kishan. Hyd=2CIndia. =20 Date: Thu=2C 13 Jan 2011 19:18:37 +0530 From: [email protected] To: [email protected] Subject: Re: [Httpunit-develop] Problems in Starting up with ServletUnit Hi Wolfgang=2C Thanks for your reply. I will try to dig into it myself and get back to you= with more information if I am able to find the root cause of the problem. BTW : Are you the only one supporting httpunit and servlet modules or you g= et some other collaborators as well from time to time ? Best RegardsNarinder 2011/1/13 Wolfgang Fahl <[email protected]> =20 =20 =20 =20 Narinder=2C =20 thanks for making the mailinglist a bit more active with your e-mail. I'd be happy to support you but there are two obstacles: - Servlet...something is not the part of httpunit I know well - I have other urgent issues on my agenda that hold me up. =20 You might want to investigate a solution and post it accoring to the FAQs.=20 =20 Yours=20 =20 Wolfgang =20 Am 13.01.11 11:19=2C schrieb Narinder Kumar: Hi=2C =20 =20 I was planning to unit test my Servlet through ServletUnit and ran across some problems : =20 =20 =20 =20 As a starting point=2C we are supposed to create a ServletRunner object. One of the constructors expects File object with web.xml file. I provide the full path of my web.xml file but somehow it ignores the path provided and searches at the top level folder. The code-snippet and error message is below: =20 <code> =20 =20 ServletRunner sr =3D new ServletRunner(new File("C:/eclipse-work= spaces/pocs/lms-csd/src/main/webapp/WEB-INF/web.xml"))=3B =20 ServletUnitClient sc =3D sr.newClient()=3B =20 =20 =20 WebRequest request =3D new PostMethodWebRequest("http://loca= lhost/login" )=3B =20 request.setParameter( "userId"=2C "test" )=3B =20 request.setParameter( "password"=2C "csd" )=3B =20 =20 =20 WebResponse response =3D sc.getResponse(request)=3B =20 =20 =20 String text =3D response.getText()=3B =20 Assert.assertTrue(text.contains("Welcome to Leave Management System"))=3B =20 </code> com.meterware.httpunit.HttpInternalErrorException: Error on HTTP request: 500 org.apache.jasper.JasperException: java.io.FileNotFoundException: C:\eclipse-workspaces\pocs\lms-csd\W= EB-INF\web.xml (The system cannot find the path specified) [http://localhost/login= ] =20 =20 =20 =20 Why does the system keep on looking at the folder structure to be .../WEB-INF/web.xml. Mine is a maven project and I would not like to change the structure of the project to adapt this way. How can I make ServletRunner class to read from a specified folder ? =20 =20 In the Servlet code=2C I use the following code : =20 String result =3D null if (someCondition) result =3D "/welcome.jsp"=3B } else { logger.warn("Password Validation failed")=3B request.setAttribute("failedlogin"=2C new Boolean(true))=3B result =3D "/index.jsp"=3B } } RequestDispatcher requestDispatcher =3D getServletContext().getRequestDispatcher(result)=3B requestDispatcher.forward(request=2C response)=3B =20 =20 =20 =20 =20 =20 =20 Again ServletUnit expects welcome.jsp to be at root foler=2C though jsp files are present at .../src/main/webapp/ folder. Again how can ServletUnit be told about the target folder location ? =20 =20 =20 =20 =20 =20 Many thanks in advance. =20 =20 =20 =20 Best Regards Narinder =20 ---------------------------------------------------------------------------= --- Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand=20 malware threats=2C the impact they can have on your business=2C and how you= =20 can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl =20 _______________________________________________ Httpunit-develop mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/httpunit-develop =20 =20 --=20 BITPlan - smart solutions Wolfgang Fahl Pater-Delp-Str. 1=2C D-47877 Willich Schiefbahn Tel. +49 2154 811-480=2C Fax +49 2154 811-481 Web: http://www.bitplan.de BITPlan GmbH=2C Willich - HRB 6820 Krefeld=2C Steuer-Nr.: 10258040548=2C Ge= sch=E4ftsf=FChrer: Wolfgang Fahl=20 =20 ---------------------------------------------------------------------------= --- Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand malware threats=2C the impact they can have on your business=2C and how you can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ Httpunit-develop mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/httpunit-develop ---------------------------------------------------------------------------= --- Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand=20 malware threats=2C the impact they can have on your business=2C and how you= =20 can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ Httpunit-develop mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/httpunit-develop = --_732069fe-bf36-4126-8b13-975ed41326a1_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <html> <head> <style><!-- .hmmessage P { margin:0px=3B padding:0px } body.hmmessage { font-size: 10pt=3B font-family:Tahoma } --></style> </head> <body class=3D'hmmessage'> Hi Narindar Kumar=2C<div><br></div><div> =3BThis is Kishan from hyd=2Ci= ndia.</div><div><br></div><div>I would like to know about httpunit.</div><d= iv><br></div><div>Could you please tell me will it work for testing any typ= e of web sites  =3B(ie. banking / finance / commerial / entertainment /= gov. / public services and moreover with https protocol ) also ?</div><div= ><br></div><div> =3B =3BBecause I tried to connect to my gmail acco= unt  =3B&=3B my internet banking for my account.=2C its not loading = home package even since Some scriptlet engine error coming while loading ho= me pages itself. But through htmlunit I'm unable to access any of web site = with having any issue. Can you please tel me what could be the issue I just= downloaded httpunit jar &=3B other dependencies jars also from  =3B= sourceforge.net link only. But its unable to access all web sites whatever = we want to connect &=3B access for testing.</div><div><br></div><div>&nb= sp=3B =3B Please help me out what to do to access all require web sites= by using this httpunit ..!</div><div><br></div><div> =3B =3BI'm ea= gerly waiting for your reply soon.</div><div><br></div><div><br></div><div>=  =3B =3BThank you &=3B regards=2C</div><div> =3B =3BKish= an.</div><div> =3B =3BHyd=2CIndia.</div><div> =3B =3B</div>= <div><br></div><div><br></div><div><br></div><div><br><br><hr id=3D"stopSpe= lling">Date: Thu=2C 13 Jan 2011 19:18:37 +0530<br>From: [email protected]<= br>To: [email protected]<br>Subject: Re: [Httpunit-dev= elop] Problems in Starting up with ServletUnit<br><br>Hi Wolfgang=2C<div><b= r></div><div>Thanks for your reply. I will try to dig into it myself and ge= t back to you with more information if I am able to find the root cause of = the problem.</div><div><br></div><div>BTW : Are you the only one supporting= httpunit and servlet modules or you get some other collaborators as well f= rom time to time ?</div> <div><br></div><div>Best Regards</div><div>Narinder<br><br><div class=3D"ec= xgmail_quote">2011/1/13 Wolfgang Fahl <span dir=3D"ltr"><=3B<a href=3D"ma= ilto:[email protected]">[email protected]</a>>=3B</span><br><blockquote class= =3D"ecxgmail_quote" style=3D"border-left:1px #ccc solid=3Bpadding-left:1ex"= > =20 =20 =20 <div> Narinder=2C<br> <br> thanks for making the mailinglist a bit more active with your e-mail.<br> I'd be happy to support you but there are two obstacles:<br> - Servlet...something is not the part of httpunit I know well<br> - I have other urgent issues on my agenda that hold me up.<br> <br> You might want to investigate a solution and post it accoring to the FAQs. <br> <br> Yours <br> <br> Wolfgang<br> <br> Am 13.01.11 11:19=2C schrieb Narinder Kumar: <blockquote><div><div></div><div class=3D"h5">Hi=2C <div><br> </div> <div>I was planning to unit test my Servlet through ServletUnit and ran across some problems :</div> <div><br> </div> <div> <ul> <li>As a starting point=2C we are supposed to create a ServletRunner object. One of the constructors expects File object with web.xml file. I provide the full path of my web.xml file but somehow it ignores the path provided and searches at the top level folder. The code-snippet and error message is below:</li> </ul> <=3Bcode>=3B</div> <div> <div><span style=3D"white-space:pre-wrap"> </span> =3B =3B  =3BServletRunner sr =3D new ServletRunner(new File("<b>C:/ec= lipse-workspaces/pocs/lms-csd/src/main/webapp/WEB-INF/web.xml</b>"))=3B</di= v> <div><span style=3D"white-space:pre-wrap"> </span>  =3B  =3BServletUnitClient sc =3D sr.newClient()=3B</div> <div><br> </div> <div><span style=3D"white-space:pre-wrap"> </span>  =3B  =3BWebRequest request  =3B =3D new PostMethodWe= bRequest("<a href=3D"http://localhost/login" target=3D"_blank">http://local= host/login</a>" )=3B</div> <div><span style=3D"white-space:pre-wrap"> </span>  =3B  =3Brequest.setParameter( "userId"=2C "test" )=3B</d= iv> <div><span style=3D"white-space:pre-wrap"> </span>  =3B  =3Brequest.setParameter( "password"=2C "csd" )=3B</= div> <div><br> </div> <div><span style=3D"white-space:pre-wrap"> </span>  =3B  =3BWebResponse response =3D sc.getResponse(request)= =3B</div> <div><span style=3D"white-space:pre-wrap"> </span>  =3B  =3B</div> <div><span style=3D"white-space:pre-wrap"> </span>  =3B  =3BString text =3D response.getText()=3B</div> <div><span style=3D"white-space:pre-wrap"> </span>  =3B  =3BAssert.assertTrue(text.contains("Welcome to Leav= e Management System"))=3B</div> </div> <div><=3B/code>=3B<br> com.meterware.httpunit.HttpInternalErrorException: Error on HTTP request: 500 org.apache.jasper.JasperException: java.io.FileNotFoundException: <b>C:\eclipse-workspaces\pocs\lms-cs= d\WEB-INF\web.xml</b> (The system cannot find the path specified) [<a href=3D"http://loca= lhost/login" target=3D"_blank">http://localhost/login</a>]<br> <ul> </ul> <div> <ul> <li>Why does the system keep on looking at the folder structure to be .../WEB-INF/web.xml. Mine is a maven project and I would not like to change the structure of the project to adapt this way. How can I make ServletRunner class to read from a specified folder ?</li> </ul> <ul> <li>In the Servlet code=2C I use the following code :</li> </ul>  =3B =3B  =3B  =3B  =3B  =3B  =3B &nb= sp=3B  =3B  =3B  =3B  =3B String result =3D null</div> <div> =3B =3B  =3B  =3B  =3B  =3B  =3B =  =3B  =3B  =3B  =3B  =3B  =3Bif (someCondition)<br> <div><span style=3D"white-space:pre-wrap"> </span>result =3D "/welcome.jsp"=3B</div> <div><span style=3D"white-space:pre-wrap"> </span>} else {</div> <div><span style=3D"white-space:pre-wrap"> </span>logger.warn("Pa= ssword Validation failed")=3B</div> <div><span style=3D"white-space:pre-wrap"> </span>request.setAttr= ibute("failedlogin"=2C new Boolean(true))=3B</div> <div><span style=3D"white-space:pre-wrap"> </span>result =3D "/index.jsp"=3B</div> <div><span style=3D"white-space:pre-wrap"> </span>}</div> <div><span style=3D"white-space:pre-wrap"> </span>}</div> <div><span style=3D"white-space:pre-wrap"> </span>RequestDispatch= er requestDispatcher =3D getServletContext().getRequestDispatcher(result)=3B</div> <div><span style=3D"white-space:pre-wrap"> </span>requestDispatch= er.forward(request=2C response)=3B</div> <div><br> </div> </div> </div> <blockquote style=3D"border:medium none=3Bpadding:0px"> <div> <div> <div>Again ServletUnit expects welcome.jsp to be at root foler=2C though jsp files are present at .../src/main/webapp/ folder. Again how can ServletUnit be told about the target folder location ?</div> </div> </div> <div><br> </div> </blockquote> <div> <div>Many thanks in advance. </div> </div> <div><br> </div> <div>Best Regards</div> <div>Narinder</div> </div></div><pre><fieldset></fieldset> ---------------------------------------------------------------------------= --- Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand=20 malware threats=2C the impact they can have on your business=2C and how you= =20 can protect your company and customers by using code signing. <a href=3D"http://p.sf.net/sfu/oracle-sfdevnl" target=3D"_blank">http://p.s= f.net/sfu/oracle-sfdevnl</a></pre> <pre><fieldset></fieldset> _______________________________________________ Httpunit-develop mailing list <a href=3D"mailto:[email protected]">Httpunit-develop@= lists.sourceforge.net</a> <a href=3D"https://lists.sourceforge.net/lists/listinfo/httpunit-develop" t= arget=3D"_blank">https://lists.sourceforge.net/lists/listinfo/httpunit-deve= lop</a> </pre> </blockquote> <br> <pre>--=20 BITPlan - smart solutions Wolfgang Fahl Pater-Delp-Str. 1=2C D-47877 Willich Schiefbahn Tel. +49 2154 811-480=2C Fax +49 2154 811-481 Web: <a href=3D"http://www.bitplan.de" target=3D"_blank">http://www.bitplan= .de</a> BITPlan GmbH=2C Willich - HRB 6820 Krefeld=2C Steuer-Nr.: 10258040548=2C Ge= sch=E4ftsf=FChrer: Wolfgang Fahl </pre> </div> <br>-----------------------------------------------------------------------= -------<br> Protect Your Site and Customers from Malware Attacks<br> Learn about various malware tactics and how to avoid them. Understand<br> malware threats=2C the impact they can have on your business=2C and how you= <br> can protect your company and customers by using code signing.<br> <a href=3D"http://p.sf.net/sfu/oracle-sfdevnl" target=3D"_blank">http://p.s= f.net/sfu/oracle-sfdevnl</a><br>___________________________________________= ____<br> Httpunit-develop mailing list<br> <a href=3D"mailto:[email protected]">Httpunit-develop@= lists.sourceforge.net</a><br> <a href=3D"https://lists.sourceforge.net/lists/listinfo/httpunit-develop" t= arget=3D"_blank">https://lists.sourceforge.net/lists/listinfo/httpunit-deve= lop</a><br> <br></blockquote></div><br> </div> <br>-----------------------------------------------------------------------= ------- Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand=20 malware threats=2C the impact they can have on your business=2C and how you= =20 can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl<br>_____________________________________= __________ Httpunit-develop mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/httpunit-develop</div> = </body> </html>= --_732069fe-bf36-4126-8b13-975ed41326a1_-- --===============2787654178962282681== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------------ Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand malware threats, the impact they can have on your business, and how you can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl --===============2787654178962282681== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Httpunit-develop mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/httpunit-develop --===============2787654178962282681==--