incubator-bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mat...@apache.org
Subject svn commit: r924153 [8/13] - in /incubator/bval/trunk: ./ agimatec-jsr303/ agimatec-jsr303/src/ agimatec-jsr303/src/main/ agimatec-jsr303/src/main/java/ agimatec-jsr303/src/main/java/com/ agimatec-jsr303/src/main/java/com/agimatec/ agimatec-jsr303/src/...
Date Wed, 17 Mar 2010 04:39:14 GMT
Added: incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/ComposedConstraintsTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/ComposedConstraintsTest.java?rev=924153&view=auto
==============================================================================
--- incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/ComposedConstraintsTest.java (added)
+++ incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/ComposedConstraintsTest.java Wed Mar 17 04:39:07 2010
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 com.agimatec.validation.jsr303;
+
+import com.agimatec.validation.jsr303.example.AgimatecAddress;
+import com.agimatec.validation.jsr303.example.FrenchAddress;
+import com.agimatec.validation.jsr303.util.TestUtils;
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import javax.validation.ConstraintViolation;
+import javax.validation.Validation;
+import javax.validation.Validator;
+import javax.validation.ValidatorFactory;
+import javax.validation.constraints.Size;
+import javax.validation.metadata.ConstraintDescriptor;
+import javax.validation.metadata.ElementDescriptor;
+import java.util.Set;
+
+/**
+ * Description: <br/>
+ * User: roman.stumm <br/>
+ * Date: 31.10.2008 <br/>
+ * Time: 16:45:11 <br/>
+ * Copyright: Agimatec GmbH
+ */
+public class ComposedConstraintsTest extends TestCase {
+    static ValidatorFactory factory;
+
+    static {
+        factory = Validation.buildDefaultValidatorFactory();
+    }
+
+    public void testMetaDataAPI_ComposedConstraints() {
+        Validator addressValidator = factory.getValidator();
+        ElementDescriptor ed =
+              addressValidator.getConstraintsForClass(FrenchAddress.class)
+                    .getConstraintsForProperty("zipCode");
+        Assert.assertEquals(1, ed.getConstraintDescriptors().size());
+        for (ConstraintDescriptor cd : ed.getConstraintDescriptors()) {
+            Assert.assertTrue(cd.isReportAsSingleViolation());
+            Assert.assertEquals(3, cd.getComposingConstraints().size());
+            Assert.assertTrue("no composing constraints found!!",
+                  !cd.getComposingConstraints().isEmpty());
+            processConstraintDescriptor(cd); //check all constraints on zip code
+        }
+    }
+
+    public void processConstraintDescriptor(ConstraintDescriptor cd) {
+        //Size.class is understood by the tool
+        if (cd.getAnnotation().annotationType().equals(Size.class)) {
+            Size m = (Size) cd.getAnnotation();
+//            System.out.println("size.max = " + m.max());  //read and use the metadata
+        }
+        for (Object composingCd : cd.getComposingConstraints()) {
+            processConstraintDescriptor((ConstraintDescriptor) composingCd);
+            //check composing constraints recursively
+        }
+    }
+
+    public void testValidateComposed() {
+        FrenchAddress adr = new FrenchAddress();
+        Validator val = factory.getValidator();
+        Set<ConstraintViolation<FrenchAddress>> findings = val.validate(adr);
+        Assert.assertEquals(1, findings.size()); // with @ReportAsSingleConstraintViolation
+
+        ConstraintViolation<FrenchAddress> finding = findings.iterator().next();
+        Assert.assertEquals("Wrong zipcode", finding.getMessage());
+
+        adr.setZipCode("12345");
+        findings = val.validate(adr);
+        Assert.assertEquals(0, findings.size());
+
+        adr.setZipCode("1234567234567");
+        findings = val.validate(adr);
+        Assert.assertTrue(findings.size() > 0); // too long
+    }
+
+    public void testOverridesAttributeConstraintIndex() {
+        AgimatecAddress adr = new AgimatecAddress("invalid-string");
+        Validator val = factory.getValidator();
+        Set<ConstraintViolation<AgimatecAddress>> findings = val.validate(adr);
+        assertEquals(2, findings.size()); // without @ReportAsSingleConstraintViolation
+        assertNotNull(TestUtils.getViolationWithMessage(findings, "Not Agimatec"));
+        assertNotNull(TestUtils.getViolationWithMessage(findings, "Not an email"));
+
+        adr =  new AgimatecAddress("ROMAN@GMX.DE");
+        findings = val.validate(adr);
+        assertEquals(1, findings.size());
+        assertNotNull(TestUtils.getViolationWithMessage(findings, "Not Agimatec"));
+
+        adr =  new AgimatecAddress("ROMAN@AGIMATEC.DE");
+        findings = val.validate(adr);
+        Assert.assertTrue(findings.isEmpty());
+    }
+
+}

Added: incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/DefaultMessageInterpolatorTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/DefaultMessageInterpolatorTest.java?rev=924153&view=auto
==============================================================================
--- incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/DefaultMessageInterpolatorTest.java (added)
+++ incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/DefaultMessageInterpolatorTest.java Wed Mar 17 04:39:07 2010
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you 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 com.agimatec.validation.jsr303;
+
+import com.agimatec.validation.jsr303.example.Author;
+import com.agimatec.validation.jsr303.example.PreferredGuest;
+import junit.framework.Assert;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import javax.validation.MessageInterpolator;
+import javax.validation.Validator;
+import javax.validation.metadata.ConstraintDescriptor;
+
+/**
+ * MessageResolverImpl Tester.
+ *
+ * @author ${USER}
+ * @version 1.0
+ * @since <pre>04/02/2008</pre>
+ *        Copyright: Agimatec GmbH 2008
+ */
+public class DefaultMessageInterpolatorTest extends TestCase {
+    DefaultMessageInterpolator interpolator = new DefaultMessageInterpolator();
+
+    public DefaultMessageInterpolatorTest(String name) {
+        super(name);
+    }
+
+    public static Test suite() {
+        return new TestSuite(DefaultMessageInterpolatorTest.class);
+    }
+
+    public void testCreateResolver() {
+
+        final Validator gvalidator = getValidator();
+
+        assertTrue(!gvalidator.getConstraintsForClass(PreferredGuest.class)
+              .getConstraintsForProperty("guestCreditCardNumber")
+              .getConstraintDescriptors().isEmpty());
+
+        MessageInterpolator.Context ctx = new MessageInterpolator.Context() {
+
+            public ConstraintDescriptor<?> getConstraintDescriptor() {
+                return (ConstraintDescriptor<?>) gvalidator
+                      .getConstraintsForClass(PreferredGuest.class).
+                      getConstraintsForProperty("guestCreditCardNumber")
+                      .getConstraintDescriptors().toArray()[0];
+            }
+
+            public Object getValidatedValue() {
+                return "12345678";
+            }
+        };
+        String msg = interpolator.interpolate("{validator.creditcard}", ctx);
+        Assert.assertEquals("credit card is not valid", msg);
+
+        ctx = new MessageInterpolator.Context() {
+            public ConstraintDescriptor<?> getConstraintDescriptor() {
+                return (ConstraintDescriptor) gvalidator
+                      .getConstraintsForClass(Author.class).
+                      getConstraintsForProperty("lastName")
+                      .getConstraintDescriptors().toArray()[0];
+            }
+
+            public Object getValidatedValue() {
+                return "";
+            }
+        };
+
+
+        msg = interpolator.interpolate("{com.agimatec.validation.constraints.NotEmpty.message}", ctx);
+        Assert.assertEquals("may not be empty", msg);
+    }
+
+
+    private Validator getValidator() {
+        return AgimatecValidatorFactory.getDefault().getValidator();
+    }
+}

