db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Van Couvering <David.Vancouver...@Sun.COM>
Subject Re: How can I configure System property when executing test of JUnit ?
Date Fri, 12 May 2006 17:21:29 GMT
Yes, the reason is that junit does not have permissions to set
properties, and it's in the

To do this, wrap your attempt to set the system property in a
PrivilegedAction block, like this:

            new java.security.PrivilegedAction()
                public Object run()
                    System.setProperty("my.property", "foo");

If you have the itch, it would be nice to put a method like
"setSystemProperty" and "getSystemProperty" in
functionTests.util.BaseTestCase.java that does this for you, so we don't
have to do this everywhere in our code.


TomohitoNakayama wrote:
> Hello.
> I'm switchovering SuicideOfStreaming test to JUnit in the issue of
> DERBY-1303, and encountered problem.
> How can I configure System property when executing tests in JUnit ?
> It seems that
> calling System.setProperty in test in JUnit fails to SecurityException
> though it was not failed when executed *not* as JUnit test ....
> The test class of SuicideOfStreaming exists in derbyTesting.jar and
> settinng System property in this class would be succeeded under
> derby_tests.policy....
> http://svn.apache.org/repos/asf/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy
> Any help would be greatly appricated ....
> Best regards.

View raw message