----- Original Message -----
From: "Rakesh Bhalla" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, September 20, 2001 2:00 PM
Subject: /JspRedirector/* makes a big difference ....
[snip]
> Here is my hello.jsp file:
>
> <html>
> <head><title>Hello World</title></head>
> <body>
> <% session.putValue("name" , "RED" ); %>
> <% out.print("<p><b>Hello Your Universe!</b>"); %>
> </body>
> </html>
>
> I have placed it under the context examplesWebApp in my server such
> that, if I point to
>
> http://localhost:7001/examplesWebApp/hello.jsp , the above jsp gets
> activated and so I get "Hello Your Universe" on the client( browser
> ).
> Now I want to test the value of the attribute stored by session on
> the server and my test case looks something like this.
>
> < --- JAVA TEST CASE CODE --->
> import java.util.*;
> import java.text.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
> import java.net.*;
> import java.io.*;
>
> import junit.framework.*;
>
> import org.apache.commons.cactus.*;
>
> public class TestJspTestCase extends JspTestCase
> {
> static final String FORWARD_URL = "hello.jsp" ;
should use "/hello.jsp" to be more correct. But "hello.jsp" is ok, the full
path will be computed from the current request, meaning you're lucky because
the request to the JSP redirector is at the same level ...
>
> public TestJspTestCase(String theName)
> {
> super(theName);
> }
>
> public static void main(String[] theArgs)
> {
> junit.ui.TestRunner.main(
> new String[] {TestJspTestCase.class.getName()});
> }
>
> public static Test suite()
> {
> return new TestSuite(TestJspTestCase.class);
> }
>
> public void beginOut(ServletTestRequest str) throws Exception {
> }
no need if you don't use it.
>
> public void testOut() throws IOException, ServletException
> {
> pageContext.forward(FORWARD_URL);
> assertEquals(pageContext.getAttribute("name"), "LG" );
should be assertEquals("LG", session.getAttribute("name"));
> }
>
> public void endOut(HttpURLConnection huc) throws IOException
> {
> }
no need if you don't use it
> }
>
> <--- >
>
>
> To my surprise the assertion passes. Actually I am setting the value
> to be RED in the jsp and asserting it to be LG . It should fail. But
> it passes . Where is it that I have gone wrong ?
don't know ...
>
> Please help me.
that's what I have been so far ... :)
-Vincent