Re: Problems in Starting up with ServletUnit

Narinder Kumar <[email protected]> Thu, 13 Jan 2011 19:18:37 +0530
Newsgroups gmane.comp.web.httpunit.devel
Message-ID <[email protected]>
--===============7029377406939052701==
Content-Type: multipart/alternative; boundary=0003255755c212857e0499ba9341

--0003255755c212857e0499ba9341
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hi Wolfgang,

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
get some other collaborators as well from time to time ?

Best Regards
Narinder

2011/1/13 Wolfgang Fahl <[email protected]>

>  Narinder,
>
> 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.
>
> You might want to investigate a solution and post it accoring to the FAQs=
.
>
> Yours
>
> Wolfgang
>
> Am 13.01.11 11:19, schrieb Narinder Kumar:
>
> Hi,
>
>  I was planning to unit test my Servlet through ServletUnit and ran acros=
s
> some problems :
>
>
>    - 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 pa=
th
>    provided and searches at the top level folder. The code-snippet and er=
ror
>    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();
>
>      WebRequest request   =3D new PostMethodWebRequest("
> http://localhost/login" );
>     request.setParameter( "userId", "test" );
>     request.setParameter( "password", "csd" );
>
>      WebResponse response =3D sc.getResponse(request);
>
>     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 c=
hange
>    the structure of the project to adapt this way. How can I make Servlet=
Runner
>    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);
>
>    Again ServletUnit expects welcome.jsp to be at root foler, though jsp
> files are present at .../src/main/webapp/ folder. Again how can ServletUn=
it
> be told about the target folder location ?
>
>   Many thanks in advance.
>
>  Best Regards
> Narinder
>
>
> -------------------------------------------------------------------------=
-----
> 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 [email protected]:=
//lists.sourceforge.net/lists/listinfo/httpunit-develop
>
>
> --
>
> 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
>
>
>
> -------------------------------------------------------------------------=
-----
> 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
>
>

--0003255755c212857e0499ba9341
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hi Wolfgang,<div><br></div><div>Thanks for your reply. I will try to dig in=
to 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 coll=
aborators as well from time to time ?</div>
<div><br></div><div>Best Regards</div><div>Narinder<br><br><div class=3D"gm=
ail_quote">2011/1/13 Wolfgang Fahl <span dir=3D"ltr">&lt;<a href=3D"mailto:=
[email protected]">[email protected]</a>&gt;</span><br><blockquote 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&#39;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>=A0=A0
          =A0ServletRunner sr =3D new ServletRunner(new File(&quot;<b>C:/ec=
lipse-workspaces/pocs/lms-csd/src/main/webapp/WEB-INF/web.xml</b>&quot;));<=
/div>
        <div><span style=3D"white-space:pre-wrap"> </span>
          =A0 =A0ServletUnitClient sc =3D sr.newClient();</div>
        <div><br>
        </div>
        <div><span style=3D"white-space:pre-wrap"> </span>
          =A0 =A0WebRequest request =A0 =3D new PostMethodWebRequest(&quot;=
<a href=3D"http://localhost/login" target=3D"_blank">http://localhost/login=
</a>&quot;
          );</div>
        <div><span style=3D"white-space:pre-wrap"> </span>
          =A0 =A0request.setParameter( &quot;userId&quot;, &quot;test&quot;=
 );</div>
        <div><span style=3D"white-space:pre-wrap"> </span>
          =A0 =A0request.setParameter( &quot;password&quot;, &quot;csd&quot=
; );</div>
        <div><br>
        </div>
        <div><span style=3D"white-space:pre-wrap"> </span>
          =A0 =A0WebResponse response =3D sc.getResponse(request);</div>
        <div><span style=3D"white-space:pre-wrap"> </span>
          =A0 =A0</div>
        <div><span style=3D"white-space:pre-wrap"> </span>
          =A0 =A0String text =3D response.getText();</div>
        <div><span style=3D"white-space:pre-wrap"> </span>
          =A0 =A0Assert.assertTrue(text.contains(&quot;Welcome to Leave
          Management System&quot;));</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-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, I use the following code :</li>
          </ul>
          =A0=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 String result =3D =
null</div>
        <div>=A0=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (someCond=
ition)<br>
          <div><span style=3D"white-space:pre-wrap"> </span>result
            =3D &quot;/welcome.jsp&quot;;</div>
          <div><span style=3D"white-space:pre-wrap"> </span>}
            else {</div>
          <div><span style=3D"white-space:pre-wrap"> </span>logger.warn(&qu=
ot;Password
            Validation failed&quot;);</div>
          <div><span style=3D"white-space:pre-wrap"> </span>request.setAttr=
ibute(&quot;failedlogin&quot;,
            new Boolean(true));</div>
          <div><span style=3D"white-space:pre-wrap"> </span>result
            =3D &quot;/index.jsp&quot;;</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);</div>
          <div><span style=3D"white-space:pre-wrap"> </span>requestDispatch=
er.forward(request,
            response);</div>
          <div><br>
          </div>
        </div>
      </div>
      <blockquote style=3D"margin:0pt 0pt 0pt 40px;border:medium none;paddi=
ng: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.s=
f.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" t=
arget=3D"_blank">https://lists.sourceforge.net/lists/listinfo/httpunit-deve=
lop</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=E4=
ftsf=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.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>

--0003255755c212857e0499ba9341--


--===============7029377406939052701==
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
--===============7029377406939052701==
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

--===============7029377406939052701==--