You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Gary Gregory <gg...@seagullsw.com> on 2004/02/12 02:34:41 UTC
RE: [lang][proposal] SystemUtils property out of sync problem; ad
d set methods.
> Do people really change these values? (other than in tests, which kinda
> don't count...)
Hello,
I would like to address this point in particular since I think it is some
kind of mismatch (for lack of a better word on my part) with my view of what
[lang] is.
We use [lang] in our production code and in unit tests for our product and
are happy with it.
My feeling is that is does not matter what /kind/ of call site uses (for
example) SystemUtils, whether it is application code or unit test code. My
application, in general terms, is the client/customer. What matters is that
[lang] provides the services that make my job of writing code
easier/better/faster.
BTW, tests *do* count IMO. Where would we be without unit tests ;-)
Gary
> -----Original Message-----
> From: Stephen Colebourne [mailto:scolebourne@btopenworld.com]
> Sent: Wednesday, February 11, 2004 17:32
> To: Jakarta Commons Developers List
> Subject: Re: [lang][proposal] SystemUtils property out of sync problem;
> add set methods.
>
> My gut feeling is that this is an unusual case. Certainly, adding javadoc
> to
> say that the values are set when the class is class loaded is a good idea.
>
> Extra set/get methods are troublesome though, and I don't really want to
> expose more constants for the extra keys.
>
> Do people really change these values? (other than in tests, which kinda
> don't count...)
>
> Stephen
>
> From: "Gary Gregory" <gg...@seagullsw.com>
> > Context: I am writing some unit tests for our product that require
> system
> > properties (like java.ext.dirs) to be temporarily fiddled with. Now my
> code
> > looks like this:
> >
> > public void testJavaExtDirDoesNotExist() {
> > String saveJavaExtDirs = SystemUtils.JAVA_EXT_DIRS;
> > try {
> > String testJavaExtDirs = "...";
> > System.setProperty("java.ext.dirs", testJavaExtDirs);
> > // The real test starts here...
> > } finally {
> > System.setProperty("java.ext.dirs", saveJavaExtDirs);
> > }
> > }
> >
> > Issue #1: Add SystemUtils.setX?
> > --------
> >
> > Instead of:
> >
> > System.setProperty("java.ext.dirs", testJavaExtDirs);
> >
> > I wonder if this would be better:
> >
> > SystemUtils.setJavaExtDirs(testJavaExtDirs);
> >
> > Seems nicer, yes?
> >
> > Issue #2: SystemUtils out of sync.
> > --------
> >
> > As soon you do:
> >
> > System.setProperty("java.ext.dirs", testJavaExtDirs);
> >
> > Then SystemUtils.JAVA_EXT_DIRS lies.
> >
> > Proposal 2a:
> > At least, the Javadoc has to be updated to something nasty like: "The
> value
> > of this constant is set when this class is first loaded."
> >
> > Proposal 2b:
> > Add SystemUtils.getJavaExtDirs() and other APIs which do not cache and
> make
> > JAVA_EXT_DIRS and others use such APIs.
> >
> > Proposal 3b:
> > Add constants for the property names like: JAVA_EXT_DIRS_KEY =
> > "java.ext.dirs".
> >
> > ?
> > Gary
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang][proposal] SystemUtils property out of sync problem; add set methods.
Posted by "Todd V. Jonker" <to...@consciouscode.com>.
Gary,
Would it meet testing needs to add a reloadSystemProperties() method that
test-code can call after tweaking things? It seems like that would make
testing easy without cluttering SystemUtils with setters (that perhaps
shouldn't be used otherwise).
.T.
On Fri, 13 Feb 2004 23:11:43 -0000, "Stephen Colebourne"
<sc...@btopenworld.com> said:
> From: "Gary Gregory" <gg...@seagullsw.com>
> > > Do people really change these values? (other than in tests, which kinda
> > > don't count...)
> >
> > My feeling is that is does not matter what /kind/ of call site uses (for
> > example) SystemUtils, whether it is application code or unit test code. My
> > application, in general terms, is the client/customer. What matters is
> that
> > [lang] provides the services that make my job of writing code
> > easier/better/faster.
>
> The point I'm really driving at is where the limits of [lang] lie. There
> is
> no technical difficulty (other than its a bit boring) of adding get and
> set
> methods for each system property in addition to the constants. The
> question
> is whether it serves a big enough need.
>
> Maybe there is a large need to change environment variables, but I just
> feel
> a little unconvinced. Consider me -0 I guess.
>
> Stephen
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [lang][proposal] SystemUtils property out of sync problem; add set methods.
Posted by Stephen Colebourne <sc...@btopenworld.com>.
From: "Gary Gregory" <gg...@seagullsw.com>
> > Do people really change these values? (other than in tests, which kinda
> > don't count...)
>
> My feeling is that is does not matter what /kind/ of call site uses (for
> example) SystemUtils, whether it is application code or unit test code. My
> application, in general terms, is the client/customer. What matters is
that
> [lang] provides the services that make my job of writing code
> easier/better/faster.
The point I'm really driving at is where the limits of [lang] lie. There is
no technical difficulty (other than its a bit boring) of adding get and set
methods for each system property in addition to the constants. The question
is whether it serves a big enough need.
Maybe there is a large need to change environment variables, but I just feel
a little unconvinced. Consider me -0 I guess.
Stephen
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org