Added: incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/FooTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/FooTest.java?rev=924153&view=auto
==============================================================================
--- incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/FooTest.java (added)
+++ incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/FooTest.java Wed Mar 17 04:39:07 2010
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 com.agimatec.validation.jsr303;
+
+import junit.framework.TestCase;
+
+import javax.validation.ConstraintViolation;
+import javax.validation.Valid;
+import javax.validation.Validator;
+import javax.validation.constraints.NotNull;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Set;
+
+/**
+ * Description: <br/>
+ * User: roman.stumm <br/>
+ * Date: 08.09.2008 <br/>
+ * Time: 13:44:58 <br/>
+ * Copyright: Agimatec GmbH
+ */
+public class FooTest extends TestCase {
+
+    @Valid
+    private Collection<Foo> foos = new ArrayList<Foo>();
+
+    public FooTest() {
+        foos.add(new Foo("foo1"));
+        foos.add(null);
+        foos.add(new Foo("foo3"));
+    }
+
+
+    public class Foo {
+        @NotNull
+        public String bar;
+
+        public Foo(String bar) {
+            this.bar = bar;
+        }
+
+    }
+
+    public void testValidation() {
+        FooTest t = new FooTest();
+
+        Validator v = AgimatecValidatorFactory.getDefault().getValidator();
+        Set<ConstraintViolation<FooTest>> errors = v.validate(t);
+        System.out.println("got errors:");
+        for (ConstraintViolation error : errors) {
+            System.out.println(error.getPropertyPath());
+        }
+    }
+}
\ No newline at end of file

Added: incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/Jsr303Test.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/Jsr303Test.java?rev=924153&view=auto
==============================================================================
--- incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/Jsr303Test.java (added)
+++ incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/Jsr303Test.java Wed Mar 17 04:39:07 2010
@@ -0,0 +1,221 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 com.agimatec.validation.jsr303;
+
+import com.agimatec.validation.constraints.SizeValidatorForString;
+import com.agimatec.validation.jsr303.example.*;
+import com.agimatec.validation.jsr303.util.TestUtils;
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import javax.validation.ConstraintViolation;
+import javax.validation.UnexpectedTypeException;
+import javax.validation.ValidationException;
+import javax.validation.Validator;
+import javax.validation.metadata.BeanDescriptor;
+import javax.validation.metadata.ConstraintDescriptor;
+import javax.validation.metadata.ElementDescriptor;
+import javax.validation.metadata.PropertyDescriptor;
+import java.math.BigDecimal;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Description: <br/>
+ * User: roman.stumm <br/>
+ * Date: 01.04.2008 <br/>
+ * Time: 15:12:29 <br/>
+ * Copyright: Agimatec GmbH 2008
+ */
+public class Jsr303Test extends TestCase {
+/*    static {
+        AgimatecValidatorFactory.getDefault().getMetaBeanManager()
+                .addResourceLoader("com/agimatec/validation/example/test-beanInfos.xml");
+    }*/
+
+    /*  public void testUseAgimatecXmlMetaData() {
+        Validator validator = getValidator();
+
+        BusinessObject object = new BusinessObject();
+        object.setTitle("1234567834567 too long title ");
+        Set<ConstraintViolation<BusinessObject>> violations = validator.validate(object);
+        Assert.assertNotNull(violations);
+        Assert.assertTrue(!violations.isEmpty());
+
+        Assert.assertTrue(!validator.validateProperty(object, "title").isEmpty());
+    }*/
+
+    public void testPropertyDescriptorHasConstraints() {
+        BeanDescriptor cons = getValidator().getConstraintsForClass(Book.class);
+        assertTrue(cons.getConstraintsForProperty("author").hasConstraints());
+        assertTrue(cons.getConstraintsForProperty("title").hasConstraints());
+        assertTrue(cons.getConstraintsForProperty("uselessField").hasConstraints());
+        // cons.getConstraintsForProperty("unconstraintField") == null without Introspector
+        // cons.getConstraintsForProperty("unconstraintField") != null with Introspector
+        assertTrue(cons.getConstraintsForProperty("unconstraintField") == null ||
+              !cons.getConstraintsForProperty("unconstraintField").hasConstraints());
+        assertNull(cons.getConstraintsForProperty("unknownField"));
+    }
+
+    public void testValidateValue() {
+        Validator validator = getValidator();
+        assertTrue(
+              validator.validateValue(Book.class, "subtitle", "123456789098765432").isEmpty());
+        assertFalse(validator.validateValue(Book.class, "subtitle",
+              "123456789098765432123412345678909876543212341234564567890987654321234",
+              Second.class).isEmpty());
+        // tests for issue 22: validation of a field without any constraints 
+        assertEquals(0, validator.validateValue(Book.class, "unconstraintField", 4).size());
+        // tests for issue 22: validation of unknown field cause ValidationException
+        try {
+            validator.validateValue(Book.class, "unknownProperty", 4);
+            fail("unknownProperty not detected");
+        } catch (ValidationException ex) {
+            // OK
+            assertEquals(
+                  "unknown property 'unknownProperty' in com.agimatec.validation.jsr303.example.Book",
+                  ex.getMessage());
+        }
+    }
+
+    public void testMetadataAPI_Book() {
+        Validator validator = getValidator();
+        Assert.assertNotNull(validator.getConstraintsForClass(Book.class));
+        Assert.assertTrue(validator.getConstraintsForClass(Book.class) ==
+              validator.getConstraintsForClass(Book.class));
+        BeanDescriptor bc = validator.getConstraintsForClass(Book.class);
+//        assertEquals(ElementType.TYPE, bc.getElementType());
+        Assert.assertEquals(Book.class, bc.getElementClass());
+//        assertEquals(false, bc.isCascaded());
+//        assertEquals("", bc.getPropertyPath());
+        Assert.assertTrue(bc.getConstraintDescriptors() != null);
+    }
+
+    public void testMetadataAPI_Engine() {
+        Validator validator = getValidator();
+        ElementDescriptor desc = validator.getConstraintsForClass(Engine.class)
+              .getConstraintsForProperty("serialNumber");
+        assertNotNull(desc);
+//        assertEquals(ElementType.FIELD, desc.getElementType());
+        Assert.assertEquals(String.class, desc.getElementClass());
+    }
+
+    public void testMetadataAPI_Address() {
+        Validator validator = getValidator();
+        Assert.assertFalse(validator.getConstraintsForClass(Address.class)
+              .getConstraintDescriptors().isEmpty());
+
+        Set<PropertyDescriptor> props =
+              validator.getConstraintsForClass(Address.class).getConstrainedProperties();
+        Set<String> propNames = new HashSet(props.size());
+        for (PropertyDescriptor each : props) {
+            propNames.add(each.getPropertyName());
+        }
+        Assert.assertTrue(propNames.contains("addressline1")); // annotated at field level
+        Assert.assertTrue(propNames.contains("addressline2"));
+        Assert.assertTrue(propNames.contains("zipCode"));
+        Assert.assertTrue(propNames.contains("country"));
+        Assert.assertTrue(propNames.contains("city"));       // annotated at method level
+        Assert.assertEquals(5, props.size());
+
+        ElementDescriptor desc = validator.getConstraintsForClass(Address.class)
+              .getConstraintsForProperty("addressline1");
+        Assert.assertNotNull(desc);
+        boolean found = false;
+        for (ConstraintDescriptor each : desc.getConstraintDescriptors()) {
+            if (each.getConstraintValidatorClasses().get(0)
+                  .equals(SizeValidatorForString.class)) {
+                Assert.assertTrue(each.getAttributes().containsKey("max"));
+                assertEquals(30, each.getAttributes().get("max"));
+                found = true;
+            }
+        }
+        Assert.assertTrue(found);
+
+    }
+
+    public void testValidateMultiValuedConstraints() {
+        Validator validator = getValidator();
+        Engine engine = new Engine();
+        engine.serialNumber = "abcd-defg-0123";
+        Set<ConstraintViolation<Engine>> violations;
+        violations = validator.validate(engine);
+        assertEquals(0, violations.size());
+
+        engine.serialNumber = "!)/(/()";
+        violations = validator.validate(engine);
+        assertEquals(2, violations.size());
+        for (String msg : new String[]{"must contain alphabetical characters only",
+              "must match ....-....-...."}) {
+            assertNotNull(TestUtils.getViolationWithMessage(violations, msg));
+        }
+    }
+
+    public void testConstraintValidatorResolutionAlgorithm() {
+        MaxTestEntity entity = new MaxTestEntity();
+        entity.setText("101");
+        entity.setProperty("201");
+        entity.setLongValue(301);
+        entity.setDecimalValue(new BigDecimal(401));
+        Validator validator = getValidator();
+        Set<ConstraintViolation<MaxTestEntity>> violations = validator.validate(entity);
+        assertEquals(4, violations.size());
+
+        NoValidatorTestEntity entity2 = new NoValidatorTestEntity();
+        try {
+            validator.validate(entity2);
+            fail("UnexpectedTypeException expected but not thrown");
+        } catch (UnexpectedTypeException ex) {
+            // we expected this
+            assertEquals("No validator could be found for type java.lang.Object. " +
+                  "See: @Max at private java.lang.Object " +
+                  "com.agimatec.validation.jsr303.example." + "NoValidatorTestEntity.anything",
+                  ex.getMessage());
+        }
+    }
+
+    public void testSizeValidation() {
+        SizeTestEntity en = new SizeTestEntity();
+        en.ba = new byte[3];
+        en.ca = new char[3];
+        en.boa = new boolean[3];
+        en.coll = Arrays.asList("1", "2", "3");
+        en.da = new double[3];
+        en.fa = new float[3];
+        en.it = new int[3];
+        en.la = new long[3];
+        en.map = new HashMap();
+        en.map.put("1", "1");
+        en.map.put("3", "3");
+        en.map.put("2", "2");
+        en.oa = new Integer[3];
+        en.oa2 = new Integer[3];
+        en.sa = new short[3];
+        en.text = "123";
+        Set<ConstraintViolation<SizeTestEntity>> vi = getValidator().validate(en);
+        assertEquals(13, vi.size());
+    }
+
+    private Validator getValidator() {
+//        return Validation.buildDefaultValidatorFactory().getValidator();
+        return AgimatecValidatorFactory.getDefault().getValidator();
+    }
+}

