incubator-bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r928387 [14/15] - in /incubator/bval/trunk: ./ agimatec-jsr303/ agimatec-validation/ bval-core/ bval-core/.externalToolBuilders/ bval-core/.settings/ bval-core/src/ bval-core/src/main/ bval-core/src/main/java/ bval-core/src/main/java/org/ b...
Date Sun, 28 Mar 2010 12:28:32 GMT
Added: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GClass3.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GClass3.java?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GClass3.java (added)
+++ incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GClass3.java Sun Mar 28 12:28:25 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 org.apache.bval.jsr303.groups;
+
+import javax.validation.GroupSequence;
+
+/**
+ * Description: <br/>
+ * User: roman <br/>
+ * Date: 25.02.2009 <br/>
+ * Time: 17:37:04 <br/>
+ * Copyright: Agimatec GmbH
+ */
+@GroupSequence({GClass3.class, GClass1.class})
+public class GClass3 {
+}

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GClass3.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GClass3.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GClass3.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GInterface1.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GInterface1.java?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GInterface1.java (added)
+++ incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GInterface1.java Sun Mar 28 12:28:25 2010
@@ -0,0 +1,33 @@
+/*
+ * 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 org.apache.bval.jsr303.groups;
+
+import javax.validation.GroupSequence;
+
+/**
+ * Description: <br/>
+ * User: roman <br/>
+ * Date: 25.02.2009 <br/>
+ * Time: 16:44:56 <br/>
+ * Copyright: Agimatec GmbH
+ */
+@GroupSequence(GInterface1.class)
+public interface GInterface1 {
+
+}

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GInterface1.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GInterface1.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GInterface1.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupSequenceTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupSequenceTest.java?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupSequenceTest.java (added)
+++ incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupSequenceTest.java Sun Mar 28 12:28:25 2010
@@ -0,0 +1,182 @@
+/*
+ * 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 org.apache.bval.jsr303.groups;
+
+import org.apache.bval.jsr303.example.*;
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import javax.validation.ConstraintViolation;
+import javax.validation.Validator;
+
+import org.apache.bval.jsr303.AgimatecValidatorFactory;
+import org.apache.bval.jsr303.Jsr303Features;
+import org.apache.bval.jsr303.example.Author;
+import org.apache.bval.jsr303.example.Book;
+import org.apache.bval.jsr303.example.First;
+import org.apache.bval.jsr303.example.Last;
+import org.apache.bval.jsr303.example.Second;
+import org.apache.bval.jsr303.groups.Group;
+import org.apache.bval.jsr303.util.TestUtils;
+import org.apache.bval.model.MetaBean;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Description: test of group sequence behavior<br/>
+ * User: roman <br/>
+ * Date: 25.02.2009 <br/>
+ * Time: 16:47:06 <br/>
+ * Copyright: Agimatec GmbH
+ */
+public class GroupSequenceTest extends TestCase {
+    public void testGroupSequence1() {
+        MetaBean metaBean =
+              AgimatecValidatorFactory.getDefault().usingContext().getMetaBeanFinder()
+                    .findForClass(GInterface1.class);
+        List<Group> gseq = metaBean.getFeature(Jsr303Features.Bean.GROUP_SEQUENCE);
+        Assert.assertNotNull(gseq);
+        Assert.assertEquals(1, gseq.size());
+        Assert.assertEquals(Group.DEFAULT, gseq.get(0));
+    }
+
+    public void testGroupSequence2() {
+        MetaBean metaBean =
+              AgimatecValidatorFactory.getDefault().usingContext().getMetaBeanFinder()
+                    .findForClass(GClass1.class);
+        List<Group> gseq = metaBean.getFeature(Jsr303Features.Bean.GROUP_SEQUENCE);
+        Assert.assertNotNull(gseq);
+        Assert.assertEquals(1, gseq.size());
+        Assert.assertEquals(Group.DEFAULT, gseq.get(0));
+    }
+
+    public void testGroupSequence3() {
+        MetaBean metaBean =
+              AgimatecValidatorFactory.getDefault().usingContext().getMetaBeanFinder()
+                    .findForClass(GClass2.class);
+        List<Group> gseq = metaBean.getFeature(Jsr303Features.Bean.GROUP_SEQUENCE);
+        Assert.assertNotNull(gseq);
+        Assert.assertEquals(2, gseq.size());
+        Assert.assertEquals(new Group(GClass1.class), gseq.get(0));
+        Assert.assertEquals(Group.DEFAULT, gseq.get(1));
+    }
+
+    public void testGroupSequence4() {
+        MetaBean metaBean =
+              AgimatecValidatorFactory.getDefault().usingContext().getMetaBeanFinder()
+                    .findForClass(GClass3.class);
+        List<Group> gseq = metaBean.getFeature(Jsr303Features.Bean.GROUP_SEQUENCE);
+        Assert.assertNotNull(gseq);
+        Assert.assertEquals(2, gseq.size());
+        Assert.assertEquals(Group.DEFAULT, gseq.get(0));
+        Assert.assertEquals(new Group(GClass1.class), gseq.get(1));
+    }
+
+    public void testGroups() {
+        Validator validator = getValidator();
+
+        Author author = new Author();
+        author.setLastName("");
+        author.setFirstName("");
+        Book book = new Book();
+        book.setTitle("");
+        book.setAuthor(author);
+
+        Set<ConstraintViolation<Book>> constraintViolations =
+              validator.validate(book, First.class, Second.class, Last.class);
+        assertEquals("Wrong number of constraints", 3, constraintViolations.size());
+        assertNotNull(TestUtils.getViolation(constraintViolations, "title"));
+        assertNotNull(TestUtils.getViolation(constraintViolations, "author.firstName"));
+        assertNotNull(TestUtils.getViolation(constraintViolations, "author.lastName"));
+
+        author.setFirstName("Gavin");
+        author.setLastName("King");
+
+        constraintViolations = validator.validate(book, First.class, Second.class, Last.class);
+        ConstraintViolation constraintViolation = constraintViolations.iterator().next();
+        assertEquals(1, constraintViolations.size());
+        assertEquals("may not be empty", constraintViolation.getMessage());
+        assertEquals(book, constraintViolation.getRootBean());
+        assertEquals(book.getTitle(), constraintViolation.getInvalidValue());
+        assertEquals("title", constraintViolation.getPropertyPath().toString());
+
+        book.setTitle("My fault");
+        book.setSubtitle("confessions of a president - a book for a nice price");
+
+        constraintViolations = validator.validate(book, First.class, Second.class, Last.class);
+        assertEquals(1, constraintViolations.size());
+        constraintViolation = constraintViolations.iterator().next();
+        assertEquals("size must be between 0 and 30", constraintViolation.getMessage());
+        assertEquals(book, constraintViolation.getRootBean());
+        assertEquals(book.getSubtitle(), constraintViolation.getInvalidValue());
+        assertEquals("subtitle", constraintViolation.getPropertyPath().toString());
+
+        book.setSubtitle("Capitalism in crisis");
+        author.setCompany("1234567890ß9876543212578909876542245678987432");
+
+        constraintViolations = validator.validate(book);
+        constraintViolation = constraintViolations.iterator().next();
+        assertEquals(1, constraintViolations.size());
+        assertEquals("size must be between 0 and 40", constraintViolation.getMessage());
+        assertEquals(book, constraintViolation.getRootBean());
+        assertEquals(author.getCompany(), constraintViolation.getInvalidValue());
+        assertEquals("author.company", constraintViolation.getPropertyPath().toString());
+
+        author.setCompany("agimatec");
+
+        constraintViolations = validator.validate(book, First.class, Second.class, Last.class);
+        assertEquals(0, constraintViolations.size());
+    }
+
+    public void testGroupSequence() {
+        Validator validator = getValidator();
+
+        Author author = new Author();
+        author.setLastName("");
+        author.setFirstName("");
+        Book book = new Book();
+        book.setAuthor(author);
+
+        Set<ConstraintViolation<Book>> constraintViolations =
+              validator.validate(book, Book.All.class);
+        assertEquals(2, constraintViolations.size());
+
+        author.setFirstName("Kelvin");
+        author.setLastName("Cline");
+
+        constraintViolations = validator.validate(book, Book.All.class);
+        ConstraintViolation constraintViolation = constraintViolations.iterator().next();
+        assertEquals(1, constraintViolations.size());
+        assertEquals("may not be null", constraintViolation.getMessage());
+        assertEquals(book, constraintViolation.getRootBean());
+        assertEquals(book.getTitle(), constraintViolation.getInvalidValue());
+        assertEquals("title", constraintViolation.getPropertyPath().toString());
+
+        book.setTitle("247307892430798789024389798789");
+        book.setSubtitle("f43u rlök fjöq3liu opiur ölw3kj rölkj d");
+
+        constraintViolations = validator.validate(book, Book.All.class);
+        assertEquals(1, constraintViolations.size());
+    }
+
+    public Validator getValidator() {
+        return AgimatecValidatorFactory.getDefault().getValidator();
+    }
+}

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupSequenceTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupSequenceTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupSequenceTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupValidationTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupValidationTest.java?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupValidationTest.java (added)
+++ incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupValidationTest.java Sun Mar 28 12:28:25 2010
@@ -0,0 +1,89 @@
+/*
+ * 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 org.apache.bval.jsr303.groups;
+
+import junit.framework.TestCase;
+
+import javax.validation.ConstraintViolation;
+import javax.validation.Validator;
+
+import org.apache.bval.jsr303.AgimatecValidatorFactory;
+import org.apache.bval.jsr303.util.TestUtils;
+
+import java.util.Set;
+
+/**
+ * Description: test features from spec chapter 3.4 group and group sequence<br/>
+ * User: roman <br/>
+ * Date: 05.10.2009 <br/>
+ * Time: 11:29:53 <br/>
+ * Copyright: Agimatec GmbH
+ */
+public class GroupValidationTest extends TestCase {
+    private Validator validator;
+
+    protected void setUp() {
+        validator = AgimatecValidatorFactory.getDefault().getValidator();
+    }
+
+    /**
+     * test spec: @NotNull on firstname and on lastname are validated when
+     * the Default group is validated.
+     */
+    public void testValidateFirstNameLastNameWithDefaultGroup() {
+        BillableUser user = new BillableUser();
+
+        Set<ConstraintViolation<BillableUser>> violations = validator.validate(user);
+        assertEquals(2, violations.size());
+        ConstraintViolation violation = TestUtils.getViolation(violations, "firstname");
+        assertNotNull(violation);
+        assertEquals(user, violation.getRootBean());
+        violation = TestUtils.getViolation(violations, "lastname");
+        assertNotNull(violation);
+        assertEquals(user, violation.getRootBean());
+    }
+
+    /**
+     * test spec: @NotNull is checked on defaultCreditCard when either the
+     * Billable or BuyInOneClick group is validated.
+     */
+  public void testValidateDefaultCreditCardInBillableGroup() {
+        BillableUser user = new BillableUser();
+
+        Set<ConstraintViolation<BillableUser>> violations = validator.validate(user,
+              Billable.class);
+        assertEquals(1, violations.size());
+        ConstraintViolation violation = TestUtils.getViolation(violations, "defaultCreditCard");
+        assertNotNull(violation);
+        assertEquals(user, violation.getRootBean());
+    }
+
+  public void testValidateDefaultCreditCardInBillableAndByInOneClickGroup() {
+        BillableUser user = new BillableUser();
+
+        Set<ConstraintViolation<BillableUser>> violations = validator.validate(user,
+              BuyInOneClick.class, Billable.class);
+        assertEquals(1, violations.size());
+        ConstraintViolation violation = TestUtils.getViolation(violations, "defaultCreditCard");
+        assertNotNull(violation);
+        assertEquals(user, violation.getRootBean());
+    }
+
+
+}

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupValidationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupValidationTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupValidationTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupsComputerTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupsComputerTest.java?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupsComputerTest.java (added)
+++ incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupsComputerTest.java Sun Mar 28 12:28:25 2010
@@ -0,0 +1,152 @@
+/*
+ * 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 org.apache.bval.jsr303.groups;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import javax.validation.ValidationException;
+import javax.validation.groups.Default;
+
+import org.apache.bval.jsr303.example.Address;
+import org.apache.bval.jsr303.example.First;
+import org.apache.bval.jsr303.example.Last;
+import org.apache.bval.jsr303.example.Second;
+import org.apache.bval.jsr303.groups.Group;
+import org.apache.bval.jsr303.groups.Groups;
+import org.apache.bval.jsr303.groups.GroupsComputer;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * GroupListComputer Tester.
+ *
+ * @author <Authors name>
+ * @version 1.0
+ * @since <pre>04/09/2009</pre>
+ */
+public class GroupsComputerTest extends TestCase {
+    GroupsComputer groupsComputer;
+
+    public GroupsComputerTest(String name) {
+        super(name);
+    }
+
+    public void setUp() throws Exception {
+        super.setUp();
+        groupsComputer = new GroupsComputer();
+    }
+
+    public void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    public static Test suite() {
+        return new TestSuite(GroupsComputerTest.class);
+    }
+
+    public void testComputeGroupsNotAnInterface() {
+        Set<Class<?>> groups = new HashSet<Class<?>>();
+        groups.add(String.class);
+        try {
+            groupsComputer.computeGroups(groups);
+            fail();
+        } catch (ValidationException ex) {
+
+        }
+    }
+
+    public void testGroupChainForNull() {
+        try {
+            groupsComputer.computeGroups((Class<?>[]) null);
+            fail();
+        } catch (IllegalArgumentException ex) {
+
+        }
+    }
+
+    public void testGroupChainForEmptySet() {
+        try {
+            groupsComputer.computeGroups(new HashSet<Class<?>>());
+            fail();
+        } catch (IllegalArgumentException ex) {
+
+        }
+    }
+
+    public void testCyclicGroupSequences() {
+        try {
+            Set<Class<?>> groups = new HashSet<Class<?>>();
+            groups.add(CyclicGroupSequence1.class);
+            groupsComputer.computeGroups(groups);
+            fail();
+        } catch (ValidationException ex) {
+
+        }
+    }
+
+    public void testCyclicGroupSequence() {
+        try {
+            Set<Class<?>> groups = new HashSet<Class<?>>();
+            groups.add(CyclicGroupSequence.class);
+            groupsComputer.computeGroups(groups);
+            fail();
+        } catch (ValidationException ex) {
+
+        }
+    }
+
+    public void testGroupDuplicates() {
+        Set<Class<?>> groups = new HashSet<Class<?>>();
+        groups.add(First.class);
+        groups.add(Second.class);
+        groups.add(Last.class);
+        Groups chain = groupsComputer.computeGroups(groups);
+        assertEquals(3, chain.groups.size());
+
+        groups.clear();
+        groups.add(First.class);
+        groups.add(First.class);
+        chain = groupsComputer.computeGroups(groups);
+        assertEquals(1, chain.groups.size());
+
+        groups.clear();
+        groups.add(First.class);
+        groups.add(Last.class);
+        groups.add(First.class);
+        chain = groupsComputer.computeGroups(groups);
+        assertEquals(2, chain.groups.size());
+    }
+
+
+    public void testSequenceResolution() {
+        Set<Class<?>> groups = new HashSet<Class<?>>();
+        groups.add(Address.Complete.class);
+        Groups chain = groupsComputer.computeGroups(groups);
+        Iterator<List<Group>> sequences = chain.getSequences().iterator();
+        List<Group> sequence = sequences.next();
+
+        assertEquals(Default.class, sequence.get(0).getGroup());
+        assertEquals(Address.HighLevelCoherence.class, sequence.get(1).getGroup());
+    }
+}

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupsComputerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupsComputerTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupsComputerTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/implicit/Auditable.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/implicit/Auditable.java?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/implicit/Auditable.java (added)
+++ incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/implicit/Auditable.java Sun Mar 28 12:28:25 2010
@@ -0,0 +1,33 @@
+/*
+ * 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 org.apache.bval.jsr303.groups.implicit;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * Auditable object contract.
+ * Example 3.7. Example of interface / group hosting constraints
+ */
+public interface Auditable {
+    @NotNull String getCreationDate();
+    @NotNull
+    String getLastUpdate();
+    @NotNull String getLastModifier();
+    @NotNull String getLastReader();
+}

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/implicit/Auditable.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/implicit/Auditable.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/implicit/Auditable.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/implicit/ImplicitGroupingTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/implicit/ImplicitGroupingTest.java?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/implicit/ImplicitGroupingTest.java (added)
+++ incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/implicit/ImplicitGroupingTest.java Sun Mar 28 12:28:25 2010
@@ -0,0 +1,68 @@
+/*
+ * 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 org.apache.bval.jsr303.groups.implicit;
+
+import junit.framework.TestCase;
+
+import javax.validation.ConstraintViolation;
+import javax.validation.Validator;
+
+import org.apache.bval.jsr303.AgimatecValidatorFactory;
+import org.apache.bval.jsr303.util.TestUtils;
+
+import java.util.Set;
+
+/**
+ * Description: test spec chapter 3.4.4. Implicit grouping<br/>
+ * User: roman <br/>
+ * Date: 05.10.2009 <br/>
+ * Time: 12:45:24 <br/>
+ * Copyright: Agimatec GmbH
+ */
+public class ImplicitGroupingTest extends TestCase {
+    private Validator validator;
+
+    protected void setUp() {
+        validator = AgimatecValidatorFactory.getDefault().getValidator();
+    }
+
+    public void testValidateImplicitGrouping() {
+        Order order = new Order();
+        // When an Order object is validated on the Default group, ...
+        Set<ConstraintViolation<Order>> violations = validator.validate(order);
+        assertNotNull(TestUtils.getViolation(violations, "creationDate"));
+        assertNotNull(TestUtils.getViolation(violations, "lastUpdate"));
+        assertNotNull(TestUtils.getViolation(violations, "lastModifier"));
+        assertNotNull(TestUtils.getViolation(violations, "lastReader"));
+        assertNotNull(TestUtils.getViolation(violations, "orderNumber"));
+        assertEquals(5, violations.size());
+
+        // When an Order object is validated on the Auditable group, ...
+
+        /* Only the constraints present on Auditable (and any of its super interfaces)
+           and belonging to the Default group are validated
+           when the group Auditable is requested. */
+        violations = validator.validate(order, Auditable.class);
+        assertEquals("Implicit grouping not correctly implemented", 4, violations.size());
+        assertNotNull(TestUtils.getViolation(violations, "creationDate"));
+        assertNotNull(TestUtils.getViolation(violations, "lastUpdate"));
+        assertNotNull(TestUtils.getViolation(violations, "lastModifier"));
+        assertNotNull(TestUtils.getViolation(violations, "lastReader"));
+    }
+}

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/implicit/ImplicitGroupingTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/implicit/ImplicitGroupingTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/implicit/ImplicitGroupingTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/implicit/Order.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/implicit/Order.java?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/implicit/Order.java (added)
+++ incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/implicit/Order.java Sun Mar 28 12:28:25 2010
@@ -0,0 +1,76 @@
+/*
+ * 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 org.apache.bval.jsr303.groups.implicit;
+
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+/**
+ * Represents an order in the system
+ */
+public class Order implements Auditable {
+    private String creationDate;
+    private String lastUpdate;
+    private String lastModifier;
+    private String lastReader;
+
+    private String orderNumber;
+
+    public String getCreationDate() {
+        return this.creationDate;
+    }
+
+    public String getLastUpdate() {
+        return this.lastUpdate;
+    }
+
+    public String getLastModifier() {
+        return this.lastModifier;
+    }
+
+    public String getLastReader() {
+        return this.lastReader;
+    }
+
+    @NotNull
+    @Size(min=10, max=10)
+    public String getOrderNumber() {
+        return this.orderNumber;
+    }
+
+    public void setCreationDate(String creationDate) {
+        this.creationDate = creationDate;
+    }
+
+    public void setLastUpdate(String lastUpdate) {
+        this.lastUpdate = lastUpdate;
+    }
+
+    public void setLastModifier(String lastModifier) {
+        this.lastModifier = lastModifier;
+    }
+
+    public void setLastReader(String lastReader) {
+        this.lastReader = lastReader;
+    }
+
+    public void setOrderNumber(String orderNumber) {
+        this.orderNumber = orderNumber;
+    }
+}
\ No newline at end of file

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/implicit/Order.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/implicit/Order.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/implicit/Order.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/inheritance/BillableUser.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/inheritance/BillableUser.java?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/inheritance/BillableUser.java (added)
+++ incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/inheritance/BillableUser.java Sun Mar 28 12:28:25 2010
@@ -0,0 +1,68 @@
+/*
+ * 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 org.apache.bval.jsr303.groups.inheritance;
+
+
+import javax.validation.constraints.NotNull;
+import javax.validation.groups.Default;
+
+import org.apache.bval.jsr303.groups.Billable;
+import org.apache.bval.jsr303.groups.BillableCreditCard;
+
+/**
+ * Description: <br/>
+ * User: roman <br/>
+ * Date: 05.10.2009 <br/>
+ * Time: 12:18:31 <br/>
+ * Copyright: Agimatec GmbH
+ */
+public class BillableUser {
+    @NotNull
+    private String firstname;
+
+    @NotNull(groups = Default.class)
+    private String lastname;
+
+    @NotNull(groups = {Billable.class})
+    private BillableCreditCard defaultCreditCard;
+
+    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 BillableCreditCard getDefaultCreditCard() {
+        return defaultCreditCard;
+    }
+
+    public void setDefaultCreditCard(BillableCreditCard defaultCreditCard) {
+        this.defaultCreditCard = defaultCreditCard;
+    }
+}
\ No newline at end of file

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/inheritance/BillableUser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/inheritance/BillableUser.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/inheritance/BillableUser.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/inheritance/BuyInOneClick.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/inheritance/BuyInOneClick.java?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/inheritance/BuyInOneClick.java (added)
+++ incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/inheritance/BuyInOneClick.java Sun Mar 28 12:28:25 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 org.apache.bval.jsr303.groups.inheritance;
+
+
+import javax.validation.groups.Default;
+
+import org.apache.bval.jsr303.groups.Billable;
+
+/**
+ * Customer can buy without harrassing checking process.
+ * spec: Example 3.3. Groups can inherit other groups
+ */
+public interface BuyInOneClick extends Default, Billable {
+}

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/inheritance/BuyInOneClick.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/inheritance/BuyInOneClick.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/inheritance/BuyInOneClick.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/inheritance/GroupInheritanceTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/inheritance/GroupInheritanceTest.java?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/inheritance/GroupInheritanceTest.java (added)
+++ incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/inheritance/GroupInheritanceTest.java Sun Mar 28 12:28:25 2010
@@ -0,0 +1,62 @@
+/*
+ * 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 org.apache.bval.jsr303.groups.inheritance;
+
+import junit.framework.TestCase;
+
+import javax.validation.ConstraintViolation;
+import javax.validation.Validator;
+
+import org.apache.bval.jsr303.AgimatecValidatorFactory;
+import org.apache.bval.jsr303.util.TestUtils;
+
+import java.util.Set;
+
+/**
+ * Description: <br/>
+ * User: roman <br/>
+ * Date: 05.10.2009 <br/>
+ * Time: 12:19:40 <br/>
+ * Copyright: Agimatec GmbH
+ */
+public class GroupInheritanceTest extends TestCase {
+    private Validator validator;
+
+    protected void setUp() {
+        validator = AgimatecValidatorFactory.getDefault().getValidator();
+    }
+
+    /**
+     * validating the group BuyInOneClick will lead to the following constraints checking:
+     *<pre>
+     *  * @NotNull on firstname and lastname
+     *  * @NotNull on defaultCreditCard</pre>
+     * because Default and Billable are superinterfaces of BuyInOneClick.
+     */
+    public void testValidGroupBuyInOneClick() {
+        BillableUser user = new BillableUser();
+
+        Set<ConstraintViolation<BillableUser>> violations =
+              validator.validate(user, BuyInOneClick.class);
+        assertEquals(3, violations.size());
+        assertNotNull(TestUtils.getViolation(violations, "firstname"));
+        assertNotNull(TestUtils.getViolation(violations, "lastname"));
+        assertNotNull(TestUtils.getViolation(violations, "defaultCreditCard"));
+    }
+}

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/inheritance/GroupInheritanceTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/inheritance/GroupInheritanceTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/inheritance/GroupInheritanceTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/redefining/Address.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/redefining/Address.java?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/redefining/Address.java (added)
+++ incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/redefining/Address.java Sun Mar 28 12:28:25 2010
@@ -0,0 +1,77 @@
+/*
+ * 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 org.apache.bval.jsr303.groups.redefining;
+
+
+import javax.validation.GroupSequence;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+import org.apache.bval.constraints.ZipCodeCityCoherence;
+import org.apache.bval.jsr303.example.ZipCodeCityCarrier;
+
+/**
+ * Example 3.6. Redefining Default group for Address:
+ * To redefine Default for a class, place a @GroupSequence annotation on the class ; 
+ * this sequence expresses the sequence of groups that does
+ * substitute Default for this class.
+ */
+@GroupSequence({Address.class, Address.HighLevelCoherence.class})
+@ZipCodeCityCoherence(groups = Address.HighLevelCoherence.class)
+public class Address implements ZipCodeCityCarrier {
+    @NotNull @Size(max = 50)
+    private String street1;
+
+    @NotNull 
+    private String zipCode;
+
+    @NotNull
+    @Size(max = 30)
+    private String city;
+
+    /**
+     * check coherence on the overall object
+     * Needs basic checking to be green first
+     */
+    public interface HighLevelCoherence {}
+
+    public String getStreet1() {
+        return street1;
+    }
+
+    public void setStreet1(String street1) {
+        this.street1 = street1;
+    }
+
+    public String getZipCode() {
+        return zipCode;
+    }
+
+    public void setZipCode(String zipCode) {
+        this.zipCode = zipCode;
+    }
+
+    public String getCity() {
+        return city;
+    }
+
+    public void setCity(String city) {
+        this.city = city;
+    }
+}
\ No newline at end of file

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/redefining/Address.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/redefining/Address.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/redefining/Address.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/redefining/InvalidRedefinedDefaultGroupAddress.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/redefining/InvalidRedefinedDefaultGroupAddress.java?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/redefining/InvalidRedefinedDefaultGroupAddress.java (added)
+++ incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/redefining/InvalidRedefinedDefaultGroupAddress.java Sun Mar 28 12:28:25 2010
@@ -0,0 +1,44 @@
+/*
+ * 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 org.apache.bval.jsr303.groups.redefining;
+
+import javax.validation.GroupSequence;
+import javax.validation.constraints.NotNull;
+
+
+/**
+ * If a @GroupSequence redefining the Default group for a class A does not
+ * contain the group A, a GroupDefinitionException is raised when the class is
+ * validated or when its metadata is requested.
+ */
+@GroupSequence({Address.class, Address.HighLevelCoherence.class})
+public class InvalidRedefinedDefaultGroupAddress {
+    @NotNull(groups = Address.HighLevelCoherence.class)
+    private String street;
+
+    @NotNull
+    private String city;
+
+    /**
+     * check coherence on the overall object
+     * Needs basic checking to be green first
+     */
+    public interface HighLevelCoherence {}
+
+}

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/redefining/InvalidRedefinedDefaultGroupAddress.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/redefining/InvalidRedefinedDefaultGroupAddress.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/redefining/InvalidRedefinedDefaultGroupAddress.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/redefining/RedefiningDefaultGroupTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/redefining/RedefiningDefaultGroupTest.java?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/redefining/RedefiningDefaultGroupTest.java (added)
+++ incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/redefining/RedefiningDefaultGroupTest.java Sun Mar 28 12:28:25 2010
@@ -0,0 +1,93 @@
+/*
+ * 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 org.apache.bval.jsr303.groups.redefining;
+
+import junit.framework.TestCase;
+
+import javax.validation.ConstraintViolation;
+import javax.validation.GroupDefinitionException;
+import javax.validation.Validator;
+
+import org.apache.bval.jsr303.AgimatecValidatorFactory;
+import org.apache.bval.jsr303.util.TestUtils;
+
+import java.util.Set;
+
+/**
+ * Description: test Redefining the Default group for a class (spec. chapter 3.4.3)<br/>
+ * User: roman <br/>
+ * Date: 05.10.2009 <br/>
+ * Time: 12:42:40 <br/>
+ * Copyright: Agimatec GmbH
+ */
+public class RedefiningDefaultGroupTest extends TestCase {
+    private Validator validator;
+
+    protected void setUp() {
+        validator = AgimatecValidatorFactory.getDefault().getValidator();
+    }
+
+    /**
+     * when an address object is validated for the group Default,
+     * all constraints belonging to the group Default and hosted on Address are evaluated
+     */
+    public void testValidateDefaultGroup() {
+        Address address = new Address();
+        Set<ConstraintViolation<Address>> violations = validator.validate(address);
+        assertEquals(3, violations.size());
+        assertNotNull(TestUtils.getViolation(violations, "street1"));
+        assertNotNull(TestUtils.getViolation(violations, "zipCode"));
+        assertNotNull(TestUtils.getViolation(violations, "city"));
+
+        address.setStreet1("Elmstreet");
+        address.setZipCode("1234");
+        address.setCity("Gotham City");
+        violations = validator.validate(address);
+        assertTrue(violations.isEmpty());
+
+        violations = validator.validate(address, Address.HighLevelCoherence.class);
+        assertEquals(0, violations.size());
+
+        address.setCity("error");
+        violations = validator.validate(address, Address.HighLevelCoherence.class);
+        assertEquals(1, violations.size());
+
+        /**
+         * If none fails, all HighLevelCoherence constraints present on Address are evaluated.
+         *
+         * In other words, when validating the Default group for Address,
+         * the group sequence defined on the Address class is used.
+         */
+        violations = validator.validate(address);
+        assertEquals(
+              "redefined default group for Address must also validate HighLevelCoherence",
+              1, violations.size());
+    }
+
+    public void testRaiseGroupDefinitionException() {
+        InvalidRedefinedDefaultGroupAddress address =
+              new InvalidRedefinedDefaultGroupAddress();
+        try {
+            validator.validate(address);
+            fail();
+        } catch (GroupDefinitionException ex) {
+
+        }
+    }
+}

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/redefining/RedefiningDefaultGroupTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/redefining/RedefiningDefaultGroupTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/redefining/RedefiningDefaultGroupTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/util/ConverterUtilsTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/util/ConverterUtilsTest.java?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/util/ConverterUtilsTest.java (added)
+++ incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/util/ConverterUtilsTest.java Sun Mar 28 12:28:25 2010
@@ -0,0 +1,67 @@
+/*
+ * 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 org.apache.bval.jsr303.util;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import javax.validation.ValidationException;
+
+import org.apache.bval.jsr303.util.ConverterUtils;
+
+/**
+ * ConverterUtils Tester.
+ *
+ * @author <Authors name>
+ * @version 1.0
+ * @since <pre>11/25/2009</pre>
+ */
+public class ConverterUtilsTest extends TestCase {
+    public ConverterUtilsTest(String name) {
+        super(name);
+    }
+
+    public void testLong() {
+        long lng = (Long) ConverterUtils.fromStringToType("444", long.class);
+        assertEquals(444L, lng);
+
+        try {
+            ConverterUtils.fromStringToType("hallo", long.class);
+            fail();
+        } catch (ValidationException ve) {
+            // yes
+        }
+    }
+
+    public void testClass() {
+        assertEquals(getClass(),
+              ConverterUtils.fromStringToType(getClass().getName(), Class.class));
+    }
+
+    public void testEnum() {
+        Thread.State state = (Thread.State) ConverterUtils
+              .fromStringToType(Thread.State.TERMINATED.name(), Thread.State.class);
+        assertEquals(Thread.State.TERMINATED, state);
+    }
+
+    public static Test suite() {
+        return new TestSuite(ConverterUtilsTest.class);
+    }
+}

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/util/ConverterUtilsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/util/ConverterUtilsTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/util/ConverterUtilsTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/util/PathImplTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/util/PathImplTest.java?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/util/PathImplTest.java (added)
+++ incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/util/PathImplTest.java Sun Mar 28 12:28:25 2010
@@ -0,0 +1,153 @@
+/*
+ * 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 org.apache.bval.jsr303.util;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import javax.validation.Path;
+
+import org.apache.bval.jsr303.util.NodeImpl;
+import org.apache.bval.jsr303.util.PathImpl;
+
+import java.util.Iterator;
+
+/**
+ * ErrorBuilderImpl Tester.
+ *
+ * @author <Authors name>
+ * @version 1.0
+ * @since <pre>10/01/2009</pre>
+ */
+public class PathImplTest extends TestCase {
+    public PathImplTest(String name) {
+        super(name);
+    }
+
+    public void testParsing() {
+        String property = "order[3].deliveryAddress.addressline[1]";
+        Path path = PathImpl.createPathFromString(property);
+        assertEquals(property, path.toString());
+        
+        Iterator<Path.Node> propIter = path.iterator();
+
+        assertTrue(propIter.hasNext());
+        Path.Node elem = propIter.next();
+        assertEquals("order", elem.getName());
+        assertTrue(elem.isInIterable());
+        assertEquals(new Integer(3), elem.getIndex());
+
+        assertTrue(propIter.hasNext());
+        elem = propIter.next();
+        assertEquals("deliveryAddress", elem.getName());
+        assertFalse(elem.isInIterable());
+        assertEquals(null, elem.getIndex());
+
+        assertTrue(propIter.hasNext());
+        elem = propIter.next();
+        assertEquals("addressline", elem.getName());
+        assertTrue(elem.isInIterable());
+        assertEquals(new Integer(1), elem.getIndex());
+
+        assertFalse(propIter.hasNext());
+    }
+
+    public void testParseMapBasedProperty() {
+        String property = "order[foo].deliveryAddress";
+        Path path = PathImpl.createPathFromString(property);
+        Iterator<Path.Node> propIter = path.iterator();
+
+        assertTrue(propIter.hasNext());
+        Path.Node elem = propIter.next();
+        assertEquals("order", elem.getName());
+        assertTrue(elem.isInIterable());
+        assertEquals("foo", elem.getKey());
+
+        assertTrue(propIter.hasNext());
+        elem = propIter.next();
+        assertEquals("deliveryAddress", elem.getName());
+        assertFalse(elem.isInIterable());
+        assertEquals(null, elem.getIndex());
+
+        assertFalse(propIter.hasNext());
+    }
+
+    public void testNull() {
+        assertEquals(PathImpl.createPathFromString(null), PathImpl.create(null));
+
+        assertEquals("", PathImpl.create(null).toString());
+        Path path = PathImpl.create(null);
+        Path.Node node = path.iterator().next();
+        assertEquals(null, node.getName());
+    }
+
+    public void testUnbalancedBraces() {
+        try {
+            PathImpl.createPathFromString("foo[.bar");
+            fail();
+        } catch (IllegalArgumentException ex) {
+        }
+    }
+
+    public void testIndexInMiddleOfProperty() {
+        try {
+            PathImpl.createPathFromString("f[1]oo.bar");
+            fail();
+        } catch (IllegalArgumentException ex) {
+        }
+    }
+
+    public void testTrailingPathSeperator() {
+        try {
+            PathImpl.createPathFromString("foo.bar.");
+            fail();
+        } catch (IllegalArgumentException ex) {
+        }
+    }
+
+    public void testLeadingPathSeperator() {
+        try {
+            PathImpl.createPathFromString(".foo.bar");
+            fail();
+        } catch (IllegalArgumentException ex) {
+        }
+    }
+
+    public void testEmptyString() {
+        Path path = PathImpl.createPathFromString("");
+        assertEquals(null, path.iterator().next().getName());
+    }
+
+    public void testToString() {
+        PathImpl path = PathImpl.create(null);
+        path.addNode(new NodeImpl("firstName"));
+        assertEquals("firstName", path.toString());
+
+        path = PathImpl.create(null);
+        path.getLeafNode().setIndex(2);
+        assertEquals("[2]", path.toString());
+        path.addNode(new NodeImpl("firstName"));
+        assertEquals("[2].firstName", path.toString());
+    }
+
+    public static Test suite() {
+        return new TestSuite(PathImplTest.class);
+    }
+}

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/util/PathImplTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/util/PathImplTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/util/PathImplTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/util/TestUtils.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/util/TestUtils.java?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/util/TestUtils.java (added)
+++ incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/util/TestUtils.java Sun Mar 28 12:28:25 2010
@@ -0,0 +1,52 @@
+/*
+ * 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 org.apache.bval.jsr303.util;
+
+import javax.validation.ConstraintViolation;
+import java.util.Set;
+
+/**
+ * Description: <br/>
+ * User: roman <br/>
+ * Date: 05.10.2009 <br/>
+ * Time: 12:00:35 <br/>
+ * Copyright: Agimatec GmbH
+ */
+public class TestUtils {
+    /**
+     * @param violations
+     * @param propertyPath - string format of a propertyPath
+     * @return the constraintViolation with the propertyPath's string representation given
+     */
+    public static ConstraintViolation getViolation(Set violations, String propertyPath)
+    {
+        for(ConstraintViolation each : (Set<ConstraintViolation>)violations) {
+            if(each.getPropertyPath().toString().equals(propertyPath)) return each;
+        }
+        return null;
+    }
+
+    public static ConstraintViolation getViolationWithMessage(Set violations, String message)
+    {
+        for(ConstraintViolation each : (Set<ConstraintViolation>)violations) {
+            if(each.getMessage().equals(message)) return each;
+        }
+        return null;
+    }
+}

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/util/TestUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/util/TestUtils.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/util/TestUtils.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/xml/TestConstraintValidatorFactory.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/xml/TestConstraintValidatorFactory.java?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/xml/TestConstraintValidatorFactory.java (added)
+++ incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/xml/TestConstraintValidatorFactory.java Sun Mar 28 12:28:25 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 org.apache.bval.jsr303.xml;
+
+import org.apache.bval.jsr303.DefaultConstraintValidatorFactory;
+
+/**
+ * Description: <br/>
+ * User: roman <br/>
+ * Date: 25.11.2009 <br/>
+ * Time: 13:24:04 <br/>
+ * Copyright: Agimatec GmbH
+ */
+public class TestConstraintValidatorFactory extends DefaultConstraintValidatorFactory {
+}

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/xml/TestConstraintValidatorFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/xml/TestConstraintValidatorFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/xml/TestConstraintValidatorFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/xml/TestMessageInterpolator.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/xml/TestMessageInterpolator.java?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/xml/TestMessageInterpolator.java (added)
+++ incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/xml/TestMessageInterpolator.java Sun Mar 28 12:28:25 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 org.apache.bval.jsr303.xml;
+
+import org.apache.bval.jsr303.DefaultMessageInterpolator;
+
+/**
+ * Description: <br/>
+ * User: roman <br/>
+ * Date: 25.11.2009 <br/>
+ * Time: 13:20:51 <br/>
+ * Copyright: Agimatec GmbH
+ */
+public class TestMessageInterpolator extends DefaultMessageInterpolator {
+}

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/xml/TestMessageInterpolator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/xml/TestMessageInterpolator.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/xml/TestMessageInterpolator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/xml/ValidationParserTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/xml/ValidationParserTest.java?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/xml/ValidationParserTest.java (added)
+++ incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/xml/ValidationParserTest.java Sun Mar 28 12:28:25 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 org.apache.bval.jsr303.xml;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import javax.validation.ConstraintViolation;
+import javax.validation.Validation;
+import javax.validation.Validator;
+import javax.validation.ValidatorFactory;
+
+import org.apache.bval.jsr303.AgimatecValidationProvider;
+import org.apache.bval.jsr303.AgimatecValidatorConfiguration;
+import org.apache.bval.jsr303.ConfigurationImpl;
+import org.apache.bval.jsr303.example.XmlEntitySampleBean;
+import org.apache.bval.jsr303.resolver.SimpleTraversableResolver;
+import org.apache.bval.jsr303.xml.ValidationParser;
+
+import java.util.Set;
+
+/**
+ * ValidationParser Tester.
+ *
+ * @author <Authors name>
+ * @version 1.0
+ * @since <pre>11/25/2009</pre>
+ */
+public class ValidationParserTest extends TestCase
+      implements AgimatecValidatorConfiguration.Properties {
+    public ValidationParserTest(String name) {
+        super(name);
+    }
+
+    public void testParse() {
+        ValidationParser vp = new ValidationParser("sample-validation.xml");
+        ConfigurationImpl config =
+              new ConfigurationImpl(null, new AgimatecValidationProvider());
+        vp.processValidationConfig(config);
+    }
+
+    public void testConfigureFromXml() {
+        ValidatorFactory factory = getFactory();
+        assertTrue(factory.getMessageInterpolator() instanceof TestMessageInterpolator);
+        assertTrue(factory
+              .getConstraintValidatorFactory() instanceof TestConstraintValidatorFactory);
+        assertTrue(factory.getTraversableResolver() instanceof SimpleTraversableResolver);
+        Validator validator = factory.getValidator();
+        assertNotNull(validator);
+    }
+
+    private ValidatorFactory getFactory() {
+        AgimatecValidatorConfiguration config =
+              Validation.byProvider(AgimatecValidationProvider.class).configure();
+        config.addProperty(VALIDATION_XML_PATH, "sample-validation.xml");
+        return config.buildValidatorFactory();
+    }
+
+    public void testXmlEntitySample() {
+        XmlEntitySampleBean bean = new XmlEntitySampleBean();
+        bean.setFirstName("tooooooooooooooooooooooooooo long");
+        bean.setValueCode("illegal");
+        Validator validator = getFactory().getValidator();
+        Set<ConstraintViolation<XmlEntitySampleBean>> results = validator.validate(bean);
+        assertTrue(!results.isEmpty());
+        assertTrue(results.size() == 3);
+
+        bean.setZipCode("valid");
+        bean.setValueCode("20");
+        bean.setFirstName("valid");
+        results = validator.validate(bean);
+        assertTrue(results.isEmpty());
+    }
+
+    public static Test suite() {
+        return new TestSuite(ValidationParserTest.class);
+    }
+}

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/xml/ValidationParserTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/xml/ValidationParserTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/xml/ValidationParserTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/bval/trunk/bval-jsr303/src/test/resources/ValidationMessages.properties
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/test/resources/ValidationMessages.properties?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/test/resources/ValidationMessages.properties (added)
+++ incubator/bval/trunk/bval-jsr303/src/test/resources/ValidationMessages.properties Sun Mar 28 12:28:25 2010
@@ -0,0 +1,26 @@
+# 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.
+
+# standard messages
+javax.validation.constraints.Pattern.message=must match "{regexp}"
+
+# custom messages (examples) for validation-api-1.0.Beta4
+test.validator.creditcard=credit card is not valid
+
+# custom messages (examples) for validation-api-1.0.CR1
+validator.creditcard=credit card is not valid
+

