Update of /cvsroot/springframework/spring/test/org/springframework/jdbc/support
In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14903/test/org/springframework/jdbc/support
Modified Files:
SQLErrorCodeSQLExceptionTranslatorTests.java
Log Message:
added a DuplicatKeyException catagory for SQLException translation (SPR-5125 backport)
Index: SQLErrorCodeSQLExceptionTranslatorTests.java
===================================================================
RCS file: /cvsroot/springframework/spring/test/org/springframework/jdbc/support/SQLErrorCodeSQLExceptionTranslatorTests.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** SQLErrorCodeSQLExceptionTranslatorTests.java 29 Aug 2007 21:00:48 -0000 1.9
--- SQLErrorCodeSQLExceptionTranslatorTests.java 17 Mar 2009 15:12:22 -0000 1.10
***************
*** 28,31 ****
--- 28,32 ----
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.dao.DeadlockLoserDataAccessException;
+ import org.springframework.dao.DuplicateKeyException;
import org.springframework.jdbc.BadSqlGrammarException;
import org.springframework.jdbc.InvalidResultSetAccessException;
***************
*** 40,43 ****
--- 41,45 ----
ERROR_CODES.setBadSqlGrammarCodes(new String[] { "1", "2" });
ERROR_CODES.setInvalidResultSetAccessCodes(new String[] { "3", "4" });
+ ERROR_CODES.setDuplicateKeyCodes(new String[] {"10"});
ERROR_CODES.setDataAccessResourceFailureCodes(new String[] { "5" });
ERROR_CODES.setDataIntegrityViolationCodes(new String[] { "6" });
***************
*** 65,68 ****
--- 67,76 ----
checkTranslation(sext, 8, DeadlockLoserDataAccessException.class);
checkTranslation(sext, 9, CannotSerializeTransactionException.class);
+ checkTranslation(sext, 10, DuplicateKeyException.class);
+
+ SQLException dupKeyEx = new SQLException("", "", 10);
+ DataAccessException dksex = sext.translate("task", "SQL", dupKeyEx);
+ assertTrue("Not instance of DataIntegrityViolationException",
+ DataIntegrityViolationException.class.isAssignableFrom(dksex.getClass()));
// Test fallback. We assume that no database will ever return this error code,
|