Hibernate SVN: r16834 - validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-06-18 12:25:46 -0400 (Thu, 18 Jun 2009)
New Revision: 16834
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/PatternValidator.java
Log:
throw the right exception in case the provided regular expression pattern is not valid.
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/PatternValidator.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/PatternValidator.java 2009-06-18 16:25:06 UTC (rev 16833)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/PatternValidator.java 2009-06-18 16:25:46 UTC (rev 16834)
@@ -19,9 +19,9 @@
import java.util.regex.Matcher;
import java.util.regex.PatternSyntaxException;
+import javax.validation.ConstraintDeclarationException;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
-import javax.validation.ValidationException;
import javax.validation.constraints.Pattern;
/**
@@ -42,7 +42,7 @@
pattern = java.util.regex.Pattern.compile( parameters.regexp(), intFlag );
}
catch ( PatternSyntaxException e ) {
- throw new ValidationException( "Invalid regular expression.", e );
+ throw new ConstraintDeclarationException( "Invalid regular expression.", e );
}
}
15 years, 5 months
Hibernate SVN: r16833 - validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-06-18 12:25:06 -0400 (Thu, 18 Jun 2009)
New Revision: 16833
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintTree.java
Log:
Made sure an unexpected RuntimeException in ConstraintValidator.isValid is wrapped into a ValidationException
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintTree.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintTree.java 2009-06-18 16:22:31 UTC (rev 16832)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintTree.java 2009-06-18 16:25:06 UTC (rev 16833)
@@ -24,20 +24,18 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import javax.validation.metadata.ConstraintDescriptor;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorFactory;
import javax.validation.ConstraintViolation;
import javax.validation.UnexpectedTypeException;
import javax.validation.ValidationException;
+import javax.validation.metadata.ConstraintDescriptor;
import com.googlecode.jtype.TypeUtils;
import org.slf4j.Logger;
import org.hibernate.validation.util.LoggerFactory;
import org.hibernate.validation.util.ValidatorTypeHelper;
-import org.hibernate.validation.engine.ExecutionContext;
-import org.hibernate.validation.engine.ConstraintValidatorContextImpl;
/**
* Due to constraint conposition a single constraint annotation can lead to a whole constraint tree beeing validated.
@@ -127,13 +125,9 @@
value, type, executionContext.getConstraintValidatorFactory()
);
- if ( !validator.isValid( value, constraintValidatorContext ) ) {
- constraintViolations.addAll(
- executionContext.createConstraintViolations(
- value, constraintValidatorContext
- )
- );
- }
+ validateSingleConstraint(
+ value, executionContext, constraintViolations, constraintValidatorContext, validator
+ );
}
if ( reportAsSingleViolation() && constraintViolations.size() > 0 ) {
@@ -147,6 +141,23 @@
}
}
+ private <T, V> void validateSingleConstraint(V value, ExecutionContext<T> executionContext, List<ConstraintViolation<T>> constraintViolations, ConstraintValidatorContextImpl constraintValidatorContext, ConstraintValidator<A, V> validator) {
+ boolean isValid;
+ try {
+ isValid = validator.isValid( value, constraintValidatorContext );
+ }
+ catch ( RuntimeException e ) {
+ throw new ValidationException( "Unexpected exception during isValid call", e );
+ }
+ if ( !isValid ) {
+ constraintViolations.addAll(
+ executionContext.createConstraintViolations(
+ value, constraintValidatorContext
+ )
+ );
+ }
+ }
+
private boolean reportAsSingleViolation() {
return getParent() != null
&& getParent().getDescriptor().isReportAsSingleViolation();
15 years, 5 months
Hibernate SVN: r16832 - in beanvalidation/trunk/validation-tck/src/main: java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-06-18 12:22:31 -0400 (Thu, 18 Jun 2009)
New Revision: 16832
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/Negative.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/NegativeConstraintValidator.java
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/BoundariesConstraintValidator.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/CustomConstraintValidatorTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/PositiveConstraintValidator.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/ValidatorResolutionTest.java
beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
Log:
Adding TCK test mappings for basic validation routine
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/BoundariesConstraintValidator.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/BoundariesConstraintValidator.java 2009-06-18 14:24:56 UTC (rev 16831)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/BoundariesConstraintValidator.java 2009-06-18 16:22:31 UTC (rev 16832)
@@ -20,20 +20,39 @@
import java.lang.annotation.Annotation;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
+import javax.validation.ValidationException;
/**
* @author Emmanuel Bernard
*/
public abstract class BoundariesConstraintValidator<T extends Annotation> implements ConstraintValidator<T, Integer> {
+ public static boolean initializeCalled = false;
+ public static int isValidCalls = 0;
+ public static boolean throwRuntimeExceptionFromInitalize = false;
+ public static boolean throwRuntimeExceptionFromIsValid = false;
+
private int low;
private int high;
protected void initialize(int low, int high) {
+ initializeCalled = true;
+ if ( throwRuntimeExceptionFromInitalize ) {
+ throwRuntimeExceptionFromInitalize = false;
+ throw new RuntimeException( "Throwing a RuntimeException from BoundariesConstraintValidator.initialize" );
+ }
this.low = low;
this.high = high;
}
public boolean isValid(Integer value, ConstraintValidatorContext constraintValidatorContext) {
+ if ( !initializeCalled ) {
+ throw new ValidationException( "initialize() must be called before the usage of isValid()" );
+ }
+ if ( throwRuntimeExceptionFromIsValid ) {
+ throwRuntimeExceptionFromIsValid = false;
+ throw new RuntimeException( "Throwing a RuntimeException from BoundariesConstraintValidator.isValid" );
+ }
+ isValidCalls++;
return value >= low && value <= high;
}
}
\ No newline at end of file
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/CustomConstraintValidatorTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/CustomConstraintValidatorTest.java 2009-06-18 14:24:56 UTC (rev 16831)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/CustomConstraintValidatorTest.java 2009-06-18 16:22:31 UTC (rev 16832)
@@ -18,17 +18,22 @@
package org.hibernate.jsr303.tck.tests.constraints.customconstraint;
import java.util.Set;
-import javax.validation.Validation;
+import javax.validation.ConstraintViolation;
+import javax.validation.UnexpectedTypeException;
+import javax.validation.ValidationException;
import javax.validation.Validator;
-import javax.validation.ConstraintViolation;
import javax.validation.metadata.PropertyDescriptor;
-import org.testng.annotations.Test;
-import static org.testng.Assert.*;
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecAssertions;
+import org.jboss.testharness.AbstractTest;
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.ArtifactType;
import org.jboss.testharness.impl.packaging.Classes;
-import org.jboss.testharness.AbstractTest;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
import org.hibernate.jsr303.tck.util.TestUtil;
@@ -40,18 +45,108 @@
public class CustomConstraintValidatorTest extends AbstractTest {
@Test
- public void testInheritedConstraintValidationImpl() {
- Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
- Phone p = new Phone();
- p.size = -2;
- final PropertyDescriptor propertyDescriptor = validator.getConstraintsForClass( Phone.class )
+ @SpecAssertions({
+ @SpecAssertion(section = "2.4", id = "a"),
+ @SpecAssertion(section = "2.4", id = "b"),
+ @SpecAssertion(section = "2.4", id = "e")
+ })
+ public void testRightValidatorIsSlectedAndInializedCalled() {
+ Validator validator = TestUtil.getDefaultValidator();
+ Shoe shoe = new Shoe();
+ shoe.size = -2;
+ final PropertyDescriptor propertyDescriptor = validator.getConstraintsForClass( Shoe.class )
.getConstraintsForProperty( "size" );
assertNotNull( propertyDescriptor );
- final Set<ConstraintViolation<Phone>> constraintViolations = validator.validate( p );
+
+ BoundariesConstraintValidator.isValidCalls = 0;
+ final Set<ConstraintViolation<Shoe>> constraintViolations = validator.validate( shoe );
assertEquals( 1, constraintViolations.size() );
+ assertTrue(
+ BoundariesConstraintValidator.isValidCalls == 1,
+ "Ensure the right validator implementation class was picked."
+ );
+ assertTrue(
+ BoundariesConstraintValidator.initializeCalled,
+ "Check initilize was called. Note this is not really ensuring that it was called before isValid. That is done in the actual implementation of the validator."
+ );
}
- public static class Phone {
- @Positive public int size;
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "2.4", id = "a"),
+ @SpecAssertion(section = "2.4", id = "b"),
+ @SpecAssertion(section = "2.4", id = "f")
+ })
+ public void testIsValidIsCalledForEachValidation() {
+ Validator validator = TestUtil.getDefaultValidator();
+ Shoe shoe = new Shoe();
+ shoe.size = -2;
+
+ BoundariesConstraintValidator.isValidCalls = 0;
+ validator.validate( shoe );
+ assertTrue(
+ BoundariesConstraintValidator.isValidCalls == 1,
+ "Ensure is valid hasbeen called."
+ );
+
+ validator.validate( shoe );
+ assertTrue(
+ BoundariesConstraintValidator.isValidCalls == 2,
+ "Ensure is valid hasbeen called."
+ );
+
+ validator.validateProperty( shoe, "size" );
+ assertTrue(
+ BoundariesConstraintValidator.isValidCalls == 3,
+ "Ensure is valid hasbeen called."
+ );
+
+ validator.validateValue( Shoe.class, "size", 41 );
+ assertTrue(
+ BoundariesConstraintValidator.isValidCalls == 4,
+ "Ensure is valid hasbeen called."
+ );
}
+
+
+ @SpecAssertion(section = "2.4", id = "i")
+ @Test(expectedExceptions = UnexpectedTypeException.class)
+ public void testUnexpectedTypeExceptionIsRaisedForInvalidType() {
+ Validator validator = TestUtil.getDefaultValidator();
+ validator.validate( new OddShoe() );
+ }
+
+ @SpecAssertion(section = "2.4", id = "j")
+ @Test(expectedExceptions = ValidationException.class)
+ public void testRuntimeExceptionFromIsValidIsWrapped() {
+ Validator validator = TestUtil.getDefaultValidator();
+ Shoe shoe = new Shoe();
+ shoe.size = -2;
+ BoundariesConstraintValidator.throwRuntimeExceptionFromIsValid = true;
+ validator.validate( shoe );
+ }
+
+ @SpecAssertion(section = "2.4", id = "j")
+ @Test(expectedExceptions = ValidationException.class)
+ public void testRuntimeExceptionFromInitializeIsWrapped() {
+ Validator validator = TestUtil.getDefaultValidator();
+ validator.validate( new Freezer() );
+ }
+
+ public static class Shoe {
+ @Positive
+ public int size;
+ }
+
+ public static class OddShoe {
+ @Positive
+ public String size;
+ }
+
+ public static class Freezer {
+ @Negative
+ public int temprature;
+ }
+
+
}
\ No newline at end of file
Copied: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/Negative.java (from rev 16812, beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/Positive.java)
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/Negative.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/Negative.java 2009-06-18 16:22:31 UTC (rev 16832)
@@ -0,0 +1,39 @@
+// $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.jsr303.tck.tests.constraints.customconstraint;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Documented;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import javax.validation.Constraint;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Constraint( validatedBy = { PositiveConstraintValidator.class })
+@Target({ METHOD, FIELD, ANNOTATION_TYPE })
+@Retention(RUNTIME)
+@Documented
+public @interface Negative {
+ public abstract String message() default "{validation.negative}";
+ public abstract Class<?>[] groups() default {};
+}
\ No newline at end of file
Copied: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/NegativeConstraintValidator.java (from rev 16812, beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/BoundariesConstraintValidator.java)
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/NegativeConstraintValidator.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/NegativeConstraintValidator.java 2009-06-18 16:22:31 UTC (rev 16832)
@@ -0,0 +1,35 @@
+// $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.jsr303.tck.tests.constraints.customconstraint;
+
+import java.lang.annotation.Annotation;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public abstract class NegativeConstraintValidator implements ConstraintValidator<Negative, Integer> {
+ protected void initialize(int low, int high) {
+ throw new RuntimeException( "Throwing a RuntimeException from NegativeConstraintValidator.initialize" );
+ }
+
+ public boolean isValid(Integer value, ConstraintValidatorContext constraintValidatorContext) {
+ return true;
+ }
+}
\ No newline at end of file
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/PositiveConstraintValidator.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/PositiveConstraintValidator.java 2009-06-18 14:24:56 UTC (rev 16831)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/PositiveConstraintValidator.java 2009-06-18 16:22:31 UTC (rev 16832)
@@ -20,7 +20,7 @@
/**
* @author Emmanuel Bernard
*/
-public class PositiveConstraintValidator extends BoundariesConstraintValidator<Positive> {
+public class PositiveConstraintValidator extends BoundariesConstraintValidator<Positive> {
public void initialize(Positive constraintAnnotation) {
super.initialize( 0, Integer.MAX_VALUE );
}
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/ValidatorResolutionTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/ValidatorResolutionTest.java 2009-06-18 14:24:56 UTC (rev 16831)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/ValidatorResolutionTest.java 2009-06-18 16:22:31 UTC (rev 16832)
@@ -49,7 +49,8 @@
@Test
@SpecAssertions({
@SpecAssertion(section = "3.5.3", id = "e"),
- @SpecAssertion(section = "2.1", id = "d")
+ @SpecAssertion(section = "2.1", id = "d"),
+ @SpecAssertion(section = "2.4", id = "i")
})
public void testUnexpectedTypeInValidatorResolution() {
Validator validator = TestUtil.getDefaultValidator();
Modified: beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-06-18 14:24:56 UTC (rev 16831)
+++ beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-06-18 16:22:31 UTC (rev 16832)
@@ -135,11 +135,11 @@
<text>The implementation classes are specified by the validatedBy element of the
@Contraint annotation that decorates the constraint definition</text>
</assertion>
- <assertion id="c">
+ <assertion id="c" testable="false">
<text>The constraint validation implementation implements the ConstraintValidator
interface</text>
</assertion>
- <assertion id="d">
+ <assertion id="d" testable="false">
<text>T must resolve in a non parameterized type or generic parameters of T must be
unbounded wildcard types</text>
</assertion>
@@ -151,34 +151,33 @@
<text>The isValid method is evaluated by the Bean Validation provider each time a given
value is validated</text>
</assertion>
- <assertion id="g">
+ <assertion id="g" testable="false">
<text>It returns false if the value is not valid, true otherwise</text>
</assertion>
<assertion id="h" testable="false">
<text>isValid implementations must be thread-safe</text>
</assertion>
<assertion id="i">
- <text>If the property is of an unanticipated type, an UnexpectedTypeException is
- raised</text>
+ <text>If the property is of an unanticipated type, an UnexpectedTypeException is raised</text>
</assertion>
<assertion id="j">
<text>If an exception occurs either in the initialize or isValid method, the runtime
- exception is wrapped into a Valid- ationException by the Bean Validation engine
+ exception is wrapped into a ValidationException by the Bean Validation engine
</text>
</assertion>
- <assertion id="k">
+ <assertion id="k" testable="false">
<text>The constraint validation implementation is not allowed to change the state of the
value passed to isValid. </text>
</assertion>
<assertion id="l">
<text>By default, each invalid constraint leads to the generation of one error object
represented by a ConstraintViolation object. This object is build from the default
- error message as defined by the constraint de- claration and the context in which
+ error message as defined by the constraint declaration and the context in which
the constraint declaration is placed on (bean, property, attribute)</text>
</assertion>
<assertion id="m">
<text>The ConstraintValidatorContext methods let the constraint implementation disable
- the default error object gen- eration and create one or more custom ones</text>
+ the default error object generation and create one or more custom ones</text>
</assertion>
<assertion id="n">
<text>The non-interpolated message passed as a parameter is used to build the
@@ -302,7 +301,7 @@
<text>A constraint declaration can be placed on an interface</text>
</assertion>
<assertion id="b">
- <text>For a given class, constraint declarations held on super- classes as well as
+ <text>For a given class, constraint declarations held on superclasses as well as
interfaces are evaluated by the Bean Validation provider</text>
</assertion>
</section>
@@ -379,7 +378,7 @@
</section>
<section id="3.4.3" title="Redefining the Default group for a class">
<assertion id="a">
- <text>To redefine Default for a class, place a @GroupSequence annotation on the class.
+ <text>To redefine Default for a class, place a @GroupSequence annotation on the class.
this sequence expresses the sequence of groups that does substitute Default for this
class.</text>
</assertion>
@@ -1170,7 +1169,7 @@
</assertion>
</section>
<section id="8.3" title="ConstraintDeclarationException and UnexpectedTypeException">
- <assertion id="a">
+ <assertion id="a" testable="false">
<text>When a constraint declaration is illegal, ConstraintDeclarationException is
raised</text>
</assertion>
15 years, 5 months
Hibernate SVN: r16831 - validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-06-18 10:24:56 -0400 (Thu, 18 Jun 2009)
New Revision: 16831
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/GroupChainGenerator.java
Log:
Fixed an error message and made sure the right exception is thrown in case a cyclic group depency is detected
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/GroupChainGenerator.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/GroupChainGenerator.java 2009-06-18 14:23:51 UTC (rev 16830)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/GroupChainGenerator.java 2009-06-18 14:24:56 UTC (rev 16831)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
@@ -24,6 +24,7 @@
import java.util.Map;
import javax.validation.GroupSequence;
import javax.validation.ValidationException;
+import javax.validation.GroupDefinitionException;
/**
* Used to determine the execution order.
@@ -41,7 +42,7 @@
for ( Class<?> clazz : groups ) {
if ( !clazz.isInterface() ) {
- throw new ValidationException( "A groups has to be an interface. " + clazz.getName() + " is not." );
+ throw new ValidationException( "A group has to be an interface. " + clazz.getName() + " is not." );
}
}
@@ -81,7 +82,7 @@
private List<Group> resolveSequence(Class<?> group, List<Class<?>> processedSequences) {
if ( processedSequences.contains( group ) ) {
- throw new ValidationException( "Cyclic dependecy in groups definition" );
+ throw new GroupDefinitionException( "Cyclic dependency in groups definition" );
}
else {
processedSequences.add( group );
15 years, 5 months
Hibernate SVN: r16830 - in beanvalidation/trunk/validation-tck/src/main: java/org/hibernate/jsr303/tck/tests/constraints/groups and 3 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-06-18 10:23:51 -0400 (Thu, 18 Jun 2009)
New Revision: 16830
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/DefaultGroupRedefinitionTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/ConstraintInheritanceTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/Fubar.java
Removed:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Billable.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/BuyInOneClick.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Optional.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/InheritanceTest.java
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider/BootstrapTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Address.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/GroupTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/User.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/Bar.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/ValidatorResolutionTest.java
beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
Log:
Started mapping group tests to audit file
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider/BootstrapTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider/BootstrapTest.java 2009-06-18 00:29:12 UTC (rev 16829)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider/BootstrapTest.java 2009-06-18 14:23:51 UTC (rev 16830)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
@@ -121,7 +121,6 @@
@Test
public void testCustomMessageInterpolatorViaConfiguration() {
- // create a configurtation with a custom message interpolator
Configuration<?> configuration = Validation.byDefaultProvider().configure();
configuration.messageInterpolator( new DummyMessageInterpolator() );
@@ -136,7 +135,6 @@
@SpecAssertion(section = "4.3.2", id = "b")
})
public void testCustomMessageInterpolatorViaValidatorContext() {
- // create a configurtation with a custom message interpolator
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
DummyMessageInterpolator dummyMessageInterpolator = new DummyMessageInterpolator();
Validator validator = factory.usingContext().messageInterpolator( dummyMessageInterpolator ).getValidator();
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Address.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Address.java 2009-06-18 00:29:12 UTC (rev 16829)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Address.java 2009-06-18 14:23:51 UTC (rev 16830)
@@ -11,16 +11,16 @@
@GroupSequence({ Address.class, Address.HighLevelCoherence.class })
@ZipCodeCoherenceChecker(groups = Address.HighLevelCoherence.class)
public class Address {
- @NotNull
- @Size(max = 50)
+ @NotNull(groups = Default.class)
+ @Size(max = 50, message = "Streetnames cannot have more than {max} characters.")
private String street;
- @NotNull
- @Size(max = 5)
+ @NotNull(groups = Default.class)
+ @Size(max = 5, message = "Zipcode cannot have more than {max} characters.")
private String zipcode;
- @NotNull
- @Size(max = 30)
+ @NotNull(groups = Default.class)
+ @Size(max = 30, message = "City cannot have more than {max} characters.")
private String city;
public String getStreet() {
Deleted: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Billable.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Billable.java 2009-06-18 00:29:12 UTC (rev 16829)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Billable.java 2009-06-18 14:23:51 UTC (rev 16830)
@@ -1,9 +0,0 @@
-package org.hibernate.jsr303.tck.tests.constraints.groups;
-
-/**
- * Validation group checking whether user is billable.
- *
- * @author Emmanuel Bernard
- */
-public interface Billable {
-}
\ No newline at end of file
Deleted: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/BuyInOneClick.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/BuyInOneClick.java 2009-06-18 00:29:12 UTC (rev 16829)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/BuyInOneClick.java 2009-06-18 14:23:51 UTC (rev 16830)
@@ -1,11 +0,0 @@
-package org.hibernate.jsr303.tck.tests.constraints.groups;
-
-import javax.validation.groups.Default;
-
-/**
- * Customer can buy without being harrassed by the checking-out process.
- *
- * @author Emmanuel Bernard
- */
-public interface BuyInOneClick extends Default, Billable {
-}
\ No newline at end of file
Copied: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/DefaultGroupRedefinitionTest.java (from rev 16812, beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/GroupTest.java)
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/DefaultGroupRedefinitionTest.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/DefaultGroupRedefinitionTest.java 2009-06-18 14:23:51 UTC (rev 16830)
@@ -0,0 +1,174 @@
+// $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.jsr303.tck.tests.constraints.groups;
+
+import java.lang.annotation.Annotation;
+import java.util.Set;
+import javax.validation.ConstraintViolation;
+import javax.validation.ValidationException;
+import javax.validation.Validator;
+import javax.validation.constraints.NotNull;
+import javax.validation.groups.Default;
+import javax.validation.metadata.BeanDescriptor;
+
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.testharness.AbstractTest;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.ArtifactType;
+import org.jboss.testharness.impl.packaging.Classes;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+import org.testng.annotations.Test;
+
+import org.hibernate.jsr303.tck.util.TestUtil;
+
+/**
+ * Tests for the group and group sequence feature.
+ *
+ * @author Hardy Ferentschik
+ */
+@Artifact(artifactType = ArtifactType.JSR303)
+(a)Classes(TestUtil.class)
+public class DefaultGroupRedefinitionTest extends AbstractTest {
+
+ @Test
+ @SpecAssertion(section = "3.4.3", id = "a")
+ public void testRedefiningDefaultGroup() {
+ Address address = new Address();
+ address.setStreet( "Guldmyntgatan" );
+ address.setCity( "Gothenborg" );
+
+ Validator validator = TestUtil.getDefaultValidator();
+
+ Set<ConstraintViolation<Address>> constraintViolations = validator.validate( address );
+ assertEquals(
+ constraintViolations.size(),
+ 1,
+ "There should only be one violation for zipcode"
+ );
+
+ ConstraintViolation<Address> violation = constraintViolations.iterator().next();
+ TestUtil.assertConstraintViolation( violation, Address.class, null, "zipcode" );
+
+ address.setZipcode( "41841" );
+
+ // now the second group in the re-defined default group causes an error
+ constraintViolations = validator.validate( address );
+ assertEquals(
+ constraintViolations.size(),
+ 1,
+ "There should only be one violation for zipcode"
+ );
+
+ violation = constraintViolations.iterator().next();
+ TestUtil.assertConstraintViolation( violation, Address.class, address, "" );
+ }
+
+ @Test(enabled = false)
+ @SpecAssertion(section = "3.4.3", id = "b")
+ public void testConstraintsHostedOnEntityZBelongToGroupZ() {
+ Validator validator = TestUtil.getDefaultValidator();
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Address.class );
+ assertTrue( beanDescriptor.isBeanConstrained() );
+
+ Address address = new Address();
+ Set<ConstraintViolation<Address>> violations = validator.validate( address );
+ assertTrue( violations.size() == 3, "All 3 @NotNull constraints should fail." );
+ assertAssertionType( violations );
+
+ violations = validator.validate( address, Default.class );
+ assertTrue( violations.size() == 3, "All 3 @NotNull constraints should fail." );
+ assertAssertionType( violations );
+
+ violations = validator.validate( address, Address.class );
+ assertTrue( violations.size() == 3, "All 3 @NotNull constraints should fail." );
+ assertAssertionType( violations );
+ }
+
+ @Test
+ public void testRedefiningDefaultGroup2() {
+ Car car = new Car();
+ car.setType( "A" );
+
+ Validator validator = TestUtil.getDefaultValidator();
+
+ Set<ConstraintViolation<Car>> constraintViolations = validator.validate( car );
+ assertEquals(
+ constraintViolations.size(),
+ 1,
+ "There should be one violations due to the re-defintion of the default group"
+ );
+ assertEquals(
+ "size must be between 2 and 20",
+ constraintViolations.iterator().next().getMessage(),
+ "Wrong constraint"
+ );
+
+ constraintViolations = validator.validateProperty( car, "type" );
+ assertEquals(
+ constraintViolations.size(),
+ 1,
+ "There should be one violations due to the re-defintion of the default group"
+ );
+ assertEquals(
+ "size must be between 2 and 20",
+ constraintViolations.iterator().next().getMessage(),
+ "Wrong constraint"
+ );
+
+ constraintViolations = validator.validateValue( Car.class, "type", "A" );
+ assertEquals(
+ constraintViolations.size(),
+ 1,
+ "There should be one violations due to the re-defintion of the default group"
+ );
+ assertEquals(
+ "size must be between 2 and 20",
+ constraintViolations.iterator().next().getMessage(),
+ "Wrong constraint"
+ );
+ }
+
+ @Test
+ public void testInvalidRedefinitionOfDefaultGroup() {
+ Address address = new AddressWithInvalidGroupSequence();
+ Validator validator = TestUtil.getDefaultValidator();
+ try {
+ validator.validate( address );
+ fail( "It shoud not be allowed to have Default.class in the group sequence of a class." );
+ }
+ catch ( ValidationException e ) {
+ assertEquals(
+ "'Default.class' cannot appear in default group sequence list.", e.getMessage(), "Wrong message"
+ );
+ }
+ }
+
+ private void assertAssertionType(Set<ConstraintViolation<Address>> violations) {
+ for ( ConstraintViolation<Address> violation : violations ) {
+ // cast is required for JDK 5 - at least on Mac OS X
+ Annotation ann = (Annotation) violation.getConstraintDescriptor().getAnnotation();
+ assertEquals(
+ NotNull.class,
+ ann.annotationType(),
+ "Wrong assertion type"
+ );
+ }
+ }
+}
\ No newline at end of file
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/GroupTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/GroupTest.java 2009-06-18 00:29:12 UTC (rev 16829)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/GroupTest.java 2009-06-18 14:23:51 UTC (rev 16830)
@@ -19,24 +19,26 @@
import java.util.Set;
import javax.validation.ConstraintViolation;
-import javax.validation.ValidationException;
+import javax.validation.GroupDefinitionException;
import javax.validation.Validator;
import javax.validation.groups.Default;
import javax.validation.metadata.BeanDescriptor;
+import javax.validation.metadata.ConstraintDescriptor;
import javax.validation.metadata.PropertyDescriptor;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
-import org.testng.annotations.Test;
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecAssertions;
import org.jboss.testharness.AbstractTest;
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.ArtifactType;
import org.jboss.testharness.impl.packaging.Classes;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+import org.testng.annotations.Test;
import org.hibernate.jsr303.tck.util.TestUtil;
-
/**
* Tests for the group and group sequence feature.
*
@@ -47,6 +49,115 @@
public class GroupTest extends AbstractTest {
@Test
+ @SpecAssertion(section = "3.4", id = "a")
+ public void testConstraintWithNoExplicitlySpecifiedGroupBelongsToDefault() {
+ Validator validator = TestUtil.getDefaultValidator();
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( User.class );
+ assertTrue( beanDescriptor.isBeanConstrained() );
+
+ PropertyDescriptor propDesc = beanDescriptor.getConstraintsForProperty( "firstname" );
+ assertTrue( propDesc.getConstraintDescriptors().size() == 1 );
+
+ ConstraintDescriptor descriptor = propDesc.getConstraintDescriptors().iterator().next();
+ assertTrue( descriptor.getGroups().size() == 1 );
+ assertEquals(
+ descriptor.getGroups().iterator().next(),
+ Default.class,
+ "Constraint should implicitly belong to the Default group."
+ );
+ }
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "3.4", id = "b"),
+ @SpecAssertion(section = "3.4", id = "d")
+ })
+ public void testValidateAgainstDifferentGroups() {
+ User user = new User();
+
+ // all fields per default null. Depending on the validation groups there should be a different amount
+ // of constraint failures.
+ Validator validator = TestUtil.getDefaultValidator();
+
+ Set<ConstraintViolation<User>> constraintViolations = validator.validate( user );
+ assertEquals(
+ constraintViolations.size(),
+ 2,
+ "There should be two violations against the implicit default group"
+ );
+
+ constraintViolations = validator.validate( user, Default.class );
+ assertEquals(
+ constraintViolations.size(),
+ 2,
+ "There should be two violations against the explicit defualt group"
+ );
+
+ constraintViolations = validator.validate( user, User.Billable.class );
+ assertEquals(
+ constraintViolations.size(),
+ 1,
+ "There should be one violation against Billable"
+ );
+
+ constraintViolations = validator.validate( user, Default.class, User.Billable.class );
+ assertEquals(
+ constraintViolations.size(),
+ 3,
+ "There should be 3 violation against Default and Billable"
+ );
+
+ constraintViolations = validator.validate( user, User.BuyInOneClick.class );
+ assertEquals(
+ constraintViolations.size(),
+ 3,
+ "Three violations expected since BuyInOneClick extends Default and Billable"
+ );
+
+ constraintViolations = validator.validate( user, User.BuyInOneClick.class, User.Billable.class );
+ assertEquals(
+ constraintViolations.size(),
+ 3,
+ "BuyInOneClick already contains all other groups. Adding Billable does not change the number of violations"
+ );
+
+ constraintViolations = validator.validate( user, User.BuyInOneClick.class, Default.class );
+ assertEquals(
+ constraintViolations.size(),
+ 3,
+ "BuyInOneClick already contains all other groups. Adding Default does not change the number of violations"
+ );
+
+ constraintViolations = validator.validate( user, User.BuyInOneClick.class, Default.class, User.Billable.class );
+ assertEquals(
+ constraintViolations.size(),
+ 3,
+ "BuyInOneClick already contains all other groups. Adding Billable and Default does not change the number of violations"
+ );
+
+ constraintViolations = validator.validate( user, User.Billable.class, User.Billable.class );
+ assertEquals(
+ constraintViolations.size(),
+ 1,
+ "Adding the same group twice is still only leads to a single violation"
+ );
+ }
+
+ @Test
+ @SpecAssertion(section = "3.4", id = "c")
+ public void testConstraintCanBelongToMoreThanOneGroup() {
+ Validator validator = TestUtil.getDefaultValidator();
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( User.class );
+ assertTrue( beanDescriptor.isBeanConstrained() );
+
+ PropertyDescriptor propDesc = beanDescriptor.getConstraintsForProperty( "defaultCreditCard" );
+ assertTrue( propDesc.getConstraintDescriptors().size() == 1 );
+
+ ConstraintDescriptor descriptor = propDesc.getConstraintDescriptors().iterator().next();
+ assertTrue( descriptor.getGroups().size() == 2 );
+ }
+
+ @Test
public void testGroups() {
Validator validator = TestUtil.getDefaultValidator();
@@ -176,81 +287,6 @@
}
@Test
- public void testValidateAgainstDifferentGroups() {
- User user = new User();
-
- // all fields per default null. Depending on the validation groups there should be a different amount
- // of constraint failures.
- Validator validator = TestUtil.getDefaultValidator();
-
- Set<ConstraintViolation<User>> constraintViolations = validator.validate( user );
- assertEquals(
- constraintViolations.size(),
- 2,
- "There should be two violations against the implicit default group"
- );
-
- constraintViolations = validator.validate( user, Default.class );
- assertEquals(
- constraintViolations.size(),
- 2,
- "There should be two violations against the explicit defualt group"
- );
-
- constraintViolations = validator.validate( user, Billable.class );
- assertEquals(
- constraintViolations.size(),
- 1,
- "There should be one violation against Billable"
- );
-
- constraintViolations = validator.validate( user, Default.class, Billable.class );
- assertEquals(
- constraintViolations.size(),
- 3,
- "There should be 3 violation against Default and Billable"
- );
-
- constraintViolations = validator.validate( user, BuyInOneClick.class );
- assertEquals(
- constraintViolations.size(),
- 3,
- "Three violations expected since BuyInOneClick extends Default and Billable"
- );
-
- constraintViolations = validator.validate( user, BuyInOneClick.class, Billable.class );
- assertEquals(
- constraintViolations.size(),
- 3,
- "BuyInOneClick already contains all other groups. Adding Billable does not change the number of violations"
- );
-
- constraintViolations = validator.validate( user, BuyInOneClick.class, Default.class );
- assertEquals(
- constraintViolations.size(),
- 3,
- "BuyInOneClick already contains all other groups. Adding Default does not change the number of violations"
- );
-
- constraintViolations = validator.validate( user, BuyInOneClick.class, Default.class, Billable.class );
- assertEquals(
- constraintViolations.size(),
- 3,
- "BuyInOneClick already contains all other groups. Adding Billable and Default does not change the number of violations"
- );
-
- constraintViolations = validator.validate( user, Billable.class, Billable.class );
- assertEquals(
- constraintViolations.size(),
- 1,
- "Adding the same group twice is still only leads to a single violation"
- );
- }
-
- /**
- * HV-85
- */
- @Test
public void testGroupSequenceFollowedByGroup() {
User user = new User();
user.setFirstname( "Foo" );
@@ -260,7 +296,7 @@
Validator validator = TestUtil.getDefaultValidator();
Set<ConstraintViolation<User>> constraintViolations = validator.validate(
- user, BuyInOneClick.class, Optional.class
+ user, User.BuyInOneClick.class, User.Optional.class
);
assertEquals(
constraintViolations.size(),
@@ -291,124 +327,30 @@
}
}
- /**
- * HV-113
- */
@Test
- public void testRedefiningDefaultGroup() {
- Address address = new Address();
- address.setStreet( "Guldmyntgatan" );
- address.setCity( "Gothenborg" );
-
+ @SpecAssertion(section = "3.4.4", id = "a")
+ public void testImplicitGrouping() {
Validator validator = TestUtil.getDefaultValidator();
-
- Set<ConstraintViolation<Address>> constraintViolations = validator.validate( address );
- assertEquals(
- constraintViolations.size(),
- 1,
- "There should only be one violation for zipcode"
- );
-
- ConstraintViolation<Address> violation = constraintViolations.iterator().next();
- TestUtil.assertConstraintViolation( violation, Address.class, null, "zipcode" );
-
- address.setZipcode( "41841" );
-
- // now the second group in the re-defined default group causes an error
- constraintViolations = validator.validate( address );
- assertEquals(
- constraintViolations.size(),
- 1,
- "There should only be one violation for zipcode"
- );
-
- violation = constraintViolations.iterator().next();
- TestUtil.assertConstraintViolation( violation, Address.class, address, "" );
- }
-
- /**
- * HV-113
- */
- @Test
- public void testRedefiningDefaultGroup2() {
- Car car = new Car();
- car.setType( "A" );
-
- Validator validator = TestUtil.getDefaultValidator();
-
- Set<ConstraintViolation<Car>> constraintViolations = validator.validate( car );
- assertEquals(
- constraintViolations.size(),
- 1,
- "There should be one violations due to the re-defintion of the default group"
- );
- assertEquals(
- "size must be between 2 and 20",
- constraintViolations.iterator().next().getMessage(),
- "Wrong constraint"
- );
-
- constraintViolations = validator.validateProperty( car, "type" );
- assertEquals(
- constraintViolations.size(),
- 1,
- "There should be one violations due to the re-defintion of the default group"
- );
- assertEquals(
- "size must be between 2 and 20",
- constraintViolations.iterator().next().getMessage(),
- "Wrong constraint"
- );
-
- constraintViolations = validator.validateValue( Car.class, "type", "A" );
- assertEquals(
- constraintViolations.size(),
- 1,
- "There should be one violations due to the re-defintion of the default group"
- );
- assertEquals(
- "size must be between 2 and 20",
- constraintViolations.iterator().next().getMessage(),
- "Wrong constraint"
- );
- }
-
- /**
- * HV-113
- */
- @Test
- public void testInvalidRedefinitionOfDefaultGroup() {
- Address address = new AddressWithInvalidGroupSequence();
- Validator validator = TestUtil.getDefaultValidator();
- try {
- validator.validate( address );
- fail( "It shoud not be allowed to have Default.class in the group sequence of a class." );
- }
- catch ( ValidationException e ) {
- assertEquals(
- "'Default.class' cannot appear in default group sequence list.", e.getMessage(), "Wrong message"
- );
- }
- }
-
- /**
- * HV-115
- */
- @Test
- public void testImplicitGroup() {
- Validator validator = TestUtil.getDefaultValidator();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
assertTrue( beanDescriptor.isBeanConstrained() );
- Set<PropertyDescriptor> constraintProperties = beanDescriptor.getConstrainedProperties();
- assertTrue( constraintProperties.size() == 5, "Each of the properties should have at least one constraint." );
-
+ // validating the Default Group should validate all 5 constraints
Order order = new Order();
Set<ConstraintViolation<Order>> violations = validator.validate( order );
assertTrue( violations.size() == 5, "All 5 NotNull constraints should fail." );
- // use implicit group Auditable
+ // use implicit group Auditable - only the constraints defined on Auditable should be validated
violations = validator.validate( order, Auditable.class );
assertTrue( violations.size() == 4, "All 4 NotNull constraints on Auditable should fail." );
}
+
+ @Test(expectedExceptions = GroupDefinitionException.class)
+ @SpecAssertions({
+ @SpecAssertion(section = "3.4.2", id = "e"),
+ @SpecAssertion(section = "8.4", id = "a")
+ })
+ public void testCyclicGroupSequence() {
+ Validator validator = TestUtil.getDefaultValidator();
+ validator.validate( new Order(), CyclicGroupSequence.class );
+ }
}
\ No newline at end of file
Deleted: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Optional.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Optional.java 2009-06-18 00:29:12 UTC (rev 16829)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Optional.java 2009-06-18 14:23:51 UTC (rev 16830)
@@ -1,9 +0,0 @@
-package org.hibernate.jsr303.tck.tests.constraints.groups;
-
-/**
- * Validation group checking whether user is billable.
- *
- * @author Emmanuel Bernard
- */
-public interface Optional {
-}
\ No newline at end of file
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/User.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/User.java 2009-06-18 00:29:12 UTC (rev 16829)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/User.java 2009-06-18 14:23:51 UTC (rev 16830)
@@ -55,4 +55,13 @@
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
+
+ public interface BuyInOneClick extends Default, Billable {
+ }
+
+ public interface Billable {
+ }
+
+ public interface Optional {
+ }
}
\ No newline at end of file
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/Bar.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/Bar.java 2009-06-18 00:29:12 UTC (rev 16829)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/Bar.java 2009-06-18 14:23:51 UTC (rev 16830)
@@ -20,5 +20,9 @@
/**
* @author Hardy Ferentschik
*/
-public class Bar extends Foo {
+public class Bar extends Foo implements Fubar {
+
+ public String getFubar() {
+ return null;
+ }
}
\ No newline at end of file
Copied: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/ConstraintInheritanceTest.java (from rev 16812, beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/InheritanceTest.java)
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/ConstraintInheritanceTest.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/ConstraintInheritanceTest.java 2009-06-18 14:23:51 UTC (rev 16830)
@@ -0,0 +1,80 @@
+// $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.jsr303.tck.tests.constraints.inheritance;
+
+import java.lang.annotation.Annotation;
+import javax.validation.Validator;
+import javax.validation.constraints.NotNull;
+import javax.validation.metadata.BeanDescriptor;
+import javax.validation.metadata.PropertyDescriptor;
+
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecAssertions;
+import org.jboss.testharness.AbstractTest;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.ArtifactType;
+import org.jboss.testharness.impl.packaging.Classes;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
+
+import org.hibernate.jsr303.tck.util.TestUtil;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Artifact(artifactType = ArtifactType.JSR303)
+(a)Classes(TestUtil.class)
+public class ConstraintInheritanceTest extends AbstractTest {
+
+ @Test
+ @SpecAssertion(section = "3.3", id = "b")
+ public void testConstraintsOnSuperClassAreInherited() {
+ Validator validator = TestUtil.getDefaultValidator();
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Bar.class );
+
+ String propertyName = "foo";
+ assertTrue( beanDescriptor.getConstraintsForProperty( propertyName ) != null );
+ PropertyDescriptor propDescriptor = beanDescriptor.getConstraintsForProperty( propertyName );
+
+ // cast is required for JDK 5 - at least on Mac OS X
+ Annotation constraintAnnotation = ( Annotation ) propDescriptor.getConstraintDescriptors()
+ .iterator()
+ .next().getAnnotation();
+ assertTrue( constraintAnnotation.annotationType() == NotNull.class );
+ }
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "3.3", id = "a"),
+ @SpecAssertion(section = "3.3", id = "b")
+ })
+ public void testConstraintsOnInterfaceAreInherited() {
+ Validator validator = TestUtil.getDefaultValidator();
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Bar.class );
+
+ String propertyName = "fubar";
+ assertTrue( beanDescriptor.getConstraintsForProperty( propertyName ) != null );
+ PropertyDescriptor propDescriptor = beanDescriptor.getConstraintsForProperty( propertyName );
+
+ // cast is required for JDK 5 - at least on Mac OS X
+ Annotation constraintAnnotation = ( Annotation ) propDescriptor.getConstraintDescriptors()
+ .iterator()
+ .next().getAnnotation();
+ assertTrue( constraintAnnotation.annotationType() == NotNull.class );
+ }
+}
\ No newline at end of file
Property changes on: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/ConstraintInheritanceTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/Fubar.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/Fubar.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/Fubar.java 2009-06-18 14:23:51 UTC (rev 16830)
@@ -0,0 +1,28 @@
+// $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.jsr303.tck.tests.constraints.inheritance;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public interface Fubar {
+ @NotNull
+ String getFubar();
+}
Deleted: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/InheritanceTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/InheritanceTest.java 2009-06-18 00:29:12 UTC (rev 16829)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/InheritanceTest.java 2009-06-18 14:23:51 UTC (rev 16830)
@@ -1,60 +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.jsr303.tck.tests.constraints.inheritance;
-
-import java.lang.annotation.Annotation;
-import javax.validation.Validator;
-import javax.validation.constraints.NotNull;
-import javax.validation.metadata.BeanDescriptor;
-import javax.validation.metadata.PropertyDescriptor;
-
-import org.jboss.testharness.AbstractTest;
-import org.jboss.testharness.impl.packaging.Artifact;
-import org.jboss.testharness.impl.packaging.ArtifactType;
-import org.jboss.testharness.impl.packaging.Classes;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-import org.testng.annotations.Test;
-
-import org.hibernate.jsr303.tck.util.TestUtil;
-
-/**
- * @author Hardy Ferentschik
- */
-@Artifact(artifactType = ArtifactType.JSR303)
-(a)Classes(TestUtil.class)
-public class InheritanceTest extends AbstractTest {
-
- @Test
- public void testIsBeanConstrained() {
- Validator validator = TestUtil.getDefaultValidator();
- BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Bar.class );
-
- assertFalse( beanDescriptor.hasConstraints(), "There should be no direct constraints on the specified bean." );
- assertTrue( beanDescriptor.isBeanConstrained(), "Bean should be constrainted " );
-
- assertTrue( beanDescriptor.getConstraintsForProperty( "foo" ) != null );
- PropertyDescriptor propDescriptor = beanDescriptor.getConstraintsForProperty( "foo" );
- Annotation constraintAnnotation = ( Annotation ) propDescriptor.getConstraintDescriptors()
- .iterator()
- .next().getAnnotation();
- assertTrue(
- constraintAnnotation.annotationType() == NotNull.class
- );
- }
-}
\ No newline at end of file
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/ValidatorResolutionTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/ValidatorResolutionTest.java 2009-06-18 00:29:12 UTC (rev 16829)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/ValidatorResolutionTest.java 2009-06-18 14:23:51 UTC (rev 16830)
@@ -66,7 +66,8 @@
@Test
@SpecAssertions({
- @SpecAssertion(section = "3.5.3", id = "f")
+ @SpecAssertion(section = "3.5.3", id = "f"),
+ @SpecAssertion(section = "8.3", id = "b")
})
public void testAmbigiousValidatorResolution() {
Validator validator = TestUtil.getDefaultValidator();
Modified: beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-06-18 00:29:12 UTC (rev 16829)
+++ beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-06-18 14:23:51 UTC (rev 16830)
@@ -334,13 +334,13 @@
</section>
<section id="3.4.2" title="Group sequence ">
- <assertion id="a">
+ <assertion id="a" testable="false">
<text>By default, constraints are evaluated in no particular order and this regardless
of which groups they belong to</text>
</assertion>
<assertion id="b">
<text>Each group in a group sequence must be processed sequentially in the order defined
- by @GroupSequence.value when the group defined as a se- quence is requested</text>
+ by @GroupSequence.value when the group defined as a sequence is requested</text>
</assertion>
<assertion id="c">
<text>Note that a group member of a sequence can itself be composed of several groups
@@ -379,7 +379,7 @@
</section>
<section id="3.4.3" title="Redefining the Default group for a class">
<assertion id="a">
- <text>To redefine Default for a class, place a @GroupSequence annotation on the class ;
+ <text>To redefine Default for a class, place a @GroupSequence annotation on the class.
this sequence expresses the sequence of groups that does substitute Default for this
class.</text>
</assertion>
@@ -400,7 +400,7 @@
<section id="3.4.4" title="Implicit grouping">
<assertion id="a">
<text>Every constraint hosted on an interface Z and part of the Default group
- (implicitly or expli- citly) belongs to the group Z</text>
+ (implicitly or explicitly) belongs to the group Z</text>
</assertion>
</section>
<section id="3.5" title="Validation routine">
15 years, 5 months
Hibernate SVN: r16829 - in beanvalidation/trunk/validation-api/src/main/java/javax/validation: metadata and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-06-17 20:29:12 -0400 (Wed, 17 Jun 2009)
New Revision: 16829
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/Validator.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/metadata/BeanDescriptor.java
Log:
BVAL-166 IllegalArgumentException raised on BeanDescriptor.getConstraintsForProperty and Validator.getConstraintsForClass
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/Validator.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/Validator.java 2009-06-17 23:18:27 UTC (rev 16828)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/Validator.java 2009-06-18 00:29:12 UTC (rev 16829)
@@ -96,6 +96,7 @@
*
* @return the bean descriptor for the specified class.
*
+ * @throws IllegalArgumentException if clazz is null
* @throws ValidationException if a non recoverable error happens
* during the metadata discovery or if some
* constraints are invalid.
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/metadata/BeanDescriptor.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/metadata/BeanDescriptor.java 2009-06-17 23:18:27 UTC (rev 16828)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/metadata/BeanDescriptor.java 2009-06-18 00:29:12 UTC (rev 16829)
@@ -45,9 +45,11 @@
* The returned object (and associated objects including ConstraintDescriptors)
* are immutable.
*
- * @param propertyName property evaludated
+ * @param propertyName property evaluated
*
* @return the property descriptor for a given property.
+ *
+ * @throws IllegalArgumentException if propertyName is null
*/
PropertyDescriptor getConstraintsForProperty(String propertyName);
15 years, 5 months
Hibernate SVN: r16828 - core/branches/Branch_3_3/core/src/main/java/org/hibernate/dialect.
by hibernate-commits@lists.jboss.org
Author: gbadner
Date: 2009-06-17 19:18:27 -0400 (Wed, 17 Jun 2009)
New Revision: 16828
Modified:
core/branches/Branch_3_3/core/src/main/java/org/hibernate/dialect/SQLServerDialect.java
Log:
HHH-3712 : correct SQLServerDialect to extend AbstractTransactSQLDialect
Modified: core/branches/Branch_3_3/core/src/main/java/org/hibernate/dialect/SQLServerDialect.java
===================================================================
--- core/branches/Branch_3_3/core/src/main/java/org/hibernate/dialect/SQLServerDialect.java 2009-06-17 22:48:26 UTC (rev 16827)
+++ core/branches/Branch_3_3/core/src/main/java/org/hibernate/dialect/SQLServerDialect.java 2009-06-17 23:18:27 UTC (rev 16828)
@@ -37,7 +37,7 @@
*
* @author Gavin King
*/
-public class SQLServerDialect extends SybaseDialect {
+public class SQLServerDialect extends AbstractTransactSQLDialect {
public SQLServerDialect() {
registerColumnType( Types.VARBINARY, "image" );
15 years, 5 months
Hibernate SVN: r16827 - core/trunk/core/src/main/java/org/hibernate/dialect.
by hibernate-commits@lists.jboss.org
Author: gbadner
Date: 2009-06-17 18:48:26 -0400 (Wed, 17 Jun 2009)
New Revision: 16827
Modified:
core/trunk/core/src/main/java/org/hibernate/dialect/SQLServerDialect.java
Log:
HHH-3712 : correct SQLServerDialect to extend AbstractTransactSQLDialect
Modified: core/trunk/core/src/main/java/org/hibernate/dialect/SQLServerDialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/SQLServerDialect.java 2009-06-17 20:58:17 UTC (rev 16826)
+++ core/trunk/core/src/main/java/org/hibernate/dialect/SQLServerDialect.java 2009-06-17 22:48:26 UTC (rev 16827)
@@ -37,7 +37,7 @@
*
* @author Gavin King
*/
-public class SQLServerDialect extends SybaseDialect {
+public class SQLServerDialect extends AbstractTransactSQLDialect {
public SQLServerDialect() {
registerColumnType( Types.VARBINARY, "image" );
15 years, 5 months
Hibernate SVN: r16826 - in validator/trunk/hibernate-validator/src: test/java/org/hibernate/validation/util and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-06-17 16:58:17 -0400 (Wed, 17 Jun 2009)
New Revision: 16826
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata/BeanMetaDataImpl.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/TestUtil.java
Log:
Cleanup.
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata/BeanMetaDataImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata/BeanMetaDataImpl.java 2009-06-17 20:58:05 UTC (rev 16825)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata/BeanMetaDataImpl.java 2009-06-17 20:58:17 UTC (rev 16826)
@@ -39,10 +39,8 @@
import org.slf4j.Logger;
-import org.hibernate.validation.metadata.AnnotationIgnores;
import org.hibernate.validation.util.LoggerFactory;
import org.hibernate.validation.util.ReflectionHelper;
-import org.hibernate.validation.metadata.MetaConstraint;
/**
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/TestUtil.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/TestUtil.java 2009-06-17 20:58:05 UTC (rev 16825)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/TestUtil.java 2009-06-17 20:58:17 UTC (rev 16826)
@@ -19,19 +19,19 @@
import java.io.InputStream;
import java.util.Set;
+import javax.validation.ConstraintViolation;
+import javax.validation.Validation;
+import javax.validation.Validator;
import javax.validation.metadata.ConstraintDescriptor;
-import javax.validation.ConstraintViolation;
import javax.validation.metadata.ElementDescriptor;
import javax.validation.metadata.PropertyDescriptor;
-import javax.validation.Validation;
-import javax.validation.Validator;
import org.slf4j.Logger;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
+import org.hibernate.validation.HibernateValidationProvider;
import org.hibernate.validation.engine.HibernateValidatorConfiguration;
-import org.hibernate.validation.HibernateValidationProvider;
/**
* Tests for the <code>ReflectionHelper</code>.
15 years, 5 months
Hibernate SVN: r16825 - validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-06-17 16:58:05 -0400 (Wed, 17 Jun 2009)
New Revision: 16825
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata/BeanDescriptorImpl.java
Log:
Ficed bug in isBeanConstrained()
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata/BeanDescriptorImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata/BeanDescriptorImpl.java 2009-06-17 20:57:08 UTC (rev 16824)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata/BeanDescriptorImpl.java 2009-06-17 20:58:05 UTC (rev 16825)
@@ -17,7 +17,7 @@
}
public boolean isBeanConstrained() {
- return metadataBean.getConstrainedProperties().size() > 0;
+ return metadataBean.geMetaConstraintList().size() > 0;
}
public PropertyDescriptor getConstraintsForProperty(String propertyName) {
15 years, 5 months