OPENJPA-1614 Testcase failures in TextException on MSSQL due to missing <object-exists> value in sql-error-state-codes.xml

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@931535 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Donald Woods 2010-04-07 13:31:43 +00:00
parent 50202d956b
commit b2b922e1c8
2 changed files with 13 additions and 4 deletions

View File

@ -49,7 +49,7 @@
<dictionary class="org.apache.openjpa.jdbc.sql.SQLServerDictionary">
<lock>1204,1205,1222</lock>
<referential-integrity>544,2601,2627,8114,8115</referential-integrity>
<object-exists></object-exists>
<object-exists>23000</object-exists>
<object-not-found></object-not-found>
<optimistic>1205</optimistic>
<query>HY008</query>

View File

@ -202,9 +202,15 @@ public class TestException extends SingleEMFTestCase {
*/
public void assertException(Throwable t, Class expectedType) {
if (!isExpectedException(t, expectedType)) {
t.printStackTrace();
getLog().error("TestException.assertException() - unexpected exception type", t);
//t.printStackTrace();
print(t, 0);
fail(t + " or its cause is not instanceof " + expectedType);
} else {
if (getLog().isTraceEnabled()) {
getLog().trace("TestException.assertException() - caught expected exception type=" +
expectedType, t);
}
}
}
@ -222,11 +228,14 @@ public class TestException extends SingleEMFTestCase {
void print(Throwable t, int tab) {
if (t == null) return;
for (int i=0; i<tab*4;i++) System.out.print(" ");
StringBuilder str = new StringBuilder(80);
for (int i=0; i<tab*4;i++)
str.append(" ");
String sqlState = (t instanceof SQLException) ?
"(SQLState=" + ((SQLException)t).getSQLState() + ":"
+ t.getMessage() + ")" : "";
System.out.println(t.getClass().getName() + sqlState);
str.append(t.getClass().getName() + sqlState);
getLog().error(str);
if (t.getCause() == t)
return;
print(t.getCause(), tab+1);