[hibernate-commits] Hibernate SVN: r17109 - in beanvalidation/trunk/validation-tck/src/main: java/org/hibernate/jsr303/tck/tests/constraints/groups/groupsequence and 3 other directories.
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Thu Jul 16 11:50:31 EDT 2009
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
+ */
+ at Artifact(artifactType = ArtifactType.JSR303)
+ at 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
- */
- at Artifact(artifactType = ArtifactType.JSR303)
- at 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>
More information about the hibernate-commits
mailing list