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.
>
>David
>
>
>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.
>>
>>    
>>
>
>
>  
>

-- 
/*

        Tomohito Nakayama
        tomonaka@basil.ocn.ne.jp
        tomohito@rose.zero.ad.jp
        tmnk@apache.org

        Naka
        http://www5.ocn.ne.jp/~tomohito/TopPage.html

*/ 


Mime
View raw message