[hibernate-commits] Hibernate SVN: r16758 - in validator/trunk/hibernate-validator/src: test/java/org/hibernate/validation/constraints and 1 other directories.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Thu Jun 11 06:23:05 EDT 2009


Author: hardy.ferentschik
Date: 2009-06-11 06:23:04 -0400 (Thu, 11 Jun 2009)
New Revision: 16758

Added:
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/AssertFalseValidatorTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/AssertTrueValidatorTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/DigitsValidatorForNumberTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/DigitsValidatorForStringTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/FutureValidatorForCalendarTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/FutureValidatorForDateTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/FutureValidatorTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/LengthValidatorTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/MaxValidatorForNumberTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/MaxValidatorForStringTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/MinValidatorForNumberTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/MinValidatorForStringTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/NotNullValidatorTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/NullValidatorTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/PastValidatorForCalendarTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/PastValidatorForDateTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/PatternValidatorTest.java
Removed:
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/NotEmptyValidator.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/AssertFalseValidatorTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/AssertTrueValidatorTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForNumberTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForStringTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForCalendarTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForDateTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/LengthValidatorTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForNumberTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForStringTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForNumberTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForStringTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotEmptyValidatorTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotNullValidatorTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NullValidatorTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PastValidatorForCalendarTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PastValidatorForDateTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PatternValidatorTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/validatorcontext/
Log:
Moved validator tests to be consistent with the package location of the actual tests classes

Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/NotEmptyValidator.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/NotEmptyValidator.java	2009-06-11 10:21:57 UTC (rev 16757)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/NotEmptyValidator.java	2009-06-11 10:23:04 UTC (rev 16758)
@@ -1,41 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,  
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.hibernate.validation.constraints.impl;
-
-import javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
-
-import org.hibernate.validation.constraints.NotEmpty;
-
-/**
- * @author Hardy Ferentschik
- * @todo Extend to not only support strings, but also collections and maps. Needs to be specified first though.
- */
-public class NotEmptyValidator implements ConstraintValidator<NotEmpty, String> {
-
-	public void initialize(NotEmpty parameters) {
-	}
-
-	public boolean isValid(String object, ConstraintValidatorContext constraintValidatorContext) {
-		if ( object == null ) {
-			return true;
-		}
-		int length = object.length();
-		return length > 0;
-	}
-}

Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/AssertFalseValidatorTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/AssertFalseValidatorTest.java	2009-06-11 10:21:57 UTC (rev 16757)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/AssertFalseValidatorTest.java	2009-06-11 10:23:04 UTC (rev 16758)
@@ -1,47 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.hibernate.validation.constraints;
-
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import org.hibernate.validation.constraints.impl.AssertFalseValidator;
-
-/**
- * @author Alaa Nassef
- */
-public class AssertFalseValidatorTest {
-
-	private static AssertFalseValidator constraint;
-
-	@BeforeClass
-	public static void init() {
-		constraint = new AssertFalseValidator();
-	}
-
-	@Test
-	public void testIsValid() {
-		assertTrue( constraint.isValid( null, null ) );
-		assertTrue( constraint.isValid( false, null ) );
-		assertTrue( constraint.isValid( Boolean.FALSE, null ) );
-		assertFalse( constraint.isValid( true, null ) );
-		assertFalse( constraint.isValid( Boolean.TRUE, null ) );
-	}
-}

Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/AssertTrueValidatorTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/AssertTrueValidatorTest.java	2009-06-11 10:21:57 UTC (rev 16757)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/AssertTrueValidatorTest.java	2009-06-11 10:23:04 UTC (rev 16758)
@@ -1,48 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.hibernate.validation.constraints;
-
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import org.hibernate.validation.constraints.impl.AssertTrueValidator;
-
-/**
- * @author Alaa Nassef
- */
-public class AssertTrueValidatorTest {
-
-	private static AssertTrueValidator constraint;
-
-	@BeforeClass
-	public static void init() {
-		constraint = new AssertTrueValidator();
-	}
-
-	@Test
-	public void testIsValid() {
-		assertTrue( constraint.isValid( null, null ) );
-		assertTrue( constraint.isValid( true, null ) );
-		assertTrue( constraint.isValid( Boolean.TRUE, null ) );
-		assertFalse( constraint.isValid( false, null ) );
-		assertFalse( constraint.isValid( Boolean.FALSE, null ) );
-	}
-}
-

Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForNumberTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForNumberTest.java	2009-06-11 10:21:57 UTC (rev 16757)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForNumberTest.java	2009-06-11 10:23:04 UTC (rev 16758)
@@ -1,109 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.hibernate.validation.constraints;
-
-import java.math.BigDecimal;
-import javax.validation.ValidationException;
-import javax.validation.constraints.Digits;
-
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-import org.testng.annotations.Test;
-
-import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
-import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
-import org.hibernate.validation.constraints.impl.DigitsValidatorForNumber;
-
-/**
- * @author Alaa Nassef
- * @author Hardy Ferentschik
- */
-public class DigitsValidatorForNumberTest {
-
-	@Test
-	public void testIsValid() {
-
-		AnnotationDescriptor<Digits> descriptor = new AnnotationDescriptor<Digits>( Digits.class );
-		descriptor.setValue( "integer", 5 );
-		descriptor.setValue( "fraction", 2 );
-		descriptor.setValue( "message", "{validator.digits}" );
-		Digits p = AnnotationFactory.create( descriptor );
-
-		DigitsValidatorForNumber constraint = new DigitsValidatorForNumber();
-		constraint.initialize( p );
-
-
-		assertTrue( constraint.isValid( null, null ) );
-		assertTrue( constraint.isValid( Byte.valueOf( "0" ), null ) );
-		assertTrue( constraint.isValid( Double.valueOf( "500.2" ), null ) );
-
-		assertTrue( constraint.isValid( new BigDecimal( "-12345.12" ), null ) );
-		assertFalse( constraint.isValid( new BigDecimal( "-123456.12" ), null ) );
-		assertFalse( constraint.isValid( new BigDecimal( "-123456.123" ), null ) );
-		assertFalse( constraint.isValid( new BigDecimal( "-12345.123" ), null ) );
-		assertFalse( constraint.isValid( new BigDecimal( "12345.123" ), null ) );
-
-		assertTrue( constraint.isValid( Float.valueOf( "-000000000.22" ), null ) );
-		assertFalse( constraint.isValid( Integer.valueOf( "256874" ), null ) );
-		assertFalse( constraint.isValid( Double.valueOf( "12.0001" ), null ) );
-	}
-
-	@Test
-	public void testIsValidZeroLength() {
-
-		AnnotationDescriptor<Digits> descriptor = new AnnotationDescriptor<Digits>( Digits.class );
-		descriptor.setValue( "integer", 0 );
-		descriptor.setValue( "fraction", 0 );
-		descriptor.setValue( "message", "{validator.digits}" );
-		Digits p = AnnotationFactory.create( descriptor );
-
-		DigitsValidatorForNumber constraint = new DigitsValidatorForNumber();
-		constraint.initialize( p );
-
-
-		assertTrue( constraint.isValid( null, null ) );
-		assertFalse( constraint.isValid( Byte.valueOf( "0" ), null ) );
-		assertFalse( constraint.isValid( Double.valueOf( "500.2" ), null ) );
-	}
-
-	@Test(expectedExceptions = ValidationException.class)
-	public void testNegativeIntegerLength() {
-
-		AnnotationDescriptor<Digits> descriptor = new AnnotationDescriptor<Digits>( Digits.class );
-		descriptor.setValue( "integer", -1 );
-		descriptor.setValue( "fraction", 1 );
-		descriptor.setValue( "message", "{validator.digits}" );
-		Digits p = AnnotationFactory.create( descriptor );
-
-		DigitsValidatorForNumber constraint = new DigitsValidatorForNumber();
-		constraint.initialize( p );
-	}
-
-	@Test(expectedExceptions = ValidationException.class)
-	public void testNegativeFractionLength() {
-
-		AnnotationDescriptor<Digits> descriptor = new AnnotationDescriptor<Digits>( Digits.class );
-		descriptor.setValue( "integer", 1 );
-		descriptor.setValue( "fraction", -1 );
-		descriptor.setValue( "message", "{validator.digits}" );
-		Digits p = AnnotationFactory.create( descriptor );
-
-		DigitsValidatorForNumber constraint = new DigitsValidatorForNumber();
-		constraint.initialize( p );
-	}
-}

Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForStringTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForStringTest.java	2009-06-11 10:21:57 UTC (rev 16757)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForStringTest.java	2009-06-11 10:23:04 UTC (rev 16758)
@@ -1,91 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.hibernate.validation.constraints;
-
-import javax.validation.ValidationException;
-import javax.validation.constraints.Digits;
-
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
-import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
-import org.hibernate.validation.constraints.impl.DigitsValidatorForString;
-
-/**
- * @author Alaa Nassef
- */
-public class DigitsValidatorForStringTest {
-
-	private static DigitsValidatorForString constraint;
-
-	@BeforeClass
-	public static void init() {
-
-		AnnotationDescriptor<Digits> descriptor = new AnnotationDescriptor<Digits>( Digits.class );
-		descriptor.setValue( "integer", 5 );
-		descriptor.setValue( "fraction", 2 );
-		descriptor.setValue( "message", "{validator.digits}" );
-		Digits p = AnnotationFactory.create( descriptor );
-
-		constraint = new DigitsValidatorForString();
-		constraint.initialize( p );
-	}
-
-	@Test
-	public void testIsValid() {
-
-		assertTrue( constraint.isValid( null, null ) );
-		assertTrue( constraint.isValid( "0", null ) );
-		assertTrue( constraint.isValid( "500.2", null ) );
-		assertTrue( constraint.isValid( "-12456.22", null ) );
-		assertTrue( constraint.isValid( "-000000000.22", null ) );
-		//should throw number format exception
-		assertFalse( constraint.isValid( "", null ) );
-		assertFalse( constraint.isValid( "256874.0", null ) );
-		assertFalse( constraint.isValid( "12.0001", null ) );
-	}
-
-	@Test(expectedExceptions = ValidationException.class)
-	public void testNegativeIntegerLength() {
-
-		AnnotationDescriptor<Digits> descriptor = new AnnotationDescriptor<Digits>( Digits.class );
-		descriptor.setValue( "integer", -1 );
-		descriptor.setValue( "fraction", 1 );
-		descriptor.setValue( "message", "{validator.digits}" );
-		Digits p = AnnotationFactory.create( descriptor );
-
-		DigitsValidatorForString constraint = new DigitsValidatorForString();
-		constraint.initialize( p );
-	}
-
-	@Test(expectedExceptions = ValidationException.class)
-	public void testNegativeFractionLength() {
-
-		AnnotationDescriptor<Digits> descriptor = new AnnotationDescriptor<Digits>( Digits.class );
-		descriptor.setValue( "integer", 1 );
-		descriptor.setValue( "fraction", -1 );
-		descriptor.setValue( "message", "{validator.digits}" );
-		Digits p = AnnotationFactory.create( descriptor );
-
-		DigitsValidatorForString constraint = new DigitsValidatorForString();
-		constraint.initialize( p );
-	}
-}

Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForCalendarTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForCalendarTest.java	2009-06-11 10:21:57 UTC (rev 16757)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForCalendarTest.java	2009-06-11 10:23:04 UTC (rev 16758)
@@ -1,65 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.hibernate.validation.constraints;
-
-import java.util.Calendar;
-
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import org.hibernate.validation.constraints.impl.FutureValidatorForCalendar;
-
-/**
- * @author Alaa Nassef
- * @author Hardy Ferentschik
- */
-public class FutureValidatorForCalendarTest {
-
-	private static FutureValidatorForCalendar constraint;
-
-	@BeforeClass
-	public static void init() {
-		constraint = new FutureValidatorForCalendar();
-	}
-
-	@Test
-	public void testIsValid() {
-		Calendar futureDate = getFutureDate();
-		Calendar pastDate = getPastDate();
-		assertTrue( constraint.isValid( null, null ) );
-		assertTrue( constraint.isValid( futureDate, null ) );
-		assertFalse( constraint.isValid( pastDate, null ) );
-	}
-
-	private Calendar getFutureDate() {
-		Calendar cal = Calendar.getInstance();
-		int year = cal.get( Calendar.YEAR );
-		cal.set( Calendar.YEAR, year + 1 );
-		return cal;
-	}
-
-	private Calendar getPastDate() {
-		Calendar cal = Calendar.getInstance();
-		int year = cal.get( Calendar.YEAR );
-		cal.set( Calendar.YEAR, year - 1 );
-		return cal;
-	}
-
-}

Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForDateTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForDateTest.java	2009-06-11 10:21:57 UTC (rev 16757)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForDateTest.java	2009-06-11 10:23:04 UTC (rev 16758)
@@ -1,62 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.hibernate.validation.constraints;
-
-import java.util.Date;
-
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import org.hibernate.validation.constraints.impl.FutureValidatorForDate;
-
-public class FutureValidatorForDateTest {
-
-	private static FutureValidatorForDate constraint;
-
-	@BeforeClass
-	public static void init() {
-		constraint = new FutureValidatorForDate();
-	}
-
-	@Test
-	public void testIsValid() {
-		Date futureDate = getFutureDate();
-		Date pastDate = getPastDate();
-		assertTrue( constraint.isValid( null, null ) );
-		assertTrue( constraint.isValid( futureDate, null ) );
-		assertFalse( constraint.isValid( new Date(), null ) );
-		assertFalse( constraint.isValid( pastDate, null ) );
-	}
-
-	private Date getFutureDate() {
-		Date date = new Date();
-		long timeStamp = date.getTime();
-		date.setTime( timeStamp + 31557600000l );
-		return date;
-	}
-
-	private Date getPastDate() {
-		Date date = new Date();
-		long timeStamp = date.getTime();
-		date.setTime( timeStamp - 31557600000l );
-		return date;
-	}
-
-}

Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/LengthValidatorTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/LengthValidatorTest.java	2009-06-11 10:21:57 UTC (rev 16757)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/LengthValidatorTest.java	2009-06-11 10:23:04 UTC (rev 16758)
@@ -1,89 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,  
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.hibernate.validation.constraints;
-
-import javax.validation.ValidationException;
-
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-import org.testng.annotations.Test;
-
-import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
-import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
-import org.hibernate.validation.constraints.impl.LengthValidator;
-
-/**
- * Tests the <code>LengthConstraint</code>.
- *
- * @author Hardy Ferentschik
- */
-public class LengthValidatorTest {
-
-	@Test
-	public void testIsValid() {
-		AnnotationDescriptor<Length> descriptor = new AnnotationDescriptor<Length>( Length.class );
-		descriptor.setValue( "min", 1 );
-		descriptor.setValue( "max", 3 );
-		descriptor.setValue( "message", "{validator.length}" );
-		Length l = AnnotationFactory.create( descriptor );
-		LengthValidator constraint = new LengthValidator();
-		constraint.initialize( l );
-		assertTrue( constraint.isValid( null, null ) );
-		assertFalse( constraint.isValid( "", null ) );
-		assertTrue( constraint.isValid( "f", null ) );
-		assertTrue( constraint.isValid( "fo", null ) );
-		assertTrue( constraint.isValid( "foo", null ) );
-		assertFalse( constraint.isValid( "foobar", null ) );
-	}
-
-	@Test(expectedExceptions = ValidationException.class)
-	public void testNegativeMinValue() {
-		AnnotationDescriptor<Length> descriptor = new AnnotationDescriptor<Length>( Length.class );
-		descriptor.setValue( "min", -1 );
-		descriptor.setValue( "max", 1 );
-		descriptor.setValue( "message", "{validator.length}" );
-		Length p = AnnotationFactory.create( descriptor );
-
-		LengthValidator constraint = new LengthValidator();
-		constraint.initialize( p );
-	}
-
-	@Test(expectedExceptions = ValidationException.class)
-	public void testNegativeMaxValue() {
-		AnnotationDescriptor<Length> descriptor = new AnnotationDescriptor<Length>( Length.class );
-		descriptor.setValue( "min", 1 );
-		descriptor.setValue( "max", -1 );
-		descriptor.setValue( "message", "{validator.length}" );
-		Length p = AnnotationFactory.create( descriptor );
-
-		LengthValidator constraint = new LengthValidator();
-		constraint.initialize( p );
-	}
-
-	@Test(expectedExceptions = ValidationException.class)
-	public void testNegativeLength() {
-		AnnotationDescriptor<Length> descriptor = new AnnotationDescriptor<Length>( Length.class );
-		descriptor.setValue( "min", 5 );
-		descriptor.setValue( "max", 4 );
-		descriptor.setValue( "message", "{validator.length}" );
-		Length p = AnnotationFactory.create( descriptor );
-
-		LengthValidator constraint = new LengthValidator();
-		constraint.initialize( p );
-	}
-}

Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForNumberTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForNumberTest.java	2009-06-11 10:21:57 UTC (rev 16757)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForNumberTest.java	2009-06-11 10:23:04 UTC (rev 16758)
@@ -1,71 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.hibernate.validation.constraints;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import javax.validation.constraints.Max;
-
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
-import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
-import org.hibernate.validation.constraints.impl.MaxValidatorForNumber;
-
-/**
- * @author Alaa Nassef
- * @author Hardy Ferentschik
- */
-public class MaxValidatorForNumberTest {
-
-	private static MaxValidatorForNumber constraint;
-
-	@BeforeClass
-	public static void init() {
-		AnnotationDescriptor<Max> descriptor = new AnnotationDescriptor<Max>( Max.class );
-		descriptor.setValue( "value", 15l );
-		descriptor.setValue( "message", "{validator.max}" );
-		Max m = AnnotationFactory.create( descriptor );
-
-		constraint = new MaxValidatorForNumber();
-		constraint.initialize( m );
-	}
-
-	@Test
-	public void testIsValid() {
-		byte b = 1;
-		Byte bWrapper = 127;
-		assertTrue( constraint.isValid( null, null ) );
-		assertTrue( constraint.isValid( b, null ) );
-		assertTrue( constraint.isValid( 15l, null ) );
-		assertTrue( constraint.isValid( 15, null ) );
-		assertTrue( constraint.isValid( 15.0, null ) );
-		assertTrue( constraint.isValid( BigDecimal.valueOf( -156000000000.0 ), null ) );
-		assertTrue( constraint.isValid( BigInteger.valueOf( -10000000l ), null ) );
-		assertTrue( constraint.isValid( 10, null ) );
-		assertTrue( constraint.isValid( 14.99, null ) );
-		assertTrue( constraint.isValid( -14.99, null ) );
-		assertFalse( constraint.isValid( 20, null ) );
-		assertFalse( constraint.isValid( bWrapper, null ) );
-		assertFalse( constraint.isValid( BigDecimal.valueOf( 156000000000.0 ), null ) );
-		assertFalse( constraint.isValid( BigInteger.valueOf( 10000000l ), null ) );
-	}
-}

Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForStringTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForStringTest.java	2009-06-11 10:21:57 UTC (rev 16757)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForStringTest.java	2009-06-11 10:23:04 UTC (rev 16758)
@@ -1,61 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.hibernate.validation.constraints;
-
-import javax.validation.constraints.Max;
-
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
-import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
-import org.hibernate.validation.constraints.impl.MaxValidatorForString;
-
-/**
- * @author Alaa Nassef
- */
-public class MaxValidatorForStringTest {
-
-	private static MaxValidatorForString constraint;
-
-	@BeforeClass
-	public static void init() {
-		AnnotationDescriptor<Max> descriptor = new AnnotationDescriptor<Max>( Max.class );
-		descriptor.setValue( "value", 15l );
-		descriptor.setValue( "message", "{validator.max}" );
-		Max m = AnnotationFactory.create( descriptor );
-
-		constraint = new MaxValidatorForString();
-		constraint.initialize( m );
-	}
-
-	@Test
-	public void testIsValid() {
-		assertTrue( constraint.isValid( null, null ) );
-		assertTrue( constraint.isValid( "15", null ) );
-		assertTrue( constraint.isValid( "15.0", null ) );
-		assertTrue( constraint.isValid( "10", null ) );
-		assertTrue( constraint.isValid( "14.99", null ) );
-		assertTrue( constraint.isValid( "-14.99", null ) );
-		assertFalse( constraint.isValid( "20", null ) );
-		//number format exception
-		assertFalse( constraint.isValid( "15l", null ) );
-	}
-}

Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForNumberTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForNumberTest.java	2009-06-11 10:21:57 UTC (rev 16757)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForNumberTest.java	2009-06-11 10:23:04 UTC (rev 16758)
@@ -1,71 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.hibernate.validation.constraints;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import javax.validation.constraints.Min;
-
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
-import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
-import org.hibernate.validation.constraints.impl.MinValidatorForNumber;
-
-/**
- * @author Alaa Nassef
- * @author Hardy Ferentschik
- */
-public class MinValidatorForNumberTest {
-
-	private static MinValidatorForNumber constraint;
-
-	@BeforeClass
-	public static void init() {
-		AnnotationDescriptor<Min> descriptor = new AnnotationDescriptor<Min>( Min.class );
-		descriptor.setValue( "value", 15l );
-		descriptor.setValue( "message", "{validator.min}" );
-		Min m = AnnotationFactory.create( descriptor );
-
-		constraint = new MinValidatorForNumber();
-		constraint.initialize( m );
-	}
-
-	@Test
-	public void testIsValid() {
-		byte b = 1;
-		Byte bWrapper = 127;
-		assertTrue( constraint.isValid( null, null ) );
-		assertTrue( constraint.isValid( bWrapper, null ) );
-		assertTrue( constraint.isValid( 20, null ) );
-		assertTrue( constraint.isValid( 15l, null ) );
-		assertTrue( constraint.isValid( 15, null ) );
-		assertTrue( constraint.isValid( 15.0, null ) );
-		assertTrue( constraint.isValid( BigDecimal.valueOf( 156000000000.0 ), null ) );
-		assertTrue( constraint.isValid( BigInteger.valueOf( 10000000l ), null ) );
-		assertFalse( constraint.isValid( b, null ) );
-		assertFalse( constraint.isValid( BigDecimal.valueOf( -156000000000.0 ), null ) );
-		assertFalse( constraint.isValid( BigInteger.valueOf( -10000000l ), null ) );
-		assertFalse( constraint.isValid( 10, null ) );
-		assertFalse( constraint.isValid( 14.99, null ) );
-		assertFalse( constraint.isValid( -14.99, null ) );
-	}
-}

Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForStringTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForStringTest.java	2009-06-11 10:21:57 UTC (rev 16757)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForStringTest.java	2009-06-11 10:23:04 UTC (rev 16758)
@@ -1,62 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.hibernate.validation.constraints;
-
-import javax.validation.constraints.Min;
-
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
-import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
-import org.hibernate.validation.constraints.impl.MinValidatorForString;
-
-/**
- * @author Alaa Nassef
- */
-public class MinValidatorForStringTest {
-
-	private static MinValidatorForString constraint;
-
-	@BeforeClass
-	public static void init() {
-		AnnotationDescriptor<Min> descriptor = new AnnotationDescriptor<Min>( Min.class );
-		descriptor.setValue( "value", 15l );
-		descriptor.setValue( "message", "{validator.min}" );
-		Min m = AnnotationFactory.create( descriptor );
-
-		constraint = new MinValidatorForString();
-		constraint.initialize( m );
-	}
-
-	@Test
-	public void testIsValid() {
-		assertTrue( constraint.isValid( null, null ) );
-		assertTrue( constraint.isValid( "20", null ) );
-		assertTrue( constraint.isValid( "15", null ) );
-		assertTrue( constraint.isValid( "15.0", null ) );
-		assertFalse( constraint.isValid( "10", null ) );
-		assertFalse( constraint.isValid( "14.99", null ) );
-		assertFalse( constraint.isValid( "-14.99", null ) );
-		//number format exception
-		assertFalse( constraint.isValid( "15l", null ) );
-	}
-
-}

Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotEmptyValidatorTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotEmptyValidatorTest.java	2009-06-11 10:21:57 UTC (rev 16757)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotEmptyValidatorTest.java	2009-06-11 10:23:04 UTC (rev 16758)
@@ -1,48 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,  
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.hibernate.validation.constraints;
-
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import org.hibernate.validation.constraints.impl.NotEmptyValidator;
-
-/**
- * @author Hardy Ferentschik
- */
-public class NotEmptyValidatorTest {
-
-	private static NotEmptyValidator constraint;
-
-	@BeforeClass
-	public static void init() {
-		constraint = new NotEmptyValidator();
-	}
-
-	@Test
-	public void testIsValid() {
-
-		assertTrue( constraint.isValid( null, null ) );
-		assertTrue( constraint.isValid( "foo", null ) );
-		assertTrue( constraint.isValid( "  ", null ) );
-
-		assertFalse( constraint.isValid( "", null ) );
-	}
-}

Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotNullValidatorTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotNullValidatorTest.java	2009-06-11 10:21:57 UTC (rev 16757)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotNullValidatorTest.java	2009-06-11 10:23:04 UTC (rev 16758)
@@ -1,38 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,  
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.hibernate.validation.constraints;
-
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-import org.testng.annotations.Test;
-
-import org.hibernate.validation.constraints.impl.NotNullValidator;
-
-/**
- * @author Hardy Ferentschik
- */
-public class NotNullValidatorTest {
-
-	@Test
-	public void testIsValid() {
-		NotNullValidator constraint = new NotNullValidator();
-
-		assertFalse( constraint.isValid( null, null ) );
-		assertTrue( constraint.isValid( new Object(), null ) );
-	}
-}

Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NullValidatorTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NullValidatorTest.java	2009-06-11 10:21:57 UTC (rev 16757)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NullValidatorTest.java	2009-06-11 10:23:04 UTC (rev 16758)
@@ -1,44 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.hibernate.validation.constraints;
-
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import org.hibernate.validation.constraints.impl.NullValidator;
-
-/**
- * @author Alaa Nassef
- */
-public class NullValidatorTest {
-
-	private static NullValidator constraint;
-
-	@BeforeClass
-	public static void init() {
-		constraint = new NullValidator();
-	}
-
-	@Test
-	public void testIsValid() {
-		assertTrue( constraint.isValid( null, null ) );
-		assertFalse( constraint.isValid( new Object(), null ) );
-	}
-}

Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PastValidatorForCalendarTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PastValidatorForCalendarTest.java	2009-06-11 10:21:57 UTC (rev 16757)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PastValidatorForCalendarTest.java	2009-06-11 10:23:04 UTC (rev 16758)
@@ -1,64 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.hibernate.validation.constraints;
-
-import java.util.Calendar;
-
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import org.hibernate.validation.constraints.impl.PastValidatorForCalendar;
-
-/**
- * @author Alaa Nassef
- * @author Hardy Ferentschik
- */
-public class PastValidatorForCalendarTest {
-
-	private static PastValidatorForCalendar constraint;
-
-	@BeforeClass
-	public static void init() {
-		constraint = new PastValidatorForCalendar();
-	}
-
-	@Test
-	public void testIsValid() {
-		Calendar futureDate = getFutureDate();
-		Calendar pastDate = getPastDate();
-		assertTrue( constraint.isValid( null, null ) );
-		assertTrue( constraint.isValid( pastDate, null ) );
-		assertFalse( constraint.isValid( futureDate, null ) );
-	}
-
-	private Calendar getFutureDate() {
-		Calendar cal = Calendar.getInstance();
-		int year = cal.get( Calendar.YEAR );
-		cal.set( Calendar.YEAR, year + 1 );
-		return cal;
-	}
-
-	private Calendar getPastDate() {
-		Calendar cal = Calendar.getInstance();
-		int year = cal.get( Calendar.YEAR );
-		cal.set( Calendar.YEAR, year - 1 );
-		return cal;
-	}
-}

Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PastValidatorForDateTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PastValidatorForDateTest.java	2009-06-11 10:21:57 UTC (rev 16757)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PastValidatorForDateTest.java	2009-06-11 10:23:04 UTC (rev 16758)
@@ -1,62 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.hibernate.validation.constraints;
-
-import java.util.Date;
-
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import org.hibernate.validation.constraints.impl.PastValidatorForDate;
-
-public class PastValidatorForDateTest {
-
-	private static PastValidatorForDate constraint;
-
-	@BeforeClass
-	public static void init() {
-		constraint = new PastValidatorForDate();
-	}
-
-	@Test
-	public void testIsValid() {
-		Date futureDate = getFutureDate();
-		Date pastDate = getPastDate();
-		assertTrue( constraint.isValid( null, null ) );
-		assertTrue( constraint.isValid( pastDate, null ) );
-		assertFalse( constraint.isValid( new Date(), null ) );
-		assertFalse( constraint.isValid( futureDate, null ) );
-	}
-
-	private Date getFutureDate() {
-		Date date = new Date();
-		long timeStamp = date.getTime();
-		date.setTime( timeStamp + 31557600000l );
-		return date;
-	}
-
-	private Date getPastDate() {
-		Date date = new Date();
-		long timeStamp = date.getTime();
-		date.setTime( timeStamp - 31557600000l );
-		return date;
-	}
-
-}