Added: incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/PayloadTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/PayloadTest.java?rev=924153&view=auto
==============================================================================
--- incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/PayloadTest.java (added)
+++ incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/PayloadTest.java Wed Mar 17 04:39:07 2010
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 com.agimatec.validation.jsr303;
+
+import com.agimatec.validation.jsr303.util.TestUtils;
+import junit.framework.TestCase;
+
+import javax.validation.ConstraintViolation;
+import javax.validation.Payload;
+import javax.validation.Validator;
+import javax.validation.constraints.NotNull;
+import java.util.Set;
+
+/**
+ * Description: test that payload information can be retrieved
+ * from error reports via the ConstraintDescriptor either accessed
+ * through the ConstraintViolation objects<br/>
+ * User: roman <br/>
+ * Date: 05.10.2009 <br/>
+ * Time: 09:59:52 <br/>
+ * Copyright: Agimatec GmbH
+ */
+public class PayloadTest extends TestCase {
+    private Validator validator;
+
+    protected void setUp() {
+        validator = AgimatecValidatorFactory.getDefault().getValidator();
+    }
+
+    static class Severity {
+        static class Info implements Payload {
+        }
+
+        static class Error implements Payload {
+        }
+    }
+
+    static class Address {
+        private String zipCode;
+        private String city;
+
+        Address(String zipCode, String city) {
+            this.zipCode = zipCode;
+            this.city = city;
+        }
+
+        @NotNull(message = "would be nice if we had one", payload = Severity.Info.class)
+        public String getZipCode() {
+            return zipCode;
+        }
+
+        @NotNull(message = "the city is mandatory", payload = Severity.Error.class)
+        public String getCity() {
+            return city;
+        }
+    }
+
+    public void testPayload() {
+        Set<ConstraintViolation<Address>> violations;
+        Address address = new Address(null, null);
+        violations = validator.validate(address);
+        assertEquals(2, violations.size());
+        ConstraintViolation vio;
+        vio = TestUtils.getViolation(violations, "zipCode");
+        assertNotNull(vio);
+        assertEquals(1, vio.getConstraintDescriptor().getPayload().size());
+        assertTrue(
+              vio.getConstraintDescriptor().getPayload().contains(Severity.Info.class));
+
+        vio = TestUtils.getViolation(violations, "city");
+        assertNotNull(vio);
+        assertEquals(1, vio.getConstraintDescriptor().getPayload().size());
+        assertTrue(
+              vio.getConstraintDescriptor().getPayload().contains(Severity.Error.class));
+    }
+}

