From: Juergen H. <jho...@us...> - 2008-10-16 19:09:38
|
Update of /cvsroot/springframework/spring/test/org/springframework/orm/hibernate3 In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv23066/test/org/springframework/orm/hibernate3 Modified Files: HibernateTemplateTests.java Log Message: translates Hibernate's DataException into a Spring DataIntegrityViolationException (for consistency with SQLExceptionSubclassTranslator's handling of the JDBC 4 SQLDataException) Index: HibernateTemplateTests.java =================================================================== RCS file: /cvsroot/springframework/spring/test/org/springframework/orm/hibernate3/HibernateTemplateTests.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** HibernateTemplateTests.java 16 Jul 2008 12:06:32 -0000 1.21 --- HibernateTemplateTests.java 16 Oct 2008 19:09:35 -0000 1.22 *************** *** 2301,2339 **** } ! final DataException dex = new DataException("mymsg", sqlEx); try { createTemplate().execute(new HibernateCallback() { public Object doInHibernate(org.hibernate.Session session) throws HibernateException { ! throw dex; } }); ! fail("Should have thrown InvalidDataAccessResourceUsageException"); } ! catch (InvalidDataAccessResourceUsageException ex) { // expected ! assertEquals(dex, ex.getCause()); assertTrue(ex.getMessage().indexOf("mymsg") != -1); } ! final LockAcquisitionException laex = new LockAcquisitionException("mymsg", sqlEx); try { createTemplate().execute(new HibernateCallback() { public Object doInHibernate(org.hibernate.Session session) throws HibernateException { ! throw laex; } }); ! fail("Should have thrown CannotAcquireLockException"); } ! catch (CannotAcquireLockException ex) { // expected ! assertEquals(laex, ex.getCause()); assertTrue(ex.getMessage().indexOf("mymsg") != -1); } ! final ConstraintViolationException cvex = new ConstraintViolationException("mymsg", sqlEx, "myconstraint"); try { createTemplate().execute(new HibernateCallback() { public Object doInHibernate(org.hibernate.Session session) throws HibernateException { ! throw cvex; } }); --- 2301,2339 ---- } ! final LockAcquisitionException laex = new LockAcquisitionException("mymsg", sqlEx); try { createTemplate().execute(new HibernateCallback() { public Object doInHibernate(org.hibernate.Session session) throws HibernateException { ! throw laex; } }); ! fail("Should have thrown CannotAcquireLockException"); } ! catch (CannotAcquireLockException ex) { // expected ! assertEquals(laex, ex.getCause()); assertTrue(ex.getMessage().indexOf("mymsg") != -1); } ! final ConstraintViolationException cvex = new ConstraintViolationException("mymsg", sqlEx, "myconstraint"); try { createTemplate().execute(new HibernateCallback() { public Object doInHibernate(org.hibernate.Session session) throws HibernateException { ! throw cvex; } }); ! fail("Should have thrown DataIntegrityViolationException"); } ! catch (DataIntegrityViolationException ex) { // expected ! assertEquals(cvex, ex.getCause()); assertTrue(ex.getMessage().indexOf("mymsg") != -1); } ! final DataException dex = new DataException("mymsg", sqlEx); try { createTemplate().execute(new HibernateCallback() { public Object doInHibernate(org.hibernate.Session session) throws HibernateException { ! throw dex; } }); *************** *** 2342,2346 **** catch (DataIntegrityViolationException ex) { // expected ! assertEquals(cvex, ex.getCause()); assertTrue(ex.getMessage().indexOf("mymsg") != -1); } --- 2342,2346 ---- catch (DataIntegrityViolationException ex) { // expected ! assertEquals(dex, ex.getCause()); assertTrue(ex.getMessage().indexOf("mymsg") != -1); } |