Hibernate SVN: r16693 - in beanvalidation/trunk/validation-tck/src/main: java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions and 3 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-06-04 06:59:42 -0400 (Thu, 04 Jun 2009)
New Revision: 16693
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintdefinition/
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/
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/Bar.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Coordinate.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/MinMax.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/PostCodeList.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/SerializableBarSubclass.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Suburb.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/ValidatorResolutionTest.java
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/InvalidConstraintDefinitionsTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/util/TestUtil.java
beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
Log:
validator resolution tests
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/InvalidConstraintDefinitionsTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/InvalidConstraintDefinitionsTest.java 2009-06-04 10:58:55 UTC (rev 16692)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/InvalidConstraintDefinitionsTest.java 2009-06-04 10:59:42 UTC (rev 16693)
@@ -57,7 +57,7 @@
@Test
@SpecAssertions({
- @SpecAssertion(section = "2.1", id = "d"),
+ @SpecAssertion(section = "2.1", id = "c"),
@SpecAssertion(section = "2.1.1", id = "c"),
@SpecAssertion(section = "8.2", id = "a")
})
@@ -74,7 +74,7 @@
@Test
@SpecAssertions({
- @SpecAssertion(section = "2.1", id = "d"),
+ @SpecAssertion(section = "2.1", id = "c"),
@SpecAssertion(section = "2.1.1", id = "d"),
@SpecAssertion(section = "8.2", id = "a")
})
@@ -91,7 +91,7 @@
@Test
@SpecAssertions({
- @SpecAssertion(section = "2.1", id = "d"),
+ @SpecAssertion(section = "2.1", id = "c"),
@SpecAssertion(section = "2.1.1", id = "e"),
@SpecAssertion(section = "8.2", id = "a")
})
Added: 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 (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Ambigious.java 2009-06-04 10:59:42 UTC (rev 16693)
@@ -0,0 +1,68 @@
+// $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;
+
+/**
+ * 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 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
Property changes on: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Ambigious.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: 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 (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Bar.java 2009-06-04 10:59:42 UTC (rev 16693)
@@ -0,0 +1,37 @@
+// : 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.jsr303.tck.tests.constraints.validatorresolution;
+
+import javax.validation.constraints.Size;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class Bar {
+ // validating Bar actually raises an UnexpectedTypeException - @Size is not defined for Integer
+ @Size
+ private Integer value = 0;
+
+ public Integer getValue() {
+ return value;
+ }
+
+ public void setValue(Integer value) {
+ this.value = value;
+ }
+}
\ No newline at end of file
Property changes on: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Bar.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Coordinate.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Coordinate.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Coordinate.java 2009-06-04 10:59:42 UTC (rev 16693)
@@ -0,0 +1,32 @@
+// $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 class Coordinate {
+
+ long longitude;
+ long latidute;
+
+ public Coordinate(long longitude, long latidute) {
+ this.longitude = longitude;
+ this.latidute = latidute;
+ }
+}
Property changes on: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Coordinate.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: 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 (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Foo.java 2009-06-04 10:59:42 UTC (rev 16693)
@@ -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.jsr303.tck.tests.constraints.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: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Foo.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/MinMax.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/MinMax.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/MinMax.java 2009-06-04 10:59:42 UTC (rev 16693)
@@ -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.validatorresolution;
+
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class MinMax {
+ @Min(10l)
+ @Max(20l)
+ Number number;
+
+ @Min(10l)
+ @Max(20l)
+ String numberAsString;
+
+ public MinMax(String stringNumber, Number number) {
+ this.numberAsString = stringNumber;
+ this.number = number;
+ }
+}
Property changes on: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/MinMax.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/PostCodeList.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/PostCodeList.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/PostCodeList.java 2009-06-04 10:59:42 UTC (rev 16693)
@@ -0,0 +1,69 @@
+// $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.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 java.util.Collection;
+import javax.validation.Constraint;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+/**
+ * A test constraint which can lead to a error when trying to reslove the validator.
+ *
+ * @author Hardy Ferentschik
+ */
+@Constraint(validatedBy = {
+ PostCodeList.PostCodeListValidatorForString.class, PostCodeList.PostCodeListValidatorForNumber.class
+})
+@Documented
+@Target({ METHOD, FIELD, TYPE })
+@Retention(RUNTIME)
+public @interface PostCodeList {
+ public abstract String message() default "foobar";
+
+ public abstract Class<?>[] groups() default { };
+
+ public class PostCodeListValidatorForNumber
+ implements ConstraintValidator<PostCodeList, Collection<? extends Number>> {
+ public void initialize(PostCodeList constraintAnnotation) {
+ }
+
+ public boolean isValid(Collection<? extends Number> value, ConstraintValidatorContext constraintValidatorContext) {
+ return true;
+ }
+ }
+
+ public class PostCodeListValidatorForString implements ConstraintValidator<PostCodeList, Collection<String>> {
+ public void initialize(PostCodeList constraintAnnotation) {
+ }
+
+ public boolean isValid(Collection<String> value, ConstraintValidatorContext constraintValidatorContext) {
+ if ( value == null ) {
+ return true;
+ }
+ return false;
+ }
+ }
+}
\ No newline at end of file
Property changes on: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/PostCodeList.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/SerializableBarSubclass.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/SerializableBarSubclass.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/SerializableBarSubclass.java 2009-06-04 10:59:42 UTC (rev 16693)
@@ -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.jsr303.tck.tests.constraints.validatorresolution;
+
+import java.io.Serializable;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class SerializableBarSubclass extends Bar implements Serializable {
+
+}
\ No newline at end of file
Property changes on: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/SerializableBarSubclass.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Suburb.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Suburb.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Suburb.java 2009-06-04 10:59:42 UTC (rev 16693)
@@ -0,0 +1,95 @@
+// $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.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import javax.validation.constraints.Size;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class Suburb {
+ public enum Facility {
+ SHOPPING_MALL, BUS_TERMINAL
+ }
+
+ @Size(min = 5, max = 10)
+ private String name;
+
+ @Size(min = 2, max = 2)
+ private Map<Facility, Boolean> facilities;
+
+ @Size(min = 2)
+ private Set<String> streetNames;
+
+ @Size(min = 4, max = 1000)
+ private Coordinate[] boundingBox;
+
+ @PostCodeList
+ private Collection<? extends Number> includedPostCodes;
+
+ public void setIncludedPostCodes(Collection<? extends Number> includedPostCodes) {
+ this.includedPostCodes = includedPostCodes;
+ }
+
+ public Collection<? extends Number> getIncludedPostcodes() {
+ return includedPostCodes;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Map<Facility, Boolean> getFacilities() {
+ return facilities;
+ }
+
+ public void addFacility(Facility f, Boolean exist) {
+ if ( facilities == null ) {
+ facilities = new HashMap<Facility, Boolean>();
+ }
+ facilities.put( f, exist );
+ }
+
+ public Set<String> getStreetNames() {
+ return streetNames;
+ }
+
+ public void addStreetName(String streetName) {
+ if ( streetNames == null ) {
+ streetNames = new HashSet<String>();
+ }
+ streetNames.add( streetName );
+ }
+
+ public Coordinate[] getBoundingBox() {
+ return boundingBox;
+ }
+
+ public void setBoundingBox(Coordinate[] boundingBox) {
+ this.boundingBox = boundingBox;
+ }
+}
Property changes on: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/Suburb.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: 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 (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/ValidatorResolutionTest.java 2009-06-04 10:59:42 UTC (rev 16693)
@@ -0,0 +1,177 @@
+// $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.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import javax.validation.ConstraintViolation;
+import javax.validation.UnexpectedTypeException;
+import javax.validation.Validator;
+
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecAssertions;
+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.fail;
+import org.testng.annotations.Test;
+
+import org.hibernate.jsr303.tck.util.TestUtil;
+import static org.hibernate.jsr303.tck.util.TestUtil.assertConstraintViolation;
+import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectNumberOfViolations;
+import static org.hibernate.jsr303.tck.util.TestUtil.assertInvalidPropertyPaths;
+
+/**
+ * Tests for constraint validator resolution.
+ *
+ * @author Hardy Ferentschik
+ */
+@Artifact(artifactType = ArtifactType.JSR303)
+(a)Classes(TestUtil.class)
+public class ValidatorResolutionTest {
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "3.5.3", id = "e"),
+ @SpecAssertion(section = "2.1", id = "d")
+ })
+ public void testUnexpectedTypeInValidatorResolution() {
+ Validator validator = TestUtil.getDefaultValidator();
+
+ Bar bar = new Bar();
+ try {
+ validator.validate( bar );
+ fail();
+ }
+ catch ( UnexpectedTypeException e ) {
+ // success
+ }
+ }
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "3.5.3", id = "f")
+ })
+ public void testAmbigiousValidatorResolution() {
+ Validator validator = TestUtil.getDefaultValidator();
+
+ Foo foo = new Foo( new SerializableBarSubclass() );
+ try {
+ validator.validate( foo );
+ fail();
+ }
+ catch ( UnexpectedTypeException e ) {
+ // success
+ }
+ }
+
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "3.5.3", id = "d")
+ })
+ public void testResolutionOfMinMaxForDifferentTypes() {
+ Validator validator = TestUtil.getDefaultValidator();
+ MinMax minMax = new MinMax( "5", 5 );
+ Set<ConstraintViolation<MinMax>> constraintViolations = validator.validate( minMax );
+ assertCorrectNumberOfViolations( constraintViolations, 2 );
+ assertInvalidPropertyPaths( constraintViolations, new String[] { "number", "numberAsString" } );
+ }
+
+ @Test
+
+ @SpecAssertions({
+ @SpecAssertion(section = "3.5.3", id = "d")
+ })
+ public void testResolutionOfMultipleSizeValidators() {
+ Validator validator = TestUtil.getDefaultValidator();
+
+ Suburb suburb = new Suburb();
+
+ List<Integer> postcodes = new ArrayList<Integer>();
+ postcodes.add( 12345 );
+ suburb.setIncludedPostCodes( postcodes );
+
+ // all values are null and should pass
+ Set<ConstraintViolation<Suburb>> constraintViolations = validator.validate( suburb );
+ assertCorrectNumberOfViolations( constraintViolations, 0 );
+
+ suburb.setName( "" );
+ constraintViolations = validator.validate( suburb );
+ assertCorrectNumberOfViolations( constraintViolations, 1 );
+ assertConstraintViolation(
+ constraintViolations.iterator().next(), Suburb.class, "", "name"
+ );
+
+ suburb.setName( "Hoegsbo" );
+ constraintViolations = validator.validate( suburb );
+ assertCorrectNumberOfViolations( constraintViolations, 0 );
+
+ suburb.addFacility( Suburb.Facility.SHOPPING_MALL, false );
+ constraintViolations = validator.validate( suburb );
+ assertCorrectNumberOfViolations( constraintViolations, 1 );
+ assertConstraintViolation(
+ constraintViolations.iterator().next(),
+ Suburb.class,
+ suburb.getFacilities(),
+ "facilities"
+ );
+
+ suburb.addFacility( Suburb.Facility.BUS_TERMINAL, true );
+ constraintViolations = validator.validate( suburb );
+ assertCorrectNumberOfViolations( constraintViolations, 0 );
+
+ suburb.addStreetName( "Sikelsgatan" );
+ constraintViolations = validator.validate( suburb );
+ assertCorrectNumberOfViolations( constraintViolations, 1 );
+ assertConstraintViolation(
+ constraintViolations.iterator().next(),
+ Suburb.class,
+ suburb.getStreetNames(),
+ "streetNames"
+ );
+
+ suburb.addStreetName( "Marklandsgatan" );
+ constraintViolations = validator.validate( suburb );
+ assertCorrectNumberOfViolations( constraintViolations, 0 );
+
+ Coordinate[] boundingBox = new Coordinate[3];
+ boundingBox[0] = new Coordinate( 0l, 0l );
+ boundingBox[1] = new Coordinate( 0l, 1l );
+ boundingBox[2] = new Coordinate( 1l, 0l );
+ suburb.setBoundingBox( boundingBox );
+ constraintViolations = validator.validate( suburb );
+ assertCorrectNumberOfViolations( constraintViolations, 1 );
+ assertConstraintViolation(
+ constraintViolations.iterator().next(),
+ Suburb.class,
+ suburb.getBoundingBox(),
+ "boundingBox"
+ );
+
+ boundingBox = new Coordinate[4];
+ boundingBox[0] = new Coordinate( 0l, 0l );
+ boundingBox[1] = new Coordinate( 0l, 1l );
+ boundingBox[2] = new Coordinate( 1l, 0l );
+ boundingBox[3] = new Coordinate( 1l, 1l );
+ suburb.setBoundingBox( boundingBox );
+ constraintViolations = validator.validate( suburb );
+ assertCorrectNumberOfViolations( constraintViolations, 0 );
+ }
+}
\ No newline at end of file
Property changes on: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/ValidatorResolutionTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/util/TestUtil.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/util/TestUtil.java 2009-06-04 10:58:55 UTC (rev 16692)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/util/TestUtil.java 2009-06-04 10:59:42 UTC (rev 16693)
@@ -17,10 +17,17 @@
*/
package org.hibernate.jsr303.tck.util;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
-/**
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+/**
* @author Hardy Ferentschik
*/
public final class TestUtil {
@@ -31,4 +38,40 @@
public static Validator getDefaultValidator() {
return Validation.buildDefaultValidatorFactory().getValidator();
}
+
+ public static <T> void assertCorrectNumberOfViolations(Set<ConstraintViolation<T>> violations, int expectedViolations) {
+ assertEquals( violations.size(), expectedViolations, "Wrong number of constraint violations" );
+ }
+
+ public static <T> void assertInvalidPropertyPaths(Set<ConstraintViolation<T>> violations, String[] propertyPaths) {
+ List<String> propertyPathsOfViolations = new ArrayList<String>();
+ for ( ConstraintViolation<?> violation : violations ) {
+ propertyPathsOfViolations.add( violation.getPropertyPath() );
+ }
+
+ for ( String propertyPath : propertyPaths ) {
+ assertTrue(
+ propertyPathsOfViolations.contains( propertyPath ),
+ propertyPath + " should be used in at least one constraint violation"
+ );
+ }
+ }
+
+ public static <T> void assertConstraintViolation(ConstraintViolation<T> violation, Class<T> rootBean, Object invalidValue, String propertyPath) {
+ assertEquals(
+ violation.getPropertyPath(),
+ propertyPath,
+ "Wrong propertyPath."
+ );
+ assertEquals(
+ violation.getRootBean().getClass(),
+ rootBean,
+ "Wrong root bean."
+ );
+ assertEquals(
+ violation.getInvalidValue(),
+ invalidValue,
+ "Wrong invalid value."
+ );
+ }
}
Modified: beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-06-04 10:58:55 UTC (rev 16692)
+++ beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-06-04 10:59:42 UTC (rev 16693)
@@ -17,21 +17,19 @@
<section id="2.1" title="Constraint Definition">
<assertion id="a">
- <text>A constraint on a JavaBean is expressed through one or more annotations</text>
- </assertion>
- <assertion id="b">
<text>An annotation is considered a constraint definition if its retention policy
contains RUNTIME and if the annotation itself is annotated with
javax.validation.Constraint</text>
</assertion>
- <assertion id="c">
- <text>Constraint annotations can target any of the following ElementTypes: FIELD, METHOD, TYPE, ANNOTATION_TYPE</text>
+ <assertion id="b">
+ <text>Constraint annotations can target any of the following ElementTypes: FIELD,
+ METHOD, TYPE, ANNOTATION_TYPE</text>
</assertion>
- <assertion id="d">
+ <assertion id="c">
<text>If a constraint definition is not valid, a ConstraintDefinitionException is raised
either at validation time or when the metadata is requested</text>
</assertion>
- <assertion id="e">
+ <assertion id="d">
<text>Applying a constraint annotation to an incompatible type will raise a
UnexpectedTypeException</text>
</assertion>
@@ -487,40 +485,29 @@
</section>
<section id="3.5.3" title="ConstraintValidator resolution algorithm">
<assertion id="a">
- <text>A constraint is associated to one or more ConstraintValidator
- implementations</text>
- </assertion>
- <assertion id="b">
- <text>The ConstraintValidator executed depends on the type hosting the constraint</text>
- </assertion>
- <assertion id="c">
- <text>For a given constraint evaluation, a single ConstraintValidator is
- considered</text>
- </assertion>
- <assertion id="d">
<text>If the constraint declaration is hosted on a class or an interface, the targeted
type is the class or the interface</text>
</assertion>
- <assertion id="e">
+ <assertion id="b">
<text>If the constraint is hosted on a class attribute, the type of the attribute is the
targeted type</text>
</assertion>
- <assertion id="f">
+ <assertion id="c">
<text>If the constraint is hosted on a getter, the return type of the getter is the
targeted type</text>
</assertion>
- <assertion id="g">
+ <assertion id="d">
<text>the ConstraintValidator chosen to validate a declared type T is the one where the
type supported by the ConstraintValidator is a supertype of T and where there is no
other ConstraintValidator whose supported type is a supertype of T and not a
supertype of the chosen ConstraintValidator supported type</text>
</assertion>
- <assertion id="h">
+ <assertion id="e">
<text>If no ConstraintValidator compliant with T is found amongst the
ConstraintValidators listed by the con- straint A, a UnexpectedTypeException is
raised</text>
</assertion>
- <assertion id="i">
+ <assertion id="f">
<text>If more than one maximally specific ConstraintValidator is found, a
UnexpectedTypeException is raised</text>
</assertion>
@@ -1140,8 +1127,8 @@
constraint declaration</text>
</assertion>
<assertion id="b">
- <text>"message" or "groups" are not permitted names, use the message or groups
- elements instead. Otherwise a ValidationException is raised</text>
+ <text>"message" or "groups" are not permitted names, use the message or groups elements
+ instead. Otherwise a ValidationException is raised</text>
</assertion>
<assertion id="c">
<text>If the element represents a primitive type, a class or an enum, the string
15 years, 6 months
Hibernate SVN: r16692 - beanvalidation/trunk/validation-api/src/main/java/javax/validation.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-06-04 06:58:55 -0400 (Thu, 04 Jun 2009)
New Revision: 16692
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/UnexpectedTypeException.java
Log:
Javadoc
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/UnexpectedTypeException.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/UnexpectedTypeException.java 2009-06-04 09:18:14 UTC (rev 16691)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/UnexpectedTypeException.java 2009-06-04 10:58:55 UTC (rev 16692)
@@ -17,11 +17,9 @@
*/
package javax.validation;
-import javax.validation.ValidationException;
-
/**
* Exception raised in the case that the constraint validator resolution
- * cannot determine a suitable validators for a given type.
+ * cannot determine a suitable validator for a given type.
*
* @author Hardy Ferentschik
*/
15 years, 6 months
Hibernate SVN: r16691 - in beanvalidation/trunk/validation-tck/src/main: resources and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-06-04 05:18:14 -0400 (Thu, 04 Jun 2009)
New Revision: 16691
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/DummyEntityInvalidDefaultGroup.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/InvalidDefaultGroup.java
Removed:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/NoGroupsValidator.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/NoMessageValidator.java
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/InvalidConstraintDefinitionsTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/NoGroups.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/NoMessage.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/ValidProperty.java
beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
Log:
Added test for default groups parameter
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/DummyEntityInvalidDefaultGroup.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/DummyEntityInvalidDefaultGroup.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/DummyEntityInvalidDefaultGroup.java 2009-06-04 09:18:14 UTC (rev 16691)
@@ -0,0 +1,25 @@
+// $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.invalidconstraintdefinitions;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@InvalidDefaultGroup
+public class DummyEntityInvalidDefaultGroup {
+}
\ No newline at end of file
Property changes on: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/DummyEntityInvalidDefaultGroup.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/InvalidConstraintDefinitionsTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/InvalidConstraintDefinitionsTest.java 2009-06-04 09:17:14 UTC (rev 16690)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/InvalidConstraintDefinitionsTest.java 2009-06-04 09:18:14 UTC (rev 16691)
@@ -41,7 +41,7 @@
@Test
@SpecAssertions({
@SpecAssertion(section = "2.1", id = "d"),
- @SpecAssertion(section = "2.1.1", id = "e"),
+ @SpecAssertion(section = "2.1.1", id = "b"),
@SpecAssertion(section = "8.2", id = "a")
})
public void testConstraintDefinitionWithParamterStartingWithValid() {
@@ -58,6 +58,23 @@
@Test
@SpecAssertions({
@SpecAssertion(section = "2.1", id = "d"),
+ @SpecAssertion(section = "2.1.1", id = "c"),
+ @SpecAssertion(section = "8.2", id = "a")
+ })
+ public void testConstraintDefinitionWithoutMessageParameter() {
+ try {
+ Validator validator = TestUtil.getDefaultValidator();
+ validator.validate( new DummyEntityNoMessage() );
+ fail( "The used constraint does not define a message parameter. The validation should have failed." );
+ }
+ catch ( ConstraintDefinitionException e ) {
+ // success
+ }
+ }
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "2.1", id = "d"),
@SpecAssertion(section = "2.1.1", id = "d"),
@SpecAssertion(section = "8.2", id = "a")
})
@@ -75,14 +92,14 @@
@Test
@SpecAssertions({
@SpecAssertion(section = "2.1", id = "d"),
- @SpecAssertion(section = "2.1.1", id = "c"),
+ @SpecAssertion(section = "2.1.1", id = "e"),
@SpecAssertion(section = "8.2", id = "a")
})
- public void testConstraintDefinitionWithoutMessageParameter() {
+ public void testConstraintDefinitionWithWrongDefaultGroupValue() {
try {
Validator validator = TestUtil.getDefaultValidator();
- validator.validate( new DummyEntityNoMessage() );
- fail( "The used constraint does not define a message parameter. The validation should have failed." );
+ validator.validate( new DummyEntityInvalidDefaultGroup() );
+ fail( "The default groups paramter is not the empty array. The validation should have failed." );
}
catch ( ConstraintDefinitionException e ) {
// success
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/InvalidDefaultGroup.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/InvalidDefaultGroup.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/InvalidDefaultGroup.java 2009-06-04 09:18:14 UTC (rev 16691)
@@ -0,0 +1,51 @@
+// $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.invalidconstraintdefinitions;
+
+import java.lang.annotation.Documented;
+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.groups.Default;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Documented
+@Constraint(validatedBy = InvalidDefaultGroup.InvalidDefaultGroupValidator.class)
+@Target({ TYPE })
+@Retention(RUNTIME)
+public @interface InvalidDefaultGroup {
+ public abstract String message() default "default message";
+
+ public abstract Class<?>[] groups() default Default.class;
+
+ public class InvalidDefaultGroupValidator implements ConstraintValidator<InvalidDefaultGroup, Object> {
+
+ public void initialize(InvalidDefaultGroup parameters) {
+ }
+
+ public boolean isValid(Object object, ConstraintValidatorContext constraintValidatorContext) {
+ return false;
+ }
+ }
+}
\ No newline at end of file
Property changes on: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/InvalidDefaultGroup.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/NoGroups.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/NoGroups.java 2009-06-04 09:17:14 UTC (rev 16690)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/NoGroups.java 2009-06-04 09:18:14 UTC (rev 16691)
@@ -23,14 +23,26 @@
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Target;
import javax.validation.Constraint;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
/**
* @author Hardy Ferentschik
*/
@Documented
-@Constraint(validatedBy = NoGroupsValidator.class)
+@Constraint(validatedBy = NoGroups.NoGroupsValidator.class)
@Target({ TYPE })
@Retention(RUNTIME)
public @interface NoGroups {
String message() default "default message";
+
+ public class NoGroupsValidator implements ConstraintValidator<NoGroups, Object> {
+
+ public void initialize(NoGroups parameters) {
+ }
+
+ public boolean isValid(Object object, ConstraintValidatorContext constraintValidatorContext) {
+ return false;
+ }
+ }
}
\ No newline at end of file
Deleted: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/NoGroupsValidator.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/NoGroupsValidator.java 2009-06-04 09:17:14 UTC (rev 16690)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/NoGroupsValidator.java 2009-06-04 09:18:14 UTC (rev 16691)
@@ -1,34 +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.invalidconstraintdefinitions;
-
-import javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
-
-/**
- * @author Hardy Ferentschik
- */
-public class NoGroupsValidator implements ConstraintValidator<NoGroups, Object> {
-
- public void initialize(NoGroups parameters) {
- }
-
- public boolean isValid(Object object, ConstraintValidatorContext constraintValidatorContext) {
- return false;
- }
-}
\ No newline at end of file
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/NoMessage.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/NoMessage.java 2009-06-04 09:17:14 UTC (rev 16690)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/NoMessage.java 2009-06-04 09:18:14 UTC (rev 16691)
@@ -23,14 +23,26 @@
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Target;
import javax.validation.Constraint;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
/**
* @author Hardy Ferentschik
*/
@Documented
-@Constraint(validatedBy = NoMessageValidator.class)
+@Constraint(validatedBy = NoMessage.NoMessageValidator.class)
@Target({ TYPE })
@Retention(RUNTIME)
public @interface NoMessage {
Class<?>[] groups() default { };
+
+ public class NoMessageValidator implements ConstraintValidator<NoMessage, Object> {
+
+ public void initialize(NoMessage parameters) {
+ }
+
+ public boolean isValid(Object object, ConstraintValidatorContext constraintValidatorContext) {
+ return false;
+ }
+ }
}
\ No newline at end of file
Deleted: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/NoMessageValidator.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/NoMessageValidator.java 2009-06-04 09:17:14 UTC (rev 16690)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/NoMessageValidator.java 2009-06-04 09:18:14 UTC (rev 16691)
@@ -1,34 +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.invalidconstraintdefinitions;
-
-import javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
-
-/**
- * @author Hardy Ferentschik
- */
-public class NoMessageValidator implements ConstraintValidator<NoMessage, Object> {
-
- public void initialize(NoMessage parameters) {
- }
-
- public boolean isValid(Object object, ConstraintValidatorContext constraintValidatorContext) {
- return false;
- }
-}
\ No newline at end of file
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/ValidProperty.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/ValidProperty.java 2009-06-04 09:17:14 UTC (rev 16690)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/ValidProperty.java 2009-06-04 09:18:14 UTC (rev 16691)
@@ -23,12 +23,14 @@
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Target;
import javax.validation.Constraint;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
/**
* @author Hardy Ferentschik
*/
@Documented
-@Constraint(validatedBy = NoGroupsValidator.class)
+@Constraint(validatedBy = ValidProperty.ValidPropertyValidator.class)
@Target({ TYPE })
@Retention(RUNTIME)
public @interface ValidProperty {
@@ -37,4 +39,14 @@
Class<?>[] groups() default { };
int validLength() default 0;
+
+ public class ValidPropertyValidator implements ConstraintValidator<ValidProperty, Object> {
+
+ public void initialize(ValidProperty parameters) {
+ }
+
+ public boolean isValid(Object object, ConstraintValidatorContext constraintValidatorContext) {
+ return false;
+ }
+ }
}
\ No newline at end of file
Modified: beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-06-04 09:17:14 UTC (rev 16690)
+++ beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-06-04 09:18:14 UTC (rev 16691)
@@ -43,7 +43,7 @@
constraint is applied to a JavaBean.</text>
</assertion>
<assertion id="b">
- <text>annotation elements starting with valid are not allowed</text>
+ <text>Annotation elements starting with valid are not allowed</text>
</assertion>
<assertion id="c">
<text>Every constraint annotation must define a message element of type String</text>
15 years, 6 months
Hibernate SVN: r16690 - validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-06-04 05:17:14 -0400 (Thu, 04 Jun 2009)
New Revision: 16690
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintHelper.java
Log:
Raising an exception now in case ther groups default value is not the empty array
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintHelper.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintHelper.java 2009-06-03 22:29:24 UTC (rev 16689)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintHelper.java 2009-06-04 09:17:14 UTC (rev 16690)
@@ -258,16 +258,24 @@
}
catch ( Exception e ) {
String msg = annotation.annotationType().getName() + " contains Constraint annotation, but does " +
- "not contain a message parameter. Annotation is getting ignored.";
+ "not contain a message parameter.";
throw new ConstraintDefinitionException( msg );
}
try {
- ReflectionHelper.getAnnotationParameter( annotation, "groups", Class[].class );
+ Class<?>[] defaultGroups = ( Class<?>[] ) annotation.annotationType()
+ .getMethod( "groups" )
+ .getDefaultValue();
+ if ( defaultGroups.length != 0 ) {
+ String msg = annotation.annotationType()
+ .getName() + " contains Constraint annotation, but the groups " +
+ "paramter default value is not empty.";
+ throw new ConstraintDefinitionException( msg );
+ }
}
- catch ( Exception e ) {
+ catch ( NoSuchMethodException nsme ) {
String msg = annotation.annotationType().getName() + " contains Constraint annotation, but does " +
- "not contain a groups parameter. Annotation is getting ignored.";
+ "not contain a groups parameter.";
throw new ConstraintDefinitionException( msg );
}
15 years, 6 months
Hibernate SVN: r16689 - in core/tags/v327: doc/reference/en/modules and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-06-03 18:29:24 -0400 (Wed, 03 Jun 2009)
New Revision: 16689
Modified:
core/tags/v327/build.xml
core/tags/v327/doc/reference/en/modules/persistent_classes.xml
Log:
2 minor changes needed to get 3.2.7 to build (committed to branch as well)
Modified: core/tags/v327/build.xml
===================================================================
--- core/tags/v327/build.xml 2009-06-03 15:14:31 UTC (rev 16688)
+++ core/tags/v327/build.xml 2009-06-03 22:29:24 UTC (rev 16689)
@@ -700,6 +700,7 @@
<target name="javadoc" description="Compile the Javadoc API documentation to dist dir" depends="splash,antlr">
<mkdir dir="${dir.out.doc}/api"/>
<javadoc classpathref="path.lib"
+ source="${javac.source}"
destdir="${dir.out.doc}/api"
use="true"
protected="true"
Modified: core/tags/v327/doc/reference/en/modules/persistent_classes.xml
===================================================================
--- core/tags/v327/doc/reference/en/modules/persistent_classes.xml 2009-06-03 15:14:31 UTC (rev 16688)
+++ core/tags/v327/doc/reference/en/modules/persistent_classes.xml 2009-06-03 22:29:24 UTC (rev 16689)
@@ -1,5 +1,3 @@
-<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
-
<chapter id="persistent-classes" revision="2">
<title>Persistent Classes</title>
15 years, 6 months
Hibernate SVN: r16688 - core/tags/v327.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-06-03 11:14:31 -0400 (Wed, 03 Jun 2009)
New Revision: 16688
Removed:
core/tags/v327/Branch_3_2/
Log:
Removed core/tags/v327/Branch_3_2
15 years, 6 months
Hibernate SVN: r16687 - in core/tags/v327: Branch_3_2 and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-06-03 11:14:09 -0400 (Wed, 03 Jun 2009)
New Revision: 16687
Added:
core/tags/v327/test/
Removed:
core/tags/v327/Branch_3_2/test/
Log:
Moved core/tags/v327/Branch_3_2/test to core/tags/v327/test.
Copied: core/tags/v327/test (from rev 16686, core/tags/v327/Branch_3_2/test)
15 years, 6 months
Hibernate SVN: r16686 - in core/tags/v327: Branch_3_2 and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-06-03 11:13:57 -0400 (Wed, 03 Jun 2009)
New Revision: 16686
Added:
core/tags/v327/src/
Removed:
core/tags/v327/Branch_3_2/src/
Log:
Moved core/tags/v327/Branch_3_2/src to core/tags/v327/src.
Copied: core/tags/v327/src (from rev 16685, core/tags/v327/Branch_3_2/src)
15 years, 6 months
Hibernate SVN: r16685 - in core/tags/v327: Branch_3_2 and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-06-03 11:13:46 -0400 (Wed, 03 Jun 2009)
New Revision: 16685
Added:
core/tags/v327/lib/
Removed:
core/tags/v327/Branch_3_2/lib/
Log:
Moved core/tags/v327/Branch_3_2/lib to core/tags/v327/lib.
Copied: core/tags/v327/lib (from rev 16684, core/tags/v327/Branch_3_2/lib)
15 years, 6 months