Hello,
--- Vincent Massol <[EMAIL PROTECTED]> wrote:
I made the changes as you mentioned. The revised Java code looks
something like this.
<-- JAVA SRC -- >
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" ;
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 testOut() throws IOException, ServletException
{
pageContext.forward(FORWARD_URL);
assertEquals("LG" , session.getAttribute("name") );
}
}
-->
The JSP code looks like this
<--JSP code
<!doctype html public "-//w3c/dtd HTML 4.0//en">
<html>
<head><title>Hello World</title></head>
<body>
<% session.setAttribute("name" , "RED" ); %>
<% out.print("Hello Your Universe!"); %>
</body>
</html>
<-- JSP Code -->
Actually this is present in the WebServer such that it can be
referred to as:
http://localhost:7001/examplesWebApp/hello.jsp .
Now when I run JUnit I get the AssertionFailedError but it says,
junit.framework.AssertionFailedError: expected:<LG> but was:<null>
Actually the other value should have been RED .
So the session attribute is not set at all. Have I gone wrong in
forwarding the PageContext ?
=====
Thanks.
Rakesh Bhalla.
__________________________________________________
Terrorist Attacks on U.S. - How can you help?
Donate cash, emergency relief information
http://dailynews.yahoo.com/fc/US/Emergency_Information/