From derby-commits-return-6947-apmail-db-derby-commits-archive=db.apache.org@db.apache.org Tue Apr 03 23:19:22 2007 Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 14132 invoked from network); 3 Apr 2007 23:19:22 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Apr 2007 23:19:22 -0000 Received: (qmail 52307 invoked by uid 500); 3 Apr 2007 23:19:29 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 52283 invoked by uid 500); 3 Apr 2007 23:19:29 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 52272 invoked by uid 99); 3 Apr 2007 23:19:29 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Apr 2007 16:19:29 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Apr 2007 16:19:20 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id A568E1A983A; Tue, 3 Apr 2007 16:19:00 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r525326 - in /db/derby/code/trunk/java: testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/ testing/org/apache/derbyTesting/functionTests/tests/derbynet/ testing/org/apa... Date: Tue, 03 Apr 2007 23:19:00 -0000 To: derby-commits@db.apache.org From: fuzzylogic@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070403231900.A568E1A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: fuzzylogic Date: Tue Apr 3 16:18:58 2007 New Revision: 525326 URL: http://svn.apache.org/viewvc?view=rev&rev=525326 Log: DERBY-2505 (partial): Convert derbynet/testij.java to JUnit. Getting an NPE looking for the test script when running with jars, need to resolve that before hooking it into the derbynet _Suite. Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/testclientij.out (with props) db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetIjTests.java (with props) db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/IjTestCase.java (with props) Removed: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/testij.out db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testij.java db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testij.sql db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testij_app.properties db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testij_sed.properties Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testclientij.sql db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ConnectionEnv.java db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/Main.java db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ij.jj db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/util.java db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/utilMain.java Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/testclientij.out URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/testclientij.out?view=auto&rev=525326 ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/testclientij.out (added) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/testclientij.out Tue Apr 3 16:18:58 2007 @@ -0,0 +1,72 @@ +ij version 10.3 +ij> -- +-- Licensed to the Apache Software Foundation (ASF) under one or more +-- contributor license agreements. See the NOTICE file distributed with +-- this work for additional information regarding copyright ownership. +-- The ASF licenses this file to You under the Apache License, Version 2.0 +-- (the "License"); you may not use this file except in compliance with +-- the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +driver 'org.apache.derby.jdbc.ClientDriver'; +ij> --Bug 4632 Make the db italian to make sure string selects are working +connect 'jdbc:derby://localhost:1527/testij;create=true;territory=it' USER 'dbadmin' PASSWORD 'dbadmin'; +ij> connect 'jdbc:derby://localhost:1527/testij' USER 'dbadmin' PASSWORD 'dbadbmin'; +ij(CONNECTION1)> -- this is a comment, a comment in front of a select should not cause an error +select * from sys.systables where 1=0; +TABLEID |TABLENAME |&|SCHEMAID |& +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +0 rows selected +ij(CONNECTION1)> -- this is a comment, a comment in front of a values clauses should not cause an error +values(1); +1 +----------- +1 + +1 row selected +ij(CONNECTION1)> -- Try some URL attributes +disconnect all; +ij> connect 'jdbc:derby://localhost:1527/testij2;create=true' USER 'dbadmin' PASSWORD 'dbadbmin'; +ij> select * from APP.notthere; +ERROR 42X05: Table/View 'APP.NOTTHERE' does not exist. +ij> -- examples from the docs + +connect 'jdbc:derby://localhost:1527/testij2;create=true;user=judy;password=judy'; +ij(CONNECTION1)> connect 'jdbc:derby://localhost:1527/./testij2;user=judy;password=judy'; +ij(CONNECTION2)> connect 'jdbc:derby://localhost:1527/toursDB'; +ERROR 08004: The connection was refused because the database toursDB was not found. +ij(CONNECTION2)> connect 'jdbc:derby://localhost:1527/toursDB' USER 'dbadmin' PASSWORD 'dbadbmin'; +ERROR 08004: The connection was refused because the database toursDB was not found. +ij(CONNECTION2)> connect 'jdbc:derby://localhost:1527/wombat' USER 'APP' PASSWORD 'APP'; +ij(CONNECTION3)> connect 'jdbc:derby://localhost:1527/testij2;create=true;user=usr;password=pwd'; +ij(CONNECTION4)> connect 'jdbc:derby://localhost:1527/testij2;upgrade=true;user=usr;password=pwd'; +ij(CONNECTION5)> connect 'jdbc:derby://localhost:1527/testij2;shutdown=true;user=usr;password=pwd'; +ERROR 08006: DERBY SQL error: SQLCODE: -1, SQLSTATE: 08006, SQLERRMC: Database 'testij2' shutdown. +ij(CONNECTION5)> connect 'jdbc:derby://localhost:1527/./testij2;create=true;user=usr;password=pwd'; +ij(CONNECTION6)> connect 'jdbc:derby://localhost:1527/./testij2;create=true;user=usr;password=pwd'; +ij(CONNECTION7)> connect 'jdbc:derby://localhost:1527/testij2;create=true;user=usr;password=pwd'; +ij(CONNECTION8)> connect 'jdbc:derby://localhost:1527/testij2;upgrade=true;user=usr;password=pwd'; +ij(CONNECTION9)> connect 'jdbc:derby://localhost:1527/testij2;shutdown=true;user=usr;password=pwd'; +ERROR 08006: DERBY SQL error: SQLCODE: -1, SQLSTATE: 08006, SQLERRMC: Database 'testij2' shutdown. +ij(CONNECTION9)> -- retrieveMessageText Testing +connect 'jdbc:derby://localhost:1527/testij2;create=true;user=usr;password=pwd;retrieveMessageText=false'; +ij(CONNECTION10)> -- Should not get message text +select * from APP.notthere; +ERROR 42X05: DERBY SQL error: SQLCODE: -1, SQLSTATE: 42X05, SQLERRMC: APP.NOTTHERE42X05 +ij(CONNECTION10)> connect 'jdbc:derby://localhost:1527/testij2;create=true;user=usr;password=pwd;retrieveMessageText=true'; +ij(CONNECTION11)> -- Should see message text +select * from APP.notthere; +ERROR 42X05: Table/View 'APP.NOTTHERE' does not exist. +ij(CONNECTION11)> -- just user security mechanism +connect 'jdbc:derby://localhost:1527/testij2;create=true;user=usr;retrieveMessageText=true'; +ij(CONNECTION12)> connect 'jdbc:derby://localhost:1527/wombat' USER 'APP'; +ij(CONNECTION13)> disconnect all; +ij> \ No newline at end of file Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/testclientij.out ------------------------------------------------------------------------------ svn:eol-style = native Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetIjTests.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetIjTests.java?view=auto&rev=525326 ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetIjTests.java (added) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetIjTests.java Tue Apr 3 16:18:58 2007 @@ -0,0 +1,46 @@ +/* + * + * Derby - Class org.apache.derbyTesting.functionTests.tests.derbynet.NetIjTests + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the License. + */ + +package org.apache.derbyTesting.functionTests.tests.derbynet; + +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.apache.derbyTesting.functionTests.util.IjTestCase; +import org.apache.derbyTesting.junit.TestConfiguration; + +/** + * Network client .sql tests to run via ij. + */ +public class NetIjTests extends IjTestCase { + + private NetIjTests(String name) { + super(name); + } + + public static Test suite() { + + TestSuite suite = new TestSuite("NetIjTests"); + suite.addTest(TestConfiguration.clientServerDecorator( + new NetIjTests("testclientij"))); + + return suite; + } +} Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetIjTests.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testclientij.sql URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testclientij.sql?view=diff&rev=525326&r1=525325&r2=525326 ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testclientij.sql (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testclientij.sql Tue Apr 3 16:18:58 2007 @@ -16,9 +16,9 @@ -- driver 'org.apache.derby.jdbc.ClientDriver'; --Bug 4632 Make the db italian to make sure string selects are working -connect 'jdbc:derby://localhost:1527/wombat;create=true;territory=it' USER 'dbadmin' PASSWORD 'dbadmin'; +connect 'jdbc:derby://localhost:1527/testij;create=true;territory=it' USER 'dbadmin' PASSWORD 'dbadmin'; -connect 'jdbc:derby://localhost:1527/wombat' USER 'dbadmin' PASSWORD 'dbadbmin'; +connect 'jdbc:derby://localhost:1527/testij' USER 'dbadmin' PASSWORD 'dbadbmin'; -- this is a comment, a comment in front of a select should not cause an error select * from sys.systables where 1=0; -- this is a comment, a comment in front of a values clauses should not cause an error @@ -26,62 +26,52 @@ -- Try some URL attributes disconnect all; -connect 'jdbc:derby://localhost:1527/junk;create=true' USER 'dbadmin' PASSWORD 'dbadbmin'; +connect 'jdbc:derby://localhost:1527/testij2;create=true' USER 'dbadmin' PASSWORD 'dbadbmin'; select * from APP.notthere; -- examples from the docs -connect 'jdbc:derby://localhost:1527/wombat;create=true;user=judy;password=judy'; +connect 'jdbc:derby://localhost:1527/testij2;create=true;user=judy;password=judy'; -connect 'jdbc:derby://localhost:1527/./wombat;user=judy;password=judy'; +connect 'jdbc:derby://localhost:1527/./testij2;user=judy;password=judy'; connect 'jdbc:derby://localhost:1527/toursDB'; - connect 'jdbc:derby://localhost:1527/toursDB' USER 'dbadmin' PASSWORD 'dbadbmin'; connect 'jdbc:derby://localhost:1527/wombat' USER 'APP' PASSWORD 'APP'; -connect 'jdbc:derby://localhost:1527/my-db-name;create=true;user=usr;password=pwd'; - -connect 'jdbc:derby://localhost:1527/my-db-name;upgrade=true;user=usr;password=pwd'; - -connect 'jdbc:derby://localhost:1527/my-db-name;shutdown=true;user=usr;password=pwd'; +connect 'jdbc:derby://localhost:1527/testij2;create=true;user=usr;password=pwd'; -connect 'jdbc:derby://localhost:1527/./my-dbname;create=true;user=usr;password=pwd'; +connect 'jdbc:derby://localhost:1527/testij2;upgrade=true;user=usr;password=pwd'; -connect 'jdbc:derby://localhost:1527/./my-dbname;create=true;user=usr;password=pwd'; +connect 'jdbc:derby://localhost:1527/testij2;shutdown=true;user=usr;password=pwd'; -connect 'jdbc:derby://localhost:1527/toursDB' USER 'dbadmin' PASSWORD 'dbadbmin'; - -connect 'jdbc:derby://localhost:1527/wombat' USER 'APP' PASSWORD 'APP'; +connect 'jdbc:derby://localhost:1527/./testij2;create=true;user=usr;password=pwd'; -connect 'jdbc:derby://localhost:1527/my-db-name;create=true;user=usr;password=pwd'; +connect 'jdbc:derby://localhost:1527/./testij2;create=true;user=usr;password=pwd'; -connect 'jdbc:derby://localhost:1527/my-db-name;upgrade=true;user=usr;password=pwd'; - -connect 'jdbc:derby://localhost:1527/my-db-name;shutdown=true;user=usr;password=pwd'; - --- Database names with /'s -connect 'jdbc:derby://localhost:1527/./my-dbname;create=true;user=usr;password=pwd'; - -connect 'jdbc:derby://localhost:1527/./my-dbname;create=true;user=usr;password=pwd'; +connect 'jdbc:derby://localhost:1527/testij2;create=true;user=usr;password=pwd'; +connect 'jdbc:derby://localhost:1527/testij2;upgrade=true;user=usr;password=pwd'; +connect 'jdbc:derby://localhost:1527/testij2;shutdown=true;user=usr;password=pwd'; -- retrieveMessageText Testing -connect 'jdbc:derby://localhost:1527/my-db-name;create=true;user=usr;password=pwd;retrieveMessageText=false'; +connect 'jdbc:derby://localhost:1527/testij2;create=true;user=usr;password=pwd;retrieveMessageText=false'; -- Should not get message text select * from APP.notthere; -connect 'jdbc:derby://localhost:1527/my-db-name;create=true;user=usr;password=pwd;retrieveMessageText=true'; +connect 'jdbc:derby://localhost:1527/testij2;create=true;user=usr;password=pwd;retrieveMessageText=true'; -- Should see message text select * from APP.notthere; -- just user security mechanism -connect 'jdbc:derby://localhost:1527/my-db-name;create=true;user=usr;retrieveMessageText=true'; +connect 'jdbc:derby://localhost:1527/testij2;create=true;user=usr;retrieveMessageText=true'; connect 'jdbc:derby://localhost:1527/wombat' USER 'APP'; + +disconnect all; Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/IjTestCase.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/IjTestCase.java?view=auto&rev=525326 ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/IjTestCase.java (added) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/IjTestCase.java Tue Apr 3 16:18:58 2007 @@ -0,0 +1,110 @@ +/* + * Derby - Class org.apache.derbyTesting.functionTests.util.ExecIjTestCase + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the License. + */ + +package org.apache.derbyTesting.functionTests.util; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.OutputStream; +import java.security.AccessController; +import java.security.PrivilegedAction; + +import org.apache.derby.tools.ij; + +/** + * Run a .sql script via ij's main method and compare with a canon. + */ +public class IjTestCase extends ScriptTestCase { + + String scriptName; + String outfileName; + File outfile; + + /** + * Create a script testcase that runs the .sql script with the + * given name. The name should not include the ".sql" suffix. + */ + public IjTestCase(String name) { + super(name); + scriptName = getName() + ".sql"; + outfileName = "system" + File.separator + getName() + ".out"; + outfile = new File(outfileName); + } + + public void setUp() throws Exception{ + super.setUp(); + setSystemProperty("ij.outfile", outfileName); + setSystemProperty("ij.defaultResourcePackage", + "/org/apache/derbyTesting/functionTests/tests/" + + getArea() + File.separator); + } + + public void tearDown() throws Exception { + super.tearDown(); + removeSystemProperty("ij.outfile"); + removeSystemProperty("ij.defaultResourcePackage"); + } + + /** + * Run a .sql test, calling ij's main method. + * Then, take the output filre and read it into our OutputStream + * so that it can be compared via compareCanon(). + */ + public void runTest() throws Throwable { + String [] args = { "-fr", scriptName }; + ij.main(args); + + String canon = + "org/apache/derbyTesting/functionTests/master/" + + getName() + ".out"; + + final File out = outfile; + FileInputStream fis = (FileInputStream) AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + FileInputStream fis = null; + try { + fis = new FileInputStream(out); + } catch (FileNotFoundException e) { + fail("Could not open ij output file."); + } + return fis; + } + }); + OutputStream os = getOutputStream(); + int b; + while ((b = fis.read()) != -1) { + os.write(b); + } + fis.close(); + + Boolean deleted = (Boolean) AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + boolean d = outfile.delete(); + + return new Boolean(d); + } + }); + + if (!deleted.booleanValue()) + println("Could not delete outfile for " + scriptName); + + this.compareCanon(canon); + } +} Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/IjTestCase.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ConnectionEnv.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ConnectionEnv.java?view=diff&rev=525326&r1=525325&r2=525326 ============================================================================== --- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ConnectionEnv.java (original) +++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ConnectionEnv.java Tue Apr 3 16:18:58 2007 @@ -28,6 +28,8 @@ import java.util.Enumeration; import java.util.Properties; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; @@ -64,8 +66,12 @@ // only load up ij.connection.* properties if there is // only one ConnectionEnv in the system. if (only) { - Properties p = System.getProperties(); - protocol = p.getProperty(ij.PROTOCOL_PROPERTY); + Properties p = (Properties) AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + return System.getProperties(); + } + }); + protocol = p.getProperty(ij.PROTOCOL_PROPERTY); String prefix = CONNECTION_PROPERTY + "."; for (Enumeration e = p.propertyNames(); e.hasMoreElements(); ) Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/Main.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/Main.java?view=diff&rev=525326&r1=525325&r2=525326 ============================================================================== --- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/Main.java (original) +++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/Main.java Tue Apr 3 16:18:58 2007 @@ -37,6 +37,8 @@ import java.io.UnsupportedEncodingException; import java.io.IOException; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.sql.Connection; import java.sql.SQLException; @@ -132,15 +134,25 @@ } } - String outFile = util.getSystemProperty("ij.outfile"); + final String outFile = util.getSystemProperty("ij.outfile"); if (outFile != null && outFile.length()>0) { LocalizedOutput oldOut = out; - try { - out = langUtil.getNewOutput(new FileOutputStream(outFile)); - } - catch (IOException ioe) { - oldOut.println(langUtil.getTextMessage("IJ_IjErroUnabTo",outFile)); - } + FileOutputStream fos = (FileOutputStream) AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + FileOutputStream out = null; + try { + out = new FileOutputStream(outFile); + } catch (FileNotFoundException e) { + out = null; + } + return out; + } + }); + out = langUtil.getNewOutput(fos); + + if (out == null) + oldOut.println(langUtil.getTextMessage("IJ_IjErroUnabTo",outFile)); + } // the old property name is deprecated... @@ -238,4 +250,5 @@ // adjust the application in accordance with derby.ui.locale and derby.ui.codeset LocalizedResource.getInstance(); } + } Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ij.jj URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ij.jj?view=diff&rev=525326&r1=525325&r2=525326 ============================================================================== --- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ij.jj (original) +++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ij.jj Tue Apr 3 16:18:58 2007 @@ -47,6 +47,8 @@ import org.apache.derby.tools.URLCheck; import java.lang.reflect.*; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.DriverManager; @@ -98,7 +100,8 @@ */ class ij { static final String PROTOCOL_PROPERTY = "ij.protocol"; - static final String USER_PROPERTY = "ij.user"; + static final String URLCHECK_PROPERTY = "ij.URLCheck"; + static final String USER_PROPERTY = "ij.user"; static final String PASSWORD_PROPERTY = "ij.password"; static final String FRAMEWORK_PROPERTY = "framework"; @@ -106,6 +109,7 @@ Connection theConnection = null; ConnectionEnv currentConnEnv = null; + String urlCheck = null; xaAbstractHelper xahelper = null; boolean exit = false; @@ -138,7 +142,12 @@ // load all protocols specified via properties // - Properties p = System.getProperties(); + Properties p = (Properties) AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + return System.getProperties(); + } + }); + urlCheck = p.getProperty(URLCHECK_PROPERTY); protocol = p.getProperty(PROTOCOL_PROPERTY); String framework_property = p.getProperty(FRAMEWORK_PROPERTY); @@ -1473,7 +1482,7 @@ } // By default perform extra checking on the URL attributes. // This checking does not change the processing. - if (System.getProperty("ij.URLCheck") == null || Boolean.getBoolean("ij.URLCheck")) { + if (urlCheck == null || Boolean.valueOf(urlCheck).booleanValue()) { URLCheck aCheck = new URLCheck(sVal); } if (!sVal.startsWith("jdbc:") && (p == null) && (protocol != null)) { Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/util.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/util.java?view=diff&rev=525326&r1=525325&r2=525326 ============================================================================== --- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/util.java (original) +++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/util.java Tue Apr 3 16:18:58 2007 @@ -31,6 +31,8 @@ import java.io.IOException; import java.lang.reflect.InvocationTargetException; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; @@ -219,11 +221,19 @@ */ static public InputStream getResourceAsStream(String resourceName) { - Class c= util.class; - resourceName = qualifyResourceName(resourceName,true); - if (resourceName == null) + final Class c = util.class; + final String resource = qualifyResourceName(resourceName,true); + if (resource == null) return null; - InputStream is = c.getResourceAsStream(resourceName); + InputStream is = (InputStream) AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + InputStream locis = + c.getResourceAsStream(resource); + return locis; + } + } + ); + if (is != null) is = new BufferedInputStream(is, utilMain.BUFFEREDFILESIZE); return is; Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/utilMain.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/utilMain.java?view=diff&rev=525326&r1=525325&r2=525326 ============================================================================== --- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/utilMain.java (original) +++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/utilMain.java Tue Apr 3 16:18:58 2007 @@ -42,6 +42,8 @@ import java.io.BufferedInputStream; import java.io.FileNotFoundException; import java.io.StringReader; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.sql.DriverManager; import java.sql.Driver; import java.sql.Connection; @@ -248,13 +250,25 @@ //check if the property is set to not show select count and set the static variable //accordingly. - boolean showNoCountForSelect = Boolean.getBoolean("ij.showNoCountForSelect"); + //boolean showNoCountForSelect = Boolean.getBoolean("ij.showNoCountForSelect"); + String prop = (String) AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + return System.getProperty("ij.showNoCountForSelect"); + } + }); + boolean showNoCountForSelect = Boolean.valueOf(prop).booleanValue(); JDBCDisplayUtil.showSelectCount = !showNoCountForSelect; //check if the property is set to not show initial connections and accordingly set the //static variable. - boolean showNoConnectionsAtStart = Boolean.getBoolean("ij.showNoConnectionsAtStart"); - if (!(showNoConnectionsAtStart)) { + prop = (String) AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + return System.getProperty("ij.showNoConnectionsAtStart"); + } + }); + boolean showNoConnectionsAtStart = Boolean.valueOf(prop).booleanValue(); + + if (!(showNoConnectionsAtStart)) { try { ijResult result = ijParser.showConnectionsMethod(true); displayResult(out,result,connEnv[currCE].getConnection());