From 5318cef733be711356c45df276e1c667da5237b3 Mon Sep 17 00:00:00 2001 From: Chris Cranford Date: Mon, 6 Jun 2016 09:21:10 -0500 Subject: [PATCH] HHH-10803 - Fix test to assert based on exception typing. --- .../hibernate/jpa/test/query/QueryTest.java | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/hibernate-core/src/test/java/org/hibernate/jpa/test/query/QueryTest.java b/hibernate-core/src/test/java/org/hibernate/jpa/test/query/QueryTest.java index caae621458..78406fc378 100644 --- a/hibernate-core/src/test/java/org/hibernate/jpa/test/query/QueryTest.java +++ b/hibernate-core/src/test/java/org/hibernate/jpa/test/query/QueryTest.java @@ -1061,18 +1061,18 @@ public class QueryTest extends BaseEntityManagerFunctionalTestCase { jpaQuery.setParameter( 2, "Expensive" ); fail( "Should fail due to a user error in parameters" ); } - catch (IllegalArgumentException e) { - // success, expected + catch (Exception e) { + assertTyping( IllegalArgumentException.class, e ); } // using jpa-style, position index specified not in query - test exception type jpaQuery = em.createQuery( "select w from Wallet w " ); try { - String parameterName = jpaQuery.getParameter( 1 ).getName(); + Parameter parameter = jpaQuery.getParameter( 1 ); fail( "Should fail due to a user error in parameters" ); } - catch ( IllegalArgumentException e ) { - // success, expected. + catch (Exception e) { + assertTyping( IllegalArgumentException.class, e ); } // using jpa-style, position index specified not in query - test exception type @@ -1081,8 +1081,8 @@ public class QueryTest extends BaseEntityManagerFunctionalTestCase { Parameter parameter = jpaQuery.getParameter( 1, Integer.class ); fail( "Should fail due to user error in parameters" ); } - catch ( IllegalArgumentException e ) { - // success, expected. + catch (Exception e) { + assertTyping( IllegalArgumentException.class, e ); } // using hql-style, should be 0-based @@ -1092,9 +1092,8 @@ public class QueryTest extends BaseEntityManagerFunctionalTestCase { hqlQuery.setParameter( 2, "Expensive" ); fail( "Should fail due to a user error in parameters" ); } - catch (IllegalArgumentException e) { - // success expected - e.printStackTrace(); + catch (Exception e) { + assertTyping( IllegalArgumentException.class, e ); } } finally { @@ -1123,8 +1122,8 @@ public class QueryTest extends BaseEntityManagerFunctionalTestCase { Parameter parameter = jpaQuery.getParameter( "brand" ); fail( "Should fail due to user error in parameters" ); } - catch ( IllegalArgumentException e ) { - // success, expected + catch (Exception e) { + assertTyping( IllegalArgumentException.class, e ); } jpaQuery = em.createQuery( "select w from Wallet w" ); @@ -1132,8 +1131,8 @@ public class QueryTest extends BaseEntityManagerFunctionalTestCase { Parameter parameter = jpaQuery.getParameter( "brand", String.class ); fail( "Should fail due to user error in parameters" ); } - catch ( IllegalArgumentException e ) { - // success, expected + catch (Exception e) { + assertTyping( IllegalArgumentException.class, e ); } }