Added: incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/ValidationTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/ValidationTest.java?rev=924153&view=auto
==============================================================================
--- incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/ValidationTest.java (added)
+++ incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/ValidationTest.java Wed Mar 17 04:39:07 2010
@@ -0,0 +1,353 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 com.agimatec.validation.jsr303;
+
+import com.agimatec.validation.constraints.NotNullValidator;
+import com.agimatec.validation.jsr303.example.*;
+import com.agimatec.validation.jsr303.util.TestUtils;
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import javax.validation.ConstraintViolation;
+import javax.validation.Validator;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import javax.validation.groups.Default;
+import javax.validation.metadata.BeanDescriptor;
+import javax.validation.metadata.ConstraintDescriptor;
+import javax.validation.metadata.PropertyDescriptor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * Description: <br/>
+ * User: roman.stumm <br/>
+ * Date: 01.04.2008 <br/>
+ * Time: 11:48:37 <br/>
+ * Copyright: Agimatec GmbH 2008
+ */
+public class ValidationTest extends TestCase {
+    public void testAccessStrategies_field_method() {
+        AccessTestBusinessObject o1 = new AccessTestBusinessObject("1");
+        AccessTestBusinessObjectSub o2 = new AccessTestBusinessObjectSub("3");
+        Validator validator = getValidator();
+        Set<ConstraintViolation<AccessTestBusinessObject>> errors =
+              validator.validate(o1);
+        assertTrue(errors.isEmpty());
+        Set<ConstraintViolation<AccessTestBusinessObjectSub>> errors2 =
+              validator.validate(o2);
+        assertTrue(errors2.isEmpty());
+
+        o2 = new AccessTestBusinessObjectSub("1");
+        errors2 = validator.validate(o2);
+        assertEquals(1, errors2.size());
+
+        // assert, that getvar2() and getVar2() are both validated with their getter method
+        o2 = new AccessTestBusinessObjectSub("3");
+        o2.setVar2("1");
+        o2.setvar2("2");
+        errors2 = validator.validate(o2);
+        assertEquals(2, errors2.size());
+
+        o2.setvar2("5");
+        o2.setVar2("6");
+        errors2 = validator.validate(o2);
+        assertEquals(0, errors2.size());
+
+        o2.setvar2("5");
+        o2.setVar2("-1");
+        errors2 = validator.validate(o2);
+        assertEquals(1, errors2.size());
+    }
+
+    public void testAccessStrategies_on_children() {
+        AccessTestBusinessObject o1 = new AccessTestBusinessObject("1");
+        AccessTestBusinessObject o2 = new AccessTestBusinessObject("2");
+        o1.next(o2);
+        Validator validator = getValidator();
+        Set<ConstraintViolation<AccessTestBusinessObject>> errors =
+              validator.validate(o1);
+        // assert, that field access 'next' is used and not getNext() is called!!!
+        assertEquals(1, errors.size());
+        o2 = new AccessTestBusinessObject("1");
+        o1.next(o2);
+        errors = validator.validate(o1);
+        assertEquals(0, errors.size());
+
+        // assert that toBeIgnored not validated, because not annotated with @Valid
+        o1.setToBeIgnored(new AccessTestBusinessObject("99"));
+        errors = validator.validate(o1);
+        assertEquals(0, errors.size());
+
+        o1.setNext(new AccessTestBusinessObject("99"));
+        errors = validator.validate(o1);
+        assertEquals(1, errors.size());
+    }
+
+    public void testBook() {
+        Validator validator = getValidator();
+        Author author = new Author();
+        author.setLastName("Baudelaire");
+        author.setFirstName("");
+        Book book = new Book();
+        book.setAuthor(author);
+        book.setSubtitle("12345678900125678901234578901234567890");
+
+        // NotEmpty failure on the title field
+        Set<ConstraintViolation<Book>> errors = validator.validate(book, Book.All.class);
+        Assert.assertTrue(!errors.isEmpty());
+
+        book.setTitle("Les fleurs du mal");
+        author.setCompany("Some random publisher with a very very very long name");
+
+        // author.firstName fails to pass the NotEmpty constraint
+        //  author.company fails to pass the Size constraint
+    }
+
+    /**
+     * test:
+     * - dynamic resolution of associated object types.
+     * - inheritance of validation constraints
+     * - complex valiation, different groups, nested object net
+     */
+    public void testValidAnnotation() {
+        Author a = new Author();
+        a.setAddresses(new ArrayList());
+        BusinessAddress adr = new BusinessAddress();
+        adr.setCountry(new Country());
+        adr.setAddressline1("line1");
+        adr.setAddressline2("line2");
+
+        adr.setZipCode("1234567890123456789");
+        a.getAddresses().add(adr);
+
+        a.setFirstName("Karl");
+        a.setLastName("May");
+
+        Validator v = getValidator();
+        Set found = v.validate(a, Default.class, First.class, Last.class);
+        Assert.assertTrue(!found.isEmpty());
+        Assert.assertEquals(4, found.size());
+
+        adr.setCity("Berlin");
+        adr.setZipCode("12345");
+        adr.setCompany("agimatec GmbH");
+        found = v.validate(a, Default.class, First.class, Last.class);
+        Assert.assertEquals(1, found.size());
+        ConstraintViolation ic = (ConstraintViolation) found.iterator().next();
+        Assert.assertEquals("addresses[0].country.name", ic.getPropertyPath().toString());
+    }
+
+    public void testPropertyPathWithIndex() {
+        Author a = new Author();
+        a.setAddresses(new ArrayList());
+        Address adr = new Address();
+        adr.setAddressline1("adr1");
+        adr.setCity("Santiago");
+        a.getAddresses().add(adr);
+        adr = new Address();
+        adr.setAddressline1("adr2");
+        adr.setCity("Havanna");
+        a.getAddresses().add(adr);
+        adr = new Address();
+        adr.setAddressline1("adr3");
+        adr.setCity("Trinidad");
+        a.getAddresses().add(adr);
+
+        Set<ConstraintViolation<Author>> constraints = getValidator().validate(a);
+        Assert.assertTrue(!constraints.isEmpty());
+
+        assertPropertyPath("addresses[0].country", constraints);
+        assertPropertyPath("addresses[1].country", constraints);
+        assertPropertyPath("addresses[2].country", constraints);
+    }
+
+    private <T> void assertPropertyPath(String propertyPath,
+                                        Set<ConstraintViolation<T>> constraints) {
+        for (ConstraintViolation each : constraints) {
+            if (each.getPropertyPath().toString().equals(propertyPath)) return;
+        }
+        Assert.fail(propertyPath + " not found in " + constraints);
+    }
+
+    public void testPropertyPathRecursive() {
+        RecursiveFoo foo1 = new RecursiveFoo();
+        RecursiveFoo foo11 = new RecursiveFoo();
+        foo1.getFoos().add(foo11);
+        RecursiveFoo foo12 = new RecursiveFoo();
+        foo1.getFoos().add(foo12);
+        RecursiveFoo foo2 = new RecursiveFoo();
+        foo11.getFoos().add(foo2);
+
+        Set<ConstraintViolation<RecursiveFoo>> constraints =
+              getValidator().validate(foo1);
+        assertPropertyPath("foos[0].foos[0].foos", constraints);
+        assertPropertyPath("foos[1].foos", constraints);
+    }
+
+    public void testNullElementInCollection() {
+        try {
+            getValidator().validate(null);
+            Assert.fail();
+        } catch (IllegalArgumentException ex) {
+        }
+        RecursiveFoo foo = new RecursiveFoo();
+        foo.getFoos().add(new RecursiveFoo());
+        foo.getFoos().add(null);
+        Assert.assertTrue(!getValidator().validate(foo).isEmpty());
+        // check that no nullpointer exception gets thrown
+    }
+
+    private Validator getValidator() {
+        return AgimatecValidatorFactory.getDefault().getValidator();
+    }
+
+    public void testGroups() {
+        Validator validator = getValidator();
+        Author author = new Author();
+        author.setCompany("ACME");
+        Book book = new Book();
+        book.setTitle("");
+        book.setAuthor(author);
+        boolean foundTitleConstraint = false;
+        Set<ConstraintViolation<Book>> constraintViolations =
+              validator.validate(book, Book.All.class);
+        assertEquals(1, constraintViolations.size());
+        //assuming an english locale, the interpolated message is returned
+        for (ConstraintViolation constraintViolation : constraintViolations) {
+            if (constraintViolation.getRootBean().getClass() == Book.class) {
+                Assert.assertTrue(
+                      "may not be empty".equals(constraintViolation.getMessage()));
+                Assert.assertTrue(book == constraintViolation.getRootBean());
+
+                //the offending property
+                if (constraintViolation.getPropertyPath().toString().equals("title")) {
+                    foundTitleConstraint = true;
+                    //the offending value
+                    Assert.assertEquals(book.getTitle(),
+                          constraintViolation.getInvalidValue());
+                }
+            }
+        }
+        Assert.assertTrue(foundTitleConstraint);
+    }
+
+    /**
+     * Example 2.14. Using the fluent API to build custom constraint violations.
+     * test that:
+     * the {@link com.agimatec.validation.constraints.ZipCodeCityCoherenceValidator} adds
+     * custom messages to the context and suppresses the default message
+     */
+    public void testConstraintValidatorContextFluentAPI() {
+        Address ad = new Address();
+        ad.setCity("error");
+        ad.setZipCode("error");
+        ad.setAddressline1("something");
+        ad.setCountry(new Country());
+        ad.getCountry().setName("something");
+        Validator v = getValidator();
+        Set<ConstraintViolation<Address>> violations = v.validate(ad);
+        Assert.assertEquals(2, violations.size());
+        for (ConstraintViolation each : violations) {
+            Assert.assertTrue(each.getMessage().endsWith(" not OK"));
+        }
+        assertNotNull(TestUtils.getViolation(violations, "city"));
+        assertNotNull(TestUtils.getViolation(violations, ""));
+    }
+
+    public void testValidateNestedPropertyPath() throws InvocationTargetException,
+          NoSuchMethodException, IllegalAccessException {
+        final String propPath = "addresses[0].country.ISO2Code";
+
+        Validator v = getValidator();
+        Author author = new Author();
+        author.setAddresses(new ArrayList());
+        Address adr = new Address();
+        author.getAddresses().add(adr);
+        Country country = new Country();
+        adr.setCountry(country);
+        country.setISO2Code("too_long");
+
+        Set<ConstraintViolation<Author>> iv = v.validateProperty(author, propPath);
+        Assert.assertEquals(1, iv.size());
+        country.setISO2Code("23");
+        iv = v.validateProperty(author, propPath);
+        Assert.assertEquals(0, iv.size());
+        iv = v.validateValue(Author.class, propPath, "345");
+        Assert.assertEquals(1, iv.size());
+        iv = v.validateValue(Author.class, propPath, "34");
+        Assert.assertEquals(0, iv.size());
+    }
+
+    public void testMetadataAPI() {
+        Validator bookValidator = getValidator();
+        BeanDescriptor bookBeanDescriptor =
+              bookValidator.getConstraintsForClass(Book.class);
+
+        // expect no constraints on Book's Class-Level
+        Assert.assertFalse(bookBeanDescriptor.hasConstraints());
+        // but there are constraints on Book's Property-Level
+        Assert.assertTrue(bookBeanDescriptor.isBeanConstrained());
+        Assert.assertTrue(
+              bookBeanDescriptor.getConstraintDescriptors().size() == 0); //no constraint
+        //more specifically "author" and "title"
+        Assert.assertEquals(4, bookBeanDescriptor.getConstrainedProperties().size());
+        //not a property
+        Assert.assertTrue(
+              bookBeanDescriptor.getConstraintsForProperty("doesNotExist") == null);
+        //property with no constraint
+        Assert.assertTrue(
+              bookBeanDescriptor.getConstraintsForProperty("description") == null);
+        PropertyDescriptor propertyDescriptor =
+              bookBeanDescriptor.getConstraintsForProperty("title");
+        Assert.assertEquals(2, propertyDescriptor.getConstraintDescriptors().size());
+        Assert.assertTrue("title".equals(propertyDescriptor.getPropertyName()));
+        //assuming the implementation returns the NotEmpty constraint first
+        Iterator<ConstraintDescriptor<?>> iter =
+              propertyDescriptor.getConstraintDescriptors().iterator();
+        ConstraintDescriptor constraintDescriptor = null;
+        while (iter.hasNext()) {
+            constraintDescriptor = iter.next();
+            if (constraintDescriptor.getAnnotation().annotationType()
+                  .equals(NotNull.class)) {
+                break;
+            }
+
+        }
+        Assert.assertTrue(constraintDescriptor != null);
+        Assert.assertTrue(constraintDescriptor.getGroups().size() == 1); //"first"
+        Assert.assertEquals(NotNullValidator.class,
+              constraintDescriptor.getConstraintValidatorClasses().get(0));
+        //assuming the implementation returns the Size constraint first
+        propertyDescriptor = bookBeanDescriptor.getConstraintsForProperty("subtitle");
+        Iterator<ConstraintDescriptor<?>> iterator =
+              propertyDescriptor.getConstraintDescriptors().iterator();
+        constraintDescriptor = iterator.next();
+        Assert.assertTrue(
+              constraintDescriptor.getAnnotation().annotationType().equals(Size.class));
+        Assert.assertTrue(
+              ((Integer) constraintDescriptor.getAttributes().get("max")) == 30);
+        Assert.assertTrue(constraintDescriptor.getGroups().size() == 1);
+        propertyDescriptor = bookBeanDescriptor.getConstraintsForProperty("author");
+        Assert.assertTrue(propertyDescriptor.getConstraintDescriptors().size() == 1);
+        Assert.assertTrue(propertyDescriptor.isCascaded());
+    }
+}

