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 "David M. Karr" <dm...@earthlink.net> on 2003/03/18 03:45:25 UTC
Conventions for "configuring" TestCase classes?
I have some configuration parameters I'd like to set for my TestCases. I'd
prefer not to hardcode them in the class. I can't just use the "web.xml" and
set servlet init parameters because I need these parameters to be readable on
the client side of the TestCase.
What do people normally do in this situation?
--
===================================================================
David M. Karr ; Java/J2EE/XML/Unix/C++
dmkarr@earthlink.net ; SCJP; SCWCD
Re: Conventions for "configuring" TestCase classes?
Posted by Fred Loney <lo...@spiritedsw.com>.
I agree that servlet config properties should be placed in a resource
bundle, preferable residing in a known file location outside of the
webapp deployment unit. There are good architectural reasons to do this,
besides making them available on the cactus client:
o it can be modified without rebuilding the web app
o an admin web page can edit the config entries and save the changes
o separation of concerns: global config params typically pertain to
application semantics, whereas the rest of web.xml pertains to the
servlet mechanism
o separation of roles: developer vs. administrator
o it is easier to generate the web.xml automatically
I find web.xml too complex and critical to touch directly. I prefer to
generate it from javadoc tags on the individual servlet classes using
xdoclet and put volatle config information in a properties file instead.
Fred Loney
Spirited Software, Inc.
www.spiritedsw.com
----- Original Message -----
From: "Vincent Massol" <vm...@pivolis.com>
To: "'Cactus Users List'" <ca...@jakarta.apache.org>
Sent: Monday, March 17, 2003 11:46 PM
Subject: RE: Conventions for "configuring" TestCase classes?
> Hi David,
>
> Why don't you use a ResourceBundle?
>
> public void beginXXX()
> {
> PropertyResourceBundle bundle =
ResourceBundle.getBundle("myprops");
> bundle.getString("someproperty");
> [...]
>
> Alternatively, if you're using a script to run the test, you can pass
> the properties as system properties, using the -D switch. For example
> with Ant:
>
> <junit printsummary="yes" haltonfailure="yes" fork="yes">
> <jvmarg value="-Dsome.thing=some.value"/>
> [...]
>
> Note that Cactus 1.5 offers a one time initialization mechanism
> (begin()) which you can use to initialize values.
>
> Hope it helps,
> -Vincent
>
> > -----Original Message-----
> > From: David M. Karr [mailto:dmkarr@earthlink.net]
> > Sent: 18 March 2003 03:45
> > To: cactus-user@jakarta.apache.org
> > Subject: Conventions for "configuring" TestCase classes?
> >
> > I have some configuration parameters I'd like to set for my
TestCases.
> > I'd
> > prefer not to hardcode them in the class. I can't just use the
> "web.xml"
> > and
> > set servlet init parameters because I need these parameters to be
> readable
> > on
> > the client side of the TestCase.
> >
> > What do people normally do in this situation?
> >
> > --
> > ===================================================================
> > David M. Karr ; Java/J2EE/XML/Unix/C++
> > dmkarr@earthlink.net ; SCJP; SCWCD
> >
> >
> >
> >
>
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: cactus-user-help@jakarta.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: cactus-user-help@jakarta.apache.org
>
RE: Conventions for "configuring" TestCase classes?
Posted by Vincent Massol <vm...@pivolis.com>.
Hi David,
Why don't you use a ResourceBundle?
public void beginXXX()
{
PropertyResourceBundle bundle = ResourceBundle.getBundle("myprops");
bundle.getString("someproperty");
[...]
Alternatively, if you're using a script to run the test, you can pass
the properties as system properties, using the -D switch. For example
with Ant:
<junit printsummary="yes" haltonfailure="yes" fork="yes">
<jvmarg value="-Dsome.thing=some.value"/>
[...]
Note that Cactus 1.5 offers a one time initialization mechanism
(begin()) which you can use to initialize values.
Hope it helps,
-Vincent
> -----Original Message-----
> From: David M. Karr [mailto:dmkarr@earthlink.net]
> Sent: 18 March 2003 03:45
> To: cactus-user@jakarta.apache.org
> Subject: Conventions for "configuring" TestCase classes?
>
> I have some configuration parameters I'd like to set for my TestCases.
> I'd
> prefer not to hardcode them in the class. I can't just use the
"web.xml"
> and
> set servlet init parameters because I need these parameters to be
readable
> on
> the client side of the TestCase.
>
> What do people normally do in this situation?
>
> --
> ===================================================================
> David M. Karr ; Java/J2EE/XML/Unix/C++
> dmkarr@earthlink.net ; SCJP; SCWCD
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: cactus-user-help@jakarta.apache.org