Hi
I'm using tomcat 3.2
Here is an excerpt from my test code.
Thanks
Eric
private QueryBodyTag tag;
private BodyContent bodyContent;
int result;
public void setUp() throws JspException,
IOException
{
response.setContentType("text/html");
Search dao = new Search();
dao.connect("jdbc:mysql://localhost/test");
assertTrue(dao.isConnected());
String[] parms = {"grade_level=2",
"Subject=\'Mathematics\'", "Keyword=\'Subtraction\'"};
BaseRowSet rs = dao.search(parms);
assertTrue(null!=pageContext.getSession());
session.setAttribute("results", rs);
tag = new QueryBodyTag();
}
public void begin10HitsQuery(WebRequest request)
{
}
public void test10HitsQuery() throws IOException,
JspTagException, JspException
{
tag.setPageContext(pageContext);
result = tag.doStartTag();
bodyContent = pageContext.pushBody();
tag.setBodyContent(bodyContent);
tag.doInitBody();
bodyContent.println("<table>");
bodyContent.println("<tr><td>Title</td><td>Abstract</td></tr>");
while (result != BodyTag.SKIP_BODY)
{
StringBuffer content = new
StringBuffer("<tr><td>");
content.append("Eric");
content.append("</td><td><a href = '");
content.append("http://java.sun.com'>");
content.append("</a></td><td>");
content.append("Activity");
content.append("</td></tr>");
bodyContent.println(content.toString());
result = tag.doAfterBody();
}
bodyContent.println("</table>");
result = tag.doAfterBody();
assertEquals(BodyTag.SKIP_BODY, result);
pageContext.popBody();
}
public void
end10HitsQuery(com.meterware.httpunit.WebResponse
response) throws SAXException, IOException
{
assertTrue(response != null);
com.meterware.httpunit.WebTable table =
response.getTableStartingWith("Title");
assertTrue(table != null);
com.meterware.httpunit.WebLink[] links =
response.getLinks();
assertTrue(10==links.length);
for(int i=0; i<links.length; i++)
{
assertTrue(links[i].getURLString().equals("http://java.sun.com"));
}
}
--- Nicholas Lesiecki <[EMAIL PROTECTED]> wrote:
> Which app server are you using? And send in the test
> methods, etc. From your
> test case, it might be interesting to look at
> them...
>
> Cheers,
>
> nick
>
> -----Original Message-----
> From: Eric Walker [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, October 16, 2001 2:07 PM
> To: [EMAIL PROTECTED]
> Subject: RE: pageContext.getSession();
>
>
> Thanks for the reply
>
> I have editied the jspRedirector and was careful not
> to insert any characters between the closing and
> opening script tags.
>
> I don't know what other info I can give with out
> sending everything which is not very practical.
>
> I basically commented out all code in my test case,
> in
> my taglib etc but no luck... I am able to continue
> working (my test cases pass), but I would just like
> to
> know why it's happening.
>
> Thanks
> Eric
>
>
> Thanks
> Eric
>
>
> --- Nicholas Lesiecki <[EMAIL PROTECTED]> wrote:
> > Eric,
> >
> > Give us a little more context. Strange things can
> > cause the response to be
> > committed. If you edited the redirector and
> > accidentally inserted a carriage
> > return, the jspRedirector's generated servlet
> might
> > be sending something...
> >
> > More info please...
> >
> > Cheers,
> >
> > Nick
> >
> > -----Original Message-----
> > From: Eric Walker [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, October 15, 2001 7:39 PM
> > To: [EMAIL PROTECTED]
> > Subject: RE: pageContext.getSession();
> >
> >
> > Hi
> >
> > I made the change to jspRedirector.jsp and now
> the
> > session object is there but now I am getting the
> > following:
> >
> > 2001-10-15 21:36:14 - Ctx( /unitplan ):
> > IllegalStateException in: R( /unitplan +
> > /jspRedirector.jsp + null) OutputStream is
> already
> > being used for this request
> >
> > I don't have any code at this point that writes to
> > the
> > OutputStream. Whats going on?
> >
> >
> > Thanks
> > Eric
> >
> >
> >
> >
> >
> >
> > --- David Winterfeldt <[EMAIL PROTECTED]>
> > wrote:
> > > I think Cactus (v1.0) creates the session for
> the
> > > session variable, but this is never set for the
> > > pageContext. So if you test a JSP tag that
> takes
> > > the
> > > pageContext, it can't get the session.
> > PageContext
> > > doesn't have a method to set the session. You
> > would
> > > have to call initialize with all the correct
> > > parameters. I also had to edit the
> redirector.jsp
> > > to
> > > get this working. Ignore this if things have
> > > changed
> > > since v1.0.
> > >
> > > David
> > >
> > > --- Nicholas Lesiecki <[EMAIL PROTECTED]> wrote:
> > > > It's probably the order of steps. The
> > pageContext
> > > > might be created (with a
> > > > null session) before Cactus creates the
> session
> > > > based on the user's
> > > > "automaticSession" value.
> > > >
> > > > I might get a chance to write a unit test for
> > this
> > > > in the next couple of
> > > > days.
> > > >
> > > > Cheers,
> > > >
> > > > Nick
> > > >
> > > > -----Original Message-----
> > > > From: Vincent Massol [mailto:[EMAIL PROTECTED]]
> > > > Sent: Saturday, October 13, 2001 4:55 AM
> > > > To: [EMAIL PROTECTED]
> > > > Subject: Re: pageContext.getSession();
> > > >
> > > >
> > > > Hi Eric,
> > > >
> > > > ----- Original Message -----
> > > > From: "Eric Walker" <[EMAIL PROTECTED]>
> > > > To: <[EMAIL PROTECTED]>
> > > > Sent: Friday, October 12, 2001 4:49 PM
> > > > Subject: pageContext.getSession();
> > > >
> > > >
> > > > > Hi
> > > > >
> > > > > I have a JspTestCase that calls
> > > > > pageContext.getSession() in setup. this
> value
> > is
> > > > > always null. any ideas?
> > > > >
> > > >
> > > > yes, I have an idea ... a bug ! I have
> > reproduced
> > > > the problem. What I wanted
> > > > to do is the following :
> > > > - in redirector.jsp, set session to false so
> > that
> > > no
> > > > session is created at
> > > > that time. This is because the creation of the
> > > > session depends whether the
> > > > user has set setAutomaticSession to true or
> > false
> > > > - internally, create the session by calling
> > > > HttpServletRequest.getSession(true) if
> automatic
> > > > session is true
> > > >
> > > > For some reason it does not work and need to
> be
> > > > corrected. In the meantime,
> > > > if you wish to progress with your tests,
> simply
> > > edit
> > > > redirector.jsp and
> > > > modfiy session="false" for session="true"
> > > >
> > > > Could you create a bug report for this
> > > > (http://nagoya.apache.org/bugzilla/)
> > > > ? Thanks a lot
> > > >
> > > > Anyone knows why it is not working ?
> > > > -Vincent
> > > >
> > > > > Thanks
> > > > > Eric
> > > > >
> > > > >
> > > > > public void setUp() throws JspException
> > > > > { .
> > > > > .
> > > > > .
> > > > >
> > > > > // why is this null?
> > > > >
> > > > assertTrue(null!=pageContext.getSession());
> > > > >
>
=== message truncated ===
__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com