From ff47006731fc56f49db88b4fd2564900cc38b116 Mon Sep 17 00:00:00 2001 From: Hardy Ferentschik Date: Thu, 11 Nov 2010 17:29:25 +0100 Subject: [PATCH] HV-361 Adding test for @Range constraint --- .../DDLWithoutCallbackTest.java | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/beanvalidation/DDLWithoutCallbackTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/beanvalidation/DDLWithoutCallbackTest.java index 61b451b8fc..07b2d879f2 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/beanvalidation/DDLWithoutCallbackTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/beanvalidation/DDLWithoutCallbackTest.java @@ -50,13 +50,13 @@ public class DDLWithoutCallbackTest extends TestCase { @RequiresDialectFeature(DialectChecks.SupportsColumnCheck.class) public void testMinAndMaxChecksGetApplied() { - MinMax minMax = new MinMax(1); + MinMax minMax = new MinMax( 1 ); assertDatabaseConstraintViolationThrown( minMax ); - minMax = new MinMax(11); + minMax = new MinMax( 11 ); assertDatabaseConstraintViolationThrown( minMax ); - minMax = new MinMax(5); + minMax = new MinMax( 5 ); Session s = openSession(); Transaction tx = s.beginTransaction(); s.persist( minMax ); @@ -65,6 +65,23 @@ public class DDLWithoutCallbackTest extends TestCase { s.close(); } + @RequiresDialectFeature(DialectChecks.SupportsColumnCheck.class) + public void testRangeChecksGetApplied() { + Range range = new Range( 1 ); + assertDatabaseConstraintViolationThrown( range ); + + range = new Range( 11 ); + assertDatabaseConstraintViolationThrown( range ); + + range = new Range( 5 ); + Session s = openSession(); + Transaction tx = s.beginTransaction(); + s.persist( range ); + s.flush(); + tx.rollback(); + s.close(); + } + public void testDDLEnabled() { PersistentClass classMapping = getCfg().getClassMapping( Address.class.getName() ); Column countryColumn = (Column) classMapping.getProperty( "country" ).getColumnIterator().next(); @@ -81,7 +98,8 @@ public class DDLWithoutCallbackTest extends TestCase { return new Class[] { Address.class, CupHolder.class, - MinMax.class + MinMax.class, + Range.class }; }