Hibernate SVN: r17110 - beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/groupsequence.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-07-16 11:51:23 -0400 (Thu, 16 Jul 2009)
New Revision: 17110
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/groupsequence/SequenceResolutionTest.java
Log:
Tests for group sequences
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/groupsequence/SequenceResolutionTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/groupsequence/SequenceResolutionTest.java 2009-07-16 15:50:31 UTC (rev 17109)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/groupsequence/SequenceResolutionTest.java 2009-07-16 15:51:23 UTC (rev 17110)
@@ -55,7 +55,7 @@
validator.validate( entity, Complete.class );
}
- @Test
+ @Test(enabled = false)
// @SpecAssertion(section = "3.4.2", id = "j")
public void testOnlyFirstGroupInSequenceGetEvaluated() {
Validator validator = TestUtil.getDefaultValidator();
16 years, 3 months
Hibernate SVN: r17109 - in beanvalidation/trunk/validation-tck/src/main: java/org/hibernate/jsr303/tck/tests/constraints/groups/groupsequence and 3 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-07-16 11:50:31 -0400 (Thu, 16 Jul 2009)
New Revision: 17109
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/groupsequence/
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/inheritance/
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/inheritance/GroupInheritanceTest.java
Removed:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/defaultgroupsequence/
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/GroupInheritanceTest.java
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/GroupTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/groupsequence/SequenceResolutionTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/groupsequence/TestEntity.java
beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
Log:
Tests for group sequences
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/GroupTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/GroupTest.java 2009-07-16 14:00:36 UTC (rev 17108)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/GroupTest.java 2009-07-16 15:50:31 UTC (rev 17109)
@@ -355,6 +355,8 @@
@Test(expectedExceptions = GroupDefinitionException.class)
@SpecAssertions({
@SpecAssertion(section = "3.4.2", id = "e"),
+ @SpecAssertion(section = "3.4.2", id = "f"),
+ @SpecAssertion(section = "3.4.2", id = "i"),
@SpecAssertion(section = "8.4", id = "a")
})
public void testCyclicGroupSequence() {
Copied: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/groupsequence (from rev 17087, beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/defaultgroupsequence)
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/groupsequence/SequenceResolutionTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/defaultgroupsequence/SequenceResolutionTest.java 2009-07-13 23:41:18 UTC (rev 17087)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/groupsequence/SequenceResolutionTest.java 2009-07-16 15:50:31 UTC (rev 17109)
@@ -15,11 +15,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.hibernate.jsr303.tck.tests.constraints.groups.defaultgroupsequence;
+package org.hibernate.jsr303.tck.tests.constraints.groups.groupsequence;
+import java.util.Set;
+import javax.validation.ConstraintViolation;
import javax.validation.GroupDefinitionException;
+import javax.validation.GroupSequence;
import javax.validation.Validator;
+import javax.validation.constraints.Pattern;
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecAssertions;
import org.jboss.testharness.AbstractTest;
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.ArtifactType;
@@ -27,6 +33,7 @@
import org.testng.annotations.Test;
import org.hibernate.jsr303.tck.util.TestUtil;
+import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectNumberOfViolations;
/**
* @author Hardy Ferentschik
@@ -36,9 +43,51 @@
public class SequenceResolutionTest extends AbstractTest {
@Test(expectedExceptions = GroupDefinitionException.class)
+ @SpecAssertions({
+ @SpecAssertion(section = "3.4.2", id = "e"),
+ @SpecAssertion(section = "3.4.2", id = "f"),
+ @SpecAssertion(section = "3.4.2", id = "i"),
+ @SpecAssertion(section = "8.4", id = "a")
+ })
public void testInvalidDefinitionOfDefaultSequenceInEntity() {
Validator validator = TestUtil.getDefaultValidator();
TestEntity entity = new TestEntity();
validator.validate( entity, Complete.class );
}
+
+ @Test
+// @SpecAssertion(section = "3.4.2", id = "j")
+ public void testOnlyFirstGroupInSequenceGetEvaluated() {
+ Validator validator = TestUtil.getDefaultValidator();
+ Car car = new Car( "USd-298" );
+
+ Set<ConstraintViolation<Car>> violations = validator.validateProperty(
+ car, "licensePlateNumber", All.class
+ );
+ assertCorrectNumberOfViolations( violations, 1 );
+ ConstraintViolation<Car> violation = violations.iterator().next();
+ }
+
+ class Car {
+ @Pattern(regexp = "[A-Z][A-Z][A-Z]-[0-9][0-9][0-9]", groups = { First.class, Second.class })
+ private String licensePlateNumber;
+
+ Car(String licensePlateNumber) {
+ this.licensePlateNumber = licensePlateNumber;
+ }
+
+ public String getLicensePlateNumber() {
+ return licensePlateNumber;
+ }
+ }
+
+ interface First {
+ }
+
+ interface Second {
+ }
+
+ @GroupSequence({ First.class, Second.class })
+ interface All {
+ }
}
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/groupsequence/TestEntity.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/defaultgroupsequence/TestEntity.java 2009-07-13 23:41:18 UTC (rev 17087)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/groupsequence/TestEntity.java 2009-07-16 15:50:31 UTC (rev 17109)
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.hibernate.jsr303.tck.tests.constraints.groups.defaultgroupsequence;
+package org.hibernate.jsr303.tck.tests.constraints.groups.groupsequence;
import javax.validation.GroupSequence;
import javax.validation.constraints.NotNull;
Copied: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/inheritance/GroupInheritanceTest.java (from rev 17108, beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/GroupInheritanceTest.java)
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/inheritance/GroupInheritanceTest.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/inheritance/GroupInheritanceTest.java 2009-07-16 15:50:31 UTC (rev 17109)
@@ -0,0 +1,130 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.jsr303.tck.tests.constraints.groups.inheritance;
+
+import java.util.Set;
+import javax.validation.ConstraintViolation;
+import javax.validation.Validator;
+import javax.validation.constraints.AssertTrue;
+import javax.validation.constraints.Digits;
+import javax.validation.constraints.Max;
+import javax.validation.metadata.BeanDescriptor;
+import javax.validation.metadata.ConstraintDescriptor;
+import javax.validation.metadata.PropertyDescriptor;
+
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.testharness.AbstractTest;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.ArtifactType;
+import org.jboss.testharness.impl.packaging.Classes;
+import static org.testng.Assert.assertEquals;
+import org.testng.annotations.Test;
+
+import org.hibernate.jsr303.tck.util.TestUtil;
+import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectConstraintTypes;
+import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectNumberOfViolations;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Artifact(artifactType = ArtifactType.JSR303)
+@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
+public class GroupInheritanceTest extends AbstractTest {
+
+ @Test
+ @SpecAssertion(section = "3.4.1", id = "a")
+ public void testGroupCanInheritGroupsViaInterfaceInheritance() {
+ Validator validator = TestUtil.getDefaultValidator();
+ Part part = new Part();
+ part.setPartNumber( 123456 );
+
+ Set<ConstraintViolation<Part>> violations = validator.validate( part, All.class );
+ assertCorrectNumberOfViolations( violations, 2 );
+ assertCorrectConstraintTypes( violations, Digits.class, AssertTrue.class );
+
+ part.setPartNumber( 12345 );
+ part.setQaChecked( true );
+ violations = validator.validate( part, All.class );
+ assertCorrectNumberOfViolations( violations, 0 );
+ }
+
+ @Test
+ @SpecAssertion(section = "3.4.1", id = "b")
+ public void testGroupMembership() {
+ Validator validator = TestUtil.getDefaultValidator();
+ BeanDescriptor descriptor = validator.getConstraintsForClass( MiniaturePart.class );
+
+ // PreManufacturing belongs implicitly to All
+ PropertyDescriptor propertyDescriptor = descriptor.getConstraintsForProperty( "partNumber" );
+ Set<ConstraintDescriptor<?>> descriptorsForGroup = propertyDescriptor.getUnorderdConstraintDescriptorsMatchingGroups(
+ All.class
+ );
+ assertEquals( descriptorsForGroup.size(), 1, "Wrong number of descriptors" );
+ assertEquals( descriptorsForGroup.iterator().next().getAnnotation().annotationType(), Digits.class );
+
+ // PostManufacturing belongs implicitly to All
+ propertyDescriptor = descriptor.getConstraintsForProperty( "qaChecked" );
+ descriptorsForGroup = propertyDescriptor.getUnorderdConstraintDescriptorsMatchingGroups( All.class );
+ assertEquals( descriptorsForGroup.size(), 1, "Wrong number of descriptors" );
+ assertEquals( descriptorsForGroup.iterator().next().getAnnotation().annotationType(), AssertTrue.class );
+
+ propertyDescriptor = descriptor.getConstraintsForProperty( "size" );
+ descriptorsForGroup = propertyDescriptor.getUnorderdConstraintDescriptorsMatchingGroups( All.class );
+ assertEquals( descriptorsForGroup.size(), 1, "Wrong number of descriptors" );
+ assertEquals( descriptorsForGroup.iterator().next().getAnnotation().annotationType(), Max.class );
+ }
+
+ class Part {
+ @Digits(integer = 5, fraction = 0, groups = PreManufacturing.class)
+ private int partNumber;
+
+ @AssertTrue(groups = PostManufacturing.class)
+ private boolean qaChecked;
+
+ public int getPartNumber() {
+ return partNumber;
+ }
+
+ public void setPartNumber(int partNumber) {
+ this.partNumber = partNumber;
+ }
+
+ public boolean getQaChecked() {
+ return qaChecked;
+ }
+
+ public void setQaChecked(boolean qaChecked) {
+ this.qaChecked = qaChecked;
+ }
+ }
+
+ class MiniaturePart extends Part {
+ @Max(value = 10, groups = All.class)
+ private int size;
+ }
+
+ interface PreManufacturing {
+ }
+
+ interface PostManufacturing {
+ }
+
+ interface All extends PreManufacturing, PostManufacturing {
+ }
+
+}
\ No newline at end of file
Property changes on: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/inheritance/GroupInheritanceTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Deleted: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/GroupInheritanceTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/GroupInheritanceTest.java 2009-07-16 14:00:36 UTC (rev 17108)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/GroupInheritanceTest.java 2009-07-16 15:50:31 UTC (rev 17109)
@@ -1,130 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.hibernate.jsr303.tck.tests.constraints.inheritance;
-
-import java.util.Set;
-import javax.validation.ConstraintViolation;
-import javax.validation.Validator;
-import javax.validation.constraints.AssertTrue;
-import javax.validation.constraints.Digits;
-import javax.validation.constraints.Max;
-import javax.validation.metadata.BeanDescriptor;
-import javax.validation.metadata.ConstraintDescriptor;
-import javax.validation.metadata.PropertyDescriptor;
-
-import org.jboss.test.audit.annotations.SpecAssertion;
-import org.jboss.testharness.AbstractTest;
-import org.jboss.testharness.impl.packaging.Artifact;
-import org.jboss.testharness.impl.packaging.ArtifactType;
-import org.jboss.testharness.impl.packaging.Classes;
-import static org.testng.Assert.assertEquals;
-import org.testng.annotations.Test;
-
-import org.hibernate.jsr303.tck.util.TestUtil;
-import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectConstraintTypes;
-import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectNumberOfViolations;
-
-/**
- * @author Hardy Ferentschik
- */
-@Artifact(artifactType = ArtifactType.JSR303)
-@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
-public class GroupInheritanceTest extends AbstractTest {
-
- @Test
- @SpecAssertion(section = "3.4.1", id = "a")
- public void testGroupCanInheritGroupsViaInterfaceInheritance() {
- Validator validator = TestUtil.getDefaultValidator();
- Part part = new Part();
- part.setPartNumber( 123456 );
-
- Set<ConstraintViolation<Part>> violations = validator.validate( part, All.class );
- assertCorrectNumberOfViolations( violations, 2 );
- assertCorrectConstraintTypes( violations, Digits.class, AssertTrue.class );
-
- part.setPartNumber( 12345 );
- part.setQaChecked( true );
- violations = validator.validate( part, All.class );
- assertCorrectNumberOfViolations( violations, 0 );
- }
-
- @Test
- @SpecAssertion(section = "3.4.1", id = "b")
- public void testGroupMembership() {
- Validator validator = TestUtil.getDefaultValidator();
- BeanDescriptor descriptor = validator.getConstraintsForClass( MiniaturePart.class );
-
- // PreManufacturing belongs implicitly to All
- PropertyDescriptor propertyDescriptor = descriptor.getConstraintsForProperty( "partNumber" );
- Set<ConstraintDescriptor<?>> descriptorsForGroup = propertyDescriptor.getUnorderdConstraintDescriptorsMatchingGroups(
- All.class
- );
- assertEquals( descriptorsForGroup.size(), 1, "Wrong number of descriptors" );
- assertEquals( descriptorsForGroup.iterator().next().getAnnotation().annotationType(), Digits.class );
-
- // PostManufacturing belongs implicitly to All
- propertyDescriptor = descriptor.getConstraintsForProperty( "qaChecked" );
- descriptorsForGroup = propertyDescriptor.getUnorderdConstraintDescriptorsMatchingGroups( All.class );
- assertEquals( descriptorsForGroup.size(), 1, "Wrong number of descriptors" );
- assertEquals( descriptorsForGroup.iterator().next().getAnnotation().annotationType(), AssertTrue.class );
-
- propertyDescriptor = descriptor.getConstraintsForProperty( "size" );
- descriptorsForGroup = propertyDescriptor.getUnorderdConstraintDescriptorsMatchingGroups( All.class );
- assertEquals( descriptorsForGroup.size(), 1, "Wrong number of descriptors" );
- assertEquals( descriptorsForGroup.iterator().next().getAnnotation().annotationType(), Max.class );
- }
-
- class Part {
- @Digits(integer = 5, fraction = 0, groups = PreManufacturing.class)
- private int partNumber;
-
- @AssertTrue(groups = PostManufacturing.class)
- private boolean qaChecked;
-
- public int getPartNumber() {
- return partNumber;
- }
-
- public void setPartNumber(int partNumber) {
- this.partNumber = partNumber;
- }
-
- public boolean getQaChecked() {
- return qaChecked;
- }
-
- public void setQaChecked(boolean qaChecked) {
- this.qaChecked = qaChecked;
- }
- }
-
- class MiniaturePart extends Part {
- @Max(value = 10, groups = All.class)
- private int size;
- }
-
- interface PreManufacturing {
- }
-
- interface PostManufacturing {
- }
-
- interface All extends PreManufacturing, PostManufacturing {
- }
-
-}
\ 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-07-16 14:00:36 UTC (rev 17108)
+++ beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-07-16 15:50:31 UTC (rev 17109)
@@ -357,11 +357,11 @@
</assertion>
<assertion id="c">
<text>Note that a group member of a sequence can itself be composed of several groups
- via inherit- ance or sequence definition. In this case, each composed group must
+ via inheritance or sequence definition. In this case, each composed group must
respect the sequence order as well.</text>
</assertion>
<assertion id="d">
- <text>if one of the groups processed in the sequence generates one or more constraint
+ <text>If one of the groups processed in the sequence generates one or more constraint
violation, the groups following in the sequence must not be processed</text>
</assertion>
<assertion id="e">
@@ -373,10 +373,11 @@
<text>If a group containing such a circularity is evaluated, a GroupDefinitionException
is raised.</text>
</assertion>
- <assertion id="g">
- <text>Groups defining a sequence should not directly inherit other groups</text>
+ <assertion id="g" testable="false">
+ <text>Groups defining a sequence should not directly inherit other groups. In other words, the interface hosting the group
+ sequence should not have any super interface.</text>
</assertion>
- <assertion id="h">
+ <assertion id="h" testable="false">
<text>Groups defining a sequence should not be used directly in constraint
declarations</text>
</assertion>
@@ -426,7 +427,7 @@
<text>Note that this implies that a given validation constraint will not be processed
more than once per validation</text>
</assertion>
- <assertion id="c">
+ <assertion id="c" testable="false">
<text>Unless ordered by group sequences, groups can be validated in no particular
order</text>
</assertion>
16 years, 3 months
Hibernate SVN: r17108 - beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-07-16 10:00:36 -0400 (Thu, 16 Jul 2009)
New Revision: 17108
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/GroupInheritanceTest.java
Log:
Tests for group inheritance
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/GroupInheritanceTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/GroupInheritanceTest.java 2009-07-16 14:00:06 UTC (rev 17107)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/GroupInheritanceTest.java 2009-07-16 14:00:36 UTC (rev 17108)
@@ -22,12 +22,17 @@
import javax.validation.Validator;
import javax.validation.constraints.AssertTrue;
import javax.validation.constraints.Digits;
+import javax.validation.constraints.Max;
+import javax.validation.metadata.BeanDescriptor;
+import javax.validation.metadata.ConstraintDescriptor;
+import javax.validation.metadata.PropertyDescriptor;
import org.jboss.test.audit.annotations.SpecAssertion;
import org.jboss.testharness.AbstractTest;
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.ArtifactType;
import org.jboss.testharness.impl.packaging.Classes;
+import static org.testng.Assert.assertEquals;
import org.testng.annotations.Test;
import org.hibernate.jsr303.tck.util.TestUtil;
@@ -58,6 +63,32 @@
assertCorrectNumberOfViolations( violations, 0 );
}
+ @Test
+ @SpecAssertion(section = "3.4.1", id = "b")
+ public void testGroupMembership() {
+ Validator validator = TestUtil.getDefaultValidator();
+ BeanDescriptor descriptor = validator.getConstraintsForClass( MiniaturePart.class );
+
+ // PreManufacturing belongs implicitly to All
+ PropertyDescriptor propertyDescriptor = descriptor.getConstraintsForProperty( "partNumber" );
+ Set<ConstraintDescriptor<?>> descriptorsForGroup = propertyDescriptor.getUnorderdConstraintDescriptorsMatchingGroups(
+ All.class
+ );
+ assertEquals( descriptorsForGroup.size(), 1, "Wrong number of descriptors" );
+ assertEquals( descriptorsForGroup.iterator().next().getAnnotation().annotationType(), Digits.class );
+
+ // PostManufacturing belongs implicitly to All
+ propertyDescriptor = descriptor.getConstraintsForProperty( "qaChecked" );
+ descriptorsForGroup = propertyDescriptor.getUnorderdConstraintDescriptorsMatchingGroups( All.class );
+ assertEquals( descriptorsForGroup.size(), 1, "Wrong number of descriptors" );
+ assertEquals( descriptorsForGroup.iterator().next().getAnnotation().annotationType(), AssertTrue.class );
+
+ propertyDescriptor = descriptor.getConstraintsForProperty( "size" );
+ descriptorsForGroup = propertyDescriptor.getUnorderdConstraintDescriptorsMatchingGroups( All.class );
+ assertEquals( descriptorsForGroup.size(), 1, "Wrong number of descriptors" );
+ assertEquals( descriptorsForGroup.iterator().next().getAnnotation().annotationType(), Max.class );
+ }
+
class Part {
@Digits(integer = 5, fraction = 0, groups = PreManufacturing.class)
private int partNumber;
@@ -82,6 +113,11 @@
}
}
+ class MiniaturePart extends Part {
+ @Max(value = 10, groups = All.class)
+ private int size;
+ }
+
interface PreManufacturing {
}
16 years, 3 months
Hibernate SVN: r17107 - in validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation: metadata and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-07-16 10:00:06 -0400 (Thu, 16 Jul 2009)
New Revision: 17107
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/GroupChain.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata/ElementDescriptorImpl.java
Log:
A first cut at HV-176
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/GroupChain.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/GroupChain.java 2009-07-16 11:09:58 UTC (rev 17106)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/GroupChain.java 2009-07-16 14:00:06 UTC (rev 17107)
@@ -19,9 +19,11 @@
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import javax.validation.GroupDefinitionException;
import javax.validation.groups.Default;
@@ -51,6 +53,15 @@
return sequenceMap.values().iterator();
}
+ public Iterator<Group> getAllGroupsUnordered() {
+ Set<Group> allGroups = new HashSet<Group>();
+ allGroups.addAll( groupList );
+ for ( List<Group> sequenceList : sequenceMap.values() ) {
+ allGroups.addAll( sequenceList );
+ }
+ return allGroups.iterator();
+ }
+
public boolean containsSequence(Class<?> groupSequence) {
return sequenceMap.containsKey( groupSequence );
}
@@ -94,7 +105,7 @@
private void ensureDefaultGroupSequenceIsExpandable(List<Group> groupList, List<Group> defaultGroupList, int defaultGroupIndex) {
for ( int i = 0; i < defaultGroupList.size(); i++ ) {
Group group = defaultGroupList.get( i );
- if(group.getGroup().equals( Default.class )) {
+ if ( group.getGroup().equals( Default.class ) ) {
continue; // we don't have to consider the default group since it is the one we want to replace
}
int index = groupList.indexOf( group ); // check whether the sequence contains group of the default group sequence
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata/ElementDescriptorImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata/ElementDescriptorImpl.java 2009-07-16 11:09:58 UTC (rev 17106)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata/ElementDescriptorImpl.java 2009-07-16 14:00:06 UTC (rev 17107)
@@ -17,12 +17,18 @@
*/
package org.hibernate.validation.metadata;
+import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.Set;
import javax.validation.metadata.ConstraintDescriptor;
import javax.validation.metadata.ElementDescriptor;
+import org.hibernate.validation.engine.groups.Group;
+import org.hibernate.validation.engine.groups.GroupChain;
+import org.hibernate.validation.engine.groups.GroupChainGenerator;
+
/**
* Describe a validated element (class, field or property).
*
@@ -41,31 +47,34 @@
constraintDescriptors.add( constraintDescriptor );
}
- /**
- * {@inheritDoc}
- */
public boolean hasConstraints() {
return constraintDescriptors.size() != 0;
}
- /**
- * {@inheritDoc}
- */
public Class<?> getElementClass() {
return type;
}
- /**
- * {@inheritDoc}
- */
public Set<ConstraintDescriptor<?>> getConstraintDescriptors() {
return Collections.unmodifiableSet( constraintDescriptors );
}
- /**
- * {@inheritDoc}
- */
public Set<ConstraintDescriptor<?>> getUnorderdConstraintDescriptorsMatchingGroups(Class<?>... groups) {
- throw new UnsupportedOperationException( "Not yet implemented HV-176");
+ Set<ConstraintDescriptor<?>> matchingDescriptors = new HashSet<ConstraintDescriptor<?>>();
+ GroupChain groupChain = new GroupChainGenerator().getGroupChainFor( Arrays.asList( groups ) );
+ Iterator<Group> groupIterator = groupChain.getGroupIterator();
+ while ( groupIterator.hasNext() ) {
+ Group g = groupIterator.next();
+ addMatchingDescriptorsForGroup( g.getGroup(), matchingDescriptors );
+ }
+ return Collections.unmodifiableSet( matchingDescriptors );
}
+
+ private void addMatchingDescriptorsForGroup(Class<?> group, Set<ConstraintDescriptor<?>> matchingDescriptors) {
+ for ( ConstraintDescriptor<?> descriptor : constraintDescriptors ) {
+ if ( descriptor.getGroups().contains( group ) ) {
+ matchingDescriptors.add( descriptor );
+ }
+ }
+ }
}
16 years, 3 months
Hibernate SVN: r17106 - in beanvalidation/trunk/validation-tck/src/main: java/org/hibernate/jsr303/tck/tests/xmlconfiguration and 4 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-07-16 07:09:58 -0400 (Thu, 16 Jul 2009)
New Revision: 17106
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/GroupInheritanceTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/GroupIsNotAllowedAsElementNameTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/MandatoryNameAttributeTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/MessageIsNotAllowedAsElementNameTest.java
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/constraints-with-group-element.xml
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/constraints-with-message-element.xml
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/constraints-with-no-name.xml
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/validation-invalid-element-name-group.xml
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/validation-invalid-element-name-message.xml
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/validation-mandatory-name-attribute.xml
Modified:
beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
Log:
more tck tests for xml mapping and group inheritance
Copied: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/GroupInheritanceTest.java (from rev 17087, beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/ConstraintInheritanceTest.java)
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/GroupInheritanceTest.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/GroupInheritanceTest.java 2009-07-16 11:09:58 UTC (rev 17106)
@@ -0,0 +1,94 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.jsr303.tck.tests.constraints.inheritance;
+
+import java.util.Set;
+import javax.validation.ConstraintViolation;
+import javax.validation.Validator;
+import javax.validation.constraints.AssertTrue;
+import javax.validation.constraints.Digits;
+
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.testharness.AbstractTest;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.ArtifactType;
+import org.jboss.testharness.impl.packaging.Classes;
+import org.testng.annotations.Test;
+
+import org.hibernate.jsr303.tck.util.TestUtil;
+import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectConstraintTypes;
+import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectNumberOfViolations;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Artifact(artifactType = ArtifactType.JSR303)
+@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
+public class GroupInheritanceTest extends AbstractTest {
+
+ @Test
+ @SpecAssertion(section = "3.4.1", id = "a")
+ public void testGroupCanInheritGroupsViaInterfaceInheritance() {
+ Validator validator = TestUtil.getDefaultValidator();
+ Part part = new Part();
+ part.setPartNumber( 123456 );
+
+ Set<ConstraintViolation<Part>> violations = validator.validate( part, All.class );
+ assertCorrectNumberOfViolations( violations, 2 );
+ assertCorrectConstraintTypes( violations, Digits.class, AssertTrue.class );
+
+ part.setPartNumber( 12345 );
+ part.setQaChecked( true );
+ violations = validator.validate( part, All.class );
+ assertCorrectNumberOfViolations( violations, 0 );
+ }
+
+ class Part {
+ @Digits(integer = 5, fraction = 0, groups = PreManufacturing.class)
+ private int partNumber;
+
+ @AssertTrue(groups = PostManufacturing.class)
+ private boolean qaChecked;
+
+ public int getPartNumber() {
+ return partNumber;
+ }
+
+ public void setPartNumber(int partNumber) {
+ this.partNumber = partNumber;
+ }
+
+ public boolean getQaChecked() {
+ return qaChecked;
+ }
+
+ public void setQaChecked(boolean qaChecked) {
+ this.qaChecked = qaChecked;
+ }
+ }
+
+ interface PreManufacturing {
+ }
+
+ interface PostManufacturing {
+ }
+
+ interface All extends PreManufacturing, PostManufacturing {
+ }
+
+}
\ No newline at end of file
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/GroupIsNotAllowedAsElementNameTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/GroupIsNotAllowedAsElementNameTest.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/GroupIsNotAllowedAsElementNameTest.java 2009-07-16 11:09:58 UTC (rev 17106)
@@ -0,0 +1,56 @@
+// $Id: InvalidXmlConfigurationTest.java 16948 2009-06-25 10:10:13Z 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.xmlconfiguration.constraintdeclaration;
+
+
+import javax.validation.ValidationException;
+
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.testharness.AbstractTest;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.ArtifactType;
+import org.jboss.testharness.impl.packaging.Classes;
+import org.jboss.testharness.impl.packaging.Resource;
+import org.jboss.testharness.impl.packaging.jsr303.ValidationXml;
+import static org.testng.Assert.fail;
+import org.testng.annotations.Test;
+
+import org.hibernate.jsr303.tck.util.TestUtil;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Artifact(artifactType = ArtifactType.JSR303)
+@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
+@ValidationXml(value = "validation-invalid-element-name-group.xml")
+@Resource(source = "constraints-with-group-element.xml",
+ destination = "WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/constraints-with-group-element")
+public class GroupIsNotAllowedAsElementNameTest extends AbstractTest {
+
+ @Test
+ @SpecAssertion(section = "7.1.1.4", id = "b")
+ public void testGroupIsNotAllowedAsElementName() {
+ try {
+ TestUtil.getDefaultValidator();
+ fail();
+ }
+ catch ( ValidationException e ) {
+ // success
+ }
+ }
+}
\ No newline at end of file
Copied: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/MandatoryNameAttributeTest.java (from rev 17087, beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/MultipleGetterDefinitionTest.java)
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/MandatoryNameAttributeTest.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/MandatoryNameAttributeTest.java 2009-07-16 11:09:58 UTC (rev 17106)
@@ -0,0 +1,56 @@
+// $Id: InvalidXmlConfigurationTest.java 16948 2009-06-25 10:10:13Z 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.xmlconfiguration.constraintdeclaration;
+
+
+import javax.validation.ValidationException;
+
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.testharness.AbstractTest;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.ArtifactType;
+import org.jboss.testharness.impl.packaging.Classes;
+import org.jboss.testharness.impl.packaging.Resource;
+import org.jboss.testharness.impl.packaging.jsr303.ValidationXml;
+import static org.testng.Assert.fail;
+import org.testng.annotations.Test;
+
+import org.hibernate.jsr303.tck.util.TestUtil;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Artifact(artifactType = ArtifactType.JSR303)
+@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
+@ValidationXml(value = "validation-mandatory-name-attribute.xml")
+@Resource(source = "constraints-with-no-name.xml",
+ destination = "WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/constraints-with-no-name.xml")
+public class MandatoryNameAttributeTest extends AbstractTest {
+
+ @Test
+ @SpecAssertion(section = "7.1.1.4", id = "a")
+ public void testNameAttributeIsMandatory() {
+ try {
+ TestUtil.getDefaultValidator();
+ fail();
+ }
+ catch ( ValidationException e ) {
+ // success
+ }
+ }
+}
\ No newline at end of file
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/MessageIsNotAllowedAsElementNameTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/MessageIsNotAllowedAsElementNameTest.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/MessageIsNotAllowedAsElementNameTest.java 2009-07-16 11:09:58 UTC (rev 17106)
@@ -0,0 +1,56 @@
+// $Id: InvalidXmlConfigurationTest.java 16948 2009-06-25 10:10:13Z 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.xmlconfiguration.constraintdeclaration;
+
+
+import javax.validation.ValidationException;
+
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.testharness.AbstractTest;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.ArtifactType;
+import org.jboss.testharness.impl.packaging.Classes;
+import org.jboss.testharness.impl.packaging.Resource;
+import org.jboss.testharness.impl.packaging.jsr303.ValidationXml;
+import static org.testng.Assert.fail;
+import org.testng.annotations.Test;
+
+import org.hibernate.jsr303.tck.util.TestUtil;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Artifact(artifactType = ArtifactType.JSR303)
+@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
+@ValidationXml(value = "validation-invalid-element-name-message.xml")
+@Resource(source = "constraints-with-message-element.xml",
+ destination = "WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/constraints-with-message-element")
+public class MessageIsNotAllowedAsElementNameTest extends AbstractTest {
+
+ @Test
+ @SpecAssertion(section = "7.1.1.4", id = "b")
+ public void testMessageIsNotAllowedAsElementName() {
+ try {
+ TestUtil.getDefaultValidator();
+ fail();
+ }
+ catch ( ValidationException e ) {
+ // success
+ }
+ }
+}
\ No newline at end of file
Added: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/constraints-with-group-element.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/constraints-with-group-element.xml (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/constraints-with-group-element.xml 2009-07-16 11:09:58 UTC (rev 17106)
@@ -0,0 +1,16 @@
+<constraint-mappings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/mapping validation-mapping-1.0.xsd"
+ xmlns="http://jboss.org/xml/ns/javax/validation/mapping">
+ <default-package>org.hibernate.jsr303.tck.tests.xmlconfiguration</default-package>
+ <bean class="User" ignore-annotations="true">
+ <field name="lastname">
+ <constraint annotation="javax.validation.constraints.Pattern">
+ <message>Last name has to start with with a capital letter.</message>
+ <element name="regexp">^[A-Z][a-z]+</element>
+ <element name="groups">
+ <value>javax.validation.groups.Default</value>
+ </element>
+ </constraint>
+ </field>
+ </bean>
+</constraint-mappings>
\ No newline at end of file
Added: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/constraints-with-message-element.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/constraints-with-message-element.xml (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/constraints-with-message-element.xml 2009-07-16 11:09:58 UTC (rev 17106)
@@ -0,0 +1,13 @@
+<constraint-mappings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/mapping validation-mapping-1.0.xsd"
+ xmlns="http://jboss.org/xml/ns/javax/validation/mapping">
+ <default-package>org.hibernate.jsr303.tck.tests.xmlconfiguration</default-package>
+ <bean class="User" ignore-annotations="true">
+ <field name="lastname">
+ <constraint annotation="javax.validation.constraints.Pattern">
+ <element name="message">Last name has to start with with a capital letter.</element>
+ <element name="regexp">^[A-Z][a-z]+</element>
+ </constraint>
+ </field>
+ </bean>
+</constraint-mappings>
\ No newline at end of file
Copied: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/constraints-with-no-name.xml (from rev 17087, beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/order-constraints.xml)
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/constraints-with-no-name.xml (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/constraints-with-no-name.xml 2009-07-16 11:09:58 UTC (rev 17106)
@@ -0,0 +1,13 @@
+<constraint-mappings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/mapping validation-mapping-1.0.xsd"
+ xmlns="http://jboss.org/xml/ns/javax/validation/mapping">
+ <default-package>org.hibernate.jsr303.tck.tests.xmlconfiguration</default-package>
+ <bean class="User" ignore-annotations="true">
+ <field>
+ <constraint annotation="javax.validation.constraints.Pattern">
+ <message>Last name has to start with with a capital letter.</message>
+ <element name="regexp">^[A-Z][a-z]+</element>
+ </constraint>
+ </field>
+ </bean>
+</constraint-mappings>
\ No newline at end of file
Property changes on: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/constraints-with-no-name.xml
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/validation-invalid-element-name-group.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/validation-invalid-element-name-group.xml (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/validation-invalid-element-name-group.xml 2009-07-16 11:09:58 UTC (rev 17106)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<validation-config xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
+ xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration validation-configuration-1.0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <constraint-mapping>
+ /org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/constraints-with-group-element.xml
+ </constraint-mapping>
+</validation-config>
\ No newline at end of file
Added: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/validation-invalid-element-name-message.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/validation-invalid-element-name-message.xml (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/validation-invalid-element-name-message.xml 2009-07-16 11:09:58 UTC (rev 17106)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<validation-config xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
+ xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration validation-configuration-1.0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <constraint-mapping>/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/constraints-with-message-element.xml</constraint-mapping>
+</validation-config>
\ No newline at end of file
Copied: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/validation-mandatory-name-attribute.xml (from rev 17087, beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation.xml)
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/validation-mandatory-name-attribute.xml (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/validation-mandatory-name-attribute.xml 2009-07-16 11:09:58 UTC (rev 17106)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<validation-config xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
+ xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration validation-configuration-1.0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <constraint-mapping>/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/constraints-with-no-name.xml</constraint-mapping>
+</validation-config>
\ No newline at end of file
Property changes on: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/validation-mandatory-name-attribute.xml
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-07-15 19:26:15 UTC (rev 17105)
+++ beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-07-16 11:09:58 UTC (rev 17106)
@@ -797,7 +797,7 @@
<section id="4.4.5" title="Validation">
<assertion id="a">
<text>The Validation implementation provided by the Bean Validation provider must not
- contain any non private attrib- ute or method aside from the three public static
+ contain any non private attribute or method aside from the three public static
bootstrap methods</text>
</assertion>
<assertion id="b">
@@ -806,7 +806,7 @@
</assertion>
<assertion id="c">
<text>When building the Configuration object, if the ValidationProviderResolver either
- fail or if the expected pro- vider is not found, a ValidationException is
+ fail or if the expected provider is not found, a ValidationException is
raised</text>
</assertion>
</section>
16 years, 3 months
Hibernate SVN: r17104 - in beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck: util and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-07-15 12:07:05 -0400 (Wed, 15 Jul 2009)
New Revision: 17104
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/GameReserve.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Herd.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/MultiCage.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/SingleCage.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Zebra.java
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/GraphNavigationTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/util/TestUtil.java
Log:
more tests for graph validation
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/GameReserve.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/GameReserve.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/GameReserve.java 2009-07-15 16:07:05 UTC (rev 17104)
@@ -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.validation.graphnavigation;
+
+import javax.validation.Valid;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class GameReserve<T extends Animal> {
+ @Valid
+ Herd<T> herd;
+
+ public void setHerd(Herd<T> herd) {
+ this.herd = herd;
+ }
+}
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/GraphNavigationTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/GraphNavigationTest.java 2009-07-15 15:34:58 UTC (rev 17103)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/GraphNavigationTest.java 2009-07-15 16:07:05 UTC (rev 17104)
@@ -125,11 +125,53 @@
}
@Test
+ @SpecAssertion(section = "3.1.3", id = "b")
+ public void testTypeOfContainedValueIsDeterminedAtRuntime() {
+ SingleCage cage = new SingleCage();
+ Elephant elephant = new Elephant();
+ elephant.setWeight( 500 );
+ cage.setContainAnimal( elephant );
+
+ Validator validator = TestUtil.getDefaultValidator();
+ Set<ConstraintViolation<SingleCage>> constraintViolations = validator.validate( cage );
+ assertCorrectNumberOfViolations( constraintViolations, 1 );
+ assertCorrectConstraintViolationMessages( constraintViolations, "An elephant weighs at least 1000 kg" );
+ }
+
+ @Test
+ @SpecAssertion(section = "3.1.3", id = "e")
+ public void testContainedSet() {
+ MultiCage cage = new MultiCage();
+ cage.addAnimal( new Zebra( null ) );
+ cage.addAnimal( new Zebra( null ) );
+
+ Validator validator = TestUtil.getDefaultValidator();
+ Set<ConstraintViolation<MultiCage>> constraintViolations = validator.validate( cage );
+ assertCorrectNumberOfViolations( constraintViolations, 2 );
+ assertCorrectConstraintViolationMessages( constraintViolations, "may not be null", "may not be null" );
+ }
+
+ @Test
+ @SpecAssertion(section = "3.1.3", id = "h")
+ public void testContainedIterable() {
+ GameReserve<Zebra> reserve = new GameReserve<Zebra>();
+ Herd<Zebra> zebraHerd = new Herd<Zebra>();
+ zebraHerd.addAnimal( new Zebra( null ) );
+ zebraHerd.addAnimal( new Zebra( null ) );
+ reserve.setHerd( zebraHerd );
+
+ Validator validator = TestUtil.getDefaultValidator();
+ Set<ConstraintViolation<GameReserve<Zebra>>> constraintViolations = validator.validate( reserve );
+ assertCorrectNumberOfViolations( constraintViolations, 2 );
+ assertCorrectConstraintViolationMessages( constraintViolations, "may not be null", "may not be null" );
+ }
+
+ @Test
@SpecAssertions({
@SpecAssertion(section = "3.1.3", id = "d"),
@SpecAssertion(section = "3.1.3", id = "j")
})
- public void testTypeOfContainedValueIsDeterminedAtRuntime() {
+ public void testTypeOfContainedValuesIsDeterminedAtRuntime() {
Zoo zoo = new Zoo();
Elephant elephant = new Elephant();
elephant.setWeight( 500 );
Copied: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Herd.java (from rev 17102, beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Animal.java)
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Herd.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Herd.java 2009-07-15 16:07:05 UTC (rev 17104)
@@ -0,0 +1,37 @@
+// $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.validation.graphnavigation;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class Herd<T extends Animal> implements Iterable<T> {
+ List<T> animals = new ArrayList<T>();
+
+ public void addAnimal(T animal) {
+ animals.add( animal );
+ }
+
+ public Iterator<T> iterator() {
+ return animals.iterator();
+ }
+}
\ No newline at end of file
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/MultiCage.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/MultiCage.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/MultiCage.java 2009-07-15 16:07:05 UTC (rev 17104)
@@ -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.jsr303.tck.tests.validation.graphnavigation;
+
+import java.util.HashSet;
+import java.util.Set;
+import javax.validation.Valid;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class MultiCage {
+ @Valid
+ private Set<Animal> animalsInCage = new HashSet<Animal>();
+
+ public void addAnimal(Animal animal) {
+ animalsInCage.add( animal );
+ }
+}
\ No newline at end of file
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/SingleCage.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/SingleCage.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/SingleCage.java 2009-07-15 16:07:05 UTC (rev 17104)
@@ -0,0 +1,36 @@
+// $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.validation.graphnavigation;
+
+import javax.validation.Valid;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class SingleCage {
+ @Valid
+ private Animal containAnimal;
+
+ public Animal getContainAnimal() {
+ return containAnimal;
+ }
+
+ public void setContainAnimal(Animal containAnimal) {
+ this.containAnimal = containAnimal;
+ }
+}
Copied: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Zebra.java (from rev 17102, beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Elephant.java)
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Zebra.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Zebra.java 2009-07-15 16:07:05 UTC (rev 17104)
@@ -0,0 +1,36 @@
+// $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.validation.graphnavigation;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class Zebra extends Animal {
+ private String name;
+
+ public Zebra(String name) {
+ this.name = name;
+ }
+
+ @NotNull
+ public String getName() {
+ return name;
+ }
+}
\ No newline at end of file
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-07-15 15:34:58 UTC (rev 17103)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/util/TestUtil.java 2009-07-15 16:07:05 UTC (rev 17104)
@@ -57,7 +57,11 @@
}
public static <T> void assertCorrectNumberOfViolations(Set<ConstraintViolation<T>> violations, int expectedViolations) {
- assertEquals( violations.size(), expectedViolations, "Wrong number of constraint violations" );
+ assertEquals(
+ violations.size(),
+ expectedViolations,
+ "Wrong number of constraint violations. Expected: " + expectedViolations + " Actual: " + violations.size()
+ );
}
public static <T> void assertCorrectConstraintViolationMessages(Set<ConstraintViolation<T>> violations, String... messages) {
@@ -66,7 +70,10 @@
actualMessages.add( violation.getMessage() );
}
- assertTrue( actualMessages.size() == messages.length, "Wrong number or error messages" );
+ assertTrue(
+ actualMessages.size() == messages.length,
+ "Wrong number or error messages. Expected: " + messages.length + " Actual: " + actualMessages.size()
+ );
for ( String expectedMessage : messages ) {
assertTrue(
16 years, 4 months
Hibernate SVN: r17103 - in beanvalidation/trunk/validation-tck/src/main: resources and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-07-15 11:34:58 -0400 (Wed, 15 Jul 2009)
New Revision: 17103
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/GraphNavigationTest.java
beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
Log:
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/GraphNavigationTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/GraphNavigationTest.java 2009-07-15 15:25:24 UTC (rev 17102)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/GraphNavigationTest.java 2009-07-15 15:34:58 UTC (rev 17103)
@@ -176,6 +176,10 @@
}
@Test
+ @SpecAssertions({
+ @SpecAssertion(section = "3.4.2", id = "b"),
+ @SpecAssertion(section = "3.4.2", id = "d")
+ })
public void testFullGraphValidationBeforeNextGroupInSequence() {
Parent p = new Parent();
p.setChild( new Child() );
Modified: beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-07-15 15:25:24 UTC (rev 17102)
+++ beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-07-15 15:34:58 UTC (rev 17103)
@@ -281,38 +281,32 @@
are used</text>
</assertion>
<assertion id="c">
- <text>Collection-valued, array-valued or Iterable fields and properties may also be
- decorated with the @Valid annota- tion. This causes the contents of the collection,
- array or iterator to be validated</text>
+ <text>Array of objects is supported by @Valid. The content of the array is validated.</text>
</assertion>
<assertion id="d">
- <text>Array of objects is supported by @Valid</text>
+ <text>java.util.Collection is supported by @Valid. The content of the collection is validated.</text>
</assertion>
- <assertion id="e" >
- <text>java.util.Collection is supported by @Valid
- </text>
+ <assertion id="e">
+ <text>java.util.Set is supported by @Valid. The content of the Set is validated.</text>
</assertion>
<assertion id="f">
- <text>java.util.Set is supported by @Valid</text>
+ <text>java.util.List is supported by @Valid. The content of the list is validated.</text>
</assertion>
- <assertion id="g">
- <text>java.util.List is supported by @Valid</text>
+ <assertion id="g">
+ <text>java.util.Map is supported by @Valid</text>
</assertion>
- <assertion id="h">
- <text>java.util.Map is supported by @Valid
- </text>
+ <assertion id="h">
+ <text>java.lang.Iterable is supported by @Valid. The elements of the iterable are validated</text>
</assertion>
<assertion id="i">
- <text>java.lang.Iterable is supported by @Valid</text>
- </assertion>
- <assertion id="j">
<text>For Map, the value of each entry is validated (the key is not validated)</text>
</assertion>
- <assertion id="k">
- <text>Like regular references, the type of the collection, array or Iterable element is determined at runtime and the constraint
- definitions for this particular type are used</text>
+ <assertion id="j">
+ <text>Like regular references, the type of the collection, array or Iterable element is
+ determined at runtime and the constraint definitions for this particular type are
+ used</text>
</assertion>
- <assertion id="l">
+ <assertion id="k">
<text>The @Valid annotation is applied recursively</text>
</assertion>
</section>
@@ -940,7 +934,8 @@
constraint</text>
</assertion>
<assertion id="g">
- <text>getPayload returns the payloads the constraint hosts or an empty set if none</text>
+ <text>getPayload returns the payloads the constraint hosts or an empty set if
+ none</text>
</assertion>
</section>
@@ -998,7 +993,8 @@
<section id="7" title="XML deployment descriptor">
<assertion id="a" testable="true">
- <text>If the xml configuration file does not validate against the given xsd files a ValidationException is raised. </text>
+ <text>If the xml configuration file does not validate against the given xsd files a
+ ValidationException is raised. </text>
</assertion>
</section>
<section id="7.1" title="Constraint definition and declaration">
16 years, 4 months
Hibernate SVN: r17102 - in beanvalidation/trunk/validation-tck/src/main: java/org/hibernate/jsr303/tck/tests/validation/graphnavigation and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-07-15 11:25:24 -0400 (Wed, 15 Jul 2009)
New Revision: 17102
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Animal.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/AnimalCaretaker.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Condor.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Elephant.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Zoo.java
Removed:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/ChildFirst.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/ParentSecond.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/ProperOrder.java
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Child.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/GraphNavigationTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Parent.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:
added mappings around graph validation
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateTest.java 2009-07-15 15:24:21 UTC (rev 17101)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateTest.java 2009-07-15 15:25:24 UTC (rev 17102)
@@ -210,6 +210,7 @@
@Test
@SpecAssertions({
@SpecAssertion(section = "2.4", id = "o"),
+ @SpecAssertion(section = "3.1.3", id = "c"),
@SpecAssertion(section = "4.2", id = "h")
})
public void testGraphValidationWithArray() {
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Animal.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Animal.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Animal.java 2009-07-15 15:25:24 UTC (rev 17102)
@@ -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.validation.graphnavigation;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class Animal {
+}
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/AnimalCaretaker.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/AnimalCaretaker.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/AnimalCaretaker.java 2009-07-15 15:25:24 UTC (rev 17102)
@@ -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.jsr303.tck.tests.validation.graphnavigation;
+
+import java.util.HashMap;
+import java.util.Map;
+import javax.validation.Valid;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class AnimalCaretaker {
+ @Valid
+ Map<String, Animal> caresFor = new HashMap<String, Animal>();
+
+ public void addAnimal(String name, Animal animal) {
+ caresFor.put( name, animal );
+ }
+}
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Child.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Child.java 2009-07-15 15:24:21 UTC (rev 17101)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Child.java 2009-07-15 15:25:24 UTC (rev 17102)
@@ -25,7 +25,7 @@
public class Child {
private String name;
- @NotNull(groups = ChildFirst.class)
+ @NotNull(groups = Parent.ChildFirst.class)
public String getName() {
return name;
}
Deleted: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/ChildFirst.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/ChildFirst.java 2009-07-15 15:24:21 UTC (rev 17101)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/ChildFirst.java 2009-07-15 15:25:24 UTC (rev 17102)
@@ -1,24 +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.validation.graphnavigation;
-
-/**
- * @author Emmanuel Bernard
- */
-public interface ChildFirst {
-}
\ No newline at end of file
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Condor.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Condor.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Condor.java 2009-07-15 15:25:24 UTC (rev 17102)
@@ -0,0 +1,36 @@
+// $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.validation.graphnavigation;
+
+import javax.validation.constraints.Min;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class Condor extends Animal {
+ @Min(value = 250, message = "The wingspan of a condor is at least 250 cm")
+ private int wingspan;
+
+ public int getWingspan() {
+ return wingspan;
+ }
+
+ public void setWingspan(int wingspan) {
+ this.wingspan = wingspan;
+ }
+}
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Elephant.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Elephant.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Elephant.java 2009-07-15 15:25:24 UTC (rev 17102)
@@ -0,0 +1,36 @@
+// $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.validation.graphnavigation;
+
+import javax.validation.constraints.Min;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class Elephant extends Animal {
+ @Min(value = 1000, message = "An elephant weighs at least 1000 kg")
+ private int weight;
+
+ public int getWeight() {
+ return weight;
+ }
+
+ public void setWeight(int weight) {
+ this.weight = weight;
+ }
+}
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/GraphNavigationTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/GraphNavigationTest.java 2009-07-15 15:24:21 UTC (rev 17101)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/GraphNavigationTest.java 2009-07-15 15:25:24 UTC (rev 17102)
@@ -31,6 +31,8 @@
import org.testng.annotations.Test;
import org.hibernate.jsr303.tck.util.TestUtil;
+import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectConstraintViolationMessages;
+import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectNumberOfViolations;
import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectPropertyPaths;
@@ -38,11 +40,13 @@
* @author Hardy Ferentschik
*/
@Artifact(artifactType = ArtifactType.JSR303)
-(a)Classes({TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class})
+@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
public class GraphNavigationTest extends AbstractTest {
@Test
@SpecAssertions({
+ @SpecAssertion(section = "3.1.3", id = "a"),
+ @SpecAssertion(section = "3.1.3", id = "k"),
@SpecAssertion(section = "3.5.1", id = "a"),
@SpecAssertion(section = "3.5.1", id = "b")
})
@@ -72,7 +76,7 @@
Validator validator = TestUtil.getDefaultValidator();
Set<ConstraintViolation<Order>> constraintViolations = validator.validate( order );
- assertEquals( constraintViolations.size(), 3, "Wrong number of constraints" );
+ assertCorrectNumberOfViolations( constraintViolations, 3 );
assertCorrectPropertyPaths(
constraintViolations,
"shippingAddress.addressline1",
@@ -82,7 +86,10 @@
}
@Test
- @SpecAssertion(section = "3.5.1", id = "d")
+ @SpecAssertions({
+ @SpecAssertion(section = "3.1.3", id = "f"),
+ @SpecAssertion(section = "3.5.1", id = "d")
+ })
public void testNoEndlessLoop() {
User john = new User( "John", null );
john.knows( john );
@@ -101,28 +108,79 @@
john.knows( jane );
constraintViolations = validator.validate( john );
- assertEquals( constraintViolations.size(), 1, "Wrong number of constraints" );
+ assertCorrectNumberOfViolations( constraintViolations, 1 );
TestUtil.assertConstraintViolation(
constraintViolations.iterator().next(), User.class, null, "lastName"
);
constraintViolations = validator.validate( jane );
- assertEquals( constraintViolations.size(), 1, "Wrong number of constraints" );
+ assertCorrectNumberOfViolations( constraintViolations, 1 );
TestUtil.assertConstraintViolation(
constraintViolations.iterator().next(), User.class, null, "knowsUser[0].lastName"
);
john.setLastName( "Doe" );
constraintViolations = validator.validate( john );
- assertEquals( constraintViolations.size(), 0, "Wrong number of constraints" );
+ assertCorrectNumberOfViolations( constraintViolations, 0 );
}
@Test
+ @SpecAssertions({
+ @SpecAssertion(section = "3.1.3", id = "d"),
+ @SpecAssertion(section = "3.1.3", id = "j")
+ })
+ public void testTypeOfContainedValueIsDeterminedAtRuntime() {
+ Zoo zoo = new Zoo();
+ Elephant elephant = new Elephant();
+ elephant.setWeight( 500 );
+ zoo.addAnimal( elephant );
+
+ Condor condor = new Condor();
+ condor.setWingspan( 200 );
+ zoo.addAnimal( condor );
+
+ Validator validator = TestUtil.getDefaultValidator();
+ Set<ConstraintViolation<Zoo>> constraintViolations = validator.validate( zoo );
+ assertCorrectNumberOfViolations( constraintViolations, 2 );
+ assertCorrectConstraintViolationMessages(
+ constraintViolations,
+ "The wingspan of a condor is at least 250 cm",
+ "An elephant weighs at least 1000 kg"
+ );
+
+ }
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "3.1.3", id = "g"),
+ @SpecAssertion(section = "3.1.3", id = "i")
+ })
+ public void testContainedMap() {
+ AnimalCaretaker caretaker = new AnimalCaretaker();
+ Elephant elephant = new Elephant();
+ elephant.setWeight( 500 );
+ caretaker.addAnimal( "Jumbo", elephant );
+
+ Condor condor = new Condor();
+ condor.setWingspan( 200 );
+ caretaker.addAnimal( "Andes", condor );
+
+ Validator validator = TestUtil.getDefaultValidator();
+ Set<ConstraintViolation<AnimalCaretaker>> constraintViolations = validator.validate( caretaker );
+ assertCorrectNumberOfViolations( constraintViolations, 2 );
+ assertCorrectPropertyPaths(
+ constraintViolations,
+ "caresFor[Jumbo].weight",
+ "caresFor[Andes].wingspan"
+ );
+ }
+
+ @Test
public void testFullGraphValidationBeforeNextGroupInSequence() {
Parent p = new Parent();
p.setChild( new Child() );
Validator validator = TestUtil.getDefaultValidator();
- Set<ConstraintViolation<Parent>> errors = validator.validate( p, ProperOrder.class );
+ Set<ConstraintViolation<Parent>> errors = validator.validate( p, Parent.ProperOrder.class );
assertEquals( 1, errors.size() );
assertCorrectPropertyPaths( errors, "child.name" );
}
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Parent.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Parent.java 2009-07-15 15:24:21 UTC (rev 17101)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Parent.java 2009-07-15 15:25:24 UTC (rev 17102)
@@ -17,8 +17,9 @@
*/
package org.hibernate.jsr303.tck.tests.validation.graphnavigation;
+import javax.validation.GroupSequence;
+import javax.validation.Valid;
import javax.validation.constraints.NotNull;
-import javax.validation.Valid;
/**
* @author Emmanuel Bernard
@@ -44,4 +45,14 @@
public void setChild(Child child) {
this.child = child;
}
+
+ public interface ParentSecond {
+ }
+
+ public interface ChildFirst {
+ }
+
+ @GroupSequence({ ChildFirst.class, ParentSecond.class })
+ public interface ProperOrder {
+ }
}
\ No newline at end of file
Deleted: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/ParentSecond.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/ParentSecond.java 2009-07-15 15:24:21 UTC (rev 17101)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/ParentSecond.java 2009-07-15 15:25:24 UTC (rev 17102)
@@ -1,24 +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.validation.graphnavigation;
-
-/**
- * @author Emmanuel Bernard
- */
-public interface ParentSecond {
-}
\ No newline at end of file
Deleted: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/ProperOrder.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/ProperOrder.java 2009-07-15 15:24:21 UTC (rev 17101)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/ProperOrder.java 2009-07-15 15:25:24 UTC (rev 17102)
@@ -1,27 +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.validation.graphnavigation;
-
-import javax.validation.GroupSequence;
-
-/**
- * @author Emmanuel Bernard
- */
-@GroupSequence( {ChildFirst.class, ParentSecond.class } )
-public interface ProperOrder {
-}
\ No newline at end of file
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Zoo.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Zoo.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Zoo.java 2009-07-15 15:25:24 UTC (rev 17102)
@@ -0,0 +1,38 @@
+// $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.validation.graphnavigation;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import javax.validation.Valid;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class Zoo {
+ @Valid
+ Collection<Animal> inhabitants = new ArrayList<Animal>();
+
+ public Collection<Animal> getInhabitants() {
+ return inhabitants;
+ }
+
+ public void addAnimal(Animal animal) {
+ inhabitants.add( animal );
+ }
+}
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-07-15 15:24:21 UTC (rev 17101)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/util/TestUtil.java 2009-07-15 15:25:24 UTC (rev 17102)
@@ -116,7 +116,7 @@
}
}
if ( !containsPath ) {
- fail( expectedPath + " is not in the list of path instances contained in the actual constraint violations" );
+ fail( expectedPath + " is not in the list of path instances contained in the actual constraint violations: " + propertyPathsOfViolations );
}
}
}
@@ -213,7 +213,7 @@
*
* @see <a href="http://www.regexplanet.com/simple/index.jsp">Regular expression tester</a>
*/
- private static final Pattern pathPattern = Pattern.compile( "(\\w+)(\\[(\\w?)\\])?(\\.(.*))*" );
+ private static final Pattern pathPattern = Pattern.compile( "(\\w+)(\\[(\\w*)\\])?(\\.(.*))*" );
private static final String PROPERTY_PATH_SEPERATOR = ".";
Modified: beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-07-15 15:24:21 UTC (rev 17101)
+++ beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-07-15 15:25:24 UTC (rev 17102)
@@ -286,18 +286,33 @@
array or iterator to be validated</text>
</assertion>
<assertion id="d">
- <text>The following types are supported, any array of objects, java.util.Collection,
- java.util.Set, java.util.List, java.util.Map and any object implementing
- java.lang.Iterable </text>
+ <text>Array of objects is supported by @Valid</text>
</assertion>
- <assertion id="e">
+ <assertion id="e" >
+ <text>java.util.Collection is supported by @Valid
+ </text>
+ </assertion>
+ <assertion id="f">
+ <text>java.util.Set is supported by @Valid</text>
+ </assertion>
+ <assertion id="g">
+ <text>java.util.List is supported by @Valid</text>
+ </assertion>
+ <assertion id="h">
+ <text>java.util.Map is supported by @Valid
+ </text>
+ </assertion>
+ <assertion id="i">
+ <text>java.lang.Iterable is supported by @Valid</text>
+ </assertion>
+ <assertion id="j">
<text>For Map, the value of each entry is validated (the key is not validated)</text>
</assertion>
- <assertion id="f">
- <text>Like regular references, its type is determined at runtime and the constraint
+ <assertion id="k">
+ <text>Like regular references, the type of the collection, array or Iterable element is determined at runtime and the constraint
definitions for this particular type are used</text>
</assertion>
- <assertion id="g">
+ <assertion id="l">
<text>The @Valid annotation is applied recursively</text>
</assertion>
</section>
16 years, 4 months