incubator-bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r1079503 - /incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/ValidationTest.java
Date Tue, 08 Mar 2011 19:43:58 GMT
Author: mbenson
Date: Tue Mar  8 19:43:57 2011
New Revision: 1079503

URL: http://svn.apache.org/viewvc?rev=1079503&view=rev
Log:
testcase to exhibit a bug whereby the code supporting CascadingPropertyValidator causes, when
validating multiple groups, the validated property's siblings to be erroneously validated
as well

Modified:
    incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/ValidationTest.java

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/ValidationTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/ValidationTest.java?rev=1079503&r1=1079502&r2=1079503&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/ValidationTest.java
(original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/ValidationTest.java
Tue Mar  8 19:43:57 2011
@@ -441,6 +441,35 @@ public class ValidationTest extends Test
         Assert.assertEquals(1, iv.size());
     }
 
+    public interface Foo {
+    }
+
+    public static class FooAddress extends Address {
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        @NotNull(groups = Foo.class)
+        public String getCity() {
+            return super.getCity();
+        }
+    }
+
+    public void testValidateCascadingPropertyWithMultipleGroupsIgnoresSiblingProperties()
{
+        final String propPath = "addresses[0].country";
+        
+        CascadingPropertyValidator v = validator.unwrap(CascadingPropertyValidator.class);
+        Author author = new Author();
+        author.setAddresses(new ArrayList<Address>());
+        Address adr = new FooAddress();
+        author.getAddresses().add(adr);
+        Country country = new Country();
+        adr.setCountry(country);
+        
+        Set<ConstraintViolation<Author>> iv = v.validateProperty(author, propPath,
true, Default.class, Foo.class);
+        Assert.assertEquals(1, iv.size());
+    }
+
     public void testMetadataAPI() {
         BeanDescriptor bookBeanDescriptor = validator.getConstraintsForClass(Book.class);
 



Mime
View raw message