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 Trevor Porter <tr...@woz.com> on 2003/09/16 02:45:37 UTC
Cactus ant integration and cactus.contextURL
Hi all,
I just discovered a limitation with Cactus when trying to use the cactus
ant task while overriding the default contextURL using one of the
prescribed methods. It appears that the ant task ignores any such
attempt to alter cactus.contextURL unless I set the cactus.contextURL
system property in my test class (which I'd rather not do). A quick
glance at the CactusTask.java source file and I can see why -- the
servername is always set to 'localhost', the port is set to 8080 unless
otherwise specified in the port attribute under containerset elements,
and the context name is set based on the name of the test war file. This
makes sense given that the cactus task starts/stops the servlet
container locally, but what if a cactus test case needs to perform a
test that examines the value of request.getServerName()? An easy
workaround is to define a system property under the cactus task
containing the value of cactus.contextURL and then setting
cactus.contextURL from begin() in the test class. It's not so bad, but
I'm wondering if I missed anything or if someone has a better alternative.
Thanks,
Trevor
RE: Cactus ant integration and cactus.contextURL
Posted by Vincent Massol <vm...@pivolis.com>.
Hi Trevor,
The solution for what you ask is the WebRequest.setURL() method that you
need to call in your beginXXX method. If I recall correctly the first
parameter is the server name you wish to have.
Please see the website doc or better yet, the cactus tests in
sample/servlet (found in the cactus distribution you downloaded).
-Vincent
> -----Original Message-----
> From: Trevor Porter [mailto:trevor@woz.com]
> Sent: 16 September 2003 02:46
> To: cactus-user@jakarta.apache.org
> Subject: Cactus ant integration and cactus.contextURL
>
> Hi all,
>
> I just discovered a limitation with Cactus when trying to use the
cactus
> ant task while overriding the default contextURL using one of the
> prescribed methods. It appears that the ant task ignores any such
> attempt to alter cactus.contextURL unless I set the cactus.contextURL
> system property in my test class (which I'd rather not do). A quick
> glance at the CactusTask.java source file and I can see why -- the
> servername is always set to 'localhost', the port is set to 8080
unless
> otherwise specified in the port attribute under containerset elements,
> and the context name is set based on the name of the test war file.
This
> makes sense given that the cactus task starts/stops the servlet
> container locally, but what if a cactus test case needs to perform a
> test that examines the value of request.getServerName()? An easy
> workaround is to define a system property under the cactus task
> containing the value of cactus.contextURL and then setting
> cactus.contextURL from begin() in the test class. It's not so bad, but
> I'm wondering if I missed anything or if someone has a better
alternative.
>
> Thanks,
> Trevor
>
>
>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: cactus-user-help@jakarta.apache.org