Hi Vincent, I would like to submit to you two Cactus enhancements. The first is the one described below, involving sending the cookie to the test result post.
I have attached the source file that includes this patch. In
AbstractHttpClient.java I have added a few lines to add the cookies to the
resultsRequest.
private WebTestResult callGetResult(WebRequest theRequest,
AbstractAuthentication theAuthentication) throws Throwable
{
WebRequest resultsRequest = new WebRequest();
// Add the cookies from the request used in the test
Vector cookies = theRequest.getCookies();
if (cookies != null) {
for (int i=0; i < cookies.size(); i++) {
resultsRequest.addCookie((Cookie)cookies.elementAt(i));
}
}
...
}
Then in the doTest method, the call to the callGetResult method is modified
to pass the WebRequest object used in the callRunTest method.
public HttpURLConnection doTest(WebRequest theRequest)
throws Throwable
{
// Open the first connection to the redirector to execute the test
on
// the server side
HttpURLConnection connection = callRunTest(theRequest);
// Open the second connection to get the test results
WebTestResult result = callGetResult(theRequest,
theRequest.getAuthentication());
...
}
---
My second feature request involves the addition of two new optional methods
for any class that extends AbstractTestCase (i.e. ServletTestCase,
JspTestCase, and FilterTestCase). This would be a generic begin method and
a generic end method that if declared will be called automatically for every
testXXX method.
They take this form:
public void begin(WebRequest theRequest);
public void end(WebResponse theResponse);
In the attached AbstractTestCase.java there are a set of new methods:
1. callGenericBeginMethod
2. callGenericEndMethod
3. getGenericBeginMethodName
4. getGenericEndMethodName
The runGenericTest method is modified to make calls to the generic methods
and the specific base test method-name methods.
Let me know if you have any questions.
Thanks,
Charley
> -----Original Message-----
> From: Vincent Massol [mailto:[EMAIL PROTECTED]]
> Sent: Friday, July 12, 2002 1:17 AM
> To: 'Charles Massey'; 'Cactus Users List'
> Subject: RE: Cactus - possible bug
>
>
> Hi Charles,
>
> > -----Original Message-----
> > From: Charles Massey [mailto:[EMAIL PROTECTED]]
> > Sent: 08 July 2002 16:50
> > To: '[EMAIL PROTECTED]'
> > Subject: Cactus - possible bug
> >
> > Hi Vincent,
> >
> > I came across what might be a possible bug in Cactus. I am using a
> > session
> > cookie to re-use the session that is created on our application
> server. I
> > receive the JSESSIONID cookie when the session is first created and
> pass
> > it
> > back in the outgoing request for every subsequent textXXX method
> calls.
>
> How do you do that as there is no order in the tests ? Do you
> check in a
> setUp() method if an instance variable (containing) is set and if so,
> add a cookie to the request ? Or something like that ?
>
> >
> > The cookie is successfully added to the request in the begin method.
> > After
> > Cactus executes the testXXX method, the second call to the
> > ServletRedirector
> > is called to get the result. When this second call is performed,
> Cactus
> > creates a new WebRequest object and the state from the previous
> WebRequest
> > initialized in the beginXXX method is not called. This second call,
> to
> > get
> > the test result, is what is causing us problems.
> >
> > We are using Dynamo and ATG has placed a 20 session limit on our
> developer
> > licenses, so that is why it is important to create as
> little sessions
> as
> > possible.
>
> Arg! I would never have thought about that!
>
> >
> > The work around that I found to solve this is to edit the
> > AbstractHttpClient
> > class and in the callGetResult method, add the cookie to the request
> > object
> > before the post is performed. I have tested this solution out on my
> > machine, and only two sessions are created for the entire test run.
> >
> > I'm not sure if you would consider this a bug, so I thought I would
> send
> > this to you to see what you thought.
>
> I would definitely not consider this a bug but more a feature
> request !
> :-)
>
> However, I would be happy to apply a patch if you submit one ...
>
> Thanks
> -Vincent
>
> >
> > Thanks,
> > Charley
>
AbstractTestCase.java
Description: Binary data
AbstractHttpClient.java
Description: Binary data
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
