db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David W. Van Couvering" <David.Vancouver...@Sun.COM>
Subject Re: svn commit: r387640 - in /db/derby/code/trunk/java/testing: ./ org/apache/derbyTesting/functionTests/master/ org/apache/derbyTesting/functionTests/suites/ org/apache/derbyTesting/functionTests/tests/jdbc4/
Date Tue, 21 Mar 2006 22:28:00 GMT
Hi, Rick, this looks great, thanks for this work!

A couple of questions:

- Is there any reason these weren't written as JUnit tests?  I suspect 
the answer is (a) they were originally written before the JUnit 
framework was in place and (b) it was too much work to migrate as part 
of this patch.

- I noticed in a couple of places you directly call 
System.getProperty("framework").  Shouldn't these be in privileged 
blocks?  Or is this only an issue with JUnit tests because they require 
JUnit to be able to access properties unless you use a privileged block?

I'm just curious -- how did you get ij.startJBMS() to work?  I got 
"null" whenever I tried to do that in the JDBC4 tests, as did others...

Thanks,

David

rhillegas@apache.org wrote:
> Author: rhillegas
> Date: Tue Mar 21 14:10:53 2006
> New Revision: 387640
> 
> URL: http://svn.apache.org/viewcvs?rev=387640&view=rev
> Log:
> Checkin patch for DERBY-1133: rototills the jdbc4 tests to conform to customary derbyall
practices.
> 
> Added:
>     db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc40.properties
  (with props)
>     db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc40.runall
  (with props)
>     db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/README.html
  (with props)
>     db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/default_app.properties
  (with props)
