Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 21156 invoked from network); 12 May 2006 17:21:42 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 12 May 2006 17:21:42 -0000 Received: (qmail 7189 invoked by uid 500); 12 May 2006 17:21:41 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 7159 invoked by uid 500); 12 May 2006 17:21:41 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 7150 invoked by uid 99); 12 May 2006 17:21:41 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 12 May 2006 10:21:41 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [192.18.42.249] (HELO nwkes-gis-mail-1.sun.com) (192.18.42.249) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 12 May 2006 10:21:39 -0700 Received: from d1-sfbay-03.sun.com ([192.18.39.113]) by nwkes-gis-mail-1.sun.com (8.12.9/8.12.9) with ESMTP id k4CHLI6O029524 for ; Fri, 12 May 2006 10:21:19 -0700 (PDT) Received: from conversion-daemon.d1-sfbay-03.sun.com by d1-sfbay-03.sun.com (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) id <0IZ500M01X95YL00@d1-sfbay-03.sun.com> (original mail from David.Vancouvering@Sun.COM) for derby-dev@db.apache.org; Fri, 12 May 2006 10:21:18 -0700 (PDT) Received: from [192.168.1.102] ([64.142.91.3]) by d1-sfbay-03.sun.com (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) with ESMTPSA id <0IZ5004DEXJION70@d1-sfbay-03.sun.com> for derby-dev@db.apache.org; Fri, 12 May 2006 10:21:18 -0700 (PDT) Date: Fri, 12 May 2006 10:21:29 -0700 From: David Van Couvering Subject: Re: How can I configure System property when executing test of JUnit ? In-reply-to: <44646539.9050402@basil.ocn.ne.jp> Sender: David.Vancouvering@Sun.COM To: derby-dev@db.apache.org Message-id: <4464C419.50409@sun.com> MIME-version: 1.0 Content-type: text/plain; charset=ISO-2022-JP Content-transfer-encoding: 7BIT References: <44646539.9050402@basil.ocn.ne.jp> User-Agent: Thunderbird 1.5.0.2 (X11/20060427) X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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. >