db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r412220 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/UnsupportedVetter.java
Date Tue, 06 Jun 2006 21:42:45 GMT
Author: rhillegas
Date: Tue Jun  6 14:42:45 2006
New Revision: 412220

URL: http://svn.apache.org/viewvc?rev=412220&view=rev
Log:
DERBY-1253: Make UnsupportedVetter test smart enough to handle methods which change shape.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/UnsupportedVetter.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/UnsupportedVetter.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/UnsupportedVetter.java?rev=412220&r1=412219&r2=412220&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/UnsupportedVetter.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/UnsupportedVetter.java
Tue Jun  6 14:42:45 2006
@@ -258,8 +258,8 @@
 						new MD( "refreshRow", new Class[] { } ),
 						new MD( "updateArray", new Class[] { int.class, java.sql.Array.class } ),
 						new MD( "updateArray", new Class[] { String.class, java.sql.Array.class } ),
-						new MD( "updateNCharacterStream", new Class[] { int.class, java.io.Reader.class, int.class
} ),
-						new MD( "updateNCharacterStream", new Class[] { String.class, java.io.Reader.class,
int.class } ),
+						new MD( "updateNCharacterStream", new Class[] { int.class, java.io.Reader.class, long.class
} ),
+						new MD( "updateNCharacterStream", new Class[] { String.class, java.io.Reader.class,
long.class } ),
 						new MD( "updateNClob", new Class[] { int.class, NClob.class } ),
 						new MD( "updateNClob", new Class[] { String.class, NClob.class } ),
 						new MD( "updateNString", new Class[] { int.class, String.class } ),
@@ -344,12 +344,13 @@
 	{
 		CONFIG.setVerbosity( true );
 
-		// Build map of interfaces to their methods which may raise SQLFeatureNotSupportedException.
-		initializeExcludableMap();
-
+		HashSet<String>	vanishedMethodList = new HashSet<String>();
 		HashSet<String>	unsupportedList = new HashSet<String>();
 		HashSet<String>	notUnderstoodList = new HashSet<String>();
 
+		// Build map of interfaces to their methods which may raise SQLFeatureNotSupportedException.
+		initializeExcludableMap( vanishedMethodList );
+
 		vetDataSource( unsupportedList, notUnderstoodList );
 		vetConnectionPooledDataSource( unsupportedList, notUnderstoodList );
 		vetXADataSource( unsupportedList, notUnderstoodList );
@@ -357,15 +358,18 @@
 		//
 		// Print methods which behave unexpectedly.
 		//
+		printVanishedMethodList( vanishedMethodList );
 		printUnsupportedList( unsupportedList );
 		printNotUnderstoodList( notUnderstoodList );
 
+		int		actualErrorCount =
+			vanishedMethodList.size() +
+			unsupportedList.size() +
+			notUnderstoodList.size();
+
 		assertEquals
-			( "These methods should not raise SQLFeatureNotSupportedException.",
-			  0, unsupportedList.size() );
-		assertEquals
-			( "These methods raise exceptions we don't understand.",
-			  0, notUnderstoodList.size() );
+			( "Unexpected discrepancies.",
+			  0, actualErrorCount );
 	}
 
 	//
@@ -520,7 +524,7 @@
 	// Initialize the hashtable of methods which are allowed to raise
 	// SQLFeatureNotSupportedException.
 	//
-	private	void	initializeExcludableMap()
+	private	void	initializeExcludableMap( HashSet<String> vanishedMethodList )
 		throws Exception
 	{
 		excludableMap = new Hashtable< Class, HashSet<Method> >();
@@ -546,9 +550,17 @@
 				//
 				if ( STRICT_ENFORCEMENT && !md.isOptional()  ) { continue; }
 
-				Method	method = iface.getMethod( md.getMethodName(), md.getArgTypes() );
+				Method	method = null;
 
-				if ( method == null ) { fail( "Unknown method: " + md.getMethodName() ); }
+				try {
+					method = iface.getMethod( md.getMethodName(), md.getArgTypes() );
+				} catch (NoSuchMethodException e) {}
+
+				if ( method == null )
+				{
+					vanishedMethodList.add
+						( "Method has vanished from SQL interface: " + iface.getName() + "." + md );
+				}
 
 				excludedMethodSet.add( method );
 			}
@@ -662,7 +674,11 @@
 		}
 		catch (Throwable e)
 		{
-			if ( e instanceof InvocationTargetException )
+			if ( !( e instanceof InvocationTargetException ) )
+			{
+				recordUnexpectedError( candidate, iface, method, notUnderstoodList, e );
+			}
+			else
 			{
 				Throwable	cause = e.getCause();
 				
@@ -706,8 +722,7 @@
 				}
 				else
 				{
-					notUnderstoodList.add
-						( candidate.getClass().getName() + " " + method + " raises " + cause );
+					recordUnexpectedError( candidate, iface, method, notUnderstoodList, cause );
 				}
 				
 			}
@@ -715,6 +730,18 @@
 	}
 
 	//
+	// Record an unexpected error.
+	//
+	private	void	recordUnexpectedError
+		( Object candidate, Class iface, Method method,
+		  HashSet<String> notUnderstoodList, Throwable cause )
+		throws Exception
+	{
+		notUnderstoodList.add
+			( candidate.getClass().getName() + " " + method + " raises " + cause );
+	}
+	
+	//
 	// Returns true if this method is allowed to raise SQLFeatureNotSupportedException.
 	//
 	private	boolean	isExcludable(Method method )
@@ -810,6 +837,27 @@
 		}
 	}
 
+	// debug print the list of methods which have disappeared from the SQL interface
+	private	void	printVanishedMethodList( HashSet<String> vanishedMethodList )
+	{
+		int			count = vanishedMethodList.size();
+
+		if ( count == 0 ) { return; }
+
+		println( "--------------- VANISHED METHODS ------------------" );
+		println( "--" );
+
+		String[]	result = new String[ count ];
+
+		vanishedMethodList.toArray( result );
+		Arrays.sort( result );
+
+		for ( int i = 0; i < count; i++ )
+		{
+			println( result[ i ] );
+		}
+	}
+
 	// Debug print the list of method failures which we don't understand
 	private	void	printNotUnderstoodList( HashSet<String> notUnderstoodList )
 	{
@@ -865,6 +913,31 @@
 
 		/** Return whether this method is optional */
 		public	boolean	isOptional() { return true; }
+
+		public	String	toString()
+		{
+			StringBuffer	buffer = new StringBuffer();
+
+			buffer.append( _methodName );
+			buffer.append( "( " );
+
+			if ( _argTypes != null )
+			{
+				int		count = _argTypes.length;
+
+				for ( int i = 0; i < count; i++ )
+				{
+					if ( i > 0 ) { buffer.append( ", " ); }
+
+					buffer.append( _argTypes[ i ].getName() );
+				}
+			}
+
+			buffer.append( " )" );
+
+			return buffer.toString();
+		}
+
 	}
 
 	/**



Mime
View raw message