Re: Problems in Starting up with ServletUnit

Russell Gold <[email protected]> Fri, 25 Mar 2011 12:44:44 -0400
Newsgroups gmane.comp.web.httpunit.devel
Message-ID <[email protected]>
--===============2984842636204080254==
Content-type: multipart/alternative; boundary=Apple-Mail-37-641737783


--Apple-Mail-37-641737783
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=iso-8859-1

Hi Narinder, sorry for not responding sooner. The error you are seeing =
seems to be coming from the jasper servlet, which handles JSP =
processing. Do you have a full stack trace? ServletUnit should not be =
doing this kind of path manipulation.

On Jan 13, 2011, at 8:48 AM, Narinder Kumar wrote:

> Hi Wolfgang,
>=20
> 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.
>=20
> BTW : Are you the only one supporting httpunit and servlet modules or =
you get some other collaborators as well from time to time ?
>=20
> Best Regards
> Narinder
>=20
> 2011/1/13 Wolfgang Fahl <[email protected]>
> Narinder,
>=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, schrieb Narinder Kumar:
>>=20
>> Hi,
>>=20
>> I was planning to unit test my Servlet through ServletUnit and ran =
across some problems :
>>=20
>> As a starting point, 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:
>> <code>
>>      ServletRunner sr =3D new ServletRunner(new =
File("C:/eclipse-workspaces/pocs/lms-csd/src/main/webapp/WEB-INF/web.xml")=
);
>>      ServletUnitClient sc =3D sr.newClient();
>>=20
>>      WebRequest request   =3D new =
PostMethodWebRequest("http://localhost/login" );
>>      request.setParameter( "userId", "test" );
>>      request.setParameter( "password", "csd" );
>>=20
>>      WebResponse response =3D sc.getResponse(request);
>>     =20
>>      String text =3D response.getText();
>>      Assert.assertTrue(text.contains("Welcome to Leave Management =
System"));
>> </code>
>> com.meterware.httpunit.HttpInternalErrorException: Error on HTTP =
request: 500 org.apache.jasper.JasperException: =
java.io.FileNotFoundException: =
C:\eclipse-workspaces\pocs\lms-csd\WEB-INF\web.xml (The system cannot =
find the path specified) [http://localhost/login]
>> 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 ?
>> In the Servlet code, I use the following code :
>>                        String result =3D null
>>                         if (someCondition)
>>  result =3D "/welcome.jsp";
>>  } else {
>>  logger.warn("Password Validation failed");
>>  request.setAttribute("failedlogin", new Boolean(true));
>>  result =3D "/index.jsp";
>>  }
>>  }
>>  RequestDispatcher requestDispatcher =3D =
getServletContext().getRequestDispatcher(result);
>>  requestDispatcher.forward(request, response);
>>=20
>> Again ServletUnit expects welcome.jsp to be at root foler, though jsp =
files are present at .../src/main/webapp/ folder. Again how can =
ServletUnit be told about the target folder location ?
>>=20
>> Many thanks in advance.
>>=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, the impact they can have on your business, 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, D-47877 Willich Schiefbahn
> Tel. +49 2154 811-480, Fax +49 2154 811-481
> Web: http://www.bitplan.de
> BITPlan GmbH, Willich - HRB 6820 Krefeld, Steuer-Nr.: 10258040548, =
Gesch=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, 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
> _______________________________________________
> Httpunit-develop mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/httpunit-develop
>=20
>=20
> =
--------------------------------------------------------------------------=
----
> Protect Your Site and Customers from Malware Attacks
> Learn about various malware tactics and how to avoid them. Understand=20=

> malware threats, the impact they can have on your business, 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

-----------------
Come read my webnovel, Take a Lemon <http://www.takealemon.com>,=20
and listen to the Misfile radio play =
<http://www.gold-family.us/audio/misfile.html>!





--Apple-Mail-37-641737783
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
	charset=iso-8859-1

<html><head></head><body style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi =
Narinder, sorry for not responding sooner. The error you are seeing =
seems to be coming from the jasper servlet, which handles JSP =
processing. Do you have a full stack trace? ServletUnit should not be =
doing this kind of path manipulation.<div><br><div><div>On Jan 13, 2011, =
at 8:48 AM, Narinder Kumar wrote:</div><br =
class=3D"Apple-interchange-newline"><blockquote type=3D"cite">Hi =
Wolfgang,<div><br></div><div>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.</div><div><br></div><div>BTW : Are =
you the only one supporting httpunit and servlet modules or you get some =
other collaborators as well from time to time ?</div>
<div><br></div><div>Best Regards</div><div>Narinder<br><br><div =
class=3D"gmail_quote">2011/1/13 Wolfgang Fahl <span dir=3D"ltr">&lt;<a =
href=3D"mailto:[email protected]">[email protected]</a>&gt;</span><br><blockquot=
e class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc =
solid;padding-left:1ex;">


 =20
   =20
 =20
  <div text=3D"#000000" bgcolor=3D"#ffffff">
    Narinder,<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, schrieb Narinder Kumar:
    <blockquote type=3D"cite"><div><div></div><div class=3D"h5">Hi,
      <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, 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>
        &lt;code&gt;</div>
      <div>
        <div><span style=3D"white-space:pre-wrap"> </span>&nbsp;&nbsp;
          &nbsp;ServletRunner sr =3D new ServletRunner(new =
File("<b>C:/eclipse-workspaces/pocs/lms-csd/src/main/webapp/WEB-INF/web.xm=
l</b>"));</div>
        <div><span style=3D"white-space:pre-wrap"> </span>
          &nbsp; &nbsp;ServletUnitClient sc =3D sr.newClient();</div>
        <div><br>
        </div>
        <div><span style=3D"white-space:pre-wrap"> </span>
          &nbsp; &nbsp;WebRequest request &nbsp; =3D new =
PostMethodWebRequest("<a href=3D"http://localhost/login" =
target=3D"_blank">http://localhost/login</a>"
          );</div>
        <div><span style=3D"white-space:pre-wrap"> </span>
          &nbsp; &nbsp;request.setParameter( "userId", "test" );</div>
        <div><span style=3D"white-space:pre-wrap"> </span>
          &nbsp; &nbsp;request.setParameter( "password", "csd" );</div>
        <div><br>
        </div>
        <div><span style=3D"white-space:pre-wrap"> </span>
          &nbsp; &nbsp;WebResponse response =3D =
sc.getResponse(request);</div>
        <div><span style=3D"white-space:pre-wrap"> </span>
          &nbsp; &nbsp;</div>
        <div><span style=3D"white-space:pre-wrap"> </span>
          &nbsp; &nbsp;String text =3D response.getText();</div>
        <div><span style=3D"white-space:pre-wrap"> </span>
          &nbsp; &nbsp;Assert.assertTrue(text.contains("Welcome to Leave
          Management System"));</div>
      </div>
      <div>&lt;/code&gt;<br>
        com.meterware.httpunit.HttpInternalErrorException: Error on HTTP
        request: 500 org.apache.jasper.JasperException:
        java.io.FileNotFoundException: =
<b>C:\eclipse-workspaces\pocs\lms-csd\WEB-INF\web.xml</b>
        (The system cannot find the path specified) [<a =
href=3D"http://localhost/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, I use the following code :</li>
          </ul>
          &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; String result =3D null</div>
        <div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (someCondition)<br>
          <div><span style=3D"white-space:pre-wrap"> </span>result
            =3D "/welcome.jsp";</div>
          <div><span style=3D"white-space:pre-wrap"> </span>}
            else {</div>
          <div><span style=3D"white-space:pre-wrap"> =
</span>logger.warn("Password
            Validation failed");</div>
          <div><span style=3D"white-space:pre-wrap"> =
</span>request.setAttribute("failedlogin",
            new Boolean(true));</div>
          <div><span style=3D"white-space:pre-wrap"> </span>result
            =3D "/index.jsp";</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>RequestDispatcher
            requestDispatcher =3D
            getServletContext().getRequestDispatcher(result);</div>
          <div><span style=3D"white-space:pre-wrap"> =
</span>requestDispatcher.forward(request,
            response);</div>
          <div><br>
          </div>
        </div>
      </div>
      <blockquote style=3D"margin:0pt 0pt 0pt 40px;border:medium =
none;padding:0px">
        <div>
          <div>
            <div>Again ServletUnit expects welcome.jsp to be at root
              foler, 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, the impact they can have on your business, 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.sf.net/sfu/oracle-sfdevnl</a></pre>
      <pre><fieldset></fieldset>
_______________________________________________
Httpunit-develop mailing list
<a href=3D"mailto:[email protected]" =
target=3D"_blank">[email protected]</a>
<a href=3D"https://lists.sourceforge.net/lists/listinfo/httpunit-develop" =
target=3D"_blank">https://lists.sourceforge.net/lists/listinfo/httpunit-de=
velop</a>
</pre>
    </blockquote>
    <br>
    <pre cols=3D"72">--=20

BITPlan - smart solutions
Wolfgang Fahl
Pater-Delp-Str. 1, D-47877 Willich Schiefbahn
Tel. +49 2154 811-480, Fax +49 2154 811-481
Web: <a href=3D"http://www.bitplan.de/" =
target=3D"_blank">http://www.bitplan.de</a>
BITPlan GmbH, Willich - HRB 6820 Krefeld, Steuer-Nr.: 10258040548, =
Gesch=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, the impact they can have on your business, 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.sf.net/sfu/oracle-sfdevnl</a><br>______________=
_________________________________<br>
Httpunit-develop mailing list<br>
<a =
href=3D"mailto:[email protected]">Httpunit-develop@li=
sts.sourceforge.net</a><br>
<a href=3D"https://lists.sourceforge.net/lists/listinfo/httpunit-develop" =
target=3D"_blank">https://lists.sourceforge.net/lists/listinfo/httpunit-de=
velop</a><br>
<br></blockquote></div><br>
</div>
=
--------------------------------------------------------------------------=
----<br>Protect Your Site and Customers from Malware Attacks<br>Learn =
about various malware tactics and how to avoid them. Understand =
<br>malware threats, the impact they can have on your business, 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________________________________=
_______________">http://p.sf.net/sfu/oracle-sfdevnl_______________________=
________________________</a><br>Httpunit-develop mailing =
list<br>[email protected]<br>https://lists.sourceforg=
e.net/lists/listinfo/httpunit-develop<br></blockquote></div><br><div>
<span class=3D"Apple-style-span" style=3D"border-collapse: separate; =
color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; =
font-style: normal; font-variant: normal; font-weight: normal; =
letter-spacing: normal; line-height: normal; orphans: 2; text-align: =
auto; text-indent: 0px; text-transform: none; white-space: normal; =
widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; =
-webkit-border-vertical-spacing: 0px; =
-webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: =
auto; -webkit-text-stroke-width: 0px; "><span class=3D"Apple-style-span" =
style=3D"border-collapse: separate; color: rgb(0, 0, 0); font-family: =
Helvetica; font-size: medium; font-style: normal; font-variant: normal; =
font-weight: normal; letter-spacing: normal; line-height: normal; =
orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; =
widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; =
-webkit-border-vertical-spacing: 0px; =
-webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: =
auto; -webkit-text-stroke-width: 0px; "><div style=3D"word-wrap: =
break-word; -webkit-nbsp-mode: space; -webkit-line-break: =
after-white-space; "><div>-----------------</div><div>Come read my =
webnovel,<span class=3D"Apple-converted-space">&nbsp;</span><i>Take a =
Lemon<span class=3D"Apple-converted-space">&nbsp;</span></i>&lt;<a =
href=3D"http://www.takealemon.com">http://www.takealemon.com</a>&gt;,&nbsp=
;</div><div>and listen to the Misfile radio play &lt;<a =
href=3D"http://www.gold-family.us/audio/misfile.html">http://www.gold-fami=
ly.us/audio/misfile.html</a>&gt;!</div><div><br></div></div></span><br =
class=3D"Apple-interchange-newline"></span><br =
class=3D"Apple-interchange-newline">
</div>
<br></div></body></html>=

--Apple-Mail-37-641737783--


--===============2984842636204080254==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software 
be a part of the solution? Download the Intel(R) Manageability Checker 
today! http://p.sf.net/sfu/intel-dev2devmar
--===============2984842636204080254==
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

--===============2984842636204080254==--