You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-user@jakarta.apache.org by Hau Phuoc Tran <tp...@tma.com.vn> on 2003/10/02 04:52:09 UTC

Problem in running testcase

Hi,

I am newbie in Cactus. It is very interesting testing framework. I have a
JSP sample below and run it after starting the tomcat4.1.18 server(client
and server sides are in my machine). When I want to verify the testOut()
function with Fail Server port(expected value=80) and then run it again but
the result is still OK. If I restart tomcat, the result will be FAILURE. I
think I missed overriding tearDown() or endOut() function.

There is anyone know this, please explain to me. Thanks

///////////////////////////////////////////////////////
...
 public void beginOut(WebRequest theRequest)throws IOException  {
         theRequest.setURL("localhost:8080", "/sample-servlet/test",
"/test.jsp", null,
                 null);
 }

 public void testOut() throws IOException {
        assertEquals("/sample-servlet/test/test.jsp",
request.getRequestURI());
        assertEquals("localhost", request.getServerName());
        assertEquals(8080, request.getServerPort());
        assertEquals("/sample-servlet/test", request.getContextPath());
 }
///////////////////////////////////////////////////////

Beside, I am looking for some samples (JSP and TagLib), please point me to
the links or sources you know. Thanks in advance.

Regards,
Hau Tran.


Re: Problem in running testcase

Posted by QingZhao <qz...@uiuc.edu>.
Hi,

Although I am not quite clear about your question, I did a similar test.
Here is my test class:
public class TestServerURL extends JspTestCase {

         public void beginOut(WebRequest theRequest){
                  theRequest.setURL("localhost:7777", "/test", "/test.jsp",
null, null);
         }

         public void testOut() {
                   assertEquals("/test/test.jsp", request.getRequestURI());
                   assertEquals("localhost", request.getServerName());
                   assertEquals(8080, request.getServerPort());
                   assertEquals("/test", request.getContextPath());
          }
    }

In the above beginOut() method, the URL is simulated to something like
http://localhost:7777/test/test.jsp.  Therefore, on the server side, the
assertEquals(8080, request.getServerPort()) will always result in failure:
expected <8080>, but was <7777>.

I tried running the test with Tomcat 4.1.26 in two ways: one using ant
intergration,  the other by starting Tomcat first and run it in a browser.
I got the same result for both approaches.

For sample sources, you can check the cactus core distribution:
http://jakarta.apache.org/cactus/downloads.html.  There are plenty of
samples including JSP and taglib.  Hope that helps.

Qing

----- Original Message ----- 
From: "Hau Phuoc Tran" <tp...@tma.com.vn>
To: <ca...@jakarta.apache.org>
Sent: Wednesday, October 01, 2003 7:52 PM
Subject: Problem in running testcase


> Hi,
>
> I am newbie in Cactus. It is very interesting testing framework. I have a
> JSP sample below and run it after starting the tomcat4.1.18 server(client
> and server sides are in my machine). When I want to verify the testOut()
> function with Fail Server port(expected value=80) and then run it again
but
> the result is still OK. If I restart tomcat, the result will be FAILURE. I
> think I missed overriding tearDown() or endOut() function.
>
> There is anyone know this, please explain to me. Thanks
>
> ///////////////////////////////////////////////////////
> ...
>  public void beginOut(WebRequest theRequest)throws IOException  {
>          theRequest.setURL("localhost:8080", "/sample-servlet/test",
> "/test.jsp", null,
>                  null);
>  }
>
>  public void testOut() throws IOException {
>         assertEquals("/sample-servlet/test/test.jsp",
> request.getRequestURI());
>         assertEquals("localhost", request.getServerName());
>         assertEquals(8080, request.getServerPort());
>         assertEquals("/sample-servlet/test", request.getContextPath());
>  }
> ///////////////////////////////////////////////////////
>
> Beside, I am looking for some samples (JSP and TagLib), please point me to
> the links or sources you know. Thanks in advance.
>
> Regards,
> Hau Tran.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: cactus-user-help@jakarta.apache.org
>