Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 69719 invoked from network); 6 Jun 2006 21:43:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 6 Jun 2006 21:43:08 -0000 Received: (qmail 73725 invoked by uid 500); 6 Jun 2006 21:43:07 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 73696 invoked by uid 500); 6 Jun 2006 21:43:07 -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 73685 invoked by uid 99); 6 Jun 2006 21:43:07 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Jun 2006 14:43:07 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Jun 2006 14:43:06 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 9FCC51A983A; Tue, 6 Jun 2006 14:42:46 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: derby-commits@db.apache.org From: rhillegas@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060606214246.9FCC51A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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 vanishedMethodList = new HashSet(); HashSet unsupportedList = new HashSet(); HashSet notUnderstoodList = new HashSet(); + // 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 vanishedMethodList ) throws Exception { excludableMap = new Hashtable< Class, HashSet >(); @@ -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 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 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 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(); + } + } /**