Added: incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/AccessTestBusinessObject.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/AccessTestBusinessObject.java?rev=924153&view=auto
==============================================================================
--- incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/AccessTestBusinessObject.java (added)
+++ incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/AccessTestBusinessObject.java Wed Mar 17 04:39:07 2010
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 com.agimatec.validation.jsr303.example;
+
+import com.agimatec.validation.constraints.HasValue;
+
+import javax.validation.Valid;
+
+/**
+ * Description: <br/>
+ * User: roman <br/>
+ * Date: 29.10.2009 <br/>
+ * Time: 14:26:54 <br/>
+ * Copyright: Agimatec GmbH
+ */
+public class AccessTestBusinessObject {
+    // test that field-access is used, not method-access 
+    @HasValue({"1", "3"})
+    protected String var1;
+
+    // test that field-access is used, not method-access
+    @Valid
+    private AccessTestBusinessObject next;
+
+    // not annotated with @Valid, not validated!!
+    private AccessTestBusinessObject toBeIgnored;
+    private AccessTestBusinessObject _next;
+
+    public AccessTestBusinessObject(String var1) {
+        this.var1 = var1;
+    }
+
+    @HasValue("3")
+    public String getVar1() {
+        return "3";
+    }
+
+    public void next(AccessTestBusinessObject next) {
+        this._next = next;
+    }
+
+
+    public void setNext(AccessTestBusinessObject next) {
+        this.next = next;
+    }
+
+    @Valid
+    public AccessTestBusinessObject getNext() {
+        return _next; // method returns '_next', not the field 'next'
+    }
+
+    public AccessTestBusinessObject getToBeIgnored() {
+        return toBeIgnored;
+    }
+
+    public void setToBeIgnored(AccessTestBusinessObject toBeIgnored) {
+        this.toBeIgnored = toBeIgnored;
+    }
+}

Added: incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/AccessTestBusinessObjectSub.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/AccessTestBusinessObjectSub.java?rev=924153&view=auto
==============================================================================
--- incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/AccessTestBusinessObjectSub.java (added)
+++ incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/AccessTestBusinessObjectSub.java Wed Mar 17 04:39:07 2010
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 com.agimatec.validation.jsr303.example;
+
+import com.agimatec.validation.constraints.HasValue;
+
+/**
+ * Description: <br/>
+ * User: roman <br/>
+ * Date: 29.10.2009 <br/>
+ * Time: 14:27:06 <br/>
+ * Copyright: Agimatec GmbH
+ */
+public class AccessTestBusinessObjectSub extends AccessTestBusinessObject {
+    private String var2, _var2;
+
+    public void setVar2(String var2) {
+        this.var2 = var2;
+    }
+
+    public void setvar2(String _var2) {
+        this._var2 = _var2;
+    }
+
+    public AccessTestBusinessObjectSub(String var1) {
+        super(var1);
+    }
+
+    // getVar1() is called on subclass, although annotated on superclass    
+    public String getVar1() {
+        return var1;
+    }
+
+    //// test that getvar2() is called, not getVar2()
+
+    @HasValue("5")
+    public String getvar2() {
+        return _var2;
+    }
+
+    @HasValue("6")
+    public String getVar2() {
+        return var2;
+    }
+}

Added: incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Address.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Address.java?rev=924153&view=auto
==============================================================================
--- incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Address.java (added)
+++ incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Address.java Wed Mar 17 04:39:07 2010
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 com.agimatec.validation.jsr303.example;
+
+import com.agimatec.validation.constraints.ZipCodeCityCoherence;
+
+import javax.validation.GroupSequence;
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import javax.validation.groups.Default;
+
+@ZipCodeCityCoherence
+public class Address implements ZipCodeCityCarrier {
+    @NotNull
+    @Size(max = 30)
+    private String addressline1;
+    @Size(max = 30)
+    private String addressline2;
+    @Size(max = 11)
+    private String zipCode;
+    @NotNull
+    @Valid
+    private Country country;
+    private String city;
+
+    public String getAddressline1() {
+        return addressline1;
+    }
+
+    public void setAddressline1(String addressline1) {
+        this.addressline1 = addressline1;
+    }
+
+    public String getAddressline2() {
+        return addressline2;
+    }
+
+    public void setAddressline2(String addressline2) {
+        this.addressline2 = addressline2;
+    }
+
+    public String getZipCode() {
+        return zipCode;
+    }
+
+    public void setZipCode(String zipCode) {
+        this.zipCode = zipCode;
+    }
+
+    @Size(max = 30)
+    @NotNull
+    public String getCity() {
+        return city;
+    }
+
+    public void setCity(String city) {
+        this.city = city;
+    }
+
+    public Country getCountry() {
+        return country;
+    }
+
+    public void setCountry(Country country) {
+        this.country = country;
+    }
+
+    /**
+     * Check conherence on the overall object
+     * Needs basic checking to be green first
+     */
+    public interface HighLevelCoherence {
+    }
+
+    /**
+     * Check both basic constraints and high level ones.
+     * High level constraints are not checked if basic constraints fail.
+     */
+    @GroupSequence(value = {Default.class, HighLevelCoherence.class})
+    public interface Complete {
+    }
+}
\ No newline at end of file

Added: incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/AgimatecAddress.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/AgimatecAddress.java?rev=924153&view=auto
==============================================================================
--- incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/AgimatecAddress.java (added)
+++ incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/AgimatecAddress.java Wed Mar 17 04:39:07 2010
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 com.agimatec.validation.jsr303.example;
+
+import com.agimatec.validation.constraints.AgimatecEmail;
+
+/**
+ * Description: <br/>
+ * User: roman <br/>
+ * Date: 28.10.2009 <br/>
+ * Time: 11:58:37 <br/>
+ * Copyright: Agimatec GmbH
+ */
+public class AgimatecAddress {
+    @AgimatecEmail
+    private String email;
+
+    public AgimatecAddress() {
+    }
+
+    public AgimatecAddress(String email) {
+        this.email = email;
+    }
+
+    // do not provided getters & setters to test that value access
+    // of combined constraints directly use the private field 'email'
+}

Added: incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Author.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Author.java?rev=924153&view=auto
==============================================================================
--- incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Author.java (added)
+++ incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Author.java Wed Mar 17 04:39:07 2010
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 com.agimatec.validation.jsr303.example;
+
+import com.agimatec.validation.constraints.NotEmpty;
+
+import javax.validation.GroupSequence;
+import javax.validation.Valid;
+import javax.validation.constraints.Size;
+import java.util.List;
+
+@GroupSequence({First.class, Author.class, Last.class})
+public class Author {
+    @NotEmpty(groups = Last.class)
+    private String firstName;
+    @NotEmpty(groups = First.class)
+    private String lastName;
+    @Size(max = 40, groups = First.class)
+    private String company;
+
+    @Valid
+    private List<Address> addresses;
+
+    public List<Address> getAddresses() {
+        return addresses;
+    }
+
+    public void setAddresses(List<Address> addresses) {
+        this.addresses = addresses;
+    }
+
+    public String getFirstName() {
+        return firstName;
+    }
+
+    public void setFirstName(String firstName) {
+        this.firstName = firstName;
+    }
+
+    public String getLastName() {
+        return lastName;
+    }
+
+    public void setLastName(String lastName) {
+        this.lastName = lastName;
+    }
+
+    public String getCompany() {
+        return company;
+    }
+
+    public void setCompany(String company) {
+        this.company = company;
+    }
+}
\ No newline at end of file

Added: incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Book.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Book.java?rev=924153&view=auto
==============================================================================
--- incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Book.java (added)
+++ incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Book.java Wed Mar 17 04:39:07 2010
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 com.agimatec.validation.jsr303.example;
+
+import com.agimatec.validation.constraints.NotEmpty;
+
+import javax.validation.GroupSequence;
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+@GroupSequence({First.class, Second.class, Book.class, Last.class})
+public class Book {
+    @NotNull(groups = First.class)
+    @NotEmpty(groups = First.class)
+    private String title;
+
+    @Size(max = 30, groups = Second.class)
+    private String subtitle;
+
+    @Valid
+    @NotNull(groups = First.class)
+    private Author author;
+
+    @NotNull
+    private int uselessField;
+
+    private int unconstraintField;
+
+    public int getUnconstraintField() {
+        return unconstraintField;
+    }
+
+    public void setUnconstraintField(int unconstraintField) {
+        this.unconstraintField = unconstraintField;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getSubtitle() {
+        return subtitle;
+    }
+
+    public void setSubtitle(String subtitle) {
+        this.subtitle = subtitle;
+    }
+
+    public Author getAuthor() {
+        return author;
+    }
+
+    public void setAuthor(Author author) {
+        this.author = author;
+    }
+
+    @GroupSequence(value = {First.class, Second.class, Last.class})
+    public interface All {
+    }
+}
\ No newline at end of file

Added: incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/BusinessAddress.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/BusinessAddress.java?rev=924153&view=auto
==============================================================================
--- incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/BusinessAddress.java (added)
+++ incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/BusinessAddress.java Wed Mar 17 04:39:07 2010
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 com.agimatec.validation.jsr303.example;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * Description: <br/>
+ * User: roman.stumm <br/>
+ * Date: 28.04.2008 <br/>
+ * Time: 10:47:15 <br/>
+ * Copyright: Agimatec GmbH
+ */
+public class BusinessAddress extends Address {
+    private String company;
+
+    @NotNull
+    public String getCompany() {
+        return company;
+    }
+
+    public void setCompany(String company) {
+        this.company = company;
+    }
+}

Added: incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Country.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Country.java?rev=924153&view=auto
==============================================================================
--- incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Country.java (added)
+++ incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Country.java Wed Mar 17 04:39:07 2010
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 com.agimatec.validation.jsr303.example;
+
+
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+public class Country {
+    @NotNull
+    private String name;
+    @Size(max = 2)
+    private String ISO2Code;
+    @Size(max = 3)
+    private String ISO3Code;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getISO2Code() {
+        return ISO2Code;
+    }
+
+    public void setISO2Code(String ISO2Code) {
+        this.ISO2Code = ISO2Code;
+    }
+
+    public String getISO3Code() {
+        return ISO3Code;
+    }
+
+    public void setISO3Code(String ISO3Code) {
+        this.ISO3Code = ISO3Code;
+    }
+}
\ No newline at end of file

Added: incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Customer.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Customer.java?rev=924153&view=auto
==============================================================================
--- incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Customer.java (added)
+++ incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Customer.java Wed Mar 17 04:39:07 2010
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 com.agimatec.validation.jsr303.example;
+
+import com.agimatec.validation.constraints.Email;
+import com.agimatec.validation.constraints.Password;
+
+import javax.validation.constraints.NotNull;
+
+public class Customer implements Person {
+    private String firstName;
+    private String middleName;
+    private String lastName;
+    @NotNull
+    private String customerId;
+    @Password(robustness = 5)
+    private String password;
+
+    @Email
+    private String emailAddress;
+
+    public String getEmailAddress() {
+        return emailAddress;
+    }
+
+    public void setEmailAddress(String emailAddress) {
+        this.emailAddress = emailAddress;
+    }
+
+    public String getFirstName() {
+        return firstName;
+    }
+
+    public void setFirstName(String firstName) {
+        this.firstName = firstName;
+    }
+
+    public String getMiddleName() {
+        return middleName;
+    }
+
+    public void setMiddleName(String middleName) {
+        this.middleName = middleName;
+    }
+
+    public String getLastName() {
+        return lastName;
+    }
+
+    public void setLastName(String lastName) {
+        this.lastName = lastName;
+    }
+
+    public String getCustomerId() {
+        return customerId;
+    }
+
+    public void setCustomerId(String customerId) {
+        this.customerId = customerId;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+}
\ No newline at end of file

Added: incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Employee.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Employee.java?rev=924153&view=auto
==============================================================================
--- incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Employee.java (added)
+++ incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Employee.java Wed Mar 17 04:39:07 2010
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 com.agimatec.validation.jsr303.example;
+
+/**
+ * Description: <br/>
+ * User: roman <br/>
+ * Date: 06.10.2009 <br/>
+ * Time: 13:41:43 <br/>
+ * Copyright: Agimatec GmbH
+ */
+public class Employee implements Person {
+    private String firstName, lastName;
+
+    public Employee(String firstN, String lastN) {
+        this.firstName = firstN;
+        this.lastName = lastN;
+    }
+
+    public String getFirstName() {
+        return firstName;
+    }
+
+    public String getMiddleName() {
+        return null;  // not supported
+    }
+
+    public String getLastName() {
+        return lastName;
+    }
+
+    public void setFirstName(String firstName) {
+        this.firstName = firstName;
+    }
+
+    public void setLastName(String lastName) {
+        this.lastName = lastName;
+    }
+}

Added: incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Engine.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Engine.java?rev=924153&view=auto
==============================================================================
--- incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Engine.java (added)
+++ incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Engine.java Wed Mar 17 04:39:07 2010
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 com.agimatec.validation.jsr303.example;
+
+import javax.validation.constraints.Pattern;
+
+public class Engine {
+    @Pattern.List({
+        @Pattern(regexp = "^[A-Z0-9-]+$", flags = Pattern.Flag.CASE_INSENSITIVE,
+                message = "must contain alphabetical characters only"),
+        @Pattern(
+                regexp = "^....-....-....$", message = "must match ....-....-....")})
+    public String serialNumber;
+
+
+}
\ No newline at end of file

Added: incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/First.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/First.java?rev=924153&view=auto
==============================================================================
--- incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/First.java (added)
+++ incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/First.java Wed Mar 17 04:39:07 2010
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 com.agimatec.validation.jsr303.example;
+
+/**
+ * Description: <br/>
+ * User: roman.stumm <br/>
+ * Date: 08.12.2008 <br/>
+ * Time: 10:24:50 <br/>
+ * Copyright: Agimatec GmbH
+ */
+public interface First {
+}

Added: incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/FrenchAddress.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/FrenchAddress.java?rev=924153&view=auto
==============================================================================
--- incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/FrenchAddress.java (added)
+++ incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/FrenchAddress.java Wed Mar 17 04:39:07 2010
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 com.agimatec.validation.jsr303.example;
+
+import com.agimatec.validation.constraints.FrenchZipCode;
+
+/**
+ * Description: <br/>
+ * User: roman.stumm <br/>
+ * Date: 31.10.2008 <br/>
+ * Time: 16:47:35 <br/>
+ * Copyright: Agimatec GmbH
+ */
+public class FrenchAddress {
+    @FrenchZipCode(size = 7)
+    String zipCode;
+
+    public FrenchAddress() {
+    }
+
+    public FrenchAddress(String zipCode) {
+        this.zipCode = zipCode;
+    }
+    
+    public String getZipCode() {
+        return zipCode;
+    }
+
+    public void setZipCode(String zipCode) {
+        this.zipCode = zipCode;
+    }
+
+}

Added: incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Last.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Last.java?rev=924153&view=auto
==============================================================================
--- incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Last.java (added)
+++ incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Last.java Wed Mar 17 04:39:07 2010
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 com.agimatec.validation.jsr303.example;
+
+/**
+ * Description: <br/>
+ * User: roman.stumm <br/>
+ * Date: 08.12.2008 <br/>
+ * Time: 10:24:56 <br/>
+ * Copyright: Agimatec GmbH
+ */
+public interface Last {
+}

Added: incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Library.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Library.java?rev=924153&view=auto
==============================================================================
--- incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Library.java (added)
+++ incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Library.java Wed Mar 17 04:39:07 2010
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 com.agimatec.validation.jsr303.example;
+
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+import java.util.*;
+
+/**
+ * Description: <br/>
+ * User: roman <br/>
+ * Date: 06.10.2009 <br/>
+ * Time: 12:35:42 <br/>
+ * Copyright: Agimatec GmbH
+ */
+public class Library {
+    @NotNull
+    private String libraryName;
+    @Valid
+    private final Map<String,Book> taggedBooks = new HashMap();
+    
+    private Person[] persons;
+
+    public String getLibraryName() {
+        return libraryName;
+    }
+
+    public void setLibraryName(String libraryName) {
+        this.libraryName = libraryName;
+    }
+
+    public Map<String, Book> getTaggedBooks() {
+        return taggedBooks;
+    }
+
+    public Person[] getPersons() {
+        return persons;
+    }
+
+    public void setPersons(Person[] persons) {
+        this.persons = persons;
+    }
+
+    @Valid
+    public List<Employee> getEmployees() {
+        if(persons == null) return Collections.emptyList();
+
+        ArrayList<Employee> emps = new ArrayList(persons.length);
+        for(Person each : persons) {
+            if(each instanceof Employee) emps.add((Employee) each);
+        }
+        return emps;
+    }
+}

Added: incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/MaxTestEntity.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/MaxTestEntity.java?rev=924153&view=auto
==============================================================================
--- incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/MaxTestEntity.java (added)
+++ incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/MaxTestEntity.java Wed Mar 17 04:39:07 2010
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 com.agimatec.validation.jsr303.example;
+
+import javax.validation.constraints.Max;
+import java.math.BigDecimal;
+
+/**
+ * Description: <br/>
+ * User: roman <br/>
+ * Date: 17.11.2009 <br/>
+ * Time: 15:21:45 <br/>
+ * Copyright: Agimatec GmbH
+ */
+public class MaxTestEntity {
+    @Max(100)
+    private String text;
+    private String property;
+
+    @Max(300)
+    private long longValue;
+
+    private BigDecimal decimalValue;
+
+    public String getText() {
+        return text;
+    }
+
+    @Max(200)
+    public String getProperty() {
+        return property;
+    }
+
+    public long getLongValue() {
+        return longValue;
+    }
+
+    @Max(400)
+    public BigDecimal getDecimalValue() {
+        return decimalValue;
+    }
+
+    public void setText(String text) {
+        this.text = text;
+    }
+
+    public void setProperty(String property) {
+        this.property = property;
+    }
+
+    public void setLongValue(long longValue) {
+        this.longValue = longValue;
+    }
+
+    public void setDecimalValue(BigDecimal decimalValue) {
+        this.decimalValue = decimalValue;
+    }
+}

Added: incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/NoValidatorTestEntity.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/NoValidatorTestEntity.java?rev=924153&view=auto
==============================================================================
--- incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/NoValidatorTestEntity.java (added)
+++ incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/NoValidatorTestEntity.java Wed Mar 17 04:39:07 2010
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 com.agimatec.validation.jsr303.example;
+
+import javax.validation.constraints.Max;
+
+/**
+ * Description: <br/>
+ * User: roman <br/>
+ * Date: 18.11.2009 <br/>
+ * Time: 10:00:15 <br/>
+ * Copyright: Agimatec GmbH
+ */
+public class NoValidatorTestEntity {
+    @Max(20)
+    private Object anything;
+    
+}

Added: incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Person.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Person.java?rev=924153&view=auto
==============================================================================
--- incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Person.java (added)
+++ incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/Person.java Wed Mar 17 04:39:07 2010
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 com.agimatec.validation.jsr303.example;
+
+import com.agimatec.validation.constraints.NotEmpty;
+
+public interface Person {
+    @NotEmpty
+    String getFirstName();
+
+    String getMiddleName();
+
+    @NotEmpty
+    String getLastName();
+}
\ No newline at end of file

Added: incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/PreferredGuest.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/PreferredGuest.java?rev=924153&view=auto
==============================================================================
--- incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/PreferredGuest.java (added)
+++ incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/PreferredGuest.java Wed Mar 17 04:39:07 2010
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 com.agimatec.validation.jsr303.example;
+
+import javax.validation.constraints.Digits;
+
+public class PreferredGuest extends Customer {
+    @Digits(integer = 10, fraction = 0)
+    private String guestCreditCardNumber;
+
+    public String getGuestCreditCardNumber() {
+        return guestCreditCardNumber;
+    }
+
+    public void setGuestCreditCardNumber(String guestCreditCardNumber) {
+        this.guestCreditCardNumber = guestCreditCardNumber;
+    }
+}
\ No newline at end of file

Added: incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/RecursiveFoo.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/RecursiveFoo.java?rev=924153&view=auto
==============================================================================
--- incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/RecursiveFoo.java (added)
+++ incubator/bval/trunk/agimatec-jsr303/src/test/java/com/agimatec/validation/jsr303/example/RecursiveFoo.java Wed Mar 17 04:39:07 2010
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 com.agimatec.validation.jsr303.example;
+
+import com.agimatec.validation.constraints.NotEmpty;
+
+import javax.validation.Valid;
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * Description: <br/>
+ * User: roman.stumm <br/>
+ * Date: 05.09.2008 <br/>
+ * Time: 11:02:24 <br/>
+ * Copyright: Agimatec GmbH
+ */
+public class RecursiveFoo {
+    @NotEmpty
+    @Valid
+    Collection<RecursiveFoo> foos = new ArrayList();
+
+    public Collection<RecursiveFoo> getFoos() {
+        return foos;
+    }
+
+    public void setFoos(Collection<RecursiveFoo> foos) {
+        this.foos = foos;
+    }
+}



Mime
View raw message