Hibernate SVN: r17411 - validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-08-25 10:06:14 -0400 (Tue, 25 Aug 2009)
New Revision: 17411
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/Group.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/GroupChainGenerator.java
Log:
HV-212
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/Group.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/Group.java 2009-08-25 14:02:05 UTC (rev 17410)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/Group.java 2009-08-25 14:06:14 UTC (rev 17411)
@@ -48,10 +48,6 @@
return group;
}
- public boolean partOfSequence() {
- return sequence != null;
- }
-
public Class<?> getSequence() {
return sequence;
}
@@ -70,10 +66,6 @@
if ( group != null ? !group.equals( group1.group ) : group1.group != null ) {
return false;
}
- if ( sequence != null ? !sequence.equals( group1.sequence ) : group1.sequence != null ) {
- return false;
- }
-
return true;
}
@@ -83,9 +75,7 @@
@Override
public int hashCode() {
- int result = group != null ? group.hashCode() : 0;
- result = 31 * result + ( sequence != null ? sequence.hashCode() : 0 );
- return result;
+ return group != null ? group.hashCode() : 0;
}
@Override
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/GroupChainGenerator.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/GroupChainGenerator.java 2009-08-25 14:02:05 UTC (rev 17410)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/GroupChainGenerator.java 2009-08-25 14:06:14 UTC (rev 17411)
@@ -22,9 +22,9 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import javax.validation.GroupDefinitionException;
import javax.validation.GroupSequence;
import javax.validation.ValidationException;
-import javax.validation.GroupDefinitionException;
/**
* Used to determine the execution order.
@@ -65,7 +65,7 @@
for ( Class<?> extendedInterface : clazz.getInterfaces() ) {
Group group = new Group( extendedInterface );
chain.insertGroup( group );
- insertInheritedGroups(extendedInterface, chain);
+ insertInheritedGroups( extendedInterface, chain );
}
}
@@ -96,10 +96,19 @@
}
else {
List<Group> tmpSequence = resolveSequence( clazz, processedSequences );
- resolvedGroupSequence.addAll( tmpSequence );
+ addTmpSequence( resolvedGroupSequence, tmpSequence );
}
}
resolvedSequences.put( group, resolvedGroupSequence );
return resolvedGroupSequence;
}
+
+ private void addTmpSequence(List<Group> resolvedGroupSequence, List<Group> tmpSequence) {
+ for ( Group tmpGroup : tmpSequence ) {
+ if ( resolvedGroupSequence.contains( tmpGroup ) && resolvedGroupSequence.indexOf( tmpGroup ) < resolvedGroupSequence.size() - 1 ) {
+ throw new GroupDefinitionException( "Unable to expand group sequence." );
+ }
+ resolvedGroupSequence.add( tmpGroup );
+ }
+ }
}
15 years, 4 months
Hibernate SVN: r17410 - in validator/trunk/hibernate-validator/src: main/java/org/hibernate/validation/engine/groups and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-08-25 10:02:05 -0400 (Tue, 25 Aug 2009)
New Revision: 17410
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/GroupChain.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupChainTest.java
Log:
Fixed typo in method name and deleted unused methods.
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java 2009-08-25 14:01:12 UTC (rev 17409)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java 2009-08-25 14:02:05 UTC (rev 17410)
@@ -201,7 +201,7 @@
BeanMetaData<U> beanMetaData = getBeanMetaData( localExecutionContext.getCurrentBeanType() );
if ( beanMetaData.defaultGroupSequenceIsRedefined() ) {
- groupChain.assertDefaulGroupSequenceIsExpandable( beanMetaData.getDefaultGroupSequence() );
+ groupChain.assertDefaultGroupSequenceIsExpandable( beanMetaData.getDefaultGroupSequence() );
}
// process first single groups. For these we can skip some object traversal, by first running all validations on the current bean
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-08-25 14:01:12 UTC (rev 17409)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/GroupChain.java 2009-08-25 14:02:05 UTC (rev 17410)
@@ -19,11 +19,9 @@
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;
@@ -53,19 +51,6 @@
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 );
- }
-
void insertGroup(Group group) {
if ( !groupList.contains( group ) ) {
groupList.add( group );
@@ -90,7 +75,7 @@
'}';
}
- public void assertDefaulGroupSequenceIsExpandable(List<Class<?>> defaultGroupSequence) {
+ public void assertDefaultGroupSequenceIsExpandable(List<Class<?>> defaultGroupSequence) {
for ( Map.Entry<Class<?>, List<Group>> entry : sequenceMap.entrySet() ) {
Class<?> sequence = entry.getKey();
List<Group> groupList = entry.getValue();
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupChainTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupChainTest.java 2009-08-25 14:01:12 UTC (rev 17409)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupChainTest.java 2009-08-25 14:02:05 UTC (rev 17410)
@@ -53,7 +53,7 @@
defaultSequence.add( Default.class );
defaultSequence.add( GroupA.class );
try {
- chain.assertDefaulGroupSequenceIsExpandable( defaultSequence );
+ chain.assertDefaultGroupSequenceIsExpandable( defaultSequence );
fail();
}
catch ( GroupDefinitionException e ) {
@@ -64,7 +64,7 @@
defaultSequence.add( GroupA.class );
defaultSequence.add( Default.class );
try {
- chain.assertDefaulGroupSequenceIsExpandable( defaultSequence );
+ chain.assertDefaultGroupSequenceIsExpandable( defaultSequence );
fail();
}
catch ( GroupDefinitionException e ) {
@@ -75,7 +75,7 @@
defaultSequence.add( Default.class );
defaultSequence.add( GroupC.class );
try {
- chain.assertDefaulGroupSequenceIsExpandable( defaultSequence );
+ chain.assertDefaultGroupSequenceIsExpandable( defaultSequence );
fail();
}
catch ( GroupDefinitionException e ) {
@@ -85,7 +85,7 @@
defaultSequence.clear();
defaultSequence.add( GroupC.class );
defaultSequence.add( Default.class );
- chain.assertDefaulGroupSequenceIsExpandable( defaultSequence );
+ chain.assertDefaultGroupSequenceIsExpandable( defaultSequence );
}
@@ -111,14 +111,14 @@
List<Class<?>> defaultSequence = new ArrayList<Class<?>>();
defaultSequence.add( Default.class );
defaultSequence.add( GroupA.class );
- chain.assertDefaulGroupSequenceIsExpandable( defaultSequence );
+ chain.assertDefaultGroupSequenceIsExpandable( defaultSequence );
defaultSequence.clear();
defaultSequence.add( GroupA.class );
defaultSequence.add( Default.class );
try {
- chain.assertDefaulGroupSequenceIsExpandable( defaultSequence );
+ chain.assertDefaultGroupSequenceIsExpandable( defaultSequence );
fail();
}
catch ( GroupDefinitionException e ) {
@@ -129,7 +129,7 @@
defaultSequence.add( Default.class );
defaultSequence.add( GroupC.class );
try {
- chain.assertDefaulGroupSequenceIsExpandable( defaultSequence );
+ chain.assertDefaultGroupSequenceIsExpandable( defaultSequence );
fail();
}
catch ( GroupDefinitionException e ) {
@@ -140,7 +140,7 @@
defaultSequence.add( GroupC.class );
defaultSequence.add( Default.class );
try {
- chain.assertDefaulGroupSequenceIsExpandable( defaultSequence );
+ chain.assertDefaultGroupSequenceIsExpandable( defaultSequence );
fail();
}
catch ( GroupDefinitionException e ) {
15 years, 4 months
Hibernate SVN: r17409 - beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/propertylevel.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-08-25 10:01:12 -0400 (Tue, 25 Aug 2009)
New Revision: 17409
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/propertylevel/IncludePropertyLevelAnnotationsDueToBeanDefaultsTest.java
Log:
Fixed typo
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/propertylevel/IncludePropertyLevelAnnotationsDueToBeanDefaultsTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/propertylevel/IncludePropertyLevelAnnotationsDueToBeanDefaultsTest.java 2009-08-25 13:52:27 UTC (rev 17408)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/propertylevel/IncludePropertyLevelAnnotationsDueToBeanDefaultsTest.java 2009-08-25 14:01:12 UTC (rev 17409)
@@ -38,8 +38,6 @@
import org.testng.annotations.Test;
import org.hibernate.jsr303.tck.util.TestUtil;
-import org.hibernate.jsr303.tck.tests.xmlconfiguration.constraintdeclaration.fieldlevel.*;
-import org.hibernate.jsr303.tck.tests.xmlconfiguration.constraintdeclaration.fieldlevel.User;
/**
* @author Hardy Ferentschik
15 years, 4 months
Hibernate SVN: r17408 - 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-08-25 09:52:27 -0400 (Tue, 25 Aug 2009)
New Revision: 17408
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/groupsequence/SequenceResolutionTest.java
Log:
Added group sequence test.
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-08-25 13:50:23 UTC (rev 17407)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/groupsequence/SequenceResolutionTest.java 2009-08-25 13:52:27 UTC (rev 17408)
@@ -57,6 +57,21 @@
}
@Test
+ @SpecAssertions({
+ @SpecAssertion(section = "3.4.2", id = "c")
+ })
+ public void testGroupSequenceContainerOtherGroupSequences() {
+ Validator validator = TestUtil.getValidatorUnderTest();
+ TestEntity entity = new TestEntity();
+ try {
+ validator.validate( entity, InvalidGroupSequence.class );
+ }
+ catch ( GroupDefinitionException e ) {
+ System.err.println( e.getMessage() );
+ }
+ }
+
+ @Test
@SpecAssertion(section = "3.4.2", id = "j")
public void testOnlyFirstGroupInSequenceGetEvaluated() {
Validator validator = TestUtil.getValidatorUnderTest();
@@ -100,11 +115,25 @@
interface Second {
}
- @GroupSequence({ First.class, Second.class })
+ interface Third {
+ }
+
+ interface FirstAndSecond extends First, Second {
+ }
+
+ @GroupSequence({ First.class, Second.class, Third.class })
interface All {
}
- @GroupSequence({ Second.class, First.class })
+ @GroupSequence({ Third.class, Second.class, First.class })
interface AllReverse {
}
+
+ @GroupSequence({ Second.class, Third.class, First.class })
+ interface Mixed {
+ }
+
+ @GroupSequence({ First.class, Third.class, Mixed.class })
+ interface InvalidGroupSequence {
+ }
}
15 years, 4 months
Hibernate SVN: r17407 - beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/application.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-08-25 09:50:23 -0400 (Tue, 25 Aug 2009)
New Revision: 17407
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/application/ValidationRequirementTest.java
Log:
Added node to @SpecAssertion
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/application/ValidationRequirementTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/application/ValidationRequirementTest.java 2009-08-25 12:07:30 UTC (rev 17406)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/application/ValidationRequirementTest.java 2009-08-25 13:50:23 UTC (rev 17407)
@@ -136,8 +136,9 @@
}
@Test(enabled = false)
- // The spec is not clear about whether validation of static fields/properties should just be ignored or an exception should be thrown.
- @SpecAssertion(section = "3.1", id = "b")
+ @SpecAssertion(section = "3.1",
+ id = "b",
+ note = "The spec is not clear about whether validation of static fields/properties should just be ignored or an exception should be thrown.")
public void testIgnoreStaticFieldsAndProperties() {
StaticFieldsAndProperties entity = new StaticFieldsAndProperties();
15 years, 4 months
Hibernate SVN: r17406 - in beanvalidation/trunk/validation-tck/src/main: java/org/hibernate/jsr303/tck/tests/validatorfactory and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-08-25 08:07:30 -0400 (Tue, 25 Aug 2009)
New Revision: 17406
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Address.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/DefaultGroupRedefinitionTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validatorfactory/CustomConstraintValidatorTest.java
beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
Log:
reviewed tests which were marked as disabled
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Address.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Address.java 2009-08-25 10:22:20 UTC (rev 17405)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Address.java 2009-08-25 12:07:30 UTC (rev 17406)
@@ -29,7 +29,7 @@
@ZipCodeCoherenceChecker(groups = Address.HighLevelCoherence.class)
public class Address {
@NotNull(groups = Default.class)
- @Size(max = 50, message = "Streetnames cannot have more than {max} characters.")
+ @Size(max = 50, message = "Street names cannot have more than {max} characters.")
private String street;
@NotNull(groups = Default.class)
@@ -65,7 +65,7 @@
}
/**
- * Check conherence on the overall object
+ * Check coherence on the overall object
* Needs basic checking to be green first
*/
public interface HighLevelCoherence {
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/DefaultGroupRedefinitionTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/DefaultGroupRedefinitionTest.java 2009-08-25 10:22:20 UTC (rev 17405)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/DefaultGroupRedefinitionTest.java 2009-08-25 12:07:30 UTC (rev 17406)
@@ -79,27 +79,6 @@
assertCorrectConstraintViolationMessages( constraintViolations, "Zip code is not coherent." );
}
- @Test(enabled = false)
- @SpecAssertion(section = "3.4.3", id = "b")
- public void testConstraintsHostedOnEntityZBelongToGroupZ() {
- Validator validator = TestUtil.getValidatorUnderTest();
- BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Address.class );
- assertTrue( beanDescriptor.isBeanConstrained() );
-
- Address address = new Address();
- Set<ConstraintViolation<Address>> violations = validator.validate( address );
- assertTrue( violations.size() == 3, "All 3 @NotNull constraints should fail." );
- assertAssertionType( violations );
-
- violations = validator.validate( address, Default.class );
- assertTrue( violations.size() == 3, "All 3 @NotNull constraints should fail." );
- assertAssertionType( violations );
-
- violations = validator.validate( address, Address.class );
- assertTrue( violations.size() == 3, "All 3 @NotNull constraints should fail." );
- assertAssertionType( violations );
- }
-
@Test
@SpecAssertion(section = "3.4.3", id = "a")
public void testValidatingAgainstRedefinedDefaultGroup() {
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validatorfactory/CustomConstraintValidatorTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validatorfactory/CustomConstraintValidatorTest.java 2009-08-25 10:22:20 UTC (rev 17405)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validatorfactory/CustomConstraintValidatorTest.java 2009-08-25 12:07:30 UTC (rev 17406)
@@ -59,7 +59,7 @@
}
@SpecAssertion(section = "2.5", id = "c")
- @Test(expectedExceptions = ValidationException.class, enabled = false)
+ @Test(expectedExceptions = ValidationException.class)
public void testValidationExceptionIsThrownInCaseFactoryReturnsNull() {
Configuration<?> config = TestUtil.getConfigurationUnderTest().constraintValidatorFactory(
new ConstraintValidatorFactory() {
Modified: beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-08-25 10:22:20 UTC (rev 17405)
+++ beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-08-25 12:07:30 UTC (rev 17406)
@@ -401,7 +401,7 @@
this sequence expresses the sequence of groups that does substitute Default for this
class.</text>
</assertion>
- <assertion id="b">
+ <assertion id="b" testable="false">
<text>Constraints hosted on a class A and belonging to the Default group (by default or
explicitly) implicitly belong to the group A</text>
</assertion>
15 years, 4 months
Hibernate SVN: r17405 - in beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests: metadata and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-08-25 06:22:20 -0400 (Tue, 25 Aug 2009)
New Revision: 17405
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/metadata/BeanDescriptorTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/ConstraintDescriptorTest.java
Log:
enabled commented out group sequence test, cleanup
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-08-25 09:50:17 UTC (rev 17404)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/groupsequence/SequenceResolutionTest.java 2009-08-25 10:22:20 UTC (rev 17405)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
@@ -22,6 +22,7 @@
import javax.validation.GroupDefinitionException;
import javax.validation.GroupSequence;
import javax.validation.Validator;
+import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import org.jboss.test.audit.annotations.SpecAssertion;
@@ -55,23 +56,35 @@
validator.validate( entity, Complete.class );
}
- @Test(enabled = false)
-// @SpecAssertion(section = "3.4.2", id = "j")
+ @Test
+ @SpecAssertion(section = "3.4.2", id = "j")
public void testOnlyFirstGroupInSequenceGetEvaluated() {
Validator validator = TestUtil.getValidatorUnderTest();
Car car = new Car( "USd-298" );
-
- Set<ConstraintViolation<Car>> violations = validator.validateProperty(
- car, "licensePlateNumber", All.class
- );
+
+ // the constraint fails for each group
+ Set<ConstraintViolation<Car>> violations = validator.validate( car, First.class );
assertCorrectNumberOfViolations( violations, 1 );
- ConstraintViolation<Car> violation = violations.iterator().next();
+
+ violations = validator.validate( car, Second.class );
+ assertCorrectNumberOfViolations( violations, 2 );
+
+ // if we validate against the sequence All we only get one violation since group Second won't be executed
+ violations = validator.validate( car, All.class );
+ assertCorrectNumberOfViolations( violations, 1 );
+
+ // if we validate against the sequence AllReverese we only get two violations since group First won't be executed
+ violations = validator.validate( car, AllReverse.class );
+ assertCorrectNumberOfViolations( violations, 2 );
}
class Car {
@Pattern(regexp = "[A-Z][A-Z][A-Z]-[0-9][0-9][0-9]", groups = { First.class, Second.class })
private String licensePlateNumber;
+ @NotNull(groups = Second.class)
+ private String make;
+
Car(String licensePlateNumber) {
this.licensePlateNumber = licensePlateNumber;
}
@@ -90,4 +103,8 @@
@GroupSequence({ First.class, Second.class })
interface All {
}
+
+ @GroupSequence({ Second.class, First.class })
+ interface AllReverse {
+ }
}
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/BeanDescriptorTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/BeanDescriptorTest.java 2009-08-25 09:50:17 UTC (rev 17404)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/BeanDescriptorTest.java 2009-08-25 10:22:20 UTC (rev 17405)
@@ -32,7 +32,6 @@
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
import org.testng.annotations.Test;
import org.hibernate.jsr303.tck.util.TestUtil;
@@ -183,29 +182,6 @@
assertEquals( constraintProperties.size(), 0, "We should get the empty set." );
}
- // TODO - enable or remove
- @Test(enabled = false)
- public void testGetConstrainedPropertiesImmutable() {
- Validator validator = TestUtil.getValidatorUnderTest();
- BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
- Set<PropertyDescriptor> constraintProperties = beanDescriptor.getConstrainedProperties();
- try {
- constraintProperties.add( null );
- fail( "Set should be immutable" );
- }
- catch ( UnsupportedOperationException e ) {
- // success
- }
-
- try {
- constraintProperties.remove( constraintProperties.iterator().next() );
- fail( "Set should be immutable" );
- }
- catch ( UnsupportedOperationException e ) {
- // success
- }
- }
-
// TODO - map or remove
@Test(expectedExceptions = IllegalArgumentException.class)
public void testGetConstraintsForNullProperty() {
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/ConstraintDescriptorTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/ConstraintDescriptorTest.java 2009-08-25 09:50:17 UTC (rev 17404)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/ConstraintDescriptorTest.java 2009-08-25 10:22:20 UTC (rev 17405)
@@ -19,11 +19,11 @@
import java.util.Map;
import java.util.Set;
+import javax.validation.ConstraintPayload;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.validation.groups.Default;
import javax.validation.metadata.ConstraintDescriptor;
-import javax.validation.ConstraintPayload;
import org.jboss.test.audit.annotations.SpecAssertion;
import org.jboss.test.audit.annotations.SpecAssertions;
@@ -45,7 +45,7 @@
* @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 ConstraintDescriptorTest extends AbstractTest {
@Test
@@ -163,43 +163,6 @@
assertTrue( payload.size() == 0 );
}
- @Test(enabled = false)
- public void testConstraintDescriptorImmutable() {
- ConstraintDescriptor<?> descriptor = getConstraintDescriptor( Order.class, "orderNumber" );
-
- try {
- descriptor.getGroups().add( Default.class );
- fail( "Should be immutable" );
- }
- catch ( UnsupportedOperationException e ) {
- // success
- }
-
- try {
- descriptor.getAttributes().put( "foo", "bar" );
- fail( "Should be immutable" );
- }
- catch ( UnsupportedOperationException e ) {
- // success
- }
-
- try {
- descriptor.getConstraintValidatorClasses().add( null );
- fail( "Should be immutable" );
- }
- catch ( UnsupportedOperationException e ) {
- // success
- }
-
- try {
- descriptor.getComposingConstraints().add( null );
- fail( "Should be immutable" );
- }
- catch ( UnsupportedOperationException e ) {
- // success
- }
- }
-
private ConstraintDescriptor<?> getConstraintDescriptor(Class<?> clazz, String property) {
Set<ConstraintDescriptor<?>> descriptors = getConstraintDescriptorsFor( clazz, property );
assertTrue( descriptors.size() == 1, "There should only by one descriptor." );
15 years, 4 months
Hibernate SVN: r17404 - in beanvalidation/trunk/validation-tck/src/main: java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/propertylevel and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-08-25 05:50:17 -0400 (Tue, 25 Aug 2009)
New Revision: 17404
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/fieldlevel/ExcludeFieldLevelAnnotationsDueToBeanDefaultsTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/fieldlevel/IncludeFieldLevelAnnotationsDueToBeanDefaultsTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/propertylevel/ExcludePropertyLevelAnnotationsDueToBeanDefaultsTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/propertylevel/IncludePropertyLevelAnnotationsDueToBeanDefaultsTest.java
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/fieldlevel/user-constraints-ExcludeFieldLevelAnnotationsDueToBeanDefaultsTest.xml
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/fieldlevel/user-constraints-IncludeFieldLevelAnnotationsDueToBeanDefaultsTest.xml
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/fieldlevel/validation-ExcludeFieldLevelAnnotationsDueToBeanDefaultsTest.xml
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/fieldlevel/validation-IncludeFieldLevelAnnotationsDueToBeanDefaultsTest.xml
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/propertylevel/user-constraints-ExcludePropertyLevelAnnotationsDueToBeanDefaultsTest.xml
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/propertylevel/user-constraints-IncludePropertyLevelAnnotationsDueToBeanDefaultsTest.xml
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/propertylevel/validation-ExcludePropertyLevelAnnotationsDueToBeanDefaultsTest.xml
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/propertylevel/validation-IncludePropertyLevelAnnotationsDueToBeanDefaultsTest.xml
Log:
xml mapping tests
Copied: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/fieldlevel/ExcludeFieldLevelAnnotationsDueToBeanDefaultsTest.java (from rev 17399, beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/fieldlevel/FieldLevelOverridingTest.java)
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/fieldlevel/ExcludeFieldLevelAnnotationsDueToBeanDefaultsTest.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/fieldlevel/ExcludeFieldLevelAnnotationsDueToBeanDefaultsTest.java 2009-08-25 09:50:17 UTC (rev 17404)
@@ -0,0 +1,61 @@
+// $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.xmlconfiguration.constraintdeclaration.fieldlevel;
+
+import javax.validation.Validator;
+import javax.validation.metadata.BeanDescriptor;
+import javax.validation.metadata.PropertyDescriptor;
+
+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;
+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.assertNotNull;
+import static org.testng.Assert.assertNull;
+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-ExcludeFieldLevelAnnotationsDueToBeanDefaultsTest.xml")
+@Resource(source = "user-constraints-ExcludeFieldLevelAnnotationsDueToBeanDefaultsTest.xml",
+ destination = "WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/fieldlevel/user-constraints-ExcludeFieldLevelAnnotationsDueToBeanDefaultsTest.xml")
+public class ExcludeFieldLevelAnnotationsDueToBeanDefaultsTest extends AbstractTest {
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "7.1.1.2", id = "b"),
+ @SpecAssertion(section = "7.1.1.2", id = "c")
+ })
+ public void testIgnoreAnnotations() {
+ Validator validator = TestUtil.getValidatorUnderTest();
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( User.class );
+ assertNotNull( beanDescriptor );
+
+ PropertyDescriptor propDescriptor = beanDescriptor.getConstraintsForProperty( "firstname" );
+ assertNull( propDescriptor, "The annotation defined constraints should be ignored." );
+ }
+}
\ No newline at end of file
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/fieldlevel/IncludeFieldLevelAnnotationsDueToBeanDefaultsTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/fieldlevel/IncludeFieldLevelAnnotationsDueToBeanDefaultsTest.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/fieldlevel/IncludeFieldLevelAnnotationsDueToBeanDefaultsTest.java 2009-08-25 09:50:17 UTC (rev 17404)
@@ -0,0 +1,70 @@
+// $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.xmlconfiguration.constraintdeclaration.fieldlevel;
+
+import java.util.Set;
+import javax.validation.Validator;
+import javax.validation.constraints.NotNull;
+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.test.audit.annotations.SpecAssertions;
+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.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+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-IncludeFieldLevelAnnotationsDueToBeanDefaultsTest.xml")
+@Resource(source = "user-constraints-IncludeFieldLevelAnnotationsDueToBeanDefaultsTest.xml",
+ destination = "WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/fieldlevel/user-constraints-IncludeFieldLevelAnnotationsDueToBeanDefaultsTest.xml")
+public class IncludeFieldLevelAnnotationsDueToBeanDefaultsTest extends AbstractTest {
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "7.1.1.2", id = "b"),
+ @SpecAssertion(section = "7.1.1.2", id = "d")
+ })
+ public void testAnnotationsIncluded() {
+ Validator validator = TestUtil.getValidatorUnderTest();
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( User.class );
+ assertNotNull( beanDescriptor );
+
+ PropertyDescriptor propDescriptor = beanDescriptor.getConstraintsForProperty( "firstname" );
+ assertNotNull( propDescriptor );
+
+ Set<ConstraintDescriptor<?>> constraintDescriptors = propDescriptor.getConstraintDescriptors();
+ assertEquals( constraintDescriptors.size(), 1, "There should be two constraints" );
+ ConstraintDescriptor<?> descriptor = constraintDescriptors.iterator().next();
+ assertTrue( descriptor.getAnnotation() instanceof NotNull, "Wrong constraint annotation." );
+ }
+}
\ No newline at end of file
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/propertylevel/ExcludePropertyLevelAnnotationsDueToBeanDefaultsTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/propertylevel/ExcludePropertyLevelAnnotationsDueToBeanDefaultsTest.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/propertylevel/ExcludePropertyLevelAnnotationsDueToBeanDefaultsTest.java 2009-08-25 09:50:17 UTC (rev 17404)
@@ -0,0 +1,61 @@
+// $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.xmlconfiguration.constraintdeclaration.propertylevel;
+
+import javax.validation.Validator;
+import javax.validation.metadata.BeanDescriptor;
+import javax.validation.metadata.PropertyDescriptor;
+
+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;
+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.assertNotNull;
+import static org.testng.Assert.assertNull;
+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-ExcludePropertyLevelAnnotationsDueToBeanDefaultsTest.xml")
+@Resource(source = "user-constraints-ExcludePropertyLevelAnnotationsDueToBeanDefaultsTest.xml",
+ destination = "WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/propertylevel/user-constraints-ExcludePropertyLevelAnnotationsDueToBeanDefaultsTest.xml")
+public class ExcludePropertyLevelAnnotationsDueToBeanDefaultsTest extends AbstractTest {
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "7.1.1.3", id = "b"),
+ @SpecAssertion(section = "7.1.1.3", id = "c")
+ })
+ public void testIgnoreAnnotations() {
+ Validator validator = TestUtil.getValidatorUnderTest();
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( User.class );
+ assertNotNull( beanDescriptor );
+
+ PropertyDescriptor propDescriptor = beanDescriptor.getConstraintsForProperty( "firstname" );
+ assertNull( propDescriptor, "The annotation defined constraints should be ignored." );
+ }
+}
\ No newline at end of file
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/propertylevel/IncludePropertyLevelAnnotationsDueToBeanDefaultsTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/propertylevel/IncludePropertyLevelAnnotationsDueToBeanDefaultsTest.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/propertylevel/IncludePropertyLevelAnnotationsDueToBeanDefaultsTest.java 2009-08-25 09:50:17 UTC (rev 17404)
@@ -0,0 +1,72 @@
+// $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.xmlconfiguration.constraintdeclaration.propertylevel;
+
+import java.util.Set;
+import javax.validation.Validator;
+import javax.validation.constraints.NotNull;
+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.test.audit.annotations.SpecAssertions;
+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.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
+
+import org.hibernate.jsr303.tck.util.TestUtil;
+import org.hibernate.jsr303.tck.tests.xmlconfiguration.constraintdeclaration.fieldlevel.*;
+import org.hibernate.jsr303.tck.tests.xmlconfiguration.constraintdeclaration.fieldlevel.User;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Artifact(artifactType = ArtifactType.JSR303)
+@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
+@ValidationXml(value = "validation-IncludePropertyLevelAnnotationsDueToBeanDefaultsTest.xml")
+@Resource(source = "user-constraints-IncludePropertyLevelAnnotationsDueToBeanDefaultsTest.xml",
+ destination = "WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/propertylevel/user-constraints-IncludePropertyLevelAnnotationsDueToBeanDefaultsTest.xml")
+public class IncludePropertyLevelAnnotationsDueToBeanDefaultsTest extends AbstractTest {
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "7.1.1.3", id = "b"),
+ @SpecAssertion(section = "7.1.1.3", id = "d")
+ })
+ public void testAnnotationsIncluded() {
+ Validator validator = TestUtil.getValidatorUnderTest();
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( User.class );
+ assertNotNull( beanDescriptor );
+
+ PropertyDescriptor propDescriptor = beanDescriptor.getConstraintsForProperty( "firstname" );
+ assertNotNull( propDescriptor );
+
+ Set<ConstraintDescriptor<?>> constraintDescriptors = propDescriptor.getConstraintDescriptors();
+ assertEquals( constraintDescriptors.size(), 1, "There should be two constraints" );
+ ConstraintDescriptor<?> descriptor = constraintDescriptors.iterator().next();
+ assertTrue( descriptor.getAnnotation() instanceof NotNull, "Wrong constraint annotation." );
+ }
+}
\ No newline at end of file
Copied: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/fieldlevel/user-constraints-ExcludeFieldLevelAnnotationsDueToBeanDefaultsTest.xml (from rev 17399, beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/fieldlevel/user-constraints-FieldLevelOverridingTest.xml)
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/fieldlevel/user-constraints-ExcludeFieldLevelAnnotationsDueToBeanDefaultsTest.xml (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/fieldlevel/user-constraints-ExcludeFieldLevelAnnotationsDueToBeanDefaultsTest.xml 2009-08-25 09:50:17 UTC (rev 17404)
@@ -0,0 +1,7 @@
+<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">
+ <bean class="org.hibernate.jsr303.tck.tests.xmlconfiguration.constraintdeclaration.fieldlevel.User">
+ <field name="firstname"/>
+ </bean>
+</constraint-mappings>
Added: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/fieldlevel/user-constraints-IncludeFieldLevelAnnotationsDueToBeanDefaultsTest.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/fieldlevel/user-constraints-IncludeFieldLevelAnnotationsDueToBeanDefaultsTest.xml (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/fieldlevel/user-constraints-IncludeFieldLevelAnnotationsDueToBeanDefaultsTest.xml 2009-08-25 09:50:17 UTC (rev 17404)
@@ -0,0 +1,8 @@
+<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">
+ <bean class="org.hibernate.jsr303.tck.tests.xmlconfiguration.constraintdeclaration.fieldlevel.User"
+ ignore-annotations="false">
+ <field name="firstname"/>
+ </bean>
+</constraint-mappings>
Copied: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/fieldlevel/validation-ExcludeFieldLevelAnnotationsDueToBeanDefaultsTest.xml (from rev 17399, beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/fieldlevel/validation-FieldLevelOverridingTest.xml)
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/fieldlevel/validation-ExcludeFieldLevelAnnotationsDueToBeanDefaultsTest.xml (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/fieldlevel/validation-ExcludeFieldLevelAnnotationsDueToBeanDefaultsTest.xml 2009-08-25 09:50:17 UTC (rev 17404)
@@ -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/fieldlevel/user-constraints-ExcludeFieldLevelAnnotationsDueToBeanDefaultsTest.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/fieldlevel/validation-IncludeFieldLevelAnnotationsDueToBeanDefaultsTest.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/fieldlevel/validation-IncludeFieldLevelAnnotationsDueToBeanDefaultsTest.xml (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/fieldlevel/validation-IncludeFieldLevelAnnotationsDueToBeanDefaultsTest.xml 2009-08-25 09:50:17 UTC (rev 17404)
@@ -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/fieldlevel/user-constraints-IncludeFieldLevelAnnotationsDueToBeanDefaultsTest.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/propertylevel/user-constraints-ExcludePropertyLevelAnnotationsDueToBeanDefaultsTest.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/propertylevel/user-constraints-ExcludePropertyLevelAnnotationsDueToBeanDefaultsTest.xml (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/propertylevel/user-constraints-ExcludePropertyLevelAnnotationsDueToBeanDefaultsTest.xml 2009-08-25 09:50:17 UTC (rev 17404)
@@ -0,0 +1,7 @@
+<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">
+ <bean class="org.hibernate.jsr303.tck.tests.xmlconfiguration.constraintdeclaration.propertylevel.User">
+ <getter name="firstname"/>
+ </bean>
+</constraint-mappings>
Added: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/propertylevel/user-constraints-IncludePropertyLevelAnnotationsDueToBeanDefaultsTest.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/propertylevel/user-constraints-IncludePropertyLevelAnnotationsDueToBeanDefaultsTest.xml (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/propertylevel/user-constraints-IncludePropertyLevelAnnotationsDueToBeanDefaultsTest.xml 2009-08-25 09:50:17 UTC (rev 17404)
@@ -0,0 +1,8 @@
+<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">
+ <bean class="org.hibernate.jsr303.tck.tests.xmlconfiguration.constraintdeclaration.propertylevel.User"
+ ignore-annotations="false">
+ <getter name="firstname"/>
+ </bean>
+</constraint-mappings>
Added: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/propertylevel/validation-ExcludePropertyLevelAnnotationsDueToBeanDefaultsTest.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/propertylevel/validation-ExcludePropertyLevelAnnotationsDueToBeanDefaultsTest.xml (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/propertylevel/validation-ExcludePropertyLevelAnnotationsDueToBeanDefaultsTest.xml 2009-08-25 09:50:17 UTC (rev 17404)
@@ -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/propertylevel/user-constraints-ExcludePropertyLevelAnnotationsDueToBeanDefaultsTest.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/propertylevel/validation-IncludePropertyLevelAnnotationsDueToBeanDefaultsTest.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/propertylevel/validation-IncludePropertyLevelAnnotationsDueToBeanDefaultsTest.xml (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/propertylevel/validation-IncludePropertyLevelAnnotationsDueToBeanDefaultsTest.xml 2009-08-25 09:50:17 UTC (rev 17404)
@@ -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/propertylevel/user-constraints-IncludePropertyLevelAnnotationsDueToBeanDefaultsTest.xml
+ </constraint-mapping>
+</validation-config>
\ No newline at end of file
15 years, 4 months
Hibernate SVN: r17403 - in beanvalidation/trunk/validation-tck/src/main: resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-08-24 10:18:16 -0400 (Mon, 24 Aug 2009)
New Revision: 17403
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/DefaultSequenceDefinedInXmlTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/Optional.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/PrePosting.java
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/package-constraints-DefaultSequenceDefinedInXmlTest.xml
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/validation-DefaultSequenceDefinedInXmlTest.xml
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/ClassLevelOverridingWithAnnotationTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/ConfigurationViaXmlAndAnnotationsTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/Package.java
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/package-constraints-ClassLevelOverridingWithAnnotationTest.xml
Log:
xml mapping tests
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/ClassLevelOverridingWithAnnotationTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/ClassLevelOverridingWithAnnotationTest.java 2009-08-24 12:42:58 UTC (rev 17402)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/ClassLevelOverridingWithAnnotationTest.java 2009-08-24 14:18:16 UTC (rev 17403)
@@ -20,6 +20,7 @@
import java.util.Set;
import javax.validation.ConstraintViolation;
import javax.validation.Validator;
+import javax.validation.groups.Default;
import org.jboss.test.audit.annotations.SpecAssertion;
import org.jboss.test.audit.annotations.SpecAssertions;
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/ConfigurationViaXmlAndAnnotationsTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/ConfigurationViaXmlAndAnnotationsTest.java 2009-08-24 12:42:58 UTC (rev 17402)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/ConfigurationViaXmlAndAnnotationsTest.java 2009-08-24 14:18:16 UTC (rev 17403)
@@ -17,8 +17,11 @@
*/
package org.hibernate.jsr303.tck.tests.xmlconfiguration.constraintdeclaration;
+import java.util.Set;
import javax.validation.Configuration;
+import javax.validation.ConstraintViolation;
import javax.validation.Validator;
+import javax.validation.groups.Default;
import javax.validation.metadata.BeanDescriptor;
import org.jboss.test.audit.annotations.SpecAssertion;
@@ -34,6 +37,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;
/**
* @author Hardy Ferentschik
@@ -54,7 +59,7 @@
public void testEntityConfiguredViaAnnotationsAndXml() {
Validator validator = TestUtil.getValidatorUnderTest();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Package.class );
- assertTrue( beanDescriptor.isBeanConstrained(), "With xml configuration there should be two constraints." );
+ assertTrue( beanDescriptor.isBeanConstrained(), "The bean should be constrained" );
assertEquals(
beanDescriptor.getConstraintsForProperty( "maxWeight" ).getConstraintDescriptors().size(),
@@ -78,4 +83,16 @@
"Without xml there should be only one constraint."
);
}
+
+ @Test
+ @SpecAssertion(section = "7.1.1.1", id = "e")
+ public void testDefaultGroupDefinitionDefinedInEntityApplies() {
+ Validator validator = TestUtil.getValidatorUnderTest();
+ Package p = new Package();
+ p.setMaxWeight(30);
+ Set<ConstraintViolation<Package>> violations = validator.validate( p, Default.class );
+
+ assertCorrectNumberOfViolations( violations, 1 );
+ assertCorrectConstraintViolationMessages( violations, "ValidPackage defined as annotation" );
+ }
}
\ No newline at end of file
Copied: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/DefaultSequenceDefinedInXmlTest.java (from rev 17390, beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/ConfigurationViaXmlAndAnnotationsTest.java)
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/DefaultSequenceDefinedInXmlTest.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/DefaultSequenceDefinedInXmlTest.java 2009-08-24 14:18:16 UTC (rev 17403)
@@ -0,0 +1,59 @@
+// $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.xmlconfiguration.constraintdeclaration;
+
+import java.util.Set;
+import javax.validation.ConstraintViolation;
+import javax.validation.Validator;
+import javax.validation.groups.Default;
+
+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 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;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Artifact(artifactType = ArtifactType.JSR303)
+@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
+@ValidationXml(value = "validation-DefaultSequenceDefinedInXmlTest.xml")
+@Resource(source = "package-constraints-DefaultSequenceDefinedInXmlTest.xml",
+ destination = "WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/package-constraints-DefaultSequenceDefinedInXmlTest.xml")
+public class DefaultSequenceDefinedInXmlTest extends AbstractTest {
+
+ @Test
+ @SpecAssertion(section = "7.1.1.1", id = "e")
+ public void testDefaultGroupDefinitionDefinedInEntityApplies() {
+ Validator validator = TestUtil.getValidatorUnderTest();
+ Package p = new Package();
+ p.setMaxWeight(30);
+ Set<ConstraintViolation<Package>> violations = validator.validate( p, Default.class );
+
+ assertCorrectNumberOfViolations( violations, 1 );
+ assertCorrectConstraintViolationMessages( violations, "The package is too heavy" );
+ }
+}
\ No newline at end of file
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/Optional.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/Optional.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/Optional.java 2009-08-24 14:18:16 UTC (rev 17403)
@@ -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.xmlconfiguration.constraintdeclaration;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public interface Optional {
+}
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/Package.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/Package.java 2009-08-24 12:42:58 UTC (rev 17402)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/Package.java 2009-08-24 14:18:16 UTC (rev 17403)
@@ -17,14 +17,16 @@
*/
package org.hibernate.jsr303.tck.tests.xmlconfiguration.constraintdeclaration;
+import javax.validation.GroupSequence;
import javax.validation.constraints.Max;
/**
* @author Hardy Ferentschik
*/
-@ValidPackage(message = "ValidPackage defined as annotation")
+@GroupSequence(value = { Package.class, PrePosting.class })
+@ValidPackage(message = "ValidPackage defined as annotation", groups = PrePosting.class)
public class Package {
- @Max(20)
+ @Max(value = 20, groups = Optional.class, message = "The package is too heavy")
private int maxWeight;
public int getMaxWeight() {
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/PrePosting.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/PrePosting.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/PrePosting.java 2009-08-24 14:18:16 UTC (rev 17403)
@@ -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.xmlconfiguration.constraintdeclaration;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public interface PrePosting {
+}
Modified: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/package-constraints-ClassLevelOverridingWithAnnotationTest.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/package-constraints-ClassLevelOverridingWithAnnotationTest.xml 2009-08-24 12:42:58 UTC (rev 17402)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/package-constraints-ClassLevelOverridingWithAnnotationTest.xml 2009-08-24 14:18:16 UTC (rev 17403)
@@ -6,6 +6,10 @@
<class ignore-annotations="false">
<constraint annotation="org.hibernate.jsr303.tck.tests.xmlconfiguration.constraintdeclaration.ValidPackage">
<message>ValidPackage defined in XML</message>
+ <groups>
+ <value>org.hibernate.jsr303.tck.tests.xmlconfiguration.constraintdeclaration.PrePosting
+ </value>
+ </groups>
</constraint>
</class>
</bean>
Copied: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/package-constraints-DefaultSequenceDefinedInXmlTest.xml (from rev 17390, beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/package-constraints-ClassLevelOverridingTest.xml)
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/package-constraints-DefaultSequenceDefinedInXmlTest.xml (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/package-constraints-DefaultSequenceDefinedInXmlTest.xml 2009-08-24 14:18:16 UTC (rev 17403)
@@ -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.constraintdeclaration</default-package>
+ <bean class="Package" ignore-annotations="false">
+ <class ignore-annotations="false">
+ <group-sequence>
+ <value>org.hibernate.jsr303.tck.tests.xmlconfiguration.constraintdeclaration.Package</value>
+ <value>org.hibernate.jsr303.tck.tests.xmlconfiguration.constraintdeclaration.Optional</value>
+ </group-sequence>
+ </class>
+ </bean>
+</constraint-mappings>
\ No newline at end of file
Copied: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/validation-DefaultSequenceDefinedInXmlTest.xml (from rev 17390, beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/validation-ClassLevelOverridingTest.xml)
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/validation-DefaultSequenceDefinedInXmlTest.xml (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/validation-DefaultSequenceDefinedInXmlTest.xml 2009-08-24 14:18:16 UTC (rev 17403)
@@ -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/package-constraints-DefaultSequenceDefinedInXmlTest.xml</constraint-mapping>
+</validation-config>
\ No newline at end of file
15 years, 4 months