Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 83059 invoked from network); 11 Mar 2008 15:08:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Mar 2008 15:08:21 -0000 Received: (qmail 50167 invoked by uid 500); 11 Mar 2008 15:08:18 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 50097 invoked by uid 500); 11 Mar 2008 15:08:18 -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 50071 invoked by uid 99); 11 Mar 2008 15:08:18 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Mar 2008 08:08:18 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED 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, 11 Mar 2008 15:07:50 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A68471A9832; Tue, 11 Mar 2008 08:08:00 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r635964 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting: functionTests/master/views.out functionTests/tests/lang/LangScripts.java functionTests/tests/lang/views.sql junit/BaseJDBCTestCase.java Date: Tue, 11 Mar 2008 15:08:00 -0000 To: derby-commits@db.apache.org From: kmarsden@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080311150800.A68471A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kmarsden Date: Tue Mar 11 08:07:56 2008 New Revision: 635964 URL: http://svn.apache.org/viewvc?rev=635964&view=rev Log: DERBY-3520 Convert views.sql to JUnit Removed: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/views.out db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/views.sql Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java?rev=635964&r1=635963&r2=635964&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java Tue Mar 11 08:07:56 2008 @@ -96,7 +96,6 @@ "union", "update", "valuesclause", - "views", }; /** Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java?rev=635964&r1=635963&r2=635964&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java Tue Mar 11 08:07:56 2008 @@ -940,28 +940,60 @@ /** * Assert that the query fails (either in compilation, * execution, or retrieval of results--doesn't matter) - * and throws a SQLException with the expected state. + * and throws a SQLException with the expected states. * * Assumption is that 'query' does *not* have parameters * that need binding and thus can be executed using a * simple Statement.execute() call. + * + * If there are extra chained SQLExceptions that are + * not in sqlStates, this method will not fail. * - * @param sqlState expected sql state. + * @param sqlStates[] expected sql state. * @param st Statement object on which to execute. * @param query the query to compile and execute. */ - public static void assertStatementError(String sqlState, + public static void assertStatementError(String[] sqlStates, Statement st, String query) { try { boolean haveRS = st.execute(query); fetchAndDiscardAllResults(st, haveRS); - fail("Expected error '" + sqlState + - "' but no error was thrown."); + String errorMsg = "Expected error(s) '" ; + for (int i = 0; i < sqlStates.length;i++) + errorMsg += " " + sqlStates[i]; + errorMsg += "' but no error was thrown."; + fail(errorMsg); } catch (SQLException se) { - assertSQLState(sqlState, se); + int count = 0; + do { + assertSQLState(sqlStates[count], se); + count++; + se = se.getNextException(); + } while (se != null && count < sqlStates.length); + // We must have at least as many exceptions as + // we expected. + assertEquals("Got " + + count + " exceptions. Expected at least"+ + sqlStates.length,count,sqlStates.length); + } } + + /** + * Assert that the query fails with a single error + * + * @param sqlState Expected SQLState of exception + * @param st + * @param query + * @see #assertStatementError(String[], Statement, String) + */ + public static void assertStatementError(String sqlState, Statement st, String query) { + assertStatementError(new String[] {sqlState},st,query); + } + + + /** * Assert that the query fails (either in compilation, * execution, or retrieval of results--doesn't matter)