Propchange: incubator/bval/trunk/bval-jsr303/src/test/resources/ValidationMessages.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-jsr303/src/test/resources/ValidationMessages.properties
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Added: incubator/bval/trunk/bval-jsr303/src/test/resources/sample-constraints.xml
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/test/resources/sample-constraints.xml?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/test/resources/sample-constraints.xml (added)
+++ incubator/bval/trunk/bval-jsr303/src/test/resources/sample-constraints.xml Sun Mar 28 12:28:25 2010
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<constraint-mappings
+    xmlns="http://jboss.org/xml/ns/javax/validation/mapping"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation=
+        "http://jboss.org/xml/ns/javax/validation/mapping validation-mapping-1.0.xsd">
+  <default-package>org.apache.bval.jsr303.example</default-package>
+
+  <bean class="XmlEntitySampleBean" ignore-annotations="false">
+    <class ignore-annotations="true"/>
+    <field name="zipCode">
+      <!--@FrenchZipCode(size=3)-->
+      <constraint annotation="org.apache.bval.constraints.FrenchZipCode">
+        <element name="size">
+          <value>3</value>
+        </element>
+      </constraint>
+
+    </field>
+    <field name="valueCode">
+      <valid/>
+      <!-- @HasValue({ 0, 20 }) -->
+      <constraint annotation="org.apache.bval.constraints.HasValue">
+        <element name="value">
+          <value>0</value>
+          <value>20</value>
+        </element>
+      </constraint>
+
+    </field>
+    <getter name="firstName">
+      <valid/>
+      <!-- @Size(message="Size is limited",
+                 groups={First.class, Default.class},
+                 max=10
+           )
+      -->
+      <constraint annotation="javax.validation.constraints.Size">
+        <message>Size is limited</message>
+        <groups>
+          <value>org.apache.bval.jsr303.example.First</value>
+          <value>javax.validation.groups.Default</value>
+        </groups>
+        <element name="max">10</element>
+      </constraint>
+
+    </getter>
+
+  </bean>
+
+  <constraint-definition annotation="javax.validation.constraints.Size">
+      <validated-by include-existing-validators="false">
+          <value>org.apache.bval.constraints.SizeValidatorForString</value>
+      </validated-by>
+  </constraint-definition>
+
+</constraint-mappings>

