Author: hardy.ferentschik
Date: 2009-07-23 08:35:38 -0400 (Thu, 23 Jul 2009)
New Revision: 17193
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/PropertyPathTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateWithGroupsTest.java
Removed:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateWithGroups.java
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/validation/ValidateTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Address.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/User.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/util/TestUtil.java
beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
Log:
tests for property path
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-07-22
20:40:50 UTC (rev 17192)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/BeanDescriptorTest.java 2009-07-23
12:35:38 UTC (rev 17193)
@@ -42,11 +42,14 @@
* @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 BeanDescriptorTest extends AbstractTest {
@Test
- @SpecAssertion(section = "5.3", id = "a")
+ @SpecAssertions({
+ @SpecAssertion(section = "5.1", id = "b"),
+ @SpecAssertion(section = "5.3", id = "a")
+ })
public void testIsBeanConstrainedDueToValidAnnotation() {
Validator validator = TestUtil.getDefaultValidator();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Customer.class );
@@ -57,7 +60,10 @@
}
@Test
- @SpecAssertion(section = "5.3", id = "a")
+ @SpecAssertions({
+ @SpecAssertion(section = "5.1", id = "b"),
+ @SpecAssertion(section = "5.3", id = "a")
+ })
public void testIsBeanConstrainedDueToConstraintOnEntity() {
Validator validator = TestUtil.getDefaultValidator();
@@ -68,7 +74,10 @@
}
@Test
- @SpecAssertion(section = "5.3", id = "a")
+ @SpecAssertions({
+ @SpecAssertion(section = "5.1", id = "b"),
+ @SpecAssertion(section = "5.3", id = "a")
+ })
public void testIsBeanConstrainedDueToConstraintProperty() {
Validator validator = TestUtil.getDefaultValidator();
@@ -79,7 +88,10 @@
}
@Test
- @SpecAssertion(section = "5.3", id = "a")
+ @SpecAssertions({
+ @SpecAssertion(section = "5.1", id = "b"),
+ @SpecAssertion(section = "5.3", id = "a")
+ })
public void testIsBeanConstrainedDueToConstraintOnInterface() {
Validator validator = TestUtil.getDefaultValidator();
@@ -90,7 +102,10 @@
}
@Test
- @SpecAssertion(section = "5.3", id = "a")
+ @SpecAssertions({
+ @SpecAssertion(section = "5.1", id = "b"),
+ @SpecAssertion(section = "5.3", id = "a")
+ })
public void testUnconstraintClass() {
Validator validator = TestUtil.getDefaultValidator();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass(
UnconstraintEntity.class );
@@ -99,7 +114,10 @@
}
@Test
- @SpecAssertion(section = "5.3", id = "b")
+ @SpecAssertions({
+ @SpecAssertion(section = "5.1", id = "b"),
+ @SpecAssertion(section = "5.3", id = "b")
+ })
public void testGetConstraintForConstrainedProperty() {
Validator validator = TestUtil.getDefaultValidator();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
@@ -112,6 +130,7 @@
@Test
@SpecAssertions({
@SpecAssertion(section = "5.3", id = "b"),
+ @SpecAssertion(section = "5.3", id = "b"),
@SpecAssertion(section = "5.4", id = "a")
})
public void testGetConstraintForUnConstrainedProperty() {
@@ -125,23 +144,21 @@
}
@Test
- @SpecAssertion(section = "5.3", id = "b")
+ @SpecAssertions({
+ @SpecAssertion(section = "5.1", id = "b"),
+ @SpecAssertion(section = "5.3", id = "b")
+ })
public void testGetConstraintsForNonExistingProperty() {
Validator validator = TestUtil.getDefaultValidator();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
assertNull( beanDescriptor.getConstraintsForProperty( "foobar" ), "There
should be no descriptor" );
}
-
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void testGetConstraintsForNullProperty() {
- Validator validator = TestUtil.getDefaultValidator();
- BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
- beanDescriptor.getConstraintsForProperty( null );
- }
-
@Test
- @SpecAssertion(section = "5.3", id = "b")
+ @SpecAssertions({
+ @SpecAssertion(section = "5.1", id = "b"),
+ @SpecAssertion(section = "5.3", id = "b")
+ })
public void testGetConstrainedProperties() {
Validator validator = TestUtil.getDefaultValidator();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
@@ -155,7 +172,10 @@
}
@Test
- @SpecAssertion(section = "5.3", id = "b")
+ @SpecAssertions({
+ @SpecAssertion(section = "5.1", id = "b"),
+ @SpecAssertion(section = "5.3", id = "b")
+ })
public void testGetConstrainedPropertiesForUnconstraintEntity() {
Validator validator = TestUtil.getDefaultValidator();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass(
UnconstraintEntity.class );
@@ -163,6 +183,7 @@
assertEquals( constraintProperties.size(), 0, "We should get the empty set."
);
}
+ // TODO - enable or remove
@Test(enabled = false)
public void testGetConstrainedPropertiesImmutable() {
Validator validator = TestUtil.getDefaultValidator();
@@ -184,4 +205,12 @@
// success
}
}
+
+ // TODO - map or remove
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void testGetConstraintsForNullProperty() {
+ Validator validator = TestUtil.getDefaultValidator();
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
+ beanDescriptor.getConstraintsForProperty( null );
+ }
}
Copied:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/PropertyPathTest.java
(from rev 17190,
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateTest.java)
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/PropertyPathTest.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/PropertyPathTest.java 2009-07-23
12:35:38 UTC (rev 17193)
@@ -0,0 +1,269 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.jsr303.tck.tests.validation;
+
+import static java.lang.annotation.ElementType.TYPE;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import javax.validation.Constraint;
+import javax.validation.ConstraintPayload;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.ConstraintViolation;
+import javax.validation.Path;
+import javax.validation.Valid;
+import javax.validation.Validator;
+
+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 static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
+
+import org.hibernate.jsr303.tck.util.TestUtil;
+import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectNumberOfViolations;
+
+/**
+ * Tests for the implementation of <code>Validator</code>.
+ *
+ * @author Hardy Ferentschik
+ */
+@Artifact(artifactType = ArtifactType.JSR303)
+@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
+public class PropertyPathTest extends AbstractTest {
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "4.2", id = "f"),
+ @SpecAssertion(section = "4.2", id = "g"),
+ @SpecAssertion(section = "4.2", id = "m")
+ })
+ public void testPropertyPathWithConstraintViolationForRootObject() {
+ Validator validator = TestUtil.getDefaultValidator();
+ Set<ConstraintViolation<VerySpecialClass>> constraintViolations =
validator.validate( new VerySpecialClass() );
+ assertCorrectNumberOfViolations( constraintViolations, 1 );
+ ConstraintViolation<VerySpecialClass> constraintViolation =
constraintViolations.iterator().next();
+
+ Iterator<Path.Node> nodeIter = constraintViolation.getPropertyPath().iterator();
+ assertTrue( nodeIter.hasNext() );
+ Path.Node node = nodeIter.next();
+ assertEquals( node.getName(), null );
+ assertFalse( node.isInIterable() );
+ assertFalse( nodeIter.hasNext() );
+ }
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "4.2", id = "f"),
+ @SpecAssertion(section = "4.2", id = "h"),
+ @SpecAssertion(section = "4.2", id = "l")
+ })
+ public void testPropertyPathTraversedObject() {
+ Validator validator = TestUtil.getDefaultValidator();
+
+ Engine engine = new Engine();
+ engine.setSerialNumber( "ABCDEFGH1234" );
+ Set<ConstraintViolation<Engine>> constraintViolations = validator.validate(
engine );
+ assertCorrectNumberOfViolations( constraintViolations, 1 );
+
+ ConstraintViolation<Engine> constraintViolation =
constraintViolations.iterator().next();
+
+ Iterator<Path.Node> nodeIter = constraintViolation.getPropertyPath().iterator();
+ assertTrue( nodeIter.hasNext() );
+ Path.Node node = nodeIter.next();
+ assertEquals( node.getName(), "serialNumber" );
+ assertFalse( node.isInIterable() );
+ assertFalse( nodeIter.hasNext() );
+ }
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "4.2", id = "f"),
+ @SpecAssertion(section = "4.2", id = "i"),
+ @SpecAssertion(section = "4.2", id = "k")
+ })
+ public void testPropertyPathWithList() {
+ Validator validator = TestUtil.getDefaultValidator();
+
+ Actor clint = new ActorListBased( "Clint", "Eastwood" );
+ Actor morgan = new ActorListBased( "Morgan", null );
+ Actor charlie = new ActorListBased( "Charlie", "Sheen" );
+
+ clint.addPlayedWith( charlie );
+ charlie.addPlayedWith( clint );
+ charlie.addPlayedWith( morgan );
+ morgan.addPlayedWith( charlie );
+
+ Set<ConstraintViolation<Actor>> constraintViolations = validator.validate(
clint );
+ checkActorViolations( constraintViolations );
+ }
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "4.2", id = "f"),
+ @SpecAssertion(section = "4.2", id = "i"),
+ @SpecAssertion(section = "4.2", id = "k")
+ })
+ public void testPropertyPathWithArray() {
+ Validator validator = TestUtil.getDefaultValidator();
+
+ Actor clint = new ActorArrayBased( "Clint", "Eastwood" );
+ Actor morgan = new ActorArrayBased( "Morgan", null );
+ Actor charlie = new ActorArrayBased( "Charlie", "Sheen" );
+
+ clint.addPlayedWith( charlie );
+ charlie.addPlayedWith( clint );
+ charlie.addPlayedWith( morgan );
+ morgan.addPlayedWith( charlie );
+
+ Set<ConstraintViolation<Actor>> constraintViolations = validator.validate(
clint );
+ checkActorViolations( constraintViolations );
+ }
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "4.2", id = "f"),
+ @SpecAssertion(section = "4.2", id = "j"),
+ @SpecAssertion(section = "4.2", id = "k")
+ })
+ public void testPropertyPathWithMap() {
+ Validator validator = TestUtil.getDefaultValidator();
+
+ ActorDB db = new ActorDB();
+ Actor morgan = new ActorArrayBased( "Morgan", null );
+ Integer id = db.addActor( morgan );
+
+ Set<ConstraintViolation<ActorDB>> constraintViolations =
validator.validate( db );
+ assertCorrectNumberOfViolations( constraintViolations, 1 );
+
+ ConstraintViolation<ActorDB> constraintViolation =
constraintViolations.iterator().next();
+ Iterator<Path.Node> nodeIter = constraintViolation.getPropertyPath().iterator();
+ assertTrue( nodeIter.hasNext() );
+ Path.Node node = nodeIter.next();
+ assertEquals( node.getName(), "actors" );
+ assertEquals( node.getKey(), id );
+ assertTrue( node.isInIterable() );
+
+ node = nodeIter.next();
+ assertEquals( node.getName(), "lastName" );
+ assertFalse( node.isInIterable() );
+
+ assertFalse( nodeIter.hasNext() );
+ }
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "4.2", id = "f"),
+ @SpecAssertion(section = "4.2", id = "k")
+ })
+ public void testPropertyPathSet() {
+ Validator validator = TestUtil.getDefaultValidator();
+
+ Customer customer = new Customer();
+ customer.setFirstName( "John" );
+ customer.setLastName( "Doe" );
+ Order order = new Order();
+ customer.addOrder( order );
+
+ Set<ConstraintViolation<Customer>> constraintViolations =
validator.validate( customer );
+ assertCorrectNumberOfViolations( constraintViolations, 1 );
+
+ ConstraintViolation<Customer> constraintViolation =
constraintViolations.iterator().next();
+ Iterator<Path.Node> nodeIter = constraintViolation.getPropertyPath().iterator();
+ assertTrue( nodeIter.hasNext() );
+ Path.Node node = nodeIter.next();
+ assertEquals( node.getName(), "orders" );
+ assertTrue( node.isInIterable() );
+
+ node = nodeIter.next();
+ assertEquals( node.getName(), "orderNumber" );
+
+ assertFalse( nodeIter.hasNext() );
+ }
+
+ private void checkActorViolations(Set<ConstraintViolation<Actor>>
constraintViolations) {
+ assertCorrectNumberOfViolations( constraintViolations, 1 );
+
+ ConstraintViolation<Actor> constraintViolation =
constraintViolations.iterator().next();
+
+ Iterator<Path.Node> nodeIter = constraintViolation.getPropertyPath().iterator();
+ assertTrue( nodeIter.hasNext() );
+ Path.Node node = nodeIter.next();
+ assertEquals( node.getName(), "playedWith" );
+ assertEquals( node.getIndex(), new Integer( 0 ) );
+ assertTrue( node.isInIterable() );
+
+ node = nodeIter.next();
+ assertEquals( node.getName(), "playedWith" );
+ assertEquals( node.getIndex(), new Integer( 1 ) );
+ assertTrue( node.isInIterable() );
+
+ node = nodeIter.next();
+ assertEquals( node.getName(), "lastName" );
+ assertFalse( node.isInIterable() );
+
+ assertFalse( nodeIter.hasNext() );
+ }
+
+ @Special()
+ class VerySpecialClass {
+ }
+
+ @Constraint(validatedBy = { SpecialValidator.class })
+ @Target({ TYPE })
+ @Retention(RUNTIME)
+ public @interface Special {
+ public abstract String message() default "special validation failed";
+
+ public abstract Class<?>[] groups() default { };
+
+ public abstract Class<? extends ConstraintPayload>[] payload() default { };
+ }
+
+ public static class SpecialValidator implements ConstraintValidator<Special,
VerySpecialClass> {
+ public void initialize(Special constraintAnnotation) {
+ }
+
+ public boolean isValid(VerySpecialClass clazz, ConstraintValidatorContext
constraintValidatorContext) {
+ return false;
+ }
+ }
+
+ class ActorDB {
+ private int idGen = 0;
+
+ @Valid
+ Map<Integer, Actor> actors = new HashMap<Integer, Actor>();
+
+ public Integer addActor(Actor actor) {
+ Integer id = idGen++;
+ actors.put( id, actor );
+ return id;
+ }
+ }
+}
\ No newline at end of file
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateTest.java 2009-07-22
20:40:50 UTC (rev 17192)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateTest.java 2009-07-23
12:35:38 UTC (rev 17193)
@@ -43,9 +43,9 @@
import org.hibernate.jsr303.tck.util.TestUtil;
import static org.hibernate.jsr303.tck.util.TestUtil.assertConstraintViolation;
+import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectConstraintTypes;
import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectNumberOfViolations;
import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectPropertyPaths;
-import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectConstraintTypes;
/**
* Tests for the implementation of <code>Validator</code>.
@@ -71,18 +71,43 @@
catch ( ValidationException e ) {
// success
}
+ }
+ @Test
+ @SpecAssertion(section = "5.1", id = "b")
+ public void testConstraintDescriptorWithoutExplicitGroup() {
+ Validator validator = TestUtil.getDefaultValidator();
+
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
+ PropertyDescriptor propertyDescriptor = beanDescriptor.getConstraintsForProperty(
"orderNumber" );
+ Set<ConstraintDescriptor<?>> descriptors =
propertyDescriptor.getConstraintDescriptors();
+
+ assertEquals( descriptors.size(), 1, "There should be only one constraint
descriptor" );
+ ConstraintDescriptor<?> descriptor = descriptors.iterator().next();
+ Set<Class<?>> groups = descriptor.getGroups();
+ assertTrue( groups.size() == 1, "There should be only one group" );
+ assertEquals(
+ groups.iterator().next(),
+ Default.class,
+ "The declared constraint does not explicitly define a group, hence Default is
expected"
+ );
}
- @SpecAssertion(section = "4.1.1", id = "b")
@Test(expectedExceptions = IllegalArgumentException.class)
+ @SpecAssertion(section = "5.1", id = "c")
+ public void testNullParamterToGetConstraintsForClass() {
+ TestUtil.getDefaultValidator().getConstraintsForClass( null );
+ }
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ @SpecAssertion(section = "4.1.1", id = "b")
public void testValidateWithNullValue() {
Validator validator = TestUtil.getDefaultValidator();
validator.validate( null );
}
- @SpecAssertion(section = "4.1.1", id = "b")
@Test(expectedExceptions = IllegalArgumentException.class)
+ @SpecAssertion(section = "4.1.1", id = "b")
@SuppressWarnings("NullArgumentToVariableArgMethod")
public void testValidateWithNullGroup() {
Validator validator = TestUtil.getDefaultValidator();
@@ -124,7 +149,7 @@
Set<ConstraintViolation<Address>> constraintViolations =
validator.validate( address );
assertCorrectNumberOfViolations( constraintViolations, 2 );
- assertCorrectConstraintTypes(constraintViolations, Size.class, NotEmpty.class );
+ assertCorrectConstraintTypes( constraintViolations, Size.class, NotEmpty.class );
}
@Test
@@ -134,14 +159,12 @@
@SpecAssertion(section = "4.2", id = "b"),
@SpecAssertion(section = "4.2", id = "c"),
@SpecAssertion(section = "4.2", id = "d"),
- @SpecAssertion(section = "4.2", id = "e"),
- @SpecAssertion(section = "4.2", id = "g")
+ @SpecAssertion(section = "4.2", id = "e")
})
public void testConstraintViolation() {
Validator validator = TestUtil.getDefaultValidator();
Engine engine = new Engine();
- engine.setSerialNumber( "mail(a)foobar.com" );
engine.setSerialNumber( "ABCDEFGH1234" );
Set<ConstraintViolation<Engine>> constraintViolations = validator.validate(
engine );
assertCorrectNumberOfViolations( constraintViolations, 1 );
@@ -165,31 +188,8 @@
@Test
@SpecAssertions({
- @SpecAssertion(section = "4.2", id = "f"),
- @SpecAssertion(section = "4.2", id = "g")
+ @SpecAssertion(section = "2.4", id = "o")
})
- public void testValidateAssociation() {
- Validator validator = TestUtil.getDefaultValidator();
-
- Customer customer = new Customer();
- customer.setFirstName( "John" );
- customer.setLastName( "Doe" );
- Order order = new Order();
- customer.addOrder( order );
-
- Set<ConstraintViolation<Customer>> constraintViolations =
validator.validate( customer );
- assertCorrectNumberOfViolations( constraintViolations, 1 );
- assertCorrectPropertyPaths( constraintViolations, "orders[].orderNumber" );
- ConstraintViolation constraintViolation = constraintViolations.iterator().next();
- assertEquals( constraintViolation.getRootBean(), customer, "Wrong root
entity" );
- assertEquals( constraintViolation.getInvalidValue(), order.getOrderNumber(),
"Wrong value" );
- }
-
- @Test
- @SpecAssertions({
- @SpecAssertion(section = "2.4", id = "o"),
- @SpecAssertion(section = "4.2", id = "h")
- })
public void testGraphValidationWithList() {
Validator validator = TestUtil.getDefaultValidator();
@@ -213,15 +213,16 @@
assertEquals( constraintViolation.getRootBean(), clint, "Wrong root entity"
);
assertEquals( constraintViolation.getInvalidValue(), morgan.getLastName(), "Wrong
value" );
assertCorrectPropertyPaths(
- constraintViolations, "playedWith[0].playedWith[1].lastName",
"playedWith[1].lastName"
+ constraintViolations,
+ "playedWith[0].playedWith[1].lastName",
+ "playedWith[1].lastName"
);
}
@Test
@SpecAssertions({
@SpecAssertion(section = "2.4", id = "o"),
- @SpecAssertion(section = "3.1.3", id = "c"),
- @SpecAssertion(section = "4.2", id = "h")
+ @SpecAssertion(section = "3.1.3", id = "c")
})
public void testGraphValidationWithArray() {
Validator validator = TestUtil.getDefaultValidator();
@@ -244,16 +245,14 @@
assertEquals( constraintViolation.getRootBean(), clint, "Wrong root entity"
);
assertEquals( constraintViolation.getInvalidValue(), morgan.getLastName(), "Wrong
value" );
assertCorrectPropertyPaths(
- constraintViolations, "playedWith[0].playedWith[1].lastName",
"playedWith[1].lastName"
+ constraintViolations,
+ "playedWith[0].playedWith[1].lastName",
+ "playedWith[1].lastName"
);
}
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void testNullParamterToValidatorImplConstructor() {
- TestUtil.getDefaultValidator().getConstraintsForClass( null );
- }
-
@Test
+ @SpecAssertion(section = "4.1.1", id = "b")
@SuppressWarnings("NullArgumentToVariableArgMethod")
public void testPassingNullAsGroup() {
Validator validator = TestUtil.getDefaultValidator();
@@ -267,6 +266,32 @@
}
@Test
+ @SpecAssertion(section = "3.5", id = "b")
+ public void testOnlyFirstGroupInSequenceGetEvaluated() {
+ Validator validator = TestUtil.getDefaultValidator();
+ Car car = new Car( "USd-298" );
+
+ Set<ConstraintViolation<Car>> violations = validator.validateProperty(
+ car, "licensePlateNumber", First.class, Second.class
+ );
+ assertCorrectNumberOfViolations( violations, 1 );
+
+ car.setLicensePlateNumber( "USD-298" );
+ violations = validator.validateProperty(
+ car, "licensePlateNumber", First.class, Second.class
+ );
+ assertCorrectNumberOfViolations( violations, 0 );
+ }
+
+ @Test(expectedExceptions = ValidationException.class)
+ @SpecAssertion(section = "4.1.1", id = "k")
+ public void testUnexpectedExceptionsInValidateGetWrappedInValidationExceptions() {
+ Validator validator = TestUtil.getDefaultValidator();
+ validator.validate( new BadlyBehavedEntity() );
+ }
+
+ // TODO - map or remove
+ @Test
public void testValidationIsPolymorphic() {
Validator validator = TestUtil.getDefaultValidator();
@@ -293,6 +318,7 @@
assertCorrectNumberOfViolations( constraintViolations, 0 );
}
+ // TODO - map or remove
@Test
public void testObjectTraversion() {
Validator validator = TestUtil.getDefaultValidator();
@@ -312,50 +338,6 @@
assertCorrectNumberOfViolations( constraintViolations, 100 );
}
- @Test
- public void testConstraintDescriptorWithoutExplicitGroup() {
- Validator validator = TestUtil.getDefaultValidator();
-
- BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
- PropertyDescriptor propertyDescriptor = beanDescriptor.getConstraintsForProperty(
"orderNumber" );
- Set<ConstraintDescriptor<?>> descriptors =
propertyDescriptor.getConstraintDescriptors();
-
- assertEquals( descriptors.size(), 1, "There should be only one constraint
descriptor" );
- ConstraintDescriptor<?> descriptor = descriptors.iterator().next();
- Set<Class<?>> groups = descriptor.getGroups();
- assertTrue( groups.size() == 1, "There should be only one group" );
- assertEquals(
- groups.iterator().next(),
- Default.class,
- "The declared constraint does not explicitly define a group, hence Default is
expected"
- );
- }
-
- @Test
- @SpecAssertion(section = "3.5", id = "b")
- public void testOnlyFirstGroupInSequenceGetEvaluated() {
- Validator validator = TestUtil.getDefaultValidator();
- Car car = new Car( "USd-298" );
-
- Set<ConstraintViolation<Car>> violations = validator.validateProperty(
- car, "licensePlateNumber", First.class, Second.class
- );
- assertCorrectNumberOfViolations( violations, 1 );
-
- car.setLicensePlateNumber( "USD-298" );
- violations = validator.validateProperty(
- car, "licensePlateNumber", First.class, Second.class
- );
- assertCorrectNumberOfViolations( violations, 0 );
- }
-
- @Test(expectedExceptions = ValidationException.class)
- @SpecAssertion(section = "4.1.1", id = "k")
- public void testUnexpectedExceptionsInValidateGetWrappedInValidationExceptions() {
- Validator validator = TestUtil.getDefaultValidator();
- validator.validate( new BadlyBehavedEntity() );
- }
-
class Car {
@Pattern(regexp = "[A-Z][A-Z][A-Z]-[0-9][0-9][0-9]", groups = { First.class,
Second.class })
private String licensePlateNumber;
Deleted:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateWithGroups.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateWithGroups.java 2009-07-22
20:40:50 UTC (rev 17192)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateWithGroups.java 2009-07-23
12:35:38 UTC (rev 17193)
@@ -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.validation;
-
-import java.util.Set;
-import javax.validation.ConstraintViolation;
-import javax.validation.Validator;
-import javax.validation.constraints.NotNull;
-import javax.validation.groups.Default;
-
-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.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;
-import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectPropertyPaths;
-
-/**
- * Tests for the implementation of {@code Validator}.
- *
- * @author Hardy Ferentschik
- */
-@Artifact(artifactType = ArtifactType.JSR303)
-@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
-public class ValidateWithGroups extends AbstractTest {
-
- @Test
- @SpecAssertions({
- @SpecAssertion(section = "4.1.2", id = "a"),
- @SpecAssertion(section = "4.1.2", id = "b")
- })
- public void testCorrectGroupsAreAppliedForValidate() {
- Validator validator = TestUtil.getDefaultValidator();
-
- Set<ConstraintViolation<Address>> constraintViolations =
validator.validate( new Address() );
- assertCorrectNumberOfViolations( constraintViolations, 2 );
- assertCorrectConstraintTypes( constraintViolations, NotNull.class, NotEmpty.class );
- assertCorrectPropertyPaths( constraintViolations, "city", "zipCode"
);
-
- constraintViolations = validator.validate( new Address(), Default.class );
- assertCorrectNumberOfViolations( constraintViolations, 2 );
- assertCorrectConstraintTypes( constraintViolations, NotNull.class, NotEmpty.class );
- assertCorrectPropertyPaths( constraintViolations, "city", "zipCode"
);
-
- constraintViolations = validator.validate( new Address(), Address.Minimal.class );
- assertCorrectNumberOfViolations( constraintViolations, 2 );
- assertCorrectConstraintTypes( constraintViolations, NotEmpty.class, NotEmpty.class );
- assertCorrectPropertyPaths( constraintViolations, "street",
"zipCode" );
-
- constraintViolations = validator.validate( new Address(), Default.class,
Address.Minimal.class );
- assertCorrectNumberOfViolations( constraintViolations, 3 );
- assertCorrectConstraintTypes( constraintViolations, NotNull.class, NotEmpty.class,
NotEmpty.class );
- assertCorrectPropertyPaths( constraintViolations, "city", "street",
"zipCode" );
- }
-
- @Test
- @SpecAssertions({
- @SpecAssertion(section = "4.1.2", id = "a"),
- @SpecAssertion(section = "4.1.2", id = "b")
- })
- public void testCorrectGroupsAreAppliedForValidateProperty() {
- Validator validator = TestUtil.getDefaultValidator();
-
- Set<ConstraintViolation<Address>> constraintViolations =
validator.validateProperty( new Address(), "city" );
- assertCorrectNumberOfViolations( constraintViolations, 1 );
- assertCorrectConstraintTypes( constraintViolations, NotNull.class );
- assertCorrectPropertyPaths( constraintViolations, "city" );
-
- constraintViolations = validator.validateProperty( new Address(), "city",
Default.class );
- assertCorrectNumberOfViolations( constraintViolations, 1 );
- assertCorrectConstraintTypes( constraintViolations, NotNull.class );
- assertCorrectPropertyPaths( constraintViolations, "city" );
-
- constraintViolations = validator.validateProperty( new Address(), "city",
Address.Minimal.class );
- assertCorrectNumberOfViolations( constraintViolations, 0 );
-
- constraintViolations = validator.validateProperty( new Address(), "street",
Address.Minimal.class );
- assertCorrectNumberOfViolations( constraintViolations, 1 );
- assertCorrectConstraintTypes( constraintViolations, NotEmpty.class );
- assertCorrectPropertyPaths( constraintViolations, "street" );
- }
-
- @Test
- @SpecAssertions({
- @SpecAssertion(section = "4.1.2", id = "a"),
- @SpecAssertion(section = "4.1.2", id = "b")
- })
- public void testCorrectGroupsAreAppliedForValidateValue() {
- Validator validator = TestUtil.getDefaultValidator();
-
- Set<ConstraintViolation<Address>> constraintViolations =
validator.validateValue( Address.class, "city", null );
- assertCorrectNumberOfViolations( constraintViolations, 1 );
- assertCorrectConstraintTypes( constraintViolations, NotNull.class );
- assertCorrectPropertyPaths( constraintViolations, "city" );
-
- constraintViolations = validator.validateValue( Address.class, "city", null,
Default.class );
- assertCorrectNumberOfViolations( constraintViolations, 1 );
- assertCorrectConstraintTypes( constraintViolations, NotNull.class );
- assertCorrectPropertyPaths( constraintViolations, "city" );
-
- constraintViolations = validator.validateValue( Address.class, "city", null,
Address.Minimal.class );
- assertCorrectNumberOfViolations( constraintViolations, 0 );
-
- constraintViolations = validator.validateValue( Address.class, "street",
null, Address.Minimal.class );
- assertCorrectNumberOfViolations( constraintViolations, 1 );
- assertCorrectConstraintTypes( constraintViolations, NotEmpty.class );
- assertCorrectPropertyPaths( constraintViolations, "street" );
- }
-}
\ No newline at end of file
Copied:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateWithGroupsTest.java
(from rev 17190,
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateWithGroups.java)
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateWithGroupsTest.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateWithGroupsTest.java 2009-07-23
12:35:38 UTC (rev 17193)
@@ -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.validation;
+
+import java.util.Set;
+import javax.validation.ConstraintViolation;
+import javax.validation.Validator;
+import javax.validation.constraints.NotNull;
+import javax.validation.groups.Default;
+
+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.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;
+import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectPropertyPaths;
+
+/**
+ * Tests for the implementation of {@code Validator}.
+ *
+ * @author Hardy Ferentschik
+ */
+@Artifact(artifactType = ArtifactType.JSR303)
+@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
+public class ValidateWithGroupsTest extends AbstractTest {
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "4.1.2", id = "a"),
+ @SpecAssertion(section = "4.1.2", id = "b")
+ })
+ public void testCorrectGroupsAreAppliedForValidate() {
+ Validator validator = TestUtil.getDefaultValidator();
+
+ Set<ConstraintViolation<Address>> constraintViolations =
validator.validate( new Address() );
+ assertCorrectNumberOfViolations( constraintViolations, 2 );
+ assertCorrectConstraintTypes( constraintViolations, NotNull.class, NotEmpty.class );
+ assertCorrectPropertyPaths( constraintViolations, "city", "zipCode"
);
+
+ constraintViolations = validator.validate( new Address(), Default.class );
+ assertCorrectNumberOfViolations( constraintViolations, 2 );
+ assertCorrectConstraintTypes( constraintViolations, NotNull.class, NotEmpty.class );
+ assertCorrectPropertyPaths( constraintViolations, "city", "zipCode"
);
+
+ constraintViolations = validator.validate( new Address(), Address.Minimal.class );
+ assertCorrectNumberOfViolations( constraintViolations, 2 );
+ assertCorrectConstraintTypes( constraintViolations, NotEmpty.class, NotEmpty.class );
+ assertCorrectPropertyPaths( constraintViolations, "street",
"zipCode" );
+
+ constraintViolations = validator.validate( new Address(), Default.class,
Address.Minimal.class );
+ assertCorrectNumberOfViolations( constraintViolations, 3 );
+ assertCorrectConstraintTypes( constraintViolations, NotNull.class, NotEmpty.class,
NotEmpty.class );
+ assertCorrectPropertyPaths( constraintViolations, "city", "street",
"zipCode" );
+ }
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "4.1.2", id = "a"),
+ @SpecAssertion(section = "4.1.2", id = "b")
+ })
+ public void testCorrectGroupsAreAppliedForValidateProperty() {
+ Validator validator = TestUtil.getDefaultValidator();
+
+ Set<ConstraintViolation<Address>> constraintViolations =
validator.validateProperty( new Address(), "city" );
+ assertCorrectNumberOfViolations( constraintViolations, 1 );
+ assertCorrectConstraintTypes( constraintViolations, NotNull.class );
+ assertCorrectPropertyPaths( constraintViolations, "city" );
+
+ constraintViolations = validator.validateProperty( new Address(), "city",
Default.class );
+ assertCorrectNumberOfViolations( constraintViolations, 1 );
+ assertCorrectConstraintTypes( constraintViolations, NotNull.class );
+ assertCorrectPropertyPaths( constraintViolations, "city" );
+
+ constraintViolations = validator.validateProperty( new Address(), "city",
Address.Minimal.class );
+ assertCorrectNumberOfViolations( constraintViolations, 0 );
+
+ constraintViolations = validator.validateProperty( new Address(), "street",
Address.Minimal.class );
+ assertCorrectNumberOfViolations( constraintViolations, 1 );
+ assertCorrectConstraintTypes( constraintViolations, NotEmpty.class );
+ assertCorrectPropertyPaths( constraintViolations, "street" );
+ }
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "4.1.2", id = "a"),
+ @SpecAssertion(section = "4.1.2", id = "b")
+ })
+ public void testCorrectGroupsAreAppliedForValidateValue() {
+ Validator validator = TestUtil.getDefaultValidator();
+
+ Set<ConstraintViolation<Address>> constraintViolations =
validator.validateValue( Address.class, "city", null );
+ assertCorrectNumberOfViolations( constraintViolations, 1 );
+ assertCorrectConstraintTypes( constraintViolations, NotNull.class );
+ assertCorrectPropertyPaths( constraintViolations, "city" );
+
+ constraintViolations = validator.validateValue( Address.class, "city", null,
Default.class );
+ assertCorrectNumberOfViolations( constraintViolations, 1 );
+ assertCorrectConstraintTypes( constraintViolations, NotNull.class );
+ assertCorrectPropertyPaths( constraintViolations, "city" );
+
+ constraintViolations = validator.validateValue( Address.class, "city", null,
Address.Minimal.class );
+ assertCorrectNumberOfViolations( constraintViolations, 0 );
+
+ constraintViolations = validator.validateValue( Address.class, "street",
null, Address.Minimal.class );
+ assertCorrectNumberOfViolations( constraintViolations, 1 );
+ assertCorrectConstraintTypes( constraintViolations, NotEmpty.class );
+ assertCorrectPropertyPaths( constraintViolations, "street" );
+ }
+}
\ No newline at end of file
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateWithGroupsTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Address.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Address.java 2009-07-22
20:40:50 UTC (rev 17192)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/Address.java 2009-07-23
12:35:38 UTC (rev 17193)
@@ -79,4 +79,15 @@
public void setInhabitant(User inhabitant) {
this.inhabitant = inhabitant;
}
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append( "Address" );
+ sb.append( "{addressline1='" ).append( addressline1 ).append(
'\'' );
+ sb.append( ", zipCode='" ).append( zipCode ).append( '\'' );
+ sb.append( ", city='" ).append( city ).append( '\'' );
+ sb.append( '}' );
+ return sb.toString();
+ }
}
\ No newline at end of file
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/User.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/User.java 2009-07-22
20:40:50 UTC (rev 17192)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/User.java 2009-07-23
12:35:38 UTC (rev 17193)
@@ -79,4 +79,16 @@
public void setLastName(String lastName) {
this.lastName = lastName;
}
+
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append( "User" );
+ sb.append( "{addresses=" ).append( addresses );
+ sb.append( ", lastName='" ).append( lastName ).append( '\''
);
+ sb.append( ", firstName='" ).append( firstName ).append( '\''
);
+ sb.append( '}' );
+ return sb.toString();
+ }
}
\ No newline at end of file
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/util/TestUtil.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/util/TestUtil.java 2009-07-22
20:40:50 UTC (rev 17192)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/util/TestUtil.java 2009-07-23
12:35:38 UTC (rev 17193)
@@ -113,6 +113,12 @@
propertyPathsOfViolations.add( violation.getPropertyPath() );
}
+ assertEquals(
+ propertyPaths.length,
+ propertyPathsOfViolations.size(),
+ "Wrong number of property paths. Expected: " + propertyPaths.length +
" Actual: " + propertyPathsOfViolations.size()
+ );
+
for ( String propertyPath : propertyPaths ) {
Path expectedPath = PathImpl.createPathFromString( propertyPath );
boolean containsPath = false;
@@ -129,8 +135,9 @@
}
public static <T> void assertConstraintViolation(ConstraintViolation<T>
violation, Class<?> rootBean, Object invalidValue, String propertyPath) {
- if ( !assertEqualPaths( violation.getPropertyPath(), PathImpl.createPathFromString(
propertyPath ) ) ) {
- fail( "Property paths differ." );
+ Path expectedPath = PathImpl.createPathFromString( propertyPath );
+ if ( !assertEqualPaths( violation.getPropertyPath(), expectedPath ) ) {
+ fail( "Property paths differ. Actual: " + violation.getPropertyPath() +
" Expected: " + expectedPath );
}
assertEquals(
@@ -224,8 +231,6 @@
private static final String PROPERTY_PATH_SEPERATOR = ".";
- private static final Node ROOT_NODE = new NodeImpl( ( String ) null );
-
private final List<Node> nodeList;
public static PathImpl createPathFromString(String propertyPath) {
@@ -234,19 +239,21 @@
}
if ( propertyPath.length() == 0 ) {
- return createNewRootPath();
+ return createNewPath( null );
}
return parseProperty( propertyPath );
}
- public static PathImpl createNewRootPath() {
- return new PathImpl();
+ public static PathImpl createNewPath(String name) {
+ PathImpl path = new PathImpl();
+ NodeImpl node = new NodeImpl( name );
+ path.addNode( node );
+ return path;
}
private PathImpl() {
nodeList = new ArrayList<Node>();
- nodeList.add( ROOT_NODE );
}
public void addNode(Node node) {
@@ -263,9 +270,6 @@
Iterator<Path.Node> iter = iterator();
while ( iter.hasNext() ) {
Node node = iter.next();
- if ( ROOT_NODE.equals( node ) ) {
- continue;
- }
builder.append( node.toString() );
if ( iter.hasNext() ) {
builder.append( PROPERTY_PATH_SEPERATOR );
Modified: beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-07-22
20:40:50 UTC (rev 17192)
+++ beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-07-23
12:35:38 UTC (rev 17193)
@@ -594,27 +594,37 @@
<text>getConstraintDescriptor provides access to the failing constraint
metadata</text>
</assertion>
<assertion id="f">
- <text>if the association is not hosted by the root object (ie hosted on
an associated
- object) a dot (.) is concatenated to the propertyPath</text>
- </assertion>
+ <text>getPropertyPath returns the Path object representing the
navigation path from the root object to the failing
+ object</text>
+ </assertion>
<assertion id="g">
- <text>the name of the association property (field name or Java Bean
property name) is
- concatenated to the propertyPath.</text>
- </assertion>
+ <text>If the failing object is the root object, the property path
consists of a single Node with name set to null.</text>
+ </assertion>
<assertion id="h">
- <text>if the association is a List or an array, the index value
surrounded by square
- brackets ([index]) is concatenated to the propertyPath (for example
- order.orderLines[1])</text>
- </assertion>
+ <text>If failing object is traversed, a Node object whose name equals
the name of the association property (field name or Java Bean property
+ name) is added to Path.
+ </text>
+ </assertion>
<assertion id="i">
- <text>if the association is a Map, for a given map entry, the result of
key.toString()
- surrounded by square brack- ets and quotes (["key.toString()"])
is concatenated to
- the propertyPath (for example
item.evaluation["quality"])</text>
- </assertion>
+ <text>If the traversed association is a List or an array, the added
Node object contains the index value in getIndex.
+ </text>
+ </assertion>
<assertion id="j">
- <text>If the propertyPath is empty, "" is returned (typically
a class-level constraint
- on the root object)</text>
+ <text>If the association is a Map, the added Node object (representing
a given map entry) contains the key value in getKey
+ </text>
+ </assertion>
+ <assertion id="k">
+ <text>For all Iterable or Map, the added Node object added is marked as
inIterable (isInIterable)
+ </text>
</assertion>
+ <assertion id="l">
+ <text>For a property level constraint (field and getter) a Node object
is added to Path whose name equals the name of the property.
+ </text>
+ </assertion>
+ <assertion id="m">
+ <text>For a class level constraint a Node object is added to Path whose
name is null
+ </text>
+ </assertion>
</section>
<section id="4.3.1" title="Default message interpolation">
<assertion id="a">
@@ -892,6 +902,13 @@
it's superclasses and interfaces according to the constraint
propagation rules) is
invalid, a ValidationException is raised</text>
</assertion>
+ <assertion id="b">
+ <text>Validator.getConstraintsForClass returns a BeanDescriptor object
describing the bean level constraints
+ and providing access to the property level constraints metadata.
</text>
+ </assertion>
+ <assertion id="c">
+ <text>Validator.getConstraintsForClass throws an
IllegalArgumentException if the clazz parameter is null</text>
+ </assertion>
</section>
<section id="5.3" title="BeanDescriptor">
<assertion id="a">