Deleted: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PatternValidatorTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PatternValidatorTest.java	2009-06-11 10:21:57 UTC (rev 16757)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PatternValidatorTest.java	2009-06-11 10:23:04 UTC (rev 16758)
@@ -1,62 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,  
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.hibernate.validation.constraints;
-
-import javax.validation.ValidationException;
-import javax.validation.constraints.Pattern;
-
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-import org.testng.annotations.Test;
-
-import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
-import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
-import org.hibernate.validation.constraints.impl.PatternValidator;
-
-/**
- * @author Hardy Ferentschik
- */
-public class PatternValidatorTest {
-
-	@Test
-	public void testIsValid() {
-		AnnotationDescriptor<Pattern> descriptor = new AnnotationDescriptor<Pattern>( Pattern.class );
-		descriptor.setValue( "regexp", "foobar" );
-		descriptor.setValue( "message", "{validator.pattern}" );
-		Pattern p = AnnotationFactory.create( descriptor );
-
-		PatternValidator constraint = new PatternValidator();
-		constraint.initialize( p );
-
-		assertTrue( constraint.isValid( null, null ) );
-		assertFalse( constraint.isValid( "", null ) );
-		assertFalse( constraint.isValid( "bla bla", null ) );
-		assertFalse( constraint.isValid( "This test is not foobar", null ) );
-	}
-
-	@Test(expectedExceptions = ValidationException.class)
-	public void testInvalidRegularExpression() {
-		AnnotationDescriptor<Pattern> descriptor = new AnnotationDescriptor<Pattern>( Pattern.class );
-		descriptor.setValue( "regexp", "(unbalanced parentheses" );
-		descriptor.setValue( "message", "{validator.pattern}" );
-		Pattern p = AnnotationFactory.create( descriptor );
-
-		PatternValidator constraint = new PatternValidator();
-		constraint.initialize( p );
-	}
-}

Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/AssertFalseValidatorTest.java (from rev 16755, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/AssertFalseValidatorTest.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/AssertFalseValidatorTest.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/AssertFalseValidatorTest.java	2009-06-11 10:23:04 UTC (rev 16758)
@@ -0,0 +1,45 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.constraints.impl;
+
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * @author Alaa Nassef
+ */
+public class AssertFalseValidatorTest {
+
+	private static AssertFalseValidator constraint;
+
+	@BeforeClass
+	public static void init() {
+		constraint = new AssertFalseValidator();
+	}
+
+	@Test
+	public void testIsValid() {
+		assertTrue( constraint.isValid( null, null ) );
+		assertTrue( constraint.isValid( false, null ) );
+		assertTrue( constraint.isValid( Boolean.FALSE, null ) );
+		assertFalse( constraint.isValid( true, null ) );
+		assertFalse( constraint.isValid( Boolean.TRUE, null ) );
+	}
+}

Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/AssertTrueValidatorTest.java (from rev 16755, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/AssertTrueValidatorTest.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/AssertTrueValidatorTest.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/AssertTrueValidatorTest.java	2009-06-11 10:23:04 UTC (rev 16758)
@@ -0,0 +1,46 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.constraints.impl;
+
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * @author Alaa Nassef
+ */
+public class AssertTrueValidatorTest {
+
+	private static AssertTrueValidator constraint;
+
+	@BeforeClass
+	public static void init() {
+		constraint = new AssertTrueValidator();
+	}
+
+	@Test
+	public void testIsValid() {
+		assertTrue( constraint.isValid( null, null ) );
+		assertTrue( constraint.isValid( true, null ) );
+		assertTrue( constraint.isValid( Boolean.TRUE, null ) );
+		assertFalse( constraint.isValid( false, null ) );
+		assertFalse( constraint.isValid( Boolean.FALSE, null ) );
+	}
+}
+

Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/DigitsValidatorForNumberTest.java (from rev 16755, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForNumberTest.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/DigitsValidatorForNumberTest.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/DigitsValidatorForNumberTest.java	2009-06-11 10:23:04 UTC (rev 16758)
@@ -0,0 +1,108 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.constraints.impl;
+
+import java.math.BigDecimal;
+import javax.validation.ValidationException;
+import javax.validation.constraints.Digits;
+
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
+
+import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
+import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
+
+/**
+ * @author Alaa Nassef
+ * @author Hardy Ferentschik
+ */
+public class DigitsValidatorForNumberTest {
+
+	@Test
+	public void testIsValid() {
+
+		AnnotationDescriptor<Digits> descriptor = new AnnotationDescriptor<Digits>( Digits.class );
+		descriptor.setValue( "integer", 5 );
+		descriptor.setValue( "fraction", 2 );
+		descriptor.setValue( "message", "{validator.digits}" );
+		Digits p = AnnotationFactory.create( descriptor );
+
+		DigitsValidatorForNumber constraint = new DigitsValidatorForNumber();
+		constraint.initialize( p );
+
+
+		assertTrue( constraint.isValid( null, null ) );
+		assertTrue( constraint.isValid( Byte.valueOf( "0" ), null ) );
+		assertTrue( constraint.isValid( Double.valueOf( "500.2" ), null ) );
+
+		assertTrue( constraint.isValid( new BigDecimal( "-12345.12" ), null ) );
+		assertFalse( constraint.isValid( new BigDecimal( "-123456.12" ), null ) );
+		assertFalse( constraint.isValid( new BigDecimal( "-123456.123" ), null ) );
+		assertFalse( constraint.isValid( new BigDecimal( "-12345.123" ), null ) );
+		assertFalse( constraint.isValid( new BigDecimal( "12345.123" ), null ) );
+
+		assertTrue( constraint.isValid( Float.valueOf( "-000000000.22" ), null ) );
+		assertFalse( constraint.isValid( Integer.valueOf( "256874" ), null ) );
+		assertFalse( constraint.isValid( Double.valueOf( "12.0001" ), null ) );
+	}
+
+	@Test
+	public void testIsValidZeroLength() {
+
+		AnnotationDescriptor<Digits> descriptor = new AnnotationDescriptor<Digits>( Digits.class );
+		descriptor.setValue( "integer", 0 );
+		descriptor.setValue( "fraction", 0 );
+		descriptor.setValue( "message", "{validator.digits}" );
+		Digits p = AnnotationFactory.create( descriptor );
+
+		DigitsValidatorForNumber constraint = new DigitsValidatorForNumber();
+		constraint.initialize( p );
+
+
+		assertTrue( constraint.isValid( null, null ) );
+		assertFalse( constraint.isValid( Byte.valueOf( "0" ), null ) );
+		assertFalse( constraint.isValid( Double.valueOf( "500.2" ), null ) );
+	}
+
+	@Test(expectedExceptions = ValidationException.class)
+	public void testNegativeIntegerLength() {
+
+		AnnotationDescriptor<Digits> descriptor = new AnnotationDescriptor<Digits>( Digits.class );
+		descriptor.setValue( "integer", -1 );
+		descriptor.setValue( "fraction", 1 );
+		descriptor.setValue( "message", "{validator.digits}" );
+		Digits p = AnnotationFactory.create( descriptor );
+
+		DigitsValidatorForNumber constraint = new DigitsValidatorForNumber();
+		constraint.initialize( p );
+	}
+
+	@Test(expectedExceptions = ValidationException.class)
+	public void testNegativeFractionLength() {
+
+		AnnotationDescriptor<Digits> descriptor = new AnnotationDescriptor<Digits>( Digits.class );
+		descriptor.setValue( "integer", 1 );
+		descriptor.setValue( "fraction", -1 );
+		descriptor.setValue( "message", "{validator.digits}" );
+		Digits p = AnnotationFactory.create( descriptor );
+
+		DigitsValidatorForNumber constraint = new DigitsValidatorForNumber();
+		constraint.initialize( p );
+	}
+}

Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/DigitsValidatorForStringTest.java (from rev 16755, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForStringTest.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/DigitsValidatorForStringTest.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/DigitsValidatorForStringTest.java	2009-06-11 10:23:04 UTC (rev 16758)
@@ -0,0 +1,90 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.constraints.impl;
+
+import javax.validation.ValidationException;
+import javax.validation.constraints.Digits;
+
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
+import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
+
+/**
+ * @author Alaa Nassef
+ */
+public class DigitsValidatorForStringTest {
+
+	private static DigitsValidatorForString constraint;
+
+	@BeforeClass
+	public static void init() {
+
+		AnnotationDescriptor<Digits> descriptor = new AnnotationDescriptor<Digits>( Digits.class );
+		descriptor.setValue( "integer", 5 );
+		descriptor.setValue( "fraction", 2 );
+		descriptor.setValue( "message", "{validator.digits}" );
+		Digits p = AnnotationFactory.create( descriptor );
+
+		constraint = new DigitsValidatorForString();
+		constraint.initialize( p );
+	}
+
+	@Test
+	public void testIsValid() {
+
+		assertTrue( constraint.isValid( null, null ) );
+		assertTrue( constraint.isValid( "0", null ) );
+		assertTrue( constraint.isValid( "500.2", null ) );
+		assertTrue( constraint.isValid( "-12456.22", null ) );
+		assertTrue( constraint.isValid( "-000000000.22", null ) );
+		//should throw number format exception
+		assertFalse( constraint.isValid( "", null ) );
+		assertFalse( constraint.isValid( "256874.0", null ) );
+		assertFalse( constraint.isValid( "12.0001", null ) );
+	}
+
+	@Test(expectedExceptions = ValidationException.class)
+	public void testNegativeIntegerLength() {
+
+		AnnotationDescriptor<Digits> descriptor = new AnnotationDescriptor<Digits>( Digits.class );
+		descriptor.setValue( "integer", -1 );
+		descriptor.setValue( "fraction", 1 );
+		descriptor.setValue( "message", "{validator.digits}" );
+		Digits p = AnnotationFactory.create( descriptor );
+
+		DigitsValidatorForString constraint = new DigitsValidatorForString();
+		constraint.initialize( p );
+	}
+
+	@Test(expectedExceptions = ValidationException.class)
+	public void testNegativeFractionLength() {
+
+		AnnotationDescriptor<Digits> descriptor = new AnnotationDescriptor<Digits>( Digits.class );
+		descriptor.setValue( "integer", 1 );
+		descriptor.setValue( "fraction", -1 );
+		descriptor.setValue( "message", "{validator.digits}" );
+		Digits p = AnnotationFactory.create( descriptor );
+
+		DigitsValidatorForString constraint = new DigitsValidatorForString();
+		constraint.initialize( p );
+	}
+}

Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/FutureValidatorForCalendarTest.java (from rev 16755, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForCalendarTest.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/FutureValidatorForCalendarTest.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/FutureValidatorForCalendarTest.java	2009-06-11 10:23:04 UTC (rev 16758)
@@ -0,0 +1,63 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.constraints.impl;
+
+import java.util.Calendar;
+
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * @author Alaa Nassef
+ * @author Hardy Ferentschik
+ */
+public class FutureValidatorForCalendarTest {
+
+	private static FutureValidatorForCalendar constraint;
+
+	@BeforeClass
+	public static void init() {
+		constraint = new FutureValidatorForCalendar();
+	}
+
+	@Test
+	public void testIsValid() {
+		Calendar futureDate = getFutureDate();
+		Calendar pastDate = getPastDate();
+		assertTrue( constraint.isValid( null, null ) );
+		assertTrue( constraint.isValid( futureDate, null ) );
+		assertFalse( constraint.isValid( pastDate, null ) );
+	}
+
+	private Calendar getFutureDate() {
+		Calendar cal = Calendar.getInstance();
+		int year = cal.get( Calendar.YEAR );
+		cal.set( Calendar.YEAR, year + 1 );
+		return cal;
+	}
+
+	private Calendar getPastDate() {
+		Calendar cal = Calendar.getInstance();
+		int year = cal.get( Calendar.YEAR );
+		cal.set( Calendar.YEAR, year - 1 );
+		return cal;
+	}
+
+}

Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/FutureValidatorForDateTest.java (from rev 16755, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForDateTest.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/FutureValidatorForDateTest.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/FutureValidatorForDateTest.java	2009-06-11 10:23:04 UTC (rev 16758)
@@ -0,0 +1,60 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.constraints.impl;
+
+import java.util.Date;
+
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public class FutureValidatorForDateTest {
+
+	private static FutureValidatorForDate constraint;
+
+	@BeforeClass
+	public static void init() {
+		constraint = new FutureValidatorForDate();
+	}
+
+	@Test
+	public void testIsValid() {
+		Date futureDate = getFutureDate();
+		Date pastDate = getPastDate();
+		assertTrue( constraint.isValid( null, null ) );
+		assertTrue( constraint.isValid( futureDate, null ) );
+		assertFalse( constraint.isValid( new Date(), null ) );
+		assertFalse( constraint.isValid( pastDate, null ) );
+	}
+
+	private Date getFutureDate() {
+		Date date = new Date();
+		long timeStamp = date.getTime();
+		date.setTime( timeStamp + 31557600000l );
+		return date;
+	}
+
+	private Date getPastDate() {
+		Date date = new Date();
+		long timeStamp = date.getTime();
+		date.setTime( timeStamp - 31557600000l );
+		return date;
+	}
+
+}

Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/FutureValidatorTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/FutureValidatorTest.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/FutureValidatorTest.java	2009-06-11 10:23:04 UTC (rev 16758)
@@ -0,0 +1,45 @@
+// $Id: FutureValidatorTest.java 16528 2009-05-11 12:18:22Z hardy.ferentschik $
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.constraints.impl;
+
+import java.util.Set;
+import javax.validation.ConstraintViolation;
+import javax.validation.Validator;
+
+import static org.testng.Assert.assertEquals;
+import org.testng.annotations.Test;
+
+import org.hibernate.validation.constraints.DateHolder;
+import org.hibernate.validation.util.TestUtil;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class FutureValidatorTest {
+
+	/**
+	 * HV-158
+	 */
+	@Test
+	public void testFutureAndPast() {
+		Validator validator = TestUtil.getValidator();
+		DateHolder dateHolder = new DateHolder();
+		Set<ConstraintViolation<DateHolder>> constraintViolations = validator.validate( dateHolder );
+		assertEquals( constraintViolations.size(), 1, "Wrong number of constraints" );
+	}
+}

Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/LengthValidatorTest.java (from rev 16755, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/LengthValidatorTest.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/LengthValidatorTest.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/LengthValidatorTest.java	2009-06-11 10:23:04 UTC (rev 16758)
@@ -0,0 +1,89 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,  
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.constraints.impl;
+
+import javax.validation.ValidationException;
+
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
+
+import org.hibernate.validation.constraints.Length;
+import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
+import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
+
+/**
+ * Tests the <code>LengthConstraint</code>.
+ *
+ * @author Hardy Ferentschik
+ */
+public class LengthValidatorTest {
+
+	@Test
+	public void testIsValid() {
+		AnnotationDescriptor<Length> descriptor = new AnnotationDescriptor<Length>( Length.class );
+		descriptor.setValue( "min", 1 );
+		descriptor.setValue( "max", 3 );
+		descriptor.setValue( "message", "{validator.length}" );
+		Length l = AnnotationFactory.create( descriptor );
+		LengthValidator constraint = new LengthValidator();
+		constraint.initialize( l );
+		assertTrue( constraint.isValid( null, null ) );
+		assertFalse( constraint.isValid( "", null ) );
+		assertTrue( constraint.isValid( "f", null ) );
+		assertTrue( constraint.isValid( "fo", null ) );
+		assertTrue( constraint.isValid( "foo", null ) );
+		assertFalse( constraint.isValid( "foobar", null ) );
+	}
+
+	@Test(expectedExceptions = ValidationException.class)
+	public void testNegativeMinValue() {
+		AnnotationDescriptor<Length> descriptor = new AnnotationDescriptor<Length>( Length.class );
+		descriptor.setValue( "min", -1 );
+		descriptor.setValue( "max", 1 );
+		descriptor.setValue( "message", "{validator.length}" );
+		Length p = AnnotationFactory.create( descriptor );
+
+		LengthValidator constraint = new LengthValidator();
+		constraint.initialize( p );
+	}
+
+	@Test(expectedExceptions = ValidationException.class)
+	public void testNegativeMaxValue() {
+		AnnotationDescriptor<Length> descriptor = new AnnotationDescriptor<Length>( Length.class );
+		descriptor.setValue( "min", 1 );
+		descriptor.setValue( "max", -1 );
+		descriptor.setValue( "message", "{validator.length}" );
+		Length p = AnnotationFactory.create( descriptor );
+
+		LengthValidator constraint = new LengthValidator();
+		constraint.initialize( p );
+	}
+
+	@Test(expectedExceptions = ValidationException.class)
+	public void testNegativeLength() {
+		AnnotationDescriptor<Length> descriptor = new AnnotationDescriptor<Length>( Length.class );
+		descriptor.setValue( "min", 5 );
+		descriptor.setValue( "max", 4 );
+		descriptor.setValue( "message", "{validator.length}" );
+		Length p = AnnotationFactory.create( descriptor );
+
+		LengthValidator constraint = new LengthValidator();
+		constraint.initialize( p );
+	}
+}

Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/MaxValidatorForNumberTest.java (from rev 16755, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForNumberTest.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/MaxValidatorForNumberTest.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/MaxValidatorForNumberTest.java	2009-06-11 10:23:04 UTC (rev 16758)
@@ -0,0 +1,70 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.constraints.impl;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import javax.validation.constraints.Max;
+
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
+import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
+
+/**
+ * @author Alaa Nassef
+ * @author Hardy Ferentschik
+ */
+public class MaxValidatorForNumberTest {
+
+	private static MaxValidatorForNumber constraint;
+
+	@BeforeClass
+	public static void init() {
+		AnnotationDescriptor<Max> descriptor = new AnnotationDescriptor<Max>( Max.class );
+		descriptor.setValue( "value", 15l );
+		descriptor.setValue( "message", "{validator.max}" );
+		Max m = AnnotationFactory.create( descriptor );
+
+		constraint = new MaxValidatorForNumber();
+		constraint.initialize( m );
+	}
+
+	@Test
+	public void testIsValid() {
+		byte b = 1;
+		Byte bWrapper = 127;
+		assertTrue( constraint.isValid( null, null ) );
+		assertTrue( constraint.isValid( b, null ) );
+		assertTrue( constraint.isValid( 15l, null ) );
+		assertTrue( constraint.isValid( 15, null ) );
+		assertTrue( constraint.isValid( 15.0, null ) );
+		assertTrue( constraint.isValid( BigDecimal.valueOf( -156000000000.0 ), null ) );
+		assertTrue( constraint.isValid( BigInteger.valueOf( -10000000l ), null ) );
+		assertTrue( constraint.isValid( 10, null ) );
+		assertTrue( constraint.isValid( 14.99, null ) );
+		assertTrue( constraint.isValid( -14.99, null ) );
+		assertFalse( constraint.isValid( 20, null ) );
+		assertFalse( constraint.isValid( bWrapper, null ) );
+		assertFalse( constraint.isValid( BigDecimal.valueOf( 156000000000.0 ), null ) );
+		assertFalse( constraint.isValid( BigInteger.valueOf( 10000000l ), null ) );
+	}
+}

Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/MaxValidatorForStringTest.java (from rev 16755, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForStringTest.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/MaxValidatorForStringTest.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/MaxValidatorForStringTest.java	2009-06-11 10:23:04 UTC (rev 16758)
@@ -0,0 +1,60 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.constraints.impl;
+
+import javax.validation.constraints.Max;
+
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
+import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
+
+/**
+ * @author Alaa Nassef
+ */
+public class MaxValidatorForStringTest {
+
+	private static MaxValidatorForString constraint;
+
+	@BeforeClass
+	public static void init() {
+		AnnotationDescriptor<Max> descriptor = new AnnotationDescriptor<Max>( Max.class );
+		descriptor.setValue( "value", 15l );
+		descriptor.setValue( "message", "{validator.max}" );
+		Max m = AnnotationFactory.create( descriptor );
+
+		constraint = new MaxValidatorForString();
+		constraint.initialize( m );
+	}
+
+	@Test
+	public void testIsValid() {
+		assertTrue( constraint.isValid( null, null ) );
+		assertTrue( constraint.isValid( "15", null ) );
+		assertTrue( constraint.isValid( "15.0", null ) );
+		assertTrue( constraint.isValid( "10", null ) );
+		assertTrue( constraint.isValid( "14.99", null ) );
+		assertTrue( constraint.isValid( "-14.99", null ) );
+		assertFalse( constraint.isValid( "20", null ) );
+		//number format exception
+		assertFalse( constraint.isValid( "15l", null ) );
+	}
+}

Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/MinValidatorForNumberTest.java (from rev 16755, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForNumberTest.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/MinValidatorForNumberTest.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/MinValidatorForNumberTest.java	2009-06-11 10:23:04 UTC (rev 16758)
@@ -0,0 +1,70 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.constraints.impl;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import javax.validation.constraints.Min;
+
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
+import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
+
+/**
+ * @author Alaa Nassef
+ * @author Hardy Ferentschik
+ */
+public class MinValidatorForNumberTest {
+
+	private static MinValidatorForNumber constraint;
+
+	@BeforeClass
+	public static void init() {
+		AnnotationDescriptor<Min> descriptor = new AnnotationDescriptor<Min>( Min.class );
+		descriptor.setValue( "value", 15l );
+		descriptor.setValue( "message", "{validator.min}" );
+		Min m = AnnotationFactory.create( descriptor );
+
+		constraint = new MinValidatorForNumber();
+		constraint.initialize( m );
+	}
+
+	@Test
+	public void testIsValid() {
+		byte b = 1;
+		Byte bWrapper = 127;
+		assertTrue( constraint.isValid( null, null ) );
+		assertTrue( constraint.isValid( bWrapper, null ) );
+		assertTrue( constraint.isValid( 20, null ) );
+		assertTrue( constraint.isValid( 15l, null ) );
+		assertTrue( constraint.isValid( 15, null ) );
+		assertTrue( constraint.isValid( 15.0, null ) );
+		assertTrue( constraint.isValid( BigDecimal.valueOf( 156000000000.0 ), null ) );
+		assertTrue( constraint.isValid( BigInteger.valueOf( 10000000l ), null ) );
+		assertFalse( constraint.isValid( b, null ) );
+		assertFalse( constraint.isValid( BigDecimal.valueOf( -156000000000.0 ), null ) );
+		assertFalse( constraint.isValid( BigInteger.valueOf( -10000000l ), null ) );
+		assertFalse( constraint.isValid( 10, null ) );
+		assertFalse( constraint.isValid( 14.99, null ) );
+		assertFalse( constraint.isValid( -14.99, null ) );
+	}
+}

Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/MinValidatorForStringTest.java (from rev 16755, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForStringTest.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/MinValidatorForStringTest.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/MinValidatorForStringTest.java	2009-06-11 10:23:04 UTC (rev 16758)
@@ -0,0 +1,61 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.constraints.impl;
+
+import javax.validation.constraints.Min;
+
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
+import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
+
+/**
+ * @author Alaa Nassef
+ */
+public class MinValidatorForStringTest {
+
+	private static MinValidatorForString constraint;
+
+	@BeforeClass
+	public static void init() {
+		AnnotationDescriptor<Min> descriptor = new AnnotationDescriptor<Min>( Min.class );
+		descriptor.setValue( "value", 15l );
+		descriptor.setValue( "message", "{validator.min}" );
+		Min m = AnnotationFactory.create( descriptor );
+
+		constraint = new MinValidatorForString();
+		constraint.initialize( m );
+	}
+
+	@Test
+	public void testIsValid() {
+		assertTrue( constraint.isValid( null, null ) );
+		assertTrue( constraint.isValid( "20", null ) );
+		assertTrue( constraint.isValid( "15", null ) );
+		assertTrue( constraint.isValid( "15.0", null ) );
+		assertFalse( constraint.isValid( "10", null ) );
+		assertFalse( constraint.isValid( "14.99", null ) );
+		assertFalse( constraint.isValid( "-14.99", null ) );
+		//number format exception
+		assertFalse( constraint.isValid( "15l", null ) );
+	}
+
+}

Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/NotNullValidatorTest.java (from rev 16755, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotNullValidatorTest.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/NotNullValidatorTest.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/NotNullValidatorTest.java	2009-06-11 10:23:04 UTC (rev 16758)
@@ -0,0 +1,36 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,  
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.constraints.impl;
+
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class NotNullValidatorTest {
+
+	@Test
+	public void testIsValid() {
+		NotNullValidator constraint = new NotNullValidator();
+
+		assertFalse( constraint.isValid( null, null ) );
+		assertTrue( constraint.isValid( new Object(), null ) );
+	}
+}

Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/NullValidatorTest.java (from rev 16755, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NullValidatorTest.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/NullValidatorTest.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/NullValidatorTest.java	2009-06-11 10:23:04 UTC (rev 16758)
@@ -0,0 +1,42 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.constraints.impl;
+
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * @author Alaa Nassef
+ */
+public class NullValidatorTest {
+
+	private static NullValidator constraint;
+
+	@BeforeClass
+	public static void init() {
+		constraint = new NullValidator();
+	}
+
+	@Test
+	public void testIsValid() {
+		assertTrue( constraint.isValid( null, null ) );
+		assertFalse( constraint.isValid( new Object(), null ) );
+	}
+}

Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/PastValidatorForCalendarTest.java (from rev 16755, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PastValidatorForCalendarTest.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/PastValidatorForCalendarTest.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/PastValidatorForCalendarTest.java	2009-06-11 10:23:04 UTC (rev 16758)
@@ -0,0 +1,64 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.constraints.impl;
+
+import java.util.Calendar;
+
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import org.hibernate.validation.constraints.impl.PastValidatorForCalendar;
+
+/**
+ * @author Alaa Nassef
+ * @author Hardy Ferentschik
+ */
+public class PastValidatorForCalendarTest {
+
+	private static PastValidatorForCalendar constraint;
+
+	@BeforeClass
+	public static void init() {
+		constraint = new PastValidatorForCalendar();
+	}
+
+	@Test
+	public void testIsValid() {
+		Calendar futureDate = getFutureDate();
+		Calendar pastDate = getPastDate();
+		assertTrue( constraint.isValid( null, null ) );
+		assertTrue( constraint.isValid( pastDate, null ) );
+		assertFalse( constraint.isValid( futureDate, null ) );
+	}
+
+	private Calendar getFutureDate() {
+		Calendar cal = Calendar.getInstance();
+		int year = cal.get( Calendar.YEAR );
+		cal.set( Calendar.YEAR, year + 1 );
+		return cal;
+	}
+
+	private Calendar getPastDate() {
+		Calendar cal = Calendar.getInstance();
+		int year = cal.get( Calendar.YEAR );
+		cal.set( Calendar.YEAR, year - 1 );
+		return cal;
+	}
+}

Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/PastValidatorForDateTest.java (from rev 16755, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PastValidatorForDateTest.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/PastValidatorForDateTest.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/PastValidatorForDateTest.java	2009-06-11 10:23:04 UTC (rev 16758)
@@ -0,0 +1,60 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.constraints.impl;
+
+import java.util.Date;
+
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public class PastValidatorForDateTest {
+
+	private static PastValidatorForDate constraint;
+
+	@BeforeClass
+	public static void init() {
+		constraint = new PastValidatorForDate();
+	}
+
+	@Test
+	public void testIsValid() {
+		Date futureDate = getFutureDate();
+		Date pastDate = getPastDate();
+		assertTrue( constraint.isValid( null, null ) );
+		assertTrue( constraint.isValid( pastDate, null ) );
+		assertFalse( constraint.isValid( new Date(), null ) );
+		assertFalse( constraint.isValid( futureDate, null ) );
+	}
+
+	private Date getFutureDate() {
+		Date date = new Date();
+		long timeStamp = date.getTime();
+		date.setTime( timeStamp + 31557600000l );
+		return date;
+	}
+
+	private Date getPastDate() {
+		Date date = new Date();
+		long timeStamp = date.getTime();
+		date.setTime( timeStamp - 31557600000l );
+		return date;
+	}
+
+}

Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/PatternValidatorTest.java (from rev 16755, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PatternValidatorTest.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/PatternValidatorTest.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/impl/PatternValidatorTest.java	2009-06-11 10:23:04 UTC (rev 16758)
@@ -0,0 +1,61 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,  
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.constraints.impl;
+
+import javax.validation.ValidationException;
+import javax.validation.constraints.Pattern;
+
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
+
+import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
+import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class PatternValidatorTest {
+
+	@Test
+	public void testIsValid() {
+		AnnotationDescriptor<Pattern> descriptor = new AnnotationDescriptor<Pattern>( Pattern.class );
+		descriptor.setValue( "regexp", "foobar" );
+		descriptor.setValue( "message", "{validator.pattern}" );
+		Pattern p = AnnotationFactory.create( descriptor );
+
+		PatternValidator constraint = new PatternValidator();
+		constraint.initialize( p );
+
+		assertTrue( constraint.isValid( null, null ) );
+		assertFalse( constraint.isValid( "", null ) );
+		assertFalse( constraint.isValid( "bla bla", null ) );
+		assertFalse( constraint.isValid( "This test is not foobar", null ) );
+	}
+
+	@Test(expectedExceptions = ValidationException.class)
+	public void testInvalidRegularExpression() {
+		AnnotationDescriptor<Pattern> descriptor = new AnnotationDescriptor<Pattern>( Pattern.class );
+		descriptor.setValue( "regexp", "(unbalanced parentheses" );
+		descriptor.setValue( "message", "{validator.pattern}" );
+		Pattern p = AnnotationFactory.create( descriptor );
+
+		PatternValidator constraint = new PatternValidator();
+		constraint.initialize( p );
+	}
+}




More information about the hibernate-commits mailing list