You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bval.apache.org by mb...@apache.org on 2010/10/05 19:53:39 UTC
svn commit: r1004735 - in /incubator/bval/sandbox/lang3-work/bval-jsr303/src:
main/java/org/apache/bval/jsr303/util/ValidationContextTraversal.java
test/java/org/apache/bval/jsr303/Jsr303Test.java
Author: mbenson
Date: Tue Oct 5 17:53:39 2010
New Revision: 1004735
URL: http://svn.apache.org/viewvc?rev=1004735&view=rev
Log:
capture non-cascaded nested path components
Modified:
incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/ValidationContextTraversal.java
incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/Jsr303Test.java
Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/ValidationContextTraversal.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/ValidationContextTraversal.java?rev=1004735&r1=1004734&r2=1004735&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/ValidationContextTraversal.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/ValidationContextTraversal.java Tue Oct 5 17:53:39 2010
@@ -130,6 +130,10 @@ public class ValidationContextTraversal
protected void moveDownIfNecessary() {
MetaProperty mp = validationContext.getMetaProperty();
if (mp != null) {
+ if (mp.getMetaBean() == null) {
+ throw new UnknownPropertyException(String.format("Property %s.%s is not cascaded", mp
+ .getParentMetaBean().getId(), mp.getName()));
+ }
validationContext.moveDown(mp, new NullSafePropertyAccess(validationContext.getMetaBean().getBeanClass(),
mp.getName()));
}
Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/Jsr303Test.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/Jsr303Test.java?rev=1004735&r1=1004734&r2=1004735&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/Jsr303Test.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/Jsr303Test.java Tue Oct 5 17:53:39 2010
@@ -42,6 +42,7 @@ import org.apache.bval.constraints.SizeV
import org.apache.bval.jsr303.example.Address;
import org.apache.bval.jsr303.example.Book;
import org.apache.bval.jsr303.example.Engine;
+import org.apache.bval.jsr303.example.IllustratedBook;
import org.apache.bval.jsr303.example.MaxTestEntity;
import org.apache.bval.jsr303.example.NoValidatorTestEntity;
import org.apache.bval.jsr303.example.Second;
@@ -132,6 +133,16 @@ public class Jsr303Test extends TestCase
}
}
+ public void testValidateNonCascadedRealNestedProperty() {
+ try {
+ validator.validateValue(IllustratedBook.class, "illustrator.firstName", "Edgar");
+ fail("unknownProperty not detected");
+ } catch (IllegalArgumentException ex) {
+ // OK
+ assertEquals("Property org.apache.bval.jsr303.example.IllustratedBook.illustrator is not cascaded", ex.getMessage());
+ }
+ }
+
public void testMetadataAPI_Book() {
Assert.assertNotNull(validator.getConstraintsForClass(Book.class));
// not necessary for implementation correctness, but we'll test