Propchange: incubator/bval/trunk/bval-jsr303/src/test/resources/sample-constraints.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-jsr303/src/test/resources/sample-constraints.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: incubator/bval/trunk/bval-jsr303/src/test/resources/sample-constraints.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: incubator/bval/trunk/bval-jsr303/src/test/resources/sample-validation.xml
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/test/resources/sample-validation.xml?rev=928387&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/test/resources/sample-validation.xml (added)
+++ incubator/bval/trunk/bval-jsr303/src/test/resources/sample-validation.xml Sun Mar 28 12:28:25 2010
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<validation-config
+    xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation=
+        "http://jboss.org/xml/ns/javax/validation/configuration validation-configuration-1.0.xsd">
+  <default-provider>org.apache.bval.jsr303.AgimatecValidationProvider</default-provider>
+  <message-interpolator>org.apache.bval.jsr303.xml.TestMessageInterpolator</message-interpolator>
+  <traversable-resolver>org.apache.bval.jsr303.resolver.SimpleTraversableResolver</traversable-resolver>
+  <constraint-validator-factory>org.apache.bval.jsr303.xml.TestConstraintValidatorFactory</constraint-validator-factory>
+  <constraint-mapping>sample-constraints.xml</constraint-mapping>
+  <property name="test-prop">test-prop-value</property>
+</validation-config>

Propchange: incubator/bval/trunk/bval-jsr303/src/test/resources/sample-validation.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-jsr303/src/test/resources/sample-validation.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: incubator/bval/trunk/bval-jsr303/src/test/resources/sample-validation.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message