You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by km...@apache.org on 2008/03/12 17:38:29 UTC
svn commit: r636410 - in
/db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting:
functionTests/master/ functionTests/tests/lang/ junit/
Author: kmarsden
Date: Wed Mar 12 09:38:20 2008
New Revision: 636410
URL: http://svn.apache.org/viewvc?rev=636410&view=rev
Log:
DERBY-3520 convert views.sql to JUnit
merge to 10.3
Added:
db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ViewsTest.java
- copied, changed from r636390, db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ViewsTest.java
Removed:
db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/master/views.out
db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/views.sql
Modified:
db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java
db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java
Modified: db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java?rev=636410&r1=636409&r2=636410&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java (original)
+++ db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java Wed Mar 12 09:38:20 2008
@@ -97,7 +97,6 @@
"union",
"update",
"valuesclause",
- "views",
};
/**
Copied: db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ViewsTest.java (from r636390, db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ViewsTest.java)
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ViewsTest.java?p2=db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ViewsTest.java&p1=db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ViewsTest.java&r1=636390&r2=636410&rev=636410&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ViewsTest.java (original)
+++ db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ViewsTest.java Wed Mar 12 09:38:20 2008
@@ -532,8 +532,7 @@
{"SYSSTATISTICS", "1"},
{"SYSTABLEPERMS", "1"},
{"SYSCOLPERMS", "1"},
- {"SYSROUTINEPERMS", "1"},
- {"SYSROLES", "1"}
+ {"SYSROUTINEPERMS", "1"}
};
JDBC.assertFullResultSet(rs, expRS, true);
@@ -641,8 +640,7 @@
{"SYSSTATISTICS", "1"},
{"SYSTABLEPERMS", "1"},
{"SYSCOLPERMS", "1"},
- {"SYSROUTINEPERMS", "1"},
- {"SYSROLES", "1"}
+ {"SYSROUTINEPERMS", "1"}
};
JDBC.assertFullResultSet(rs, expRS, true);
Modified: db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java?rev=636410&r1=636409&r2=636410&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java (original)
+++ db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java Wed Mar 12 09:38:20 2008
@@ -775,28 +775,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 states.
* @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)