Author: epbernard
Date: 2009-07-29 21:47:31 -0400 (Wed, 29 Jul 2009)
New Revision: 17217
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/validationxml/ValidationXmlBootstrapTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/BuiltinConstraintsTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/FrenchZipcode.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata/ConstraintDescriptorImpl.java
Log:
HV-193 @overridesAttribute.index starts at 0 like any other array index in Java
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/validationxml/ValidationXmlBootstrapTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/validationxml/ValidationXmlBootstrapTest.java 2009-07-29
15:22:25 UTC (rev 17216)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/validationxml/ValidationXmlBootstrapTest.java 2009-07-30
01:47:31 UTC (rev 17217)
@@ -40,7 +40,7 @@
public void testWrongProviderConfiguredInValidationXml() {
try {
Validation.buildDefaultValidatorFactory();
- fail( "valiation.xml contains a invalid provider.
Validation.buildDefaultValidatorFactory() should have failed." );
+ fail( "validation.xml contains a invalid provider.
Validation.buildDefaultValidatorFactory() should have failed." );
}
catch ( ValidationException e ) {
// success
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/BuiltinConstraintsTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/BuiltinConstraintsTest.java 2009-07-29
15:22:25 UTC (rev 17216)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/BuiltinConstraintsTest.java 2009-07-30
01:47:31 UTC (rev 17217)
@@ -57,7 +57,7 @@
import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectPropertyPaths;
/**
- * Tests for built-in constraints. Basically juyst checks the availabiltiy of the
build-in constraints.
+ * Tests for built-in constraints. Basically just checks the availabiltiy of the build-in
constraints.
*
* @author Hardy Ferentschik
*/
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionTest.java 2009-07-29
15:22:25 UTC (rev 17216)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionTest.java 2009-07-30
01:47:31 UTC (rev 17217)
@@ -213,15 +213,24 @@
BeanDescriptor descriptor = validator.getConstraintsForClass( FrenchAddress.class );
Set<ConstraintDescriptor<?>> constraintDescriptors =
descriptor.getConstraintsForProperty( "zipCode" )
.getConstraintDescriptors();
+ boolean findPattern = checkForAppropriateAnnotation( constraintDescriptors );
+ assertTrue( findPattern, "Could not find @Pattern in composing constraints"
);
+ }
+
+ private boolean checkForAppropriateAnnotation(Set<ConstraintDescriptor<?>>
constraintDescriptors) {
+ boolean findPattern = false;
for ( ConstraintDescriptor<?> constraintDescriptor : constraintDescriptors ) {
Annotation ann = constraintDescriptor.getAnnotation();
if ( Pattern.class.getName().equals( ann.annotationType().getName() ) ) {
String regexp = ( ( Pattern ) ann ).regexp();
- if ( regexp.equals( "\\d*" ) || regexp.equals( "....." ) ) {
- fail( "The regular expression should attributes are defined in the composing
constraint." );
+ if ( regexp.equals( "bar" ) ) {
+ fail( "The regular expression attributes are defined in the composing
constraint." );
}
+ findPattern = true;
}
+ findPattern |= checkForAppropriateAnnotation(
constraintDescriptor.getComposingConstraints() );
}
+ return findPattern;
}
@Test
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/FrenchZipcode.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/FrenchZipcode.java 2009-07-29
15:22:25 UTC (rev 17216)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/FrenchZipcode.java 2009-07-30
01:47:31 UTC (rev 17217)
@@ -58,6 +58,6 @@
@OverridesAttribute(constraint = Size.class, name = "message")
String sizeMessage() default "A french zip code has a length of 5";
- @OverridesAttribute(constraint = Pattern.class, name = "regexp",
constraintIndex = 2)
+ @OverridesAttribute(constraint = Pattern.class, name = "regexp",
constraintIndex = 1)
String regex() default "\\d*";
}
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata/ConstraintDescriptorImpl.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata/ConstraintDescriptorImpl.java 2009-07-29
15:22:25 UTC (rev 17216)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata/ConstraintDescriptorImpl.java 2009-07-30
01:47:31 UTC (rev 17217)
@@ -338,7 +338,7 @@
}
else if ( constraintHelper.isMultiValueConstraint( declaredAnnotation ) ) {
List<Annotation> multiValueConstraints =
constraintHelper.getMultiValueConstraints( declaredAnnotation );
- int index = 1;
+ int index = 0;
for ( Annotation constraintAnnotation : multiValueConstraints ) {
ConstraintDescriptorImpl<?> descriptor = createComposingConstraintDescriptor(
constraintAnnotation, overrideParameters, index
Show replies by date