> Removed:
>     db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc4.properties
>     db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc4.runall
>     db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestCallableStatementMethods_app.properties
>     db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData_app.properties
>     db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestJDBC40Exception_app.properties
>     db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestResultSetMethods_app.properties
> Modified:
>     db/derby/code/trunk/java/testing/README.htm
>     db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/TestDbMetaData.out
>     db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClient.exclude
>     db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/StartTestConnection.java
>     db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestCallableStatementMethods.java
>     db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnection.java
>     db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnectionMethods.java
>     db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnectionMethods_app.properties
>     db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData.java
>     db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestJDBC40Exception.java
>     db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestPreparedStatementMethods.java
>     db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestPreparedStatementMethods_app.properties
>     db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestPreparedStatement_app.properties
>     db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestQueryObject.java
>     db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestQueryObject_app.properties
>     db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestResultSetMethods.java
>     db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/copyfiles.ant
> 
> Modified: db/derby/code/trunk/java/testing/README.htm
> URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/README.htm?rev=387640&r1=387639&r2=387640&view=diff
> ==============================================================================
> --- db/derby/code/trunk/java/testing/README.htm (original)
> +++ db/derby/code/trunk/java/testing/README.htm Tue Mar 21 14:10:53 2006
> @@ -104,6 +104,11 @@
>   href="./org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/README.html">5.
>  Compatibility Tests</a></p>
>    </li>
> +  <li>
> +    <p><a
> + href="./org/apache/derbyTesting/functionTests/tests/jdbc4/README.html">6.
> +JDBC4 Tests</a></p>
> +  </li>
>  </ul>
>  <p><br>
>  <br>
> 
> Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/TestDbMetaData.out
> URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/TestDbMetaData.out?rev=387640&r1=387639&r2=387640&view=diff
> ==============================================================================
> --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/TestDbMetaData.out
(original)
> +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/TestDbMetaData.out
Tue Mar 21 14:10:53 2006
> @@ -44,17 +44,3 @@
>  SYSSTAT,null
>  TABLE_SCHEM,TABLE_CATALOG
>  APP,null
> -getClientInfoProperties():
> -FAIL -- unexpected exception
> -SQLSTATE(0A000):java.sql.SQLException: Feature not implemented: getClientInfoProperties
().
> -Caused by: org.apache.derby.client.am.SqlException: Feature not implemented: getClientInfoProperties
().
> -	... 4 more
> -getFunctionParameters():
> -java.lang.AbstractMethodError
> -getClientInfoProperties():
> -java.lang.AbstractMethodError
> -getSchemas():
> -FAIL -- unexpected exception
> -SQLSTATE(0A000):java.sql.SQLException: Feature not implemented: getSchemas (String,
String).
> -Caused by: org.apache.derby.client.am.SqlException: Feature not implemented: getSchemas
(String, String).
> -	... 4 more
> 
> Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClient.exclude
> URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClient.exclude?rev=387640&r1=387639&r2=387640&view=diff
> ==============================================================================
> --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClient.exclude
(original)
> +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClient.exclude
Tue Mar 21 14:10:53 2006
> @@ -11,6 +11,11 @@
>  # 			see DERBY-326 and DERBY-550 issues
>  lang/errorStream.java
>  # lang/scrollCursors2.java
> +#
> +# Currently, we exclude jdbc4/TestDbMetaData.java and
> +# jdbc4/TestJDBC40Exception.java from the jdbc40 suite.
> +# Eventually, we hope they will run under the network client.
> +#
>  jdbcapi/batchUpdate.java
>  jdbcapi/statementJdbc20.java
>  jdbcapi/testRelative.java
> @@ -18,3 +23,5 @@
>  jdbcapi/statementJdbc30.java
>  jdbcapi/dataSourceReference.java
>  largedata/LobLimits.java
> +jdbc4/TestDbMetaData.java
> +jdbc4/TestJDBC40Exception.java
> 
> Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc40.properties
> URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc40.properties?rev=387640&view=auto
> ==============================================================================
> --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc40.properties
(added)
> +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc40.properties
Tue Mar 21 14:10:53 2006
> @@ -0,0 +1,7 @@
> +runwithibm13=false
> +runwithibm14=false
> +runwithj9=false
> +runwithjdk12=false
> +runwithjdk13=false
> +runwithjdk14=false
> +runwithjdk15=false
> 
> Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc40.properties
> ------------------------------------------------------------------------------
>     svn:eol-style = native
> 
> Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc40.runall
> URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc40.runall?rev=387640&view=auto
> ==============================================================================
> --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc40.runall
(added)
> +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc40.runall
Tue Mar 21 14:10:53 2006
> @@ -0,0 +1,8 @@
> +jdbc4/StartTestConnection.java
> +jdbc4/TestConnectionMethods.java
> +jdbc4/TestCallableStatementMethods.java
> +jdbc4/TestPreparedStatementMethods.java
> +jdbc4/TestResultSetMethods.java
> +jdbc4/TestQueryObject.java
> +jdbc4/TestDbMetaData.java
> +jdbc4/TestJDBC40Exception.java
> 
> Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc40.runall
> ------------------------------------------------------------------------------
>     svn:eol-style = native
> 
> Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/README.html
> URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/README.html?rev=387640&view=auto
> ==============================================================================
> --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/README.html
(added)
> +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/README.html
Tue Mar 21 14:10:53 2006
> @@ -0,0 +1,49 @@
> +<html>
> +<title>Running the JDBC4 Tests</title>
> +<body>
> +<h1>Running the JDBC4 Tests</h1>
> +
> +<p>
> +Currently, there is one suite of tests used to verify JDBC4 features:
> +</p>
> +
> +<ul>
> +<li><b>jdbc40</b> - These tests can run with either the embedded or
> +network client, that is, under either the <i>embedded</i> or
> +<i>DerbyNetClient</i> frameworks. In general, JDBC4 tests do not run
> +the JCC client (<i>DerbyNet</i> framework) because that old client
> +does not support the new JDBC4 feature set.</li>
> +</ul>
> +
> +<p>
> +Note that two of the tests in this suite
> +(<i>jdbc4/TestDbMetaData.java</i> and
> +<i>jdbc4/TestJDBC40Exception.java</i>) are excluded from the
> +<i>DerbyNetClient</i> run. Eventually, we hope to run these tests
> +under <i>DerbyNetClient</i>. At that time, we can remove these tests
> +from <i>suites/DerbyNetClient.exclude</i>.
> +</p>
> +
> +<p>
> +Before running these tests, you must first build the optional jkd16
> +support as described in <i>trunk/BUILDING.txt</i>.
> +</p>
> +
> +<p>
> +Verifying the JDBC4 feature set is a little tiresome right now. You must
> +run the following commands in a shell window whose JAVA_HOME points at
> +your jdk1.6 installation. After each suite run, check the test results.
> +</p>
> +
> +<blockquote><pre>
> +java org.apache.derbyTesting.functionTests.harness.RunSuite jdbc40
> +
> +# make sure the above test run succeeded
> +
> +java -Dframework=DerbyNetClient org.apache.derbyTesting.functionTests.harness.RunSuite
jdbc40
> +
> +# make sure the above test run succeeded
> +</pre></blockquote>
> +
> +</body>
> +</html>
> 
> Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/README.html
> ------------------------------------------------------------------------------
>     svn:eol-style = native
> 
> Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/StartTestConnection.java
> URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/StartTestConnection.java?rev=387640&r1=387639&r2=387640&view=diff
> ==============================================================================
> --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/StartTestConnection.java
(original)
> +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/StartTestConnection.java
Tue Mar 21 14:10:53 2006
> @@ -20,11 +20,22 @@
>  
>  package org.apache.derbyTesting.functionTests.tests.jdbc4;
>  
> +import java.sql.*;
> +
> +import org.apache.derby.tools.ij;
> +
> +
>  public class StartTestConnection {
>      public static void main(String args[]) {
>          try {
> +			// use the ij utility to read the property file and
> +			// make the initial connection.
> +			ij.getPropertyArg(args);
> +		
> +			Connection	conn_main = ij.startJBMS();
> +
>              TestConnection tc = new TestConnection();
> -            tc.startTest();
> +            tc.startTest( conn_main );
>          } catch(Exception e) {
>              System.out.println("Exception occurred in code StartTestConnection " + e);
>              e.printStackTrace();
> 
> Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestCallableStatementMethods.java
> URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestCallableStatementMethods.java?rev=387640&r1=387639&r2=387640&view=diff
> ==============================================================================
> --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestCallableStatementMethods.java
(original)
> +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestCallableStatementMethods.java
Tue Mar 21 14:10:53 2006
> @@ -27,6 +27,7 @@
>  import java.sql.NClob;
>  import java.sql.SQLException;
>  import java.sql.SQLXML;
> +import org.apache.derby.tools.ij;
>  import org.apache.derby.shared.common.reference.SQLState;
>  
>  /**
> @@ -259,44 +260,23 @@
>          t_getSQLXML2();
>      }
>      
> -    public static void main(String args[]) {
> -        TestConnection tc=null;
> -        Connection conn_main=null;
> -        CallableStatement cs_main=null;
> -        
> -        try {
> -            tc = new TestConnection();
> -            conn_main = tc.createEmbeddedConnection();
> -        } catch(Exception e) {
> -            e.printStackTrace();
> -        }
> -        
> -        try {
> -            cs_main = conn_main.prepareCall("select count(*) from sys.systables");
> -        } catch(SQLException e) {
> -            System.out.println(""+e);
> -            e.printStackTrace();
> -        }
> -        
> -        TestCallableStatementMethods tcsm = new TestCallableStatementMethods();
> -        tcsm.startCallableStatementMethodTest(conn_main,cs_main);
> -        
> -        conn_main=null;
> -        cs_main=null;
> -        
> -        try {
> -            conn_main = tc.createClientConnection();
> -        } catch(Exception e) {
> -            e.printStackTrace();
> -        }
> -        
> -        try {
> -            cs_main = conn_main.prepareCall("select count(*) from sys.systables");
> -        } catch(SQLException e) {
> -            System.out.println(""+e);
> -            e.printStackTrace();
> -        }
> +    public static void main(String args[])
> +	{
> +		try {
> +			// use the ij utility to read the property file and
> +			// make the initial connection.
> +			ij.getPropertyArg(args);
> +		
> +			Connection	conn_main = ij.startJBMS();
> +
> +			CallableStatement cs_main = conn_main.prepareCall("select count(*) from sys.systables");
>          
> -        tcsm.startCallableStatementMethodTest(conn_main,cs_main);
> +			TestCallableStatementMethods tcsm = new TestCallableStatementMethods();
> +			tcsm.startCallableStatementMethodTest(conn_main,cs_main);
> +        			
> +		} catch(Exception e) {
> +			System.out.println(""+e);
> +			e.printStackTrace();
> +		}
>      }
>  }
> 
> Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnection.java
> URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnection.java?rev=387640&r1=387639&r2=387640&view=diff
> ==============================================================================
> --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnection.java
(original)
> +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnection.java
Tue Mar 21 14:10:53 2006
> @@ -75,10 +75,14 @@
>              e.printStackTrace();
>          }
>      }
> -    void startTest() {
> -        Connection conn = createEmbeddedConnection();
> -        closeConnection(conn);
> -        Connection conn1 = createClientConnection();
> -        closeConnection(conn1);
> +    void startTest( Connection conn_main ) {
> +		try {
> +
> +			closeConnection(conn_main);
> +
> +		} catch(Exception e) {
> +			System.out.println(""+e);
> +			e.printStackTrace();
> +		}
>      }
>  }
> 
> Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnectionMethods.java
> URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnectionMethods.java?rev=387640&r1=387639&r2=387640&view=diff
> ==============================================================================
> --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnectionMethods.java
(original)
> +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnectionMethods.java
Tue Mar 21 14:10:53 2006
> @@ -35,6 +35,7 @@
>  import java.sql.SQLXML;
>  import java.sql.Statement;
>  import java.util.Properties;
> +import org.apache.derby.tools.ij;
>  import org.apache.derby.shared.common.reference.SQLState;
>  
>  /**
> @@ -266,22 +267,42 @@
>          t_getClientInfo1();
>          t_getClientInfo2();
>      }
> +
> +	/**
> +	 * <p>
> +	 * Return true if we're running under the embedded client.
> +	 * </p>
> +	 */
> +	private	static	boolean	usingEmbeddedClient()
> +	{
> +		return "embedded".equals( System.getProperty( "framework" ) );
> +	}
> +
> +	
>      public static void main(String args[]) {
> -        TestConnection tc = new TestConnection();
> -        
> -        Connection connEmbedded = tc.createEmbeddedConnection();
> -        TestConnectionMethods tcm = new TestConnectionMethods(connEmbedded);
> -        tcm.startTestConnectionMethods_Embedded();
> -        
> -        
> -        Connection connNetwork = tc.createClientConnection();
> -        TestConnectionMethods tcm1 = new TestConnectionMethods(connNetwork);
> -        tcm1.startTestConnectionMethods_Client();
> -        try {
> -            connEmbedded.close();
> -            connNetwork.close();
> -        } catch(SQLException sqle){
> -            sqle.printStackTrace();
> -        }
> +		try {
> +			// use the ij utility to read the property file and
> +			// make the initial connection.
> +			ij.getPropertyArg(args);
> +		
> +			Connection	conn_main = ij.startJBMS();
> +
> +			if ( usingEmbeddedClient() )
> +			{
> +				TestConnectionMethods tcm = new TestConnectionMethods( conn_main );
> +				tcm.startTestConnectionMethods_Embedded();
> +			}
> +			else // DerbyNetClient
> +			{
> +				TestConnectionMethods tcm1 = new TestConnectionMethods( conn_main );
> +				tcm1.startTestConnectionMethods_Client();
> +			}
> +
> +			conn_main.close();
> +
> +		} catch(Exception e) {
> +			System.out.println(""+e);
> +			e.printStackTrace();
> +		}
>      }
>  }
> 
> Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnectionMethods_app.properties
> URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnectionMethods_app.properties?rev=387640&r1=387639&r2=387640&view=diff
> ==============================================================================
> --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnectionMethods_app.properties
(original)
> +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnectionMethods_app.properties
Tue Mar 21 14:10:53 2006
> @@ -1,8 +1,16 @@
> +ij.database=jdbc:derby:wombat;create=true
> +
> +# DataSource properties, only used if ij.dataSource is set
> +ij.dataSource.databaseName=wombat
> +ij.dataSource.createDatabase=create
> +
>  runwithibm13=false
>  runwithibm14=false
>  runwithj9=false
>  runwithjdk12=false
>  runwithjdk13=false
>  runwithjdk14=false
> +excludeJCC=at-or-after:1.0
> +
>  supportfiles=tests/jdbc4/short.txt,tests/jdbc4/littleclob.txt,tests/jdbc4/aclob.txt
>  useextdirs=true
> 
> Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData.java
> URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData.java?rev=387640&r1=387639&r2=387640&view=diff
> ==============================================================================
> --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData.java
(original)
> +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData.java
Tue Mar 21 14:10:53 2006
> @@ -38,11 +38,13 @@
>  	public static void main(String[] args) {
>  		try
>  		{
> -            // Using TestConnection for now instead of ij because
> -            // ij.startJBMS() returns null for classes built against
> -            // JDK 1.6
> -            runTests(new TestConnection().createEmbeddedConnection());
> -            runTests(new TestConnection().createClientConnection());
> +			// use the ij utility to read the property file and
> +			// make the initial connection.
> +			ij.getPropertyArg(args);
> +		
> +			Connection	conn_main = ij.startJBMS();
> +
> +            runTests( conn_main );
>          }
>          catch (SQLException e) {
>              dumpSQLExceptions(e);
> 
> Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestJDBC40Exception.java
> URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestJDBC40Exception.java?rev=387640&r1=387639&r2=387640&view=diff
> ==============================================================================
> --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestJDBC40Exception.java
(original)
> +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestJDBC40Exception.java
Tue Mar 21 14:10:53 2006
> @@ -32,11 +32,15 @@
>  import junit.framework.Test;
>  import junit.framework.TestResult;
>  import junit.framework.TestSuite;
> +import org.apache.derby.tools.ij;
>  import org.apache.derbyTesting.functionTests.tests.derbynet.testconnection;
>  
>  public class TestJDBC40Exception {    
>      
>      private static final String EXCEPTION_TABLE1 = "EXCEPTION_TABLE1";
> +
> +	private	static	String[]	_startupArgs;
> +	
>      public TestJDBC40Exception() {
>      }
>      
> @@ -44,8 +48,14 @@
>       * Stub methods to be removed after 623 is fixed and test is 
>       * moved to use junit
>       */
> -    private Connection getConnection () throws SQLException {
> -        return new TestConnection ().createEmbeddedConnection();
> +    private Connection getConnection () throws Exception {
> +		// use the ij utility to read the property file and
> +		// make the initial connection.
> +		ij.getPropertyArg( _startupArgs );
> +		
> +		Connection	conn_main = ij.startJBMS();
> +		
> +        return conn_main;
>      }
>      
>      /*
> @@ -153,6 +163,8 @@
>      
>      public static void main(String [] args) throws Exception {    
>          TestJDBC40Exception test = new TestJDBC40Exception ();
> +
> +		_startupArgs = args;
>          test.testException ();
>      }
>  }
> 
> Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestPreparedStatementMethods.java
> URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestPreparedStatementMethods.java?rev=387640&r1=387639&r2=387640&view=diff
> ==============================================================================
> --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestPreparedStatementMethods.java
(original)
> +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestPreparedStatementMethods.java
Tue Mar 21 14:10:53 2006
> @@ -26,6 +26,7 @@
>  import java.io.Reader;
>  import java.io.InputStream;
>  import java.io.IOException;
> +import java.security.*;
>  import java.sql.Blob;
>  import java.sql.Connection;
>  import java.sql.Clob;
> @@ -192,7 +193,7 @@
>              java.io.OutputStream os = clob.setAsciiStream(1);
>              buildFilePath(filename);
>              File f = new File(filepath + sep + filename);
> -            InputStream is = new FileInputStream(f);
> +            InputStream is = getInputStream(f);
>              c = is.read(fromFile);
>              while(c>0) {
>                  os.write(fromFile,0,c);
> @@ -204,6 +205,8 @@
>              ps.executeUpdate();
>          } catch(IOException ioe) {
>              ioe.printStackTrace();
> +        } catch(PrivilegedActionException pae) {
> +            pae.printStackTrace();
>          } catch(SQLException sqle) {
>              sqle.printStackTrace();
>          }
> @@ -222,7 +225,7 @@
>              java.io.OutputStream os = blob.setBinaryStream(1);
>              buildFilePath(filename);
>              File f = new File(filepath + sep + filename);
> -            InputStream is = new FileInputStream(f);
> +            InputStream is = getInputStream(f);
>              c = is.read(fromFile);
>              while(c>0) {
>                  os.write(fromFile,0,c);
> @@ -234,12 +237,32 @@
>              ps.executeUpdate();
>          } catch(IOException ioe) {
>              ioe.printStackTrace();
> +        } catch(PrivilegedActionException pae) {
> +            pae.printStackTrace();
>          } catch(SQLException sqle) {
>              sqle.printStackTrace();
>          }
>          return blob;
>      }
> -    /*
> +
> +	/**
> +     * May need to convert this into a privileged block for reading a file. 
> +     */
> +    protected static FileInputStream getInputStream(final File f)
> +		throws PrivilegedActionException, FileNotFoundException
> +    {
> +        return (FileInputStream)AccessController.doPrivileged
> +			( new PrivilegedExceptionAction<FileInputStream>(  )
> +        {
> +			public FileInputStream run() throws FileNotFoundException
> +			{
> +				return new FileInputStream(f);
> +			}
> +			});
> +    }
> +
> +
> +	/*
>       * 1) Insert the clob in to the clob table by calling the 
>       *    buildAndInsertClobValue function
>       * 2) Check whether the clob value has been correctly inserted in to the 
> @@ -483,16 +506,11 @@
>      /*
>       * Start the tests for the JDBC4.0 methods on the client side
>       */
> -    void startClientTestMethods() {
> -        Connection conn_main = null;
> +    void startClientTestMethods( Connection conn_main ) {
>          PreparedStatement ps_main = null;
>          stmtIsClosed = false;
>          
>          try {
> -            Class.forName("org.apache.derby.jdbc.ClientDriver");
> -            conn_main = DriverManager.getConnection("jdbc:derby:" +
> -                    "//localhost:1527/mydb;" +
> -                    "create=true");
>              ps_main = conn_main.prepareStatement("select count(*) from " +
>                      "sys.systables");
>              conn = conn_main;
> @@ -517,8 +535,6 @@
>              t_setPoolable();
>          } catch(SQLException sqle) {
>              sqle.printStackTrace();
> -        } catch(ClassNotFoundException cnfe) {
> -            cnfe.printStackTrace();
>          } finally {
>              try {
>                  conn_main.close();
> @@ -530,21 +546,16 @@
>      /*
>       * Start the tests for testing the JDBC4.0 methods on the embedded side
>       */
> -    void startEmbeddedTestMethods() {
> -        Connection conn_main = null;
> +    void startEmbeddedTestMethods( Connection conn_main ) {
>          PreparedStatement ps_main = null;
>          stmtIsClosed = false;
>          
> -        try {
> -            Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
> -            conn_main = DriverManager.getConnection("jdbc:derby:mydb1;" +
> -                    "create=true");
> -            
> +        try {            
>              Statement s = conn_main.createStatement();
>              s.execute("create table clobtable3 (n int,clobcol CLOB)");
>              File file = new File("extin/short.txt");
>              int fileLength = (int) file.length();
> -            InputStream fin = new FileInputStream(file);
> +            InputStream fin = getInputStream(file);
>              ps = conn_main.prepareStatement("INSERT INTO " +
>                      "clobtable3 " +
>                      "VALUES (?, ?)");
> @@ -557,7 +568,7 @@
>              s1.execute("create table blobtable3 (n int,blobcol BLOB)");
>              File file1 = new File("extin/short.txt");
>              int fileLength1 = (int) file1.length();
> -            InputStream fin1 = new FileInputStream(file1);
> +            InputStream fin1 = getInputStream(file1);
>              PreparedStatement ps1 = conn_main.prepareStatement("INSERT INTO " +
>                      "blobtable3 " +
>                      "VALUES (?, ?)");
> @@ -591,12 +602,10 @@
>          }
>          catch(SQLException sqle) {
>              sqle.printStackTrace();
> -        } catch(ClassNotFoundException cnfe) {
> -            cnfe.printStackTrace();
> -        } catch(FileNotFoundException fnfe) {
> -            fnfe.printStackTrace();
> -        } catch(IOException ioe) {
> -            ioe.printStackTrace();
> +        } catch(PrivilegedActionException pae) {
> +            pae.printStackTrace();
> +        } catch(FileNotFoundException fne) {
> +            fne.printStackTrace();
>          } finally {
>              try {
>                  conn_main.close();
> @@ -606,9 +615,41 @@
>          }
>      }
>      
> +	/**
> +	 * <p>
> +	 * Return true if we're running under the embedded client.
> +	 * </p>
> +	 */
> +	private	static	boolean	usingEmbeddedClient()
> +	{
> +		return "embedded".equals( System.getProperty( "framework" ) );
> +	}
> +
>      public static void main(String args[]) {
> -        TestPreparedStatementMethods tpsm = new TestPreparedStatementMethods();
> -        tpsm.startClientTestMethods();
> -        tpsm.startEmbeddedTestMethods();
> +		try {
> +			// use the ij utility to read the property file and
> +			// make the initial connection.
> +			ij.getPropertyArg(args);
> +		
> +			Connection	conn_main = ij.startJBMS();
> +
> +			TestPreparedStatementMethods tpsm = new TestPreparedStatementMethods();
> +
> +			if ( usingEmbeddedClient() )
> +			{
> +				tpsm.startEmbeddedTestMethods( conn_main );
> +			}
> +			else // DerbyNetClient
> +			{
> +				tpsm.startClientTestMethods( conn_main );
> +			}
> +        			
> +		} catch(Exception e) { printStackTrace( e ); }
>      }
> +
> +	private	static	void	printStackTrace( Throwable e )
> +	{
> +		System.out.println(""+e);
> +		e.printStackTrace();
> +	}
>  }
> 
> Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestPreparedStatementMethods_app.properties
> URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestPreparedStatementMethods_app.properties?rev=387640&r1=387639&r2=387640&view=diff
> ==============================================================================
> --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestPreparedStatementMethods_app.properties
(original)
> +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestPreparedStatementMethods_app.properties
Tue Mar 21 14:10:53 2006
> @@ -1,11 +1,17 @@
> -#Test runs with mustang set other runwithjvms to false
> -#Include the support files from the clob and the blob values are built
> +ij.database=jdbc:derby:wombat;create=true
> +
> +# DataSource properties, only used if ij.dataSource is set
> +ij.dataSource.databaseName=wombat
> +ij.dataSource.createDatabase=create
> +
>  runwithibm13=false
>  runwithibm14=false
>  runwithj9=false
>  runwithjdk12=false
>  runwithjdk13=false
>  runwithjdk14=false
> +excludeJCC=at-or-after:1.0
> +
>  supportfiles=tests/jdbc4/short.txt,tests/jdbc4/littleclob.txt,tests/jdbc4/aclob.txt
>  useextdirs=true
>  
> 
> Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestPreparedStatement_app.properties
> URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestPreparedStatement_app.properties?rev=387640&r1=387639&r2=387640&view=diff
> ==============================================================================
> --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestPreparedStatement_app.properties
(original)
> +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestPreparedStatement_app.properties
Tue Mar 21 14:10:53 2006
> @@ -1,6 +1,16 @@
> +ij.database=jdbc:derby:wombat;create=true
> +
> +# DataSource properties, only used if ij.dataSource is set
> +ij.dataSource.databaseName=wombat
> +ij.dataSource.createDatabase=create
> +
>  runwithibm13=false
>  runwithibm14=false
>  runwithj9=false
>  runwithjdk12=false
>  runwithjdk13=false
>  runwithjdk14=false
> +excludeJCC=at-or-after:1.0
> +
> +# test fails trying to read blob content files
> +noSecurityManager=true
> 
> Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestQueryObject.java
> URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestQueryObject.java?rev=387640&r1=387639&r2=387640&view=diff
> ==============================================================================
> --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestQueryObject.java
(original)
> +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestQueryObject.java
Tue Mar 21 14:10:53 2006
> @@ -92,17 +92,42 @@
>          }
>       }         
>  
> +	/**
> +	 * <p>
> +	 * Return true if we're running under the embedded client.
> +	 * </p>
> +	 */
> +	private	static	boolean	usingEmbeddedClient()
> +	{
> +		return "embedded".equals( System.getProperty( "framework" ) );
> +	}
> +
>      public static void main (String [] args) {
>          //this part needs to be removed while migrating
> -        //this test to junit 
> -        EmbeddedDataSource40 ds = new EmbeddedDataSource40 ();
> -        ds.setDatabaseName ("embedquerydb");
> -        ds.setCreateDatabase ("create");
> +        //this test to junit
> +
> +		DataSource	ds;
> +
> +		if ( usingEmbeddedClient() )
> +		{
> +			EmbeddedDataSource40 eds = new EmbeddedDataSource40 ();
> +			eds = new EmbeddedDataSource40 ();
> +			eds.setDatabaseName ("embedquerydb");
> +			eds.setCreateDatabase ("create");
> +
> +			ds = eds;
> +		}
> +		else // DerbyNetClient
> +		{
> +			ClientDataSource40 clds = new ClientDataSource40 ();
> +			clds = new ClientDataSource40 ();
> +			clds.setDatabaseName ("netquerydb;create=true");
> +        	clds.setServerName ("localhost");
> +			clds.setPortNumber (1527);
> +
> +			ds = clds;
> +		}
> +		
>          doTest (ds);
> -        ClientDataSource40 clds = new ClientDataSource40 ();
> -        clds.setDatabaseName ("netquerydb;create=true");
> -        clds.setServerName ("localhost");
> -        clds.setPortNumber (1527);
> -        doTest (clds);
>      }
>  }
> 
> Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestQueryObject_app.properties
> URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestQueryObject_app.properties?rev=387640&r1=387639&r2=387640&view=diff
> ==============================================================================
> --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestQueryObject_app.properties
(original)
> +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestQueryObject_app.properties
Tue Mar 21 14:10:53 2006
> @@ -1,11 +1,19 @@
> -#this case tests QueryObject related methods which are present in jdk 1.6 
> -#default QueryObjectGenerator uses reflection to check the Data Object
> -#before calling the methods to set the values. This is a privileged operation
> -#and fails in the presence of security manager
> -noSecurityManager=true
> +ij.database=jdbc:derby:wombat;create=true
> +
> +# DataSource properties, only used if ij.dataSource is set
> +ij.dataSource.databaseName=wombat
> +ij.dataSource.createDatabase=create
> +
>  runwithibm13=false
>  runwithibm14=false
>  runwithj9=false
>  runwithjdk12=false
>  runwithjdk13=false
>  runwithjdk14=false
> +excludeJCC=at-or-after:1.0
> +
> +#this case tests QueryObject related methods which are present in jdk 1.6 
> +#default QueryObjectGenerator uses reflection to check the Data Object
> +#before calling the methods to set the values. This is a privileged operation
> +#and fails in the presence of security manager
> +noSecurityManager=true
> 
> Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestResultSetMethods.java
> URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestResultSetMethods.java?rev=387640&r1=387639&r2=387640&view=diff
> ==============================================================================
> --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestResultSetMethods.java
(original)
> +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestResultSetMethods.java
Tue Mar 21 14:10:53 2006
> @@ -36,6 +36,8 @@
>  import java.lang.reflect.Method;
>  import java.util.HashMap;
>  
> +import org.apache.derby.tools.ij;
> +
>  /**
>   * This class is used to test the implementations of the JDBC 4.0 methods
>   * in the ResultSet interface
> @@ -476,51 +478,26 @@
>      }
>      
>      public static void main(String args[]) {
> -        TestConnection tc=null;
> -        Connection conn_main=null;
> -        PreparedStatement ps_main=null;
> -        ResultSet rs_main=null;
> -        
> -        try {
> -            tc = new TestConnection();
> -            conn_main = tc.createEmbeddedConnection();
> -        } catch(Exception e) {
> -            e.printStackTrace();
> -        }
> -        
> -        try {
> -            ps_main = conn_main.prepareStatement("select count(*) from sys.systables");
> -            rs_main = ps_main.executeQuery();
> -        } catch(SQLException e) {
> -            System.out.println(""+e);
> -            e.printStackTrace();
> -        }
> -        
> -        TestResultSetMethods trsm = new TestResultSetMethods();
> -        trsm.startTestResultSetMethods(conn_main,ps_main,rs_main);
> -        
> -        /****************************************************************************************
> -         * This tests the client server part of derby
> -         *****************************************************************************************/
> -        
> -        conn_main=null;
> -        ps_main=null;
> -        
> -        try {
> -            conn_main = tc.createClientConnection();
> -        } catch(Exception e) {
> -            e.printStackTrace();
> -        }
> -        
> -        try {
> -            ps_main = conn_main.prepareStatement("select count(*) from sys.systables");
> -            rs_main = ps_main.executeQuery();
> -        } catch(SQLException e) {
> -            System.out.println(""+e);
> -            e.printStackTrace();
> -        }
> -        
> -        trsm.startTestResultSetMethods(conn_main,ps_main,rs_main);
> +		try {
> +			// use the ij utility to read the property file and
> +			// make the initial connection.
> +			ij.getPropertyArg(args);
> +		
> +			Connection	conn_main = ij.startJBMS();
> +
> +			PreparedStatement ps_main=null;
> +			ResultSet rs_main=null;
> +        
> +			ps_main = conn_main.prepareStatement("select count(*) from sys.systables");
> +			rs_main = ps_main.executeQuery();
> +        
> +			TestResultSetMethods trsm = new TestResultSetMethods();
> +			trsm.startTestResultSetMethods(conn_main,ps_main,rs_main);
> +        
> +		} catch(Exception e) {
> +			System.out.println(""+e);
> +			e.printStackTrace();
> +		}
>          
>      }
>  }
> 
> Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/copyfiles.ant
> URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/copyfiles.ant?rev=387640&r1=387639&r2=387640&view=diff
> ==============================================================================
> --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/copyfiles.ant
(original)
> +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/copyfiles.ant
Tue Mar 21 14:10:53 2006
> @@ -1,14 +1,8 @@
> -TestCallableStatementMethods_app.properties
> -TestPreparedStatementMethods_app.properties
> +default_app.properties
>  TestRowId_app.properties
>  TestConnectionMethods_app.properties
> -TestResultSetMethods_app.properties
> -TestDbMetaData_app.properties
> +TestQueryObject_app.properties
> +TestPreparedStatementMethods_app.properties
>  aclob.txt
>  littleclob.txt
>  short.txt
> -TestConnectionMethods_app.properties
> -TestResultSetMethods_app.properties
> -TestDbMetaData_app.properties
> -TestJDBC40Exception_app.properties
> -TestQueryObject_app.properties
> 
> Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/default_app.properties
> URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/default_app.properties?rev=387640&view=auto
> ==============================================================================
> --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/default_app.properties
(added)
> +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/default_app.properties
Tue Mar 21 14:10:53 2006
> @@ -0,0 +1,33 @@
> +#
> +# This is the default system properties file for SQL and JAVA tests.
> +#
> +# *** DO NOT PUT PROPERTIES FOR THE DERBY SYSTEM IN THIS FILE.  
> +# *** THEY BELONG IN default_derby.properties.
> +#
> +# This file will get handed to the test on the command line in a -p <filename>
> +# argument.
> +#
> +# This causes ij to load the driver and make an
> +# initial connection to the database.
> +#
> +# The .java test has to call util.getPropertyArg and util.startJBMS
> +# to process the property file.  See any of the .java tests for this code.
> +#
> +# If you want to alter these to use a different driver, connect to a different
> +# database, or to not be used, override this file by creating
> +# a file <testname>_app.properties to be used instead of this file.
> +#
> +#
> +ij.database=jdbc:derby:wombat;create=true
> +
> +# DataSource properties, only used if ij.dataSource is set
> +ij.dataSource.databaseName=wombat
> +ij.dataSource.createDatabase=create
> +
> +runwithibm13=false
> +runwithibm14=false
> +runwithj9=false
> +runwithjdk12=false
> +runwithjdk13=false
> +runwithjdk14=false
> +excludeJCC=at-or-after:1.0
> 
> Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/default_app.properties
> ------------------------------------------------------------------------------
>     svn:eol-style = native
> 
> 

Mime
View raw message