db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From TomohitoNakayama <tomon...@basil.ocn.ne.jp>
Subject Re: How can I configure System property when executing test of JUnit ?
Date Sat, 13 May 2006 07:45:47 GMT
Hello David.

Thank you.
It seems that your answer resolve my problem.

I will add setSystemProperty method to functionTests.util.BaseTestCase.

Best regards.

David Van Couvering wrote:

>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:
>        AccessController.doPrivileged(
>            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:
>>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
>>Any help would be greatly appricated ....
>>Best regards.


        Tomohito Nakayama



View raw message