Author: hardy.ferentschik
Date: 2009-02-04 11:44:02 -0500 (Wed, 04 Feb 2009)
New Revision: 15890
Added:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/UnconstraintEntity.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/Ambigious.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/AmbigiousValidatorForBar.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/AmbigiousValidatorForSerializable.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/Bar.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/Foo.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/SerializableBar.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/ValidatorResolutionTest.java
Removed:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Unconstraint.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/constraint/
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorResolutionTest.java
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintTree.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorImplTest.java
validator/trunk/validation-api/src/main/java/javax/validation/Configuration.java
Log:
BVAL-99 added some test for ambigious validator resolution.
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java 2009-02-04
12:41:32 UTC (rev 15889)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java 2009-02-04
16:44:02 UTC (rev 15890)
@@ -268,8 +268,6 @@
* @param beanClass The class to check for constraints annotations.
*
* @return A list of constraint descriptors for all constraint specified on the given
class.
- *
- * @todo inject XML data here, probably externalizing the process
*/
private List<ConstraintDescriptorImpl> findClassLevelConstraints(Class beanClass)
{
List<ConstraintDescriptorImpl> metadata = new
ArrayList<ConstraintDescriptorImpl>();
@@ -289,8 +287,6 @@
* @param method The method to check for constraints annotations.
*
* @return A list of constraint descriptors for all constraint specified for the given
method.
- *
- * @todo inject XML data here, probably externalizing the process
*/
private List<ConstraintDescriptorImpl> findMethodLevelConstraints(Method method)
{
List<ConstraintDescriptorImpl> metadata = new
ArrayList<ConstraintDescriptorImpl>();
@@ -326,8 +322,6 @@
* @param field The field to check for constraints annotations.
*
* @return A list of constraint descriptors for all constraint specified on the given
field.
- *
- * @todo inject XML data here, probably externalizing the process
*/
private List<ConstraintDescriptorImpl> findFieldLevelConstraints(Field field) {
List<ConstraintDescriptorImpl> metadata = new
ArrayList<ConstraintDescriptorImpl>();
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-02-04
12:41:32 UTC (rev 15889)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintTree.java 2009-02-04
16:44:02 UTC (rev 15890)
@@ -206,7 +206,7 @@
do {
classesToRemove.clear();
Class clazz = assignableClasses.get( 0 );
- for ( int i = 1; i <= assignableClasses.size(); i++ ) {
+ for ( int i = 1; i < assignableClasses.size(); i++ ) {
if ( clazz.isAssignableFrom( assignableClasses.get( i ) ) ) {
classesToRemove.add( clazz );
}
Deleted:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Unconstraint.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Unconstraint.java 2009-02-04
12:41:32 UTC (rev 15889)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Unconstraint.java 2009-02-04
16:44:02 UTC (rev 15890)
@@ -1,26 +0,0 @@
-// : Person.java 69 2008-09-08 11:05:07Z 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.eg;
-
-/**
- * Empty un-constraint test class.
- *
- * @author Hardy Ferentschik
- */
-public class Unconstraint {
-}
Copied:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/UnconstraintEntity.java
(from rev 15883,
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/Unconstraint.java)
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/UnconstraintEntity.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/UnconstraintEntity.java 2009-02-04
16:44:02 UTC (rev 15890)
@@ -0,0 +1,26 @@
+// : Person.java 69 2008-09-08 11:05:07Z 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.eg;
+
+/**
+ * Empty un-constraint test class.
+ *
+ * @author Hardy Ferentschik
+ */
+public class UnconstraintEntity {
+}
Property changes on:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/UnconstraintEntity.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorImplTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorImplTest.java 2009-02-04
12:41:32 UTC (rev 15889)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorImplTest.java 2009-02-04
16:44:02 UTC (rev 15890)
@@ -42,7 +42,7 @@
import org.hibernate.validation.eg.Engine;
import org.hibernate.validation.eg.EnglishDictonary;
import org.hibernate.validation.eg.Order;
-import org.hibernate.validation.eg.Unconstraint;
+import org.hibernate.validation.eg.UnconstraintEntity;
import org.hibernate.validation.eg.groups.First;
import org.hibernate.validation.eg.groups.Last;
import org.hibernate.validation.eg.groups.Second;
@@ -80,7 +80,7 @@
@Test
public void testUnconstraintClass() {
Validator validator = TestUtil.getValidator();
- assertTrue( "There should be no constraints",
!validator.getConstraintsForClass( Unconstraint.class ).hasConstraints() );
+ assertTrue( "There should be no constraints",
!validator.getConstraintsForClass( UnconstraintEntity.class ).hasConstraints() );
}
@Test
Deleted:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorResolutionTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorResolutionTest.java 2009-02-04
12:41:32 UTC (rev 15889)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorResolutionTest.java 2009-02-04
16:44:02 UTC (rev 15890)
@@ -1,45 +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.engine;
-
-import java.util.Set;
-import javax.validation.ConstraintViolation;
-import javax.validation.Validator;
-
-import org.junit.Test;
-
-import org.hibernate.validation.eg.MultipleMinMax;
-import static org.hibernate.validation.util.TestUtil.assertNumberOfViolations;
-import static org.hibernate.validation.util.TestUtil.getValidator;
-
-/**
- * Tests for constraint validator resolution.
- *
- * @author Hardy Ferentschik
- */
-public class ValidatorResolutionTest {
-
- @Test
- public void testValidatorResolutionForMinMax() {
- Validator validator = getValidator();
-
- MultipleMinMax minMax = new MultipleMinMax( "5", 5 );
- Set<ConstraintViolation<MultipleMinMax>> constraintViolations =
validator.validate( minMax );
- assertNumberOfViolations( constraintViolations, 2 );
- }
-}
\ No newline at end of file
Copied:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/Ambigious.java
(from rev 15883,
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/FrenchZipcode.java)
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/Ambigious.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/Ambigious.java 2009-02-04
16:44:02 UTC (rev 15890)
@@ -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.engine.validatorresolution;
+
+import java.lang.annotation.Documented;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+import javax.validation.Constraint;
+
+/**
+ * A test constraint which can lead to a error when trying to reslove the validator.
+ *
+ * @author Hardy Ferentschik
+ */
+@Constraint(validatedBy = { AmbigiousValidatorForBar.class,
AmbigiousValidatorForSerializable.class })
+@Documented
+@Target({ METHOD, FIELD, TYPE })
+@Retention(RUNTIME)
+public @interface Ambigious {
+ public abstract String message() default "foobar";
+
+ public abstract Class<?>[] groups() default { };
+}
\ No newline at end of file
Property changes on:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/Ambigious.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:mergeinfo
+
Copied:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/AmbigiousValidatorForBar.java
(from rev 15883,
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/FrenchZipcodeConstraintValidator.java)
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/AmbigiousValidatorForBar.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/AmbigiousValidatorForBar.java 2009-02-04
16:44:02 UTC (rev 15890)
@@ -0,0 +1,34 @@
+// $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.engine.validatorresolution;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class AmbigiousValidatorForBar implements ConstraintValidator<Ambigious,
Bar> {
+
+ public void initialize(Ambigious parameters) {
+ }
+
+ public boolean isValid(Bar b, ConstraintValidatorContext constraintValidatorContext) {
+ return true;
+ }
+}
\ No newline at end of file
Property changes on:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/AmbigiousValidatorForBar.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:mergeinfo
+
Added:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/AmbigiousValidatorForSerializable.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/AmbigiousValidatorForSerializable.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/AmbigiousValidatorForSerializable.java 2009-02-04
16:44:02 UTC (rev 15890)
@@ -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.validation.engine.validatorresolution;
+
+import java.io.Serializable;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class AmbigiousValidatorForSerializable implements
ConstraintValidator<Ambigious, Serializable> {
+
+ public void initialize(Ambigious parameters) {
+ }
+
+ public boolean isValid(Serializable o, ConstraintValidatorContext
constraintValidatorContext) {
+ return true;
+ }
+}
\ No newline at end of file
Property changes on:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/AmbigiousValidatorForSerializable.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/Bar.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/Bar.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/Bar.java 2009-02-04
16:44:02 UTC (rev 15890)
@@ -0,0 +1,25 @@
+// : Person.java 69 2008-09-08 11:05:07Z 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.engine.validatorresolution;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class Bar {
+
+}
\ No newline at end of file
Property changes on:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/Bar.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/Foo.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/Foo.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/Foo.java 2009-02-04
16:44:02 UTC (rev 15890)
@@ -0,0 +1,35 @@
+// : Person.java 69 2008-09-08 11:05:07Z 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.engine.validatorresolution;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class Foo {
+
+ @Ambigious
+ private Bar bar;
+
+ public Foo(Bar bar) {
+ this.bar = bar;
+ }
+
+ public Bar getBar() {
+ return bar;
+ }
+}
\ No newline at end of file
Property changes on:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/Foo.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/SerializableBar.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/SerializableBar.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/SerializableBar.java 2009-02-04
16:44:02 UTC (rev 15890)
@@ -0,0 +1,27 @@
+// : Person.java 69 2008-09-08 11:05:07Z 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.engine.validatorresolution;
+
+import java.io.Serializable;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class SerializableBar extends Bar implements Serializable {
+
+}
\ No newline at end of file
Property changes on:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/SerializableBar.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/ValidatorResolutionTest.java
(from rev 15889,
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorResolutionTest.java)
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/ValidatorResolutionTest.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/ValidatorResolutionTest.java 2009-02-04
16:44:02 UTC (rev 15890)
@@ -0,0 +1,62 @@
+// $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.engine.validatorresolution;
+
+import java.util.Set;
+import javax.validation.ConstraintViolation;
+import javax.validation.ValidationException;
+import javax.validation.Validator;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import org.junit.Test;
+
+import org.hibernate.validation.eg.MultipleMinMax;
+import static org.hibernate.validation.util.TestUtil.assertNumberOfViolations;
+import static org.hibernate.validation.util.TestUtil.getValidator;
+
+/**
+ * Tests for constraint validator resolution.
+ *
+ * @author Hardy Ferentschik
+ */
+public class ValidatorResolutionTest {
+
+ @Test
+ public void testValidatorResolutionForMinMax() {
+ Validator validator = getValidator();
+
+ MultipleMinMax minMax = new MultipleMinMax( "5", 5 );
+ Set<ConstraintViolation<MultipleMinMax>> constraintViolations =
validator.validate( minMax );
+ assertNumberOfViolations( constraintViolations, 2 );
+ }
+
+ @Test
+ public void testAmbigiousValidatorResolution() {
+ Validator validator = getValidator();
+
+ Foo foo = new Foo( new SerializableBar() );
+ try {
+ validator.validate( foo );
+ fail();
+ }
+ catch ( ValidationException e ) {
+ assertTrue( e.getMessage().startsWith( "There are multiple validators" ) );
+ }
+ }
+}
\ No newline at end of file
Property changes on:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/ValidatorResolutionTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:mergeinfo
+
Modified:
validator/trunk/validation-api/src/main/java/javax/validation/Configuration.java
===================================================================
---
validator/trunk/validation-api/src/main/java/javax/validation/Configuration.java 2009-02-04
12:41:32 UTC (rev 15889)
+++
validator/trunk/validation-api/src/main/java/javax/validation/Configuration.java 2009-02-04
16:44:02 UTC (rev 15890)
@@ -32,12 +32,12 @@
* .buildValidatorFactory();
* </pre>
* <p/>
- *
+ * <p/>
* By default, the configuration information is retrieved from
* META-INF/validation.xml
* It is possible to override the configuration retrieved from the XML file
* by using one or more of the Configuration methods.
- *
+ * <p/>
* The ValidationProviderResolver is specified at Configuration time
* (see {@link javax.validation.spi.ValidationProvider}).
* If none is explicitely requested, the default ValidationProviderResolver is used.
@@ -61,8 +61,11 @@
* This method is typically useful for containers that parse
* META-INF/validation.xml themselves and pass the information
* via the Configuration methods.
+ *
+ * @return <code>this</code> following the chaining method pattern.
*/
T ignoreXmlConfiguration();
+
/**
* Defines the message interpolator used. Has priority over the configuration
* based message interpolator.
@@ -94,11 +97,11 @@
T constraintValidatorFactory(ConstraintValidatorFactory constraintValidatorFactory);
/**
- * Add a stream describing constaint mapping in the Bean Validation
+ * Add a stream describing constraint mapping in the Bean Validation
* XML format.
* <p/>
* The stream should be closed by the client API after the
- * ValidatorFactory has been built. The Bean Validation provider
+ * <code>ValidatorFactory</code> has been built. The Bean Validation
provider
* must not close the stream.
*
* @param stream XML mapping stream.
@@ -112,29 +115,33 @@
* XML Configuration properties.
* If the underlying provider does not know how to handle the property,
* it must silently ignore it.
- *
+ * <p/>
* Note: Using this non type-safe method is generally not recommended.
- *
+ * <p/>
* It is more appropriate to use, if available, the type-safe equivalent provided
* by a specific provider in its Configuration subclass.
* <code>ValidatorFactory factory =
Validation.byProvider(ACMEConfiguration.class)
- * .configure()
- * .providerSpecificProperty(ACMEState.FAST)
- * .buildValidatorFactory();
+ * .configure()
+ * .providerSpecificProperty(ACMEState.FAST)
+ * .buildValidatorFactory();
* </code>
* This method is typically used by containers parsing META-INF/validation.xml
* themselves and injecting the state to the Configuration object.
- *
+ * <p/>
* If a property with a given name is defined both via this method and in the
* XML configuration, the value set programmatically has priority.
+ *
+ * @param name property name.
+ * @param value property value.
+ * @return <code>this</code> following the chaining method pattern.
*/
T addProperty(String name, String value);
/**
* Return an implementation of the MessageInterpolator interface following the
* default MessageInterpolator defined in the specification:
- * - use the ValidationMessages resource bundle to load keys
- * - use Locale.getDefault()
+ * - use the ValidationMessages resource bundle to load keys
+ * - use Locale.getDefault()
*
* @return default MessageInterpolator implementation compliant with the specification
*/