db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r548442 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests: master/DerbyNet/ master/DerbyNetClient/ tests/jdbcapi/
Date Mon, 18 Jun 2007 18:44:20 GMT
Author: kmarsden
Date: Mon Jun 18 11:44:19 2007
New Revision: 548442

URL: http://svn.apache.org/viewvc?view=rev&rev=548442
Log:
DERBY-2658 Convert jdbcapi/parameterMetaDataJdbc30.java to JUnit

Add javadoc and cleanup
Contributed by Ramin Moazeni


Removed:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/parameterMetaDataJdbc30.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/parameterMetaDataJdbc30.out
Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ParameterMetaDataJdbc30Test.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/build.xml

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ParameterMetaDataJdbc30Test.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ParameterMetaDataJdbc30Test.java?view=diff&rev=548442&r1=548441&r2=548442
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ParameterMetaDataJdbc30Test.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ParameterMetaDataJdbc30Test.java
Mon Jun 18 11:44:19 2007
@@ -47,15 +47,27 @@
 import junit.framework.TestSuite;
 
 /**
- *
+ * Test the ParameterMetaData class in JDBC 30.
+ * This test converts the old jdbcapi/parameterMetaDataJdbc30.java 
+ * test to JUnit. 
  */
+
 public class ParameterMetaDataJdbc30Test extends BaseJDBCTestCase {
 
-        public ParameterMetaDataJdbc30Test(String arg0) {
-                super(arg0);
+	/**
+         * Create a test with the given name.
+         *
+         * @param name name of the test.
+         */
+
+        public ParameterMetaDataJdbc30Test(String name) {
+                super(name);
         }
         
-      	// to run all tests in this class
+	/**
+         * Create suite containing client and embedded tests and to run
+	 * all tests in this class
+         */
 	public static Test suite() {
         	TestSuite suite = new TestSuite("ParameterMetaDataJdbc30Test");
 
@@ -78,6 +90,7 @@
 			/**
              		 * Creates the tables and the stored procedures used in the test
              		 * cases.
+			 *
              		 * @exception SQLException if a database error occurs
              		 */
             		protected void decorateSQL(Statement stmt) throws SQLException {
@@ -105,7 +118,10 @@
   	}
 
        /**
-     	* testing a callable statement.
+     	* Testing a callable statement by calling a SQL procedure with 
+	* IN parameters, OUT parameters and IN_OUT parameters.
+        *
+	* @exception SQLException if error occurs
      	*/
 	public void testCallableStatement () throws SQLException {
 
@@ -143,17 +159,18 @@
 			
 		testParameterMetaData(paramMetaData, parameterMetaDataArray0);
 
-      		// TODO: Some of the OUT params are getting reported as IN_OUT for embedded.
-      		// Network server reports it correctly.
       		cs.execute();
 
-		//bug 4450 - parameter meta data info for the return parameter was giving
-      		//null pointer exception. In the past, we didn't need to keep the return
-      		//parameter info for callable statement execution and hence we never
-      		//generated the meta data for it. To fix the problem, at the parsing time,
-      		//I set a flag if the call statement is of ? = form. If so, the first
-      		//parameter is a return parameter and save it's meta data rather than
-      		//discarding it.
+		/*
+		/* bug 4450 - parameter meta data info for the return parameter was giving
+      		/* null pointer exception. In the past, we didn't need to keep the return
+      		/* parameter info for callable statement execution and hence we never
+      		/* generated the meta data for it. To fix the problem, at the parsing time,
+      		/* I set a flag if the call statement is of ? = form. If so, the first
+      		/* parameter is a return parameter and save it's meta data rather than
+      		/* discarding it.
+	 	 */	
+	
       		cs = prepareCall("? = call RDB(?)");
       		paramMetaData = cs.getParameterMetaData();
 		assertEquals("Unexpected parameter count", 2, paramMetaData.getParameterCount());
@@ -170,8 +187,10 @@
 		cs.close();
 	}
 	/**
-        * testing a prepared statement.
-        */
+         * Testing a prepared statement.
+     	 *
+	 * @exception SQLException if database access errors or other errors occur
+         */
 	public void testPreparedStatement () throws SQLException {
 		//next testing a prepared statement
       		PreparedStatement ps = prepareStatement("insert into t values(?, ?, ?, ?, ?)");
@@ -194,17 +213,21 @@
                 {"PARAMETER_NULLABLE", "false", "10", "0", "91", "DATE", "java.sql.Date",
"PARAMETER_MODE_IN"}};
 
                 testParameterMetaData(paramMetaData, parameterMetaDataArray0);
-
-      		// JCC seems to report these parameters as MODE_UNKNOWN, where as Derby uses MODE_IN
-      		// JCC behaviour with network server matches its behaviour with DB2
-      		// getPrecision() returns 0 for CHAR/DATE/BIT types for Derby. JCC shows maxlen
+	
+		/*
+      		 *  JCC seems to report these parameters as MODE_UNKNOWN, where as Derby uses MODE_IN
+      		 *  JCC behaviour with network server matches its behaviour with DB2
+      		 *  getPrecision() returns 0 for CHAR/DATE/BIT types for Derby. JCC shows maxlen
+		 */
       		ps.execute();
 
-		//bug 4533 - associated parameters should not be included in the parameter meta data list
-      		//Following statement systab will generate 4 associated parameters for the 2
-      		//user parameters. This results in total 6 parameters for the prepared statement
-      		//internally. But we should only show 2 user visible parameters through
-      		//getParameterMetaData().
+		/*
+		 * bug 4533 - associated parameters should not be included in the parameter meta data list
+      		 * Following statement systab will generate 4 associated parameters for the 2
+      		 * user parameters. This results in total 6 parameters for the prepared statement
+      		 * internally. But we should only show 2 user visible parameters through
+      		 * getParameterMetaData().
+		 */
       		ps = prepareStatement("select * from sys.systables where " +
              			      " tablename like ? and tableID like ?");
       		ps.setString (1, "SYS%");
@@ -225,12 +248,15 @@
 		ps.close();
 	}
 
-	/** DERBY-44 added support for SELECT ... WHERE column LIKE ? ESCAPE ?
-         *  This test case tests
+	/** 
+	 * DERBY-44 added support for SELECT ... WHERE column LIKE ? ESCAPE ?
+         * This test case tests
          *   a) that such a statement compiles, and
          *   b) that we get the correct error message if the escape
          *      sequence is an empty string (at one point this would
          *      lead to a StringIndexOutOfBoundsException)`
+	 *
+	 * @exception SQLException if error occurs
 	 */
 	public void testLikeEscaleStatement () throws SQLException {
 
@@ -261,14 +287,21 @@
 		ps.close();
 	}
 
-	 /** the test no longer tests 4552, but kept as an interesting test scenario
-          * bug 4552 - no parameters would be returned for execute statement using
-          * System.out.println("Bug 4552 - no parameters would be returned for execute statement
using");
-          * orig: ps = con.prepareStatement("execute statement systab using values('SYS%','8000001%')");
+	 /** 
+          * test execute statements that no parameters would be returned if 
+          * prepareStatement("execute statement systab using values('SYS%','8000001%')");
+	  *
+	  * @exception SQLException if error occurs
           */
 
 	public void testExecuteStatementUsing () throws SQLException {
-
+	
+		/*
+		 * the test no longer tests 4552, but kept as an interesting test scenario
+                 * bug 4552 - no parameters would be returned for execute statement using
+                 * System.out.println("Bug 4552 - no parameters would be returned for execute
statement using");
+                 * orig: ps = con.prepareStatement("execute statement systab using values('SYS%','8000001%')");
+		 */
       		PreparedStatement ps = prepareStatement("select * from sys.systables " + 
 							"where tablename like 'SYS%' and " + 
 							"tableID like '8000001%'");
@@ -281,21 +314,25 @@
 
                 testParameterMetaData(paramMetaData, parameterMetaDataArray0);
 
-
       		ps.execute();
 
 		ps.close();
 	}
-	/** Bug 4654 - Null Pointer exception while executuing a select with a
-         *  where clause parameter of type 'TRUE' or 'FALSE' constants. The existing prior
to
-         *  exposing parameter metadata didn't need to fill in metadata information for where
-         *  clause parameter in the example above.
-         *  This no longer makes sense, for we cannot take BOOLEANs anymore.
-         *  replace with a simple where 1 = ?. Which would take either 1 for true, or 0 for
false
+	/** 
+         * testing SELECT statements for BOOLEANs (1 for true, 0 for false) 
+	 *
+	 * @exception SQLException if error occurs
 	 */ 
 	public void testSelectStatementUsingBoolean () throws SQLException {
 
-      		//Bug 4654 - fill in where clause parameter type info
+		/*
+		 * Bug 4654 - Null Pointer exception while executuing a select with a
+         	 * where clause parameter of type 'TRUE' or 'FALSE' constants. The existing prior
to
+         	 * exposing parameter metadata didn't need to fill in metadata information for
where
+         	 * clause parameter in the example above.
+         	 * This no longer makes sense, for we cannot take BOOLEANs anymore.
+         	 * replace with a simple where 1 = ?. Which would take either 1 for true, or 0
for false
+		 */
       		PreparedStatement ps = prepareStatement("select * from t "+  
 							"where 1=? for update");
 
@@ -316,7 +353,9 @@
 		ps.close();
 	}
 	/** 
-         *  test: no parameter for the statement and then do getParameterMetaData() 
+         * test: no parameter for the statement and then do getParameterMetaData() 
+	 *
+	 * @exception SQLException if error occurs
          */
 	public void testSelectStatementUsingNoParameter () throws SQLException {
 
@@ -334,11 +373,13 @@
 		ps.close();
 	}
 	/**
-         *  test: the scale returned should be the one set by registerOutParameter 
+         * test: the scale returned should be the one set by registerOutParameter 
+	 *
+ 	 * @exception SQLException
          */
 	public void testCallableStatementReturnedScale () throws SQLException {
 
-		/**
+		/*
                  *  DERBY-2810 - getParameterType behavior is different in Embedded and 
                  *  Network Client when set by registerOutParameter 
                  *  temporarily disabling Network Client.
@@ -364,7 +405,9 @@
 		}
 	}
 	/**
-         *  test behaviour of meta data and out params after re-compile 
+         * test behaviour of meta data and out params after re-compile 
+	 *
+	 * @exception SQLException if error occurs
          */
 	public void testMetatdataAfterProcRecompile () throws SQLException {
 
@@ -389,7 +432,7 @@
           	cs.execute();
 		assertEquals("Unexpected DUMMYINT alias returned", 11111, cs.getInt(4));
 
-		/** 
+		/* 
 		 *  DERBY-2786 - Behaviour of inout parameters in Embedded and Network client is
          	 *  different if parameters are set but the CallableStatment is not executed.
 		 *  temporarily disabling Network Client. 
@@ -419,7 +462,9 @@
       		cs.close();
 	}
 	/**
-         *  test ParameterMetaData for Java procedures with INTEGER parameters 
+         * test ParameterMetaData for Java procedures with INTEGER parameters 
+	 * 
+	 * @exception SQLException if error occurs
          */
 	public void testParameterMetadataWithINTParameters () throws SQLException {
 
@@ -456,7 +501,9 @@
             stmt.close();
 	}
 	/**
-         *  test ParameterMetaData for Java procedures with CHAR parameters
+         * test ParameterMetaData for Java procedures with CHAR parameters
+	 *
+	 * @exception SQLException if error occurs
          */
 	 public void testParameterMetadataWithCHARParameters () throws SQLException {
 
@@ -492,6 +539,8 @@
 	}
 	/**
          *  test ParameterMetaData for Java procedures with DECIMAL parameters
+	 *
+	 * @exception SQLException if error occurs
          */
 	public void testParameterMetadataWithDECIMALParameters () throws SQLException {
 
@@ -525,7 +574,9 @@
        		cs.close();
 	}
 	/**
-         *  test ParameterMetaData for Java procedures with some literal parameters
+         * test ParameterMetaData for Java procedures with some literal parameters
+	 *
+	 * @exception SQLException if error occurs
          */
 	public void testParameterMetadataWithLITERALParameters () throws SQLException {
 
@@ -598,14 +649,16 @@
 
                 testParameterMetaData(cs.getParameterMetaData(), parameterMetaDataArray2);
 
-
           	cs.close();
           	stmt.execute("DROP PROCEDURE PMDD");
             stmt.close();
 	}
 	/**
-         *  print the parameter isNullable value in human readable form
+         * print the parameter isNullable value in human readable form
+	 *
+	 * @param nullabilityValue 
          */
+	// @return the nullability status of the given parameter
 	static String parameterIsNullableInStringForm(int nullabilityValue){
 		if (nullabilityValue ==  ParameterMetaData.parameterNoNulls)
 				  return("PARAMETER_NO_NULLS");
@@ -617,7 +670,13 @@
 				  return("ERROR: donot recognize this parameter isNullable() value");
   	}
 
-	//print the parameter mode in human readable form
+	/**
+         * print the parameter mode in human readable form
+         *
+         * @param mode identifies parameter's mode (IN, OUT, or IN_OUT)
+	 * @return     the parameter mode in readable form
+         *             
+         */
 	static String parameterModeInStringForm(int mode){
 		if (mode ==  ParameterMetaData.parameterModeIn)
 				  return("PARAMETER_MODE_IN");
@@ -630,6 +689,14 @@
 		else
 				  return("ERROR: donot recognize this parameter mode");
   	}
+	/**
+         * tests parameterMetaData and reports error if the ParameterMetaData results
+	 * does not match the expected results.
+         *
+         * @param paramMetaData ParameterMetadata object
+	 * @param paramMetaDataArray 2 dimensional array containing expected test results. 
+	 * @exception SQLException if any error occurs
+         */
 	static void testParameterMetaData(ParameterMetaData paramMetaData, String [][] paramMetaDataArray)
throws SQLException {
 		int numParam = paramMetaData.getParameterCount();
 		
@@ -646,6 +713,12 @@
 			j=0;
 		}
 	}
+ 	/**
+         * ParameterMetaData Negative Test 
+         *
+         * @param paramMetaData ParameterMetadata object
+         * @exception SQLException if any error occurs
+         */	
 	static void dumpParameterMetaDataNegative(ParameterMetaData paramMetaData) throws SQLException
{
 
                 int numParam = paramMetaData.getParameterCount();
@@ -672,23 +745,69 @@
                 }
 
 	}
-	//A really simple method to test callable statement
+	/**
+         * A simple method to test callable statement. This is the Java method 
+	 * for procedure dummyint.
+         *
+         * @param in_param 
+	 * @param in_param2  
+	 * @param in_param3 
+	 * @param in_param4
+         * @exception SQLException
+         */
         public static void dummyint (int in_param, int in_param2, int[] in_param3, int[]
in_param4)
                                                                    throws SQLException {
 
                 in_param4[0] = 11111;
         }
+
+	/**
+         *  This is the Java method for procedure dummyint.
+         *
+         * @param in_param  
+         * @param in_param2 
+         * @param in_param3 
+         * @param in_param4 
+         * @exception SQLException
+         */
         public static void dummyint2 (int in_param, int in_param2, int[] in_param3, int[]
in_param4)
                                                                    throws SQLException {
                 in_param4[0] = 22222;
         }
 
+	/**
+	 * A really simple method to test callable statement. This is the Java method
+         * for procedure dummy_numeric_Proc.
+         *
+         * @param max_param  
+         * @param min_param  
+         * @exception SQLException
+         */
         public static void dummy_numeric_Proc (BigDecimal[] max_param,BigDecimal[] min_param)
                                                                  throws SQLException {
         }
-
+	
+	/**
+         * Java method for procedure PMDC which tests ParameterMetaData for Java procedures

+         * with CHAR parameters.  
+	 * 
+         * @param in_param 
+         * @param in_param2
+         * @param in_param3 
+         * @param in_param4 
+         */
         public static void dummyString (String in_param, String in_param2, String[] in_param3,
String[] in_param4) {
         }
+	
+	/**
+         * Java method for procedure PMDD which tests ParameterMetaData for Java procedures
+	 * with DECIMAL parameters. 
+         *
+         * @param in_param  
+         * @param in_param2 
+         * @param in_param3 
+         * @param in_param4 
+         */
         public static void dummyDecimal(BigDecimal in_param, BigDecimal in_param2, BigDecimal[]
in_param3, BigDecimal[] in_param4) {
         }
 }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/build.xml?view=diff&rev=548442&r1=548441&r2=548442
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/build.xml
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/build.xml
Mon Jun 18 11:44:19 2007
@@ -113,11 +113,11 @@
       <exclude name="${this.dir}/checkDataSource.java"/>
       <exclude name="${this.dir}/checkDataSource30.java"/>
       <exclude name="${this.dir}/dataSourcePermissions.java"/>
-      <exclude name="${this.dir}/parameterMetaDataJdbc30.java"/>
       <exclude name="${this.dir}/ResultSetJDBC30Test.java"/>
       <exclude name="${this.dir}/statementJdbc30.java"/>
       <exclude name="${this.dir}/savepointJdbc30_JSR169.java"/>
       <exclude name="${this.dir}/savepointJdbc30_XA.java"/>
+      <include name="${this.dir}/ParameterMetaDataJdbc30Test.java"/>
       <exclude name="${this.dir}/xaJNDI.java"/>
       <exclude name="${this.dir}/LobStreamsTest.java"/>
       <exclude name="${this.dir}/XATest.java"/>
@@ -153,7 +153,7 @@
       <include name="${this.dir}/checkDataSource30.java"/>
       <include name="${this.dir}/savepointJdbc30_JSR169.java"/>
       <include name="${this.dir}/savepointJdbc30_XA.java"/>
-      <include name="${this.dir}/parameterMetaDataJdbc30.java"/>
+      <include name="${this.dir}/ParameterMetaDataJdbc30Test.java"/>
       <include name="${this.dir}/ResultSetJDBC30Test.java"/>
       <include name="${this.dir}/statementJdbc30.java"/>
       <include name="${this.dir}/LobStreamsTest.java"/>



Mime
View raw message