Author: hardy.ferentschik
Date: 2009-08-31 09:14:55 -0400 (Mon, 31 Aug 2009)
New Revision: 17451
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Ambiguous.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Dummy.java
Removed:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Ambigious.java
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Bar.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Foo.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/ValidatorResolutionTest.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ConstraintTree.java
Log:
Updated poms to work with latest SNAPSHOT dependencies again
Deleted:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Ambigious.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Ambigious.java 2009-08-31
12:48:22 UTC (rev 17450)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Ambigious.java 2009-08-31
13:14:55 UTC (rev 17451)
@@ -1,71 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.hibernate.jsr303.tck.tests.constraints.validatorresolution;
-
-import java.io.Serializable;
-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;
-import javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
-import javax.validation.Payload;
-
-/**
- * A test constraint which can lead to a error when trying to reslove the validator.
- *
- * @author Hardy Ferentschik
- */
-@Constraint(validatedBy = {
- Ambigious.AmbigiousValidatorForBar.class,
Ambigious.AmbigiousValidatorForSerializable.class
-})
-@Documented
-@Target({ METHOD, FIELD, TYPE })
-@Retention(RUNTIME)
-public @interface Ambigious {
- public abstract String message() default "foobar";
-
- public abstract Class<?>[] groups() default { };
-
- public abstract Class<? extends Payload>[] payload() default {};
-
-
- public class AmbigiousValidatorForBar implements ConstraintValidator<Ambigious,
Bar> {
-
- public void initialize(Ambigious parameters) {
- }
-
- public boolean isValid(Bar b, ConstraintValidatorContext constraintValidatorContext) {
- return true;
- }
- }
-
- 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
Copied:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Ambiguous.java
(from rev 17449,
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Ambigious.java)
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Ambiguous.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Ambiguous.java 2009-08-31
13:14:55 UTC (rev 17451)
@@ -0,0 +1,71 @@
+// $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.validatorresolution;
+
+import java.io.Serializable;
+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;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.Payload;
+
+/**
+ * A test constraint which can lead to a error when trying to resolve the validator.
+ *
+ * @author Hardy Ferentschik
+ */
+@Constraint(validatedBy = {
+ Ambiguous.AmbiguousValidatorForDummy.class,
Ambiguous.AmbiguousValidatorForSerializable.class
+})
+@Documented
+@Target({ METHOD, FIELD, TYPE })
+@Retention(RUNTIME)
+public @interface Ambiguous {
+ public abstract String message() default "foobar";
+
+ public abstract Class<?>[] groups() default { };
+
+ public abstract Class<? extends Payload>[] payload() default { };
+
+
+ public class AmbiguousValidatorForDummy implements ConstraintValidator<Ambiguous,
Dummy> {
+
+ public void initialize(Ambiguous parameters) {
+ }
+
+ public boolean isValid(Dummy d, ConstraintValidatorContext constraintValidatorContext)
{
+ return true;
+ }
+ }
+
+ public class AmbiguousValidatorForSerializable implements
ConstraintValidator<Ambiguous, Serializable> {
+
+ public void initialize(Ambiguous parameters) {
+ }
+
+ public boolean isValid(Serializable o, ConstraintValidatorContext
constraintValidatorContext) {
+ return true;
+ }
+ }
+}
\ No newline at end of file
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Ambiguous.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Bar.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Bar.java 2009-08-31
12:48:22 UTC (rev 17450)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Bar.java 2009-08-31
13:14:55 UTC (rev 17451)
@@ -17,12 +17,13 @@
*/
package org.hibernate.jsr303.tck.tests.constraints.validatorresolution;
+import java.io.Serializable;
import javax.validation.constraints.Size;
/**
* @author Hardy Ferentschik
*/
-public class Bar {
+public class Bar implements Serializable, Dummy {
// validating Bar actually raises an UnexpectedTypeException - @Size is not defined for
Integer
@Size
private Integer value = 0;
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Dummy.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Dummy.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Dummy.java 2009-08-31
13:14:55 UTC (rev 17451)
@@ -0,0 +1,24 @@
+// $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.validatorresolution;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public interface Dummy {
+}
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Foo.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Foo.java 2009-08-31
12:48:22 UTC (rev 17450)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Foo.java 2009-08-31
13:14:55 UTC (rev 17451)
@@ -22,7 +22,7 @@
*/
public class Foo {
- @Ambigious
+ @Ambiguous
private Bar bar;
public Foo(Bar bar) {
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-08-31
12:48:22 UTC (rev 17450)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/ValidatorResolutionTest.java 2009-08-31
13:14:55 UTC (rev 17451)
@@ -244,13 +244,13 @@
@SpecAssertion(section = "3.5.3", id = "f"),
@SpecAssertion(section = "8.3", id = "b")
})
- public void testAmbigiousValidatorResolution() {
+ public void testAmbiguousValidatorResolution() {
Validator validator = TestUtil.getValidatorUnderTest();
Foo foo = new Foo( new SerializableBarSubclass() );
try {
validator.validate( foo );
- fail();
+ fail("The test should have failed due to ambiguous validator resolution.");
}
catch ( UnexpectedTypeException e ) {
// success
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ConstraintTree.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ConstraintTree.java 2009-08-31
12:48:22 UTC (rev 17450)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ConstraintTree.java 2009-08-31
13:14:55 UTC (rev 17451)
@@ -117,7 +117,6 @@
);
}
ConstraintValidator<A, V> validator = getInitializedValidator(
- localExecutionContext.getCurrentValidatedValue(),
type,
executionContext.getConstraintValidatorFactory()
);
@@ -166,15 +165,14 @@
}
/**
- * @param value The value to be validated.
* @param type The type of the value to be validated (the type of the member/class the
constraint was placed on).
* @param constraintFactory constraint factory used to instantiate the constraint
validator.
*
* @return A initialized constraint validator matching the type of the value to be
validated.
*/
@SuppressWarnings("unchecked")
- private <V> ConstraintValidator<A, V> getInitializedValidator(V value, Type
type, ConstraintValidatorFactory constraintFactory) {
- Class<? extends ConstraintValidator<?, ?>> validatorClass =
findMatchingValidatorClass( value, type );
+ private <V> ConstraintValidator<A, V> getInitializedValidator(Type type,
ConstraintValidatorFactory constraintFactory) {
+ Class<? extends ConstraintValidator<?, ?>> validatorClass =
findMatchingValidatorClass( type );
ConstraintValidator<A, V> constraintValidator;
@@ -203,22 +201,17 @@
/**
* Runs the validator resolution algorithm.
*
- * @param value The value to be validated.
* @param type The type of the value to be validated (the type of the member/class the
constraint was placed on).
*
* @return The class of a matching validator.
*/
- private Class<? extends ConstraintValidator<?, ?>>
findMatchingValidatorClass(Object value, Type type) {
+ private Class<? extends ConstraintValidator<?, ?>>
findMatchingValidatorClass(Type type) {
Map<Type, Class<? extends ConstraintValidator<?, ?>>> validatorTypes
=
ValidatorTypeHelper.getValidatorsTypes( descriptor.getConstraintValidatorClasses()
);
List<Type> suitableTypes = new ArrayList<Type>();
findSuitableValidatorTypes( type, validatorTypes, suitableTypes );
- if ( value != null ) {
- findSuitableValidatorTypes( value.getClass(), validatorTypes, suitableTypes );
- }
-
resolveAssignableTypes( suitableTypes );
verifyResolveWasUnique( type, suitableTypes );