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 Aldrin Leal <al...@leal.eng.br> on 2003/04/06 01:19:55 UTC
ServletTestRunner misbehaviour
Hello,
Vincent Massol asked me to post a problem i've had with cactus, in order
to find a solution, the problem affects both JUnit and Cactus'
ServletTestRunner.
They both try to call System.setProperty, causing an exception under
some hosting providers. I found this in Brazilian LocaWeb. A solution might
be disabling all the offending code, by re-writing/re-compiling
BaseTestRunner from JUnit and ServletTestRunner from Cactus.
I think an alternative could be read the setup using
getResourcesAsStream for a given class looking for a .properties file. For a
simple package, it might be really useful.
Well. I just had to report. Cactus is great. It was just a small problem
with my production environment.
Thanks in advance, Aldrin Leal, aldrin@leal.eng.br.
Re: ServletTestRunner misbehaviour
Posted by Christopher Lenz <cm...@gmx.de>.
Vincent,
IIRC adding the SecurityException catch was just half of the story. On
the client side, Cactus still uses system properties internally to
communicate configuration parameters, and that will fail if the
corresponding permission has been denied.
I had wanted to look into it some more, but the project where I needed
to use the J2EE-RI (with default, strict security permissions) has been
finished and thus the itch got less urgent :-P
Vincent Massol wrote:
> Hi Aldrin,
>
> This is already supported in Cactus 1.5. Here's the code:
>
> private void setSystemProperties(HttpServletRequest theRequest)
> {
> if (this.canSetSystemProperty)
> {
> try
> {
> System.setProperty(
> BaseConfiguration.CACTUS_CONTEXT_URL_PROPERTY,
> "http://" + theRequest.getServerName() + ":"
> + theRequest.getServerPort()
> + theRequest.getContextPath());
> }
> catch (SecurityException se)
> {
> log("Could not set the Cactus context URL as system
> property, "
> + "you will have to include a Cactus properties file
> in "
> + "the class path of the web application", se);
> this.canSetSystemProperty = false;
> }
> }
> }
>
> WRT JUnit you should report this on the junit mailing list.
>
> Thanks
> -Vincent
--
Christopher Lenz
/=/ cmlenz at gmx.de
RE: ServletTestRunner misbehaviour
Posted by Vincent Massol <vm...@pivolis.com>.
Hi Aldrin,
This is already supported in Cactus 1.5. Here's the code:
private void setSystemProperties(HttpServletRequest theRequest)
{
if (this.canSetSystemProperty)
{
try
{
System.setProperty(
BaseConfiguration.CACTUS_CONTEXT_URL_PROPERTY,
"http://" + theRequest.getServerName() + ":"
+ theRequest.getServerPort()
+ theRequest.getContextPath());
}
catch (SecurityException se)
{
log("Could not set the Cactus context URL as system
property, "
+ "you will have to include a Cactus properties file
in "
+ "the class path of the web application", se);
this.canSetSystemProperty = false;
}
}
}
WRT JUnit you should report this on the junit mailing list.
Thanks
-Vincent
> -----Original Message-----
> From: Aldrin Leal [mailto:aldrin@leal.eng.br]
> Sent: 06 April 2003 01:20
> To: cactus-user@jakarta.apache.org
> Subject: ServletTestRunner misbehaviour
>
> Hello,
>
> Vincent Massol asked me to post a problem i've had with cactus, in
> order
> to find a solution, the problem affects both JUnit and Cactus'
> ServletTestRunner.
>
> They both try to call System.setProperty, causing an exception
under
> some hosting providers. I found this in Brazilian LocaWeb. A solution
> might
> be disabling all the offending code, by re-writing/re-compiling
> BaseTestRunner from JUnit and ServletTestRunner from Cactus.
>
> I think an alternative could be read the setup using
> getResourcesAsStream for a given class looking for a .properties file.
For
> a
> simple package, it might be really useful.
>
> Well. I just had to report. Cactus is great. It was just a small
> problem
> with my production environment.
>
> Thanks in advance, Aldrin Leal, aldrin@leal.eng.br.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: cactus-user-help@jakarta.apache.org