bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1517540 [11/15] - in /bval/branches/bval-11/bval-jsr: ./ src/ src/main/ src/main/appended-resources/ src/main/appended-resources/META-INF/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/bval/ src/main/...
Date Mon, 26 Aug 2013 13:59:20 GMT
Added: bval/branches/bval-11/bval-jsr/src/main/xsd/validation-mapping-1.0.xsd
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr/src/main/xsd/validation-mapping-1.0.xsd?rev=1517540&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr/src/main/xsd/validation-mapping-1.0.xsd (added)
+++ bval/branches/bval-11/bval-jsr/src/main/xsd/validation-mapping-1.0.xsd Mon Aug 26 13:59:15 2013
@@ -0,0 +1,171 @@
+<?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.
+-->
+<xs:schema attributeFormDefault="unqualified"
+           elementFormDefault="qualified"
+           targetNamespace="http://jboss.org/xml/ns/javax/validation/mapping"
+           xmlns:xs="http://www.w3.org/2001/XMLSchema"
+           version="1.0">
+    <xs:element name="constraint-mappings"
+                type="map:constraint-mappingsType"
+                xmlns:map="http://jboss.org/xml/ns/javax/validation/mapping"/>
+
+    <xs:complexType name="payloadType">
+        <xs:sequence>
+            <xs:element type="xs:string" name="value" maxOccurs="unbounded" minOccurs="0"/>
+        </xs:sequence>
+    </xs:complexType>
+    <xs:complexType name="groupsType">
+        <xs:sequence>
+            <xs:element type="xs:string" name="value" maxOccurs="unbounded" minOccurs="0"/>
+        </xs:sequence>
+    </xs:complexType>
+    <xs:complexType name="groupSequenceType">
+        <xs:sequence>
+            <xs:element type="xs:string" name="value" maxOccurs="unbounded" minOccurs="0"/>
+        </xs:sequence>
+    </xs:complexType>
+    <xs:complexType name="constraint-mappingsType">
+        <xs:sequence>
+            <xs:element type="xs:string" name="default-package" minOccurs="0"/>
+            <xs:element type="map:beanType"
+                        name="bean"
+                        maxOccurs="unbounded"
+                        minOccurs="0"
+                        xmlns:map="http://jboss.org/xml/ns/javax/validation/mapping"/>
+            <xs:element type="map:constraint-definitionType"
+                        name="constraint-definition"
+                        maxOccurs="unbounded"
+                        minOccurs="0"
+                        xmlns:map="http://jboss.org/xml/ns/javax/validation/mapping"/>
+        </xs:sequence>
+    </xs:complexType>
+    <xs:complexType name="validated-byType">
+        <xs:sequence>
+            <xs:element type="xs:string" name="value" maxOccurs="unbounded" minOccurs="0"/>
+        </xs:sequence>
+        <xs:attribute type="xs:boolean" name="include-existing-validators" use="optional"/>
+    </xs:complexType>
+    <xs:complexType name="constraintType">
+        <xs:sequence>
+            <xs:element type="xs:string" name="message" minOccurs="0"/>
+            <xs:element type="map:groupsType"
+                        name="groups"
+                        minOccurs="0"
+                        xmlns:map="http://jboss.org/xml/ns/javax/validation/mapping"/>
+            <xs:element type="map:payloadType"
+                        name="payload"
+                        minOccurs="0"
+                        xmlns:map="http://jboss.org/xml/ns/javax/validation/mapping"/>            
+            <xs:element type="map:elementType"
+                        name="element"
+                        maxOccurs="unbounded"
+                        minOccurs="0"
+                        xmlns:map="http://jboss.org/xml/ns/javax/validation/mapping"/>
+        </xs:sequence>
+        <xs:attribute type="xs:string" name="annotation" use="required"/>
+    </xs:complexType>
+    <xs:complexType name="elementType" mixed="true">
+        <xs:sequence>
+            <xs:element type="xs:string" name="value" maxOccurs="unbounded" minOccurs="0"/>
+            <xs:element type="map:annotationType"
+                        name="annotation"
+                        maxOccurs="unbounded"
+                        minOccurs="0"
+                        xmlns:map="http://jboss.org/xml/ns/javax/validation/mapping"/>
+        </xs:sequence>
+        <xs:attribute type="xs:string" name="name" use="required"/>
+    </xs:complexType>
+    <xs:complexType name="classType">
+        <xs:sequence>
+            <xs:element type="map:groupSequenceType" 
+                        name="group-sequence" 
+                        minOccurs="0" 
+                        xmlns:map="http://jboss.org/xml/ns/javax/validation/mapping"/>
+            <xs:element type="map:constraintType"
+                        name="constraint"
+                        maxOccurs="unbounded"
+                        minOccurs="0"
+                        xmlns:map="http://jboss.org/xml/ns/javax/validation/mapping"/>
+        </xs:sequence>
+        <xs:attribute type="xs:boolean" name="ignore-annotations" use="optional"/>
+    </xs:complexType>
+    <xs:complexType name="beanType">
+        <xs:sequence>
+            <xs:element type="map:classType"
+                        name="class"
+                        minOccurs="0"
+                        xmlns:map="http://jboss.org/xml/ns/javax/validation/mapping">
+            </xs:element>
+            <xs:element type="map:fieldType"
+                        name="field"
+                        minOccurs="0"
+                        maxOccurs="unbounded"
+                        xmlns:map="http://jboss.org/xml/ns/javax/validation/mapping"/>
+            <xs:element type="map:getterType"
+                        name="getter"
+                        minOccurs="0"
+                        maxOccurs="unbounded"
+                        xmlns:map="http://jboss.org/xml/ns/javax/validation/mapping"/>
+        </xs:sequence>
+        <xs:attribute type="xs:string" name="class" use="required"/>
+        <xs:attribute type="xs:boolean" name="ignore-annotations" use="optional"/>
+    </xs:complexType>
+    <xs:complexType name="annotationType">
+        <xs:sequence>
+            <xs:element type="map:elementType"
+                        name="element"
+                        maxOccurs="unbounded"
+                        minOccurs="0"
+                        xmlns:map="http://jboss.org/xml/ns/javax/validation/mapping"/>
+        </xs:sequence>
+    </xs:complexType>
+    <xs:complexType name="getterType">
+        <xs:sequence>
+            <xs:element type="xs:string" name="valid" minOccurs="0" fixed=""/>
+            <xs:element type="map:constraintType"
+                        name="constraint"
+                        minOccurs="0"
+                        maxOccurs="unbounded"
+                        xmlns:map="http://jboss.org/xml/ns/javax/validation/mapping"/>
+        </xs:sequence>
+        <xs:attribute type="xs:string" name="name" use="required"/>
+        <xs:attribute type="xs:boolean" name="ignore-annotations" use="optional"/>
+    </xs:complexType>
+    <xs:complexType name="constraint-definitionType">
+        <xs:sequence>
+            <xs:element type="map:validated-byType"
+                        name="validated-by"
+                        xmlns:map="http://jboss.org/xml/ns/javax/validation/mapping"/>
+        </xs:sequence>
+        <xs:attribute type="xs:string" name="annotation" use="required"/>
+    </xs:complexType>
+    <xs:complexType name="fieldType">
+        <xs:sequence>
+            <xs:element type="xs:string" name="valid" minOccurs="0" fixed=""/>
+            <xs:element type="map:constraintType"
+                        name="constraint"
+                        minOccurs="0"
+                        maxOccurs="unbounded"
+                        xmlns:map="http://jboss.org/xml/ns/javax/validation/mapping"/>
+        </xs:sequence>
+        <xs:attribute type="xs:string" name="name" use="required"/>
+        <xs:attribute type="xs:boolean" name="ignore-annotations" use="optional"/>
+    </xs:complexType>
+</xs:schema>

Added: bval/branches/bval-11/bval-jsr/src/main/xsd/validation-mapping-1.1.xsd
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr/src/main/xsd/validation-mapping-1.1.xsd?rev=1517540&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr/src/main/xsd/validation-mapping-1.1.xsd (added)
+++ bval/branches/bval-11/bval-jsr/src/main/xsd/validation-mapping-1.1.xsd Mon Aug 26 13:59:15 2013
@@ -0,0 +1,254 @@
+<?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.
+-->
+<xs:schema attributeFormDefault="unqualified"
+           elementFormDefault="qualified"
+           targetNamespace="http://jboss.org/xml/ns/javax/validation/mapping"
+           xmlns:xs="http://www.w3.org/2001/XMLSchema"
+           xmlns:map="http://jboss.org/xml/ns/javax/validation/mapping"
+           version="1.1">
+  <xs:element name="constraint-mappings" type="map:constraint-mappingsType"/>
+
+  <xs:complexType name="payloadType">
+    <xs:sequence>
+      <xs:element type="xs:string" name="value" maxOccurs="unbounded" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="groupsType">
+    <xs:sequence>
+      <xs:element type="xs:string" name="value" maxOccurs="unbounded" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="groupSequenceType">
+    <xs:sequence>
+      <xs:element type="xs:string" name="value" maxOccurs="unbounded" minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="groupConversionType">
+    <xs:attribute type="xs:string" name="from" use="required"/>
+    <xs:attribute type="xs:string" name="to" use="required"/>
+  </xs:complexType>
+  <xs:complexType name="constraint-mappingsType">
+    <xs:sequence>
+      <xs:element type="xs:string" name="default-package" minOccurs="0"/>
+      <xs:element type="map:beanType"
+                  name="bean"
+                  maxOccurs="unbounded"
+                  minOccurs="0"/>
+      <xs:element type="map:constraint-definitionType"
+                  name="constraint-definition"
+                  maxOccurs="unbounded"
+                  minOccurs="0"/>
+    </xs:sequence>
+    <xs:attribute name="version" type="map:versionType" fixed="1.1" /> <!-- use="required" -->
+  </xs:complexType>
+  <xs:simpleType name="versionType">
+    <xs:restriction base="xs:token">
+      <xs:pattern value="[0-9]+(\.[0-9]+)*"/>
+    </xs:restriction>
+  </xs:simpleType>
+  <xs:complexType name="validated-byType">
+    <xs:sequence>
+      <xs:element type="xs:string" name="value" maxOccurs="unbounded" minOccurs="0"/>
+    </xs:sequence>
+    <xs:attribute type="xs:boolean" name="include-existing-validators" use="optional"/>
+  </xs:complexType>
+  <xs:complexType name="constraintType">
+    <xs:sequence>
+      <xs:element type="xs:string" name="message" minOccurs="0"/>
+      <xs:element type="map:groupsType"
+                  name="groups"
+                  minOccurs="0"/>
+      <xs:element type="map:payloadType"
+                  name="payload"
+                  minOccurs="0"/>
+      <xs:element type="map:elementType"
+                  name="element"
+                  maxOccurs="unbounded"
+                  minOccurs="0"/>
+    </xs:sequence>
+    <xs:attribute type="xs:string" name="annotation" use="required"/>
+  </xs:complexType>
+  <xs:complexType name="elementType" mixed="true">
+    <xs:sequence>
+      <xs:element type="xs:string" name="value" maxOccurs="unbounded" minOccurs="0"/>
+      <xs:element type="map:annotationType"
+                  name="annotation"
+                  maxOccurs="unbounded"
+                  minOccurs="0"/>
+    </xs:sequence>
+    <xs:attribute type="xs:string" name="name" use="required"/>
+  </xs:complexType>
+  <xs:complexType name="classType">
+    <xs:sequence>
+      <xs:element type="map:groupSequenceType"
+                  name="group-sequence"
+                  minOccurs="0"/>
+      <xs:element type="map:constraintType"
+                  name="constraint"
+                  maxOccurs="unbounded"
+                  minOccurs="0"/>
+    </xs:sequence>
+    <xs:attribute type="xs:boolean" name="ignore-annotations" use="optional"/>
+  </xs:complexType>
+  <xs:complexType name="beanType">
+    <xs:sequence>
+      <xs:element type="map:classType"
+                  name="class"
+                  minOccurs="0">
+      </xs:element>
+      <xs:element type="map:fieldType"
+                  name="field"
+                  minOccurs="0"
+                  maxOccurs="unbounded"/>
+      <xs:element type="map:getterType"
+                  name="getter"
+                  minOccurs="0"
+                  maxOccurs="unbounded"/>
+      <xs:element type="map:constructorType"
+                  name="constructor"
+                  minOccurs="0"
+                  maxOccurs="unbounded"/>
+      <xs:element type="map:methodType"
+                  name="method"
+                  minOccurs="0"
+                  maxOccurs="unbounded"/>
+    </xs:sequence>
+    <xs:attribute type="xs:string" name="class" use="required"/>
+    <xs:attribute type="xs:boolean" name="ignore-annotations" use="optional"/>
+  </xs:complexType>
+  <xs:complexType name="annotationType">
+    <xs:sequence>
+      <xs:element type="map:elementType"
+                  name="element"
+                  maxOccurs="unbounded"
+                  minOccurs="0"/>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="getterType">
+    <xs:sequence>
+      <xs:element type="xs:string" name="valid" minOccurs="0" fixed=""/>
+      <xs:element type="map:groupConversionType"
+                  name="convert-group"
+                  minOccurs="0"
+                  maxOccurs="unbounded"/>
+      <xs:element type="map:constraintType"
+                  name="constraint"
+                  minOccurs="0"
+                  maxOccurs="unbounded"/>
+    </xs:sequence>
+    <xs:attribute type="xs:string" name="name" use="required"/>
+    <xs:attribute type="xs:boolean" name="ignore-annotations" use="optional"/>
+  </xs:complexType>
+  <xs:complexType name="methodType">
+    <xs:sequence>
+      <xs:element type="map:parameterType"
+                  name="parameter"
+                  minOccurs="0"
+                  maxOccurs="unbounded"/>
+      <xs:element type="map:crossParameterType"
+                  name="cross-parameter"
+                  minOccurs="0"
+                  maxOccurs="1"/>
+      <xs:element type="map:returnValueType"
+                  name="return-value"
+                  minOccurs="0"
+                  maxOccurs="1"/>
+    </xs:sequence>
+    <xs:attribute type="xs:string" name="name" use="required"/>
+    <xs:attribute type="xs:boolean" name="ignore-annotations" use="optional"/>
+  </xs:complexType>
+  <xs:complexType name="constructorType">
+    <xs:sequence>
+      <xs:element type="map:parameterType"
+                  name="parameter"
+                  minOccurs="0"
+                  maxOccurs="unbounded"/>
+      <xs:element type="map:crossParameterType"
+                  name="cross-parameter"
+                  minOccurs="0"
+                  maxOccurs="1"/>
+      <xs:element type="map:returnValueType"
+                  name="return-value"
+                  minOccurs="0"
+                  maxOccurs="1"/>
+    </xs:sequence>
+    <xs:attribute type="xs:boolean" name="ignore-annotations" use="optional"/>
+  </xs:complexType>
+  <xs:complexType name="parameterType">
+    <xs:sequence>
+      <xs:element type="xs:string" name="valid" minOccurs="0" fixed=""/>
+      <xs:element type="map:groupConversionType"
+                  name="convert-group"
+                  minOccurs="0"
+                  maxOccurs="unbounded"/>
+      <xs:element type="map:constraintType"
+                  name="constraint"
+                  minOccurs="0"
+                  maxOccurs="unbounded"/>
+    </xs:sequence>
+    <xs:attribute type="xs:string" name="type" use="required"/>
+    <xs:attribute type="xs:boolean" name="ignore-annotations" use="optional"/>
+  </xs:complexType>
+  <xs:complexType name="returnValueType">
+    <xs:sequence>
+      <xs:element type="xs:string" name="valid" minOccurs="0" fixed=""/>
+      <xs:element type="map:groupConversionType"
+                  name="convert-group"
+                  minOccurs="0"
+                  maxOccurs="unbounded"/>
+      <xs:element type="map:constraintType"
+                  name="constraint"
+                  minOccurs="0"
+                  maxOccurs="unbounded"/>
+    </xs:sequence>
+    <xs:attribute type="xs:boolean" name="ignore-annotations" use="optional"/>
+  </xs:complexType>
+  <xs:complexType name="crossParameterType">
+    <xs:sequence>
+      <xs:element type="map:constraintType"
+                  name="constraint"
+                  minOccurs="0"
+                  maxOccurs="unbounded"/>
+    </xs:sequence>
+    <xs:attribute type="xs:boolean" name="ignore-annotations" use="optional"/>
+  </xs:complexType>
+  <xs:complexType name="constraint-definitionType">
+    <xs:sequence>
+      <xs:element type="map:validated-byType"
+                  name="validated-by"/>
+    </xs:sequence>
+    <xs:attribute type="xs:string" name="annotation" use="required"/>
+  </xs:complexType>
+  <xs:complexType name="fieldType">
+    <xs:sequence>
+      <xs:element type="xs:string" name="valid" minOccurs="0" fixed=""/>
+      <xs:element type="map:groupConversionType"
+                  name="convert-group"
+                  minOccurs="0"
+                  maxOccurs="unbounded"/>
+      <xs:element type="map:constraintType"
+                  name="constraint"
+                  minOccurs="0"
+                  maxOccurs="unbounded"/>
+    </xs:sequence>
+    <xs:attribute type="xs:string" name="name" use="required"/>
+    <xs:attribute type="xs:boolean" name="ignore-annotations" use="optional"/>
+  </xs:complexType>
+</xs:schema>

Added: bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/AssertFalseValidatorTest.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/AssertFalseValidatorTest.java?rev=1517540&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/AssertFalseValidatorTest.java (added)
+++ bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/AssertFalseValidatorTest.java Mon Aug 26 13:59:15 2013
@@ -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 org.apache.bval.constraints;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+
+/**
+ * Checks correct behaviour of {@link AssertFalseValidator}.
+ * <p>
+ * Per the spec:
+ * <ul>
+ * <li>The annotated element must be false.</li>
+ * <li><code>null</code> elements are considered valid.</li>
+ * </ul>
+ * 
+ * TODO: Mock context and verify that it's not used during validation.
+ * 
+ * @see "bean_validation-1_0_CR1-pfd-spec#Chapter6#Example6.4"
+ * 
+ * @author Carlos Vara
+ */
+public class AssertFalseValidatorTest extends TestCase {
+	
+    public static Test suite() {
+        return new TestSuite(AssertFalseValidatorTest.class);
+    }
+    
+    public AssertFalseValidatorTest(String name) {
+    	super(name);
+    }
+    
+    /**
+     * Test {@link AssertFalseValidator} with <code>null</code> context.
+     */
+    public void testAssertFalseValidator() {
+    	AssertFalseValidator afv = new AssertFalseValidator();
+    	assertFalse("True value validation must fail", afv.isValid(true, null));
+    	assertTrue("False value validation must succeed", afv.isValid(false, null));
+    	assertTrue("Null value validation must succeed", afv.isValid(null, null));
+    }
+
+}

Added: bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/AssertTrueValidatorTest.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/AssertTrueValidatorTest.java?rev=1517540&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/AssertTrueValidatorTest.java (added)
+++ bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/AssertTrueValidatorTest.java Mon Aug 26 13:59:15 2013
@@ -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 org.apache.bval.constraints;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+
+/**
+ * Checks correct behaviour of {@link AssertTrueValidator}.
+ * <p>
+ * Per the spec:
+ * <ul>
+ * <li>The annotated element must be true.</li>
+ * <li><code>null</code> elements are considered valid.</li>
+ * </ul>
+ * 
+ * TODO: Mock context and verify that it's not used during validation.
+ * 
+ * @see "bean_validation-1_0_CR1-pfd-spec#Chapter6#Example6.3"
+ * 
+ * @author Carlos Vara
+ */
+public class AssertTrueValidatorTest extends TestCase {
+	
+    public static Test suite() {
+        return new TestSuite(AssertTrueValidatorTest.class);
+    }
+    
+    public AssertTrueValidatorTest(String name) {
+    	super(name);
+    }
+    
+    /**
+     * Test {@link AssertTrueValidator} with null context.
+     */
+    public void testAssertTrueValidator() {
+    	AssertTrueValidator atv = new AssertTrueValidator();
+    	assertTrue("True value validation must succeed", atv.isValid(true, null));
+    	assertFalse("False value validation must fail", atv.isValid(false, null));
+    	assertTrue("Null value validation must succeed", atv.isValid(null, null));
+    }
+
+}

Added: bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/AuthorAddressKnown.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/AuthorAddressKnown.java?rev=1517540&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/AuthorAddressKnown.java (added)
+++ bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/AuthorAddressKnown.java Mon Aug 26 13:59:15 2013
@@ -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 org.apache.bval.constraints;
+
+import org.apache.bval.jsr.example.Address;
+import org.apache.bval.jsr.example.Author;
+
+import javax.validation.Constraint;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.Payload;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * 
+ * 
+ * @version $Rev: 999729 $ $Date: 2010-09-21 21:37:54 -0500 (Tue, 21 Sep 2010) $
+ */
+@Target( { ANNOTATION_TYPE, METHOD, FIELD })
+@Constraint(validatedBy = AuthorAddressKnown.Validator.class)
+@Retention(RUNTIME)
+public @interface AuthorAddressKnown {
+
+    String message() default "{org.apache.bval.constraints.AuthorAddressKnown.message}";
+
+    Class<?>[] groups() default {};
+
+    Class<? extends Payload>[] payload() default { };
+
+    public static class Validator implements ConstraintValidator<AuthorAddressKnown, Author> {
+
+        /**
+         * {@inheritDoc}
+         */
+        public void initialize(AuthorAddressKnown constraintAnnotation) {
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        public boolean isValid(Author value, ConstraintValidatorContext context) {
+            if (value.getAddresses() == null) {
+                return false;
+            }
+            for (Address address : value.getAddresses()) {
+                if (address != null) {
+                    return true;
+                }
+            }
+            return false;
+        }
+
+    }
+}

Added: bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/CompanyEmail.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/CompanyEmail.java?rev=1517540&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/CompanyEmail.java (added)
+++ bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/CompanyEmail.java Mon Aug 26 13:59:15 2013
@@ -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 org.apache.bval.constraints;
+
+import javax.validation.Constraint;
+import javax.validation.OverridesAttribute;
+import javax.validation.Payload;
+import javax.validation.constraints.Pattern;
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.CONSTRUCTOR;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Pattern.List({
+    // email
+    @Pattern(regexp = "[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}"),
+    // agimatec
+    @Pattern(regexp = ".*?COMPANY.*?")
+})
+/**
+ * test a constraint WITHOUT an own ConstraintValidator implementation.
+ * the validations, that must be processed are in the combined constraints only!!
+ * the @Constraint annotation is nevertheless required so that the framework searches
+ * for combined constraints.  
+ */
+@Constraint(validatedBy = {})
+@Documented
+@Target({ANNOTATION_TYPE, METHOD, FIELD, CONSTRUCTOR, PARAMETER})
+@Retention(RUNTIME)
+public @interface CompanyEmail {
+    String message() default "Not an email of COMPANY";
+
+    @OverridesAttribute(constraint = Pattern.class, name = "message",
+          constraintIndex = 0) String emailMessage() default "Not an email";
+
+    @OverridesAttribute(constraint = Pattern.class, name = "message",
+          constraintIndex = 1) String agimatecMessage() default "Not COMPANY";
+
+    Class<?>[] groups() default {};
+
+    Class<? extends Payload>[] payload() default {};
+
+    @Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER})
+    @Retention(RUNTIME)
+    @Documented
+          @interface List {
+        CompanyEmail[] value();
+    }
+}
\ No newline at end of file

Added: bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/DecimalMinMaxValidatorsTest.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/DecimalMinMaxValidatorsTest.java?rev=1517540&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/DecimalMinMaxValidatorsTest.java (added)
+++ bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/DecimalMinMaxValidatorsTest.java Mon Aug 26 13:59:15 2013
@@ -0,0 +1,63 @@
+/*
+ * 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.constraints;
+
+import junit.framework.TestCase;
+
+import javax.validation.ConstraintViolation;
+import javax.validation.Validation;
+import javax.validation.Validator;
+import javax.validation.constraints.DecimalMax;
+import javax.validation.constraints.DecimalMin;
+import java.util.Set;
+
+/**
+ * Description: <br>
+ * User: roman.stumm<br>
+ * Date: 06.04.2010<br>
+ * Time: 13:45:09<br>
+ */
+public class DecimalMinMaxValidatorsTest extends TestCase {
+
+    @DecimalMin("922392239223.06")
+    public double dmin;
+    @DecimalMax("922392239223.09")
+    public double dmax;
+
+    public void testDecimalMinValue() {
+        Validator v = Validation.buildDefaultValidatorFactory().getValidator();
+
+        this.dmin = 922392239223.05;
+        this.dmax = 922392239223.08;
+
+        Set<ConstraintViolation<DecimalMinMaxValidatorsTest>> res = v.validate(this);
+        assertFalse("Min validation failed", res.isEmpty());
+    }
+
+    public void testDecimalMaxValue() {
+        Validator v = Validation.buildDefaultValidatorFactory().getValidator();
+
+        this.dmin = Double.MAX_VALUE;
+        this.dmax = 922392239223.1;
+
+        Set<ConstraintViolation<DecimalMinMaxValidatorsTest>> res = v.validate(this);
+        assertFalse("Max validation failed", res.isEmpty());
+    }
+
+}

Added: bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/DigitsValidatorTest.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/DigitsValidatorTest.java?rev=1517540&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/DigitsValidatorTest.java (added)
+++ bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/DigitsValidatorTest.java Mon Aug 26 13:59:15 2013
@@ -0,0 +1,87 @@
+/*
+ * 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.constraints;
+
+import junit.framework.Assert;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import java.math.BigDecimal;
+
+/**
+ * DigitsConstraintValidator Tester.
+ *
+ * @author <Authors name>
+ * @since <pre>02/03/2009</pre>
+ * @version 1.0
+ */
+public class DigitsValidatorTest extends TestCase {
+    public DigitsValidatorTest(String name) {
+        super(name);
+    }
+
+    public void testValidateNumber() {
+        DigitsValidatorForNumber validator = new DigitsValidatorForNumber();
+        validator.setFractional(4);
+        validator.setIntegral(2);
+        Assert.assertFalse(validator.isValid(new BigDecimal("100.1234"), null));
+        Assert.assertFalse(validator.isValid(new BigDecimal("99.12345"), null));
+        Assert.assertTrue(validator.isValid(new BigDecimal("99.1234"), null));
+        Assert.assertFalse(validator.isValid(Double.valueOf(100.1234), null));
+        Assert.assertFalse(validator.isValid(Double.valueOf(99.12345), null));
+        Assert.assertTrue(validator.isValid(Double.valueOf(99.1234), null));
+        Assert.assertTrue(validator.isValid(Double.valueOf(99.123400), null));
+        Assert.assertTrue(validator.isValid(new BigDecimal("99.123400"), null));
+    }
+
+    public void testValidateString() {
+        DigitsValidatorForString validator = new DigitsValidatorForString();
+        validator.setFractional(4);
+        validator.setIntegral(2);
+        String val = "100.12345";
+        Assert.assertFalse(validator.isValid(val, null));
+        val = "99.1234";
+        Assert.assertTrue(validator.isValid(val, null));
+    }
+
+    public void testValidateNumber2() {
+        DigitsValidatorForNumber validator = new DigitsValidatorForNumber();
+        validator.setFractional(4);
+        validator.setIntegral(2);
+        Long val = new Long("100");
+        Assert.assertFalse(validator.isValid(val, null));
+        val = new Long("99");
+        Assert.assertTrue(validator.isValid(val, null));
+    }
+
+    public void testValidateString2() {
+        DigitsValidatorForString validator = new DigitsValidatorForString();
+        validator.setFractional(0);
+        validator.setIntegral(2);
+        String val = "99.5";
+        Assert.assertFalse(validator.isValid(val, null));
+        val = "99";
+        Assert.assertTrue(validator.isValid(val, null));
+    }
+
+    public static Test suite() {
+        return new TestSuite(DigitsValidatorTest.class);
+    }
+}

Added: bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/EmailValidatorTest.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/EmailValidatorTest.java?rev=1517540&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/EmailValidatorTest.java (added)
+++ bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/EmailValidatorTest.java Mon Aug 26 13:59:15 2013
@@ -0,0 +1,98 @@
+/*
+ * 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.constraints;
+
+import junit.framework.Assert;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.apache.bval.jsr.ApacheValidatorFactory;
+import org.apache.bval.jsr.example.Customer;
+
+import javax.validation.Validator;
+
+/**
+ * EmailValidator Tester.
+ *
+ * @author Roman Stumm
+ * @version 1.0
+ * @since <pre>10/14/2008</pre>
+ */
+public class EmailValidatorTest extends TestCase {
+    public static class EmailAddressBuilder {
+        @Email
+        private StringBuilder buffer = new StringBuilder();
+
+        /**
+         * Get the buffer.
+         * @return StringBuilder
+         */
+        public StringBuilder getBuffer() {
+            return buffer;
+        }
+
+    }
+
+    private Validator validator;
+
+    public EmailValidatorTest(String name) {
+        super(name);
+    }
+
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        validator = ApacheValidatorFactory.getDefault().getValidator();
+    }
+
+    public void testEmail() {
+        Customer customer = new Customer();
+        customer.setCustomerId("id-1");
+        customer.setFirstName("Mary");
+        customer.setLastName("Do");
+        customer.setPassword("12345");
+
+        Assert.assertEquals(0, validator.validate(customer).size());
+
+        customer.setEmailAddress("some@invalid@address");
+        Assert.assertEquals(1, validator.validate(customer).size());
+
+        customer.setEmailAddress("some.valid-012345@address_at-test.org");
+        Assert.assertEquals(0, validator.validate(customer).size());
+    }
+
+    public void testEmailCharSequence() {
+        EmailAddressBuilder emailAddressBuilder = new EmailAddressBuilder();
+        Assert.assertEquals(0, validator.validate(emailAddressBuilder).size());
+        emailAddressBuilder.getBuffer().append("foo");
+        Assert.assertEquals(1, validator.validate(emailAddressBuilder).size());
+        emailAddressBuilder.getBuffer().append('@');
+        Assert.assertEquals(1, validator.validate(emailAddressBuilder).size());
+        emailAddressBuilder.getBuffer().append("bar");
+        Assert.assertEquals(0, validator.validate(emailAddressBuilder).size());
+        emailAddressBuilder.getBuffer().append('.');
+        Assert.assertEquals(1, validator.validate(emailAddressBuilder).size());
+        emailAddressBuilder.getBuffer().append("baz");
+        Assert.assertEquals(0, validator.validate(emailAddressBuilder).size());
+    }
+
+    public static Test suite() {
+        return new TestSuite(EmailValidatorTest.class);
+    }
+}

Added: bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/FrenchZipCode.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/FrenchZipCode.java?rev=1517540&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/FrenchZipCode.java (added)
+++ bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/FrenchZipCode.java Mon Aug 26 13:59:15 2013
@@ -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.constraints;
+
+import javax.validation.Constraint;
+import javax.validation.OverridesAttribute;
+import javax.validation.Payload;
+import javax.validation.ReportAsSingleViolation;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * Description: example for composed constraint.
+ * not implemented! simple dummy implemenation for tests only! <br/>
+ */
+@NotEmpty
+@NotNull
+@Size(min = 4, max = 5, message = "Zipcode should be of size {value}")
+@Constraint(validatedBy = FrenchZipcodeValidator.class)
+@ReportAsSingleViolation
+@Documented
+@Target({ANNOTATION_TYPE, METHOD, FIELD})
+@Retention(RUNTIME)
+public @interface FrenchZipCode {
+    @OverridesAttribute.List({
+            @OverridesAttribute(constraint = Size.class, name= "min"),
+        @OverridesAttribute(constraint = Size.class, name = "max")})
+    int size() default 6;
+
+    @OverridesAttribute(constraint=Size.class, name="message")
+    String sizeMessage() default "{error.zipcode.size}";
+
+    String message() default "Wrong zipcode";
+
+    Class<?>[] groups() default {};
+
+    Class<? extends Payload>[] payload() default { };
+}

Added: bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/FrenchZipcodeValidator.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/FrenchZipcodeValidator.java?rev=1517540&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/FrenchZipcodeValidator.java (added)
+++ bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/FrenchZipcodeValidator.java Mon Aug 26 13:59:15 2013
@@ -0,0 +1,35 @@
+/*
+ * 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.constraints;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+/**
+ * Description: not implemented (test only)<br/>
+ */
+public class FrenchZipcodeValidator implements ConstraintValidator<FrenchZipCode, Object> {
+    public void initialize(FrenchZipCode constraintAnnotation) {
+        // do nothing
+    }
+
+    public boolean isValid(Object object, ConstraintValidatorContext validationContext) {
+        return null != object;
+    }
+}

Added: bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/HasStringValidator.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/HasStringValidator.java?rev=1517540&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/HasStringValidator.java (added)
+++ bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/HasStringValidator.java Mon Aug 26 13:59:15 2013
@@ -0,0 +1,39 @@
+/*
+ * 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.constraints;
+
+import org.apache.commons.lang3.ArrayUtils;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+/**
+ * Description: <br/>
+ */
+public class HasStringValidator implements ConstraintValidator<HasValue, String> {
+    private String[] values;
+
+    public void initialize(HasValue stringValues) {
+        values = stringValues.value();
+    }
+
+    public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
+        return s == null || ArrayUtils.contains(values, s);
+    }
+}

Added: bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/HasValue.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/HasValue.java?rev=1517540&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/HasValue.java (added)
+++ bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/HasValue.java Mon Aug 26 13:59:15 2013
@@ -0,0 +1,45 @@
+/*
+ * 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.constraints;
+
+import javax.validation.Constraint;
+import javax.validation.Payload;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * Description: allow distinct string values for element (like enums) <br/>
+ */
+@Target({ANNOTATION_TYPE, METHOD, FIELD})
+@Constraint(validatedBy = {HasStringValidator.class})
+@Retention(RUNTIME)
+public @interface HasValue {
+    String[] value();
+
+    String message() default "Wrong value, must be one of {value}";
+
+    Class<?>[] groups() default {};
+
+    Class<? extends Payload>[] payload() default { };
+}

Added: bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/MinMaxValidatorsForNumberTest.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/MinMaxValidatorsForNumberTest.java?rev=1517540&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/MinMaxValidatorsForNumberTest.java (added)
+++ bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/MinMaxValidatorsForNumberTest.java Mon Aug 26 13:59:15 2013
@@ -0,0 +1,69 @@
+/*
+ * 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.constraints;
+
+import junit.framework.TestCase;
+
+import javax.validation.ConstraintViolation;
+import javax.validation.Validation;
+import javax.validation.Validator;
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import java.util.Set;
+
+/**
+ * Check correct behaviour of {@link MinValidatorForNumber} and
+ * {@link MaxValidatorForNumber} on boundary values.
+ * <p/>
+ * The chosen numbers: 9223372036854775806l and 9223372036854775807l cast to the
+ * same double value.
+ * 
+ * @author Carlos Vara
+ */
+public class MinMaxValidatorsForNumberTest extends TestCase {
+
+    @Min(value = 9223372036854775807l)
+    public long min;
+
+    @Max(value = 9223372036854775806l)
+    public long max;
+
+    public void testMinBoundaryValue() {
+        Validator v = Validation.buildDefaultValidatorFactory().getValidator();
+
+        this.min = 9223372036854775806l;
+        this.max = 0l;
+
+        // Current min value is smaller, should fail, but it doesn't
+        Set<ConstraintViolation<MinMaxValidatorsForNumberTest>> res = v.validate(this);
+        assertFalse("Min validation failed", res.isEmpty());
+    }
+
+    public void testMaxBoundaryValue() {
+        Validator v = Validation.buildDefaultValidatorFactory().getValidator();
+
+        this.min = Long.MAX_VALUE;
+        this.max = 9223372036854775807l;
+
+        // Current max value is bigger, should fail, but it doesn't
+        Set<ConstraintViolation<MinMaxValidatorsForNumberTest>> res = v.validate(this);
+        assertFalse("Max validation failed", res.isEmpty());
+    }
+
+}

Added: bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/NotNullValidatorTest.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/NotNullValidatorTest.java?rev=1517540&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/NotNullValidatorTest.java (added)
+++ bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/NotNullValidatorTest.java Mon Aug 26 13:59:15 2013
@@ -0,0 +1,59 @@
+/*
+ * 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.constraints;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+
+/**
+ * Checks correct behaviour of {@link NotNullValidator}.
+ * <p>
+ * Per the spec:
+ * <ul>
+ * <li>The annotated element must not be null.</li>
+ * </ul>
+ * 
+ * TODO: Mock context and verify that it's not used during validation.
+ * 
+ * @see "bean_validation-1_0_CR1-pfd-spec#Chapter6#Example6.2"
+ * 
+ * @author Carlos Vara
+ */
+public class NotNullValidatorTest extends TestCase {
+
+    public static Test suite() {
+        return new TestSuite(NotNullValidatorTest.class);
+    }
+    
+    public NotNullValidatorTest(String name) {
+    	super(name);
+    }
+    
+    /**
+     * Test {@link NotNullValidator} with null context.
+     */
+    public void testNotNullValidator() {
+    	NotNullValidator nnv = new NotNullValidator();
+    	assertTrue("Non null value validation must succeed", nnv.isValid("hello", null));
+    	assertFalse("Null value validation must fail", nnv.isValid(null, null));    	
+    }
+	
+}

Added: bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/NullValidatorTest.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/NullValidatorTest.java?rev=1517540&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/NullValidatorTest.java (added)
+++ bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/NullValidatorTest.java Mon Aug 26 13:59:15 2013
@@ -0,0 +1,59 @@
+/*
+ * 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.constraints;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+
+/**
+ * Checks correct behaviour of {@link NullValidator}.
+ * <p>
+ * Per the spec:
+ * <ul>
+ * <li>The annotated element must be null.</li>
+ * </ul>
+ * 
+ * TODO: Mock context and verify that it's not used during validation.
+ * 
+ * @see "bean_validation-1_0_CR1-pfd-spec#Chapter6#Example6.1"
+ * 
+ * @author Carlos Vara
+ */
+public class NullValidatorTest extends TestCase {
+
+    public static Test suite() {
+        return new TestSuite(NullValidatorTest.class);
+    }
+    
+    public NullValidatorTest(String name) {
+    	super(name);
+    }
+	
+    /**
+     * Test {@link AssertFalseValidator} with null context.
+     */
+    public void testNullValidator() {
+    	NullValidator nv = new NullValidator();
+    	assertTrue("Null value validation must succeed", nv.isValid(null, null));
+    	assertFalse("Non null value validation must fail", nv.isValid("hello", null));    	
+    }
+    
+}

Added: bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/Password.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/Password.java?rev=1517540&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/Password.java (added)
+++ bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/Password.java Mon Aug 26 13:59:15 2013
@@ -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 org.apache.bval.constraints;
+
+import javax.validation.Constraint;
+import javax.validation.Payload;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import java.lang.annotation.Retention;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * Description: <br/>
+ * User: roman.stumm <br/>
+ * Date: 01.04.2008 <br/>
+ * Time: 12:02:06 <br/>
+ */
+@NotEmpty
+@NotNull
+@Size(min = 4, max = 5)
+@Retention(RUNTIME)
+@Constraint(validatedBy = {})
+// test that Password is validated although only combined constraints exists, no own implementation 
+public @interface Password {
+    Class<?>[] groups() default {};
+
+    String message() default "Wrong password";
+
+    int robustness() default 8;
+
+    Class<? extends Payload>[] payload() default { };
+}

Added: bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/ZipCodeCityCoherence.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/ZipCodeCityCoherence.java?rev=1517540&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/ZipCodeCityCoherence.java (added)
+++ bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/ZipCodeCityCoherence.java Mon Aug 26 13:59:15 2013
@@ -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 org.apache.bval.constraints;
+
+import javax.validation.Constraint;
+import javax.validation.Payload;
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * not implemented! simple dummy implemenation for tests only!
+ */
+@Documented
+@Constraint(validatedBy = ZipCodeCityCoherenceValidator.class)
+@Target({TYPE})
+@Retention(RUNTIME)
+public @interface ZipCodeCityCoherence {
+    String message() default "{validator.zipCodeCityCoherence}";    
+    Class<?>[] groups() default {};
+    Class<? extends Payload>[] payload() default { };
+}

Added: bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/ZipCodeCityCoherenceValidator.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/ZipCodeCityCoherenceValidator.java?rev=1517540&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/ZipCodeCityCoherenceValidator.java (added)
+++ bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/constraints/ZipCodeCityCoherenceValidator.java Mon Aug 26 13:59:15 2013
@@ -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.constraints;
+
+
+import org.apache.bval.jsr.example.ZipCodeCityCarrier;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+/**
+ * Description: Class not implemented! simple dummy implemenation for tests only! <br/>
+ * User: roman.stumm <br/>
+ * Date: 01.04.2008 <br/>
+ * Time: 11:45:22 <br/>
+ */
+public class ZipCodeCityCoherenceValidator
+      implements ConstraintValidator<ZipCodeCityCoherence, ZipCodeCityCarrier> {
+    public void initialize(ZipCodeCityCoherence constraintAnnotation) {
+    }
+
+    public boolean isValid(ZipCodeCityCarrier adr, ConstraintValidatorContext context) {
+        boolean r = true;
+        if ("error".equals(adr.getZipCode())) {
+            context.disableDefaultConstraintViolation();
+            context.buildConstraintViolationWithTemplate("zipcode not OK").addConstraintViolation();
+            r = false;
+        }
+        if ("error".equals(adr.getCity())) {
+            context.disableDefaultConstraintViolation();
+            context.buildConstraintViolationWithTemplate("city not OK").addNode("city").addConstraintViolation();
+            r = false;
+        }
+        return r;
+    }
+}

Added: bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/jsr/BeanDescriptorTest.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/jsr/BeanDescriptorTest.java?rev=1517540&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/jsr/BeanDescriptorTest.java (added)
+++ bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/jsr/BeanDescriptorTest.java Mon Aug 26 13:59:15 2013
@@ -0,0 +1,238 @@
+/*
+ * 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.jsr;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.bval.jsr.util.TestUtils;
+
+import javax.validation.Constraint;
+import javax.validation.Payload;
+import javax.validation.Validation;
+import javax.validation.Validator;
+import javax.validation.ValidatorFactory;
+import javax.validation.constraints.NotNull;
+import javax.validation.groups.Default;
+import javax.validation.metadata.BeanDescriptor;
+import javax.validation.metadata.ConstraintDescriptor;
+import javax.validation.metadata.ElementDescriptor;
+import javax.validation.metadata.ElementDescriptor.ConstraintFinder;
+import javax.validation.metadata.PropertyDescriptor;
+import javax.validation.metadata.Scope;
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import java.util.Locale;
+import java.util.Set;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * Tests the implementation of {@link BeanDescriptor} and its dependent
+ * interfaces.
+ * 
+ * @author Carlos Vara
+ */
+public class BeanDescriptorTest extends TestCase {
+    static ValidatorFactory factory;
+
+    static {
+        factory = Validation.buildDefaultValidatorFactory();
+        ((DefaultMessageInterpolator) factory.getMessageInterpolator()).setLocale(Locale.ENGLISH);
+    }
+
+    /**
+     * Validator instance to test
+     */
+    protected Validator validator;
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        validator = createValidator();
+    }
+
+    /**
+     * Create the validator instance.
+     * 
+     * @return Validator
+     */
+    protected Validator createValidator() {
+        return factory.getValidator();
+    }
+
+    /**
+     * Check that groups(), message() and payload() are always in the
+     * attributes.
+     */
+    public void testMandatoryAttributesPresentInConstraintDescriptor() {
+        Set<ConstraintDescriptor<?>> nameDescriptors =
+            validator.getConstraintsForClass(Form.class).getConstraintsForProperty("name").getConstraintDescriptors();
+        Assert.assertEquals("Incorrect number of descriptors", 1, nameDescriptors.size());
+        ConstraintDescriptor<?> nameDescriptor = nameDescriptors.iterator().next();
+        Assert.assertTrue("groups attribute not present", nameDescriptor.getAttributes().containsKey("groups"));
+        Assert.assertTrue("payload attribute not present", nameDescriptor.getAttributes().containsKey("payload"));
+        Assert.assertTrue("message attribute not present", nameDescriptor.getAttributes().containsKey("message"));
+    }
+
+    /**
+     * Check that the groups() attribute value has the correct value when
+     * inheriting groups.
+     */
+    public void testCorrectValueForInheritedGroupsAttribute() {
+        Set<ConstraintDescriptor<?>> passwordDescriptors =
+            validator.getConstraintsForClass(Account.class).getConstraintsForProperty("password")
+                .getConstraintDescriptors();
+        Assert.assertEquals("Incorrect number of descriptors", 1, passwordDescriptors.size());
+        ConstraintDescriptor<?> passwordDescriptor = passwordDescriptors.iterator().next();
+        Assert.assertEquals("Incorrect number of composing constraints", 1, passwordDescriptor
+            .getComposingConstraints().size());
+        ConstraintDescriptor<?> notNullDescriptor = passwordDescriptor.getComposingConstraints().iterator().next();
+
+        // Check that the groups value containts Group1.class
+        Class<?>[] notNullGroups = (Class<?>[]) notNullDescriptor.getAttributes().get("groups");
+        boolean found = false;
+        for (Class<?> group : notNullGroups) {
+            if (group == Group1.class) {
+                found = true;
+                break;
+            }
+        }
+        Assert.assertTrue("Group1 not present in groups attribute", found);
+    }
+
+    /**
+     * Check that the groups() attribute value contains the correct interface as
+     * implicit group when the constraint is defined in that interface instead
+     * of the queried class.
+     */
+    public void testImplicitGroupIsPresent() {
+        Set<ConstraintDescriptor<?>> nameDescriptors =
+            validator.getConstraintsForClass(Woman.class).getConstraintsForProperty("name").getConstraintDescriptors();
+        Assert.assertEquals("Incorrect number of descriptors", 1, nameDescriptors.size());
+        ConstraintDescriptor<?> notNullDescriptor = nameDescriptors.iterator().next();
+
+        // Check that the groups attribute value contains the implicit group
+        // Person and the Default group
+        Class<?>[] notNullGroups = (Class<?>[]) notNullDescriptor.getAttributes().get("groups");
+        Assert.assertEquals("Incorrect number of groups", 2, notNullGroups.length);
+        Assert.assertTrue("Default group not present", notNullGroups[0].equals(Default.class)
+            || notNullGroups[1].equals(Default.class));
+        Assert.assertTrue("Implicit group not present", notNullGroups[0].equals(Person.class)
+            || notNullGroups[1].equals(Person.class));
+    }
+
+    /**
+     * Check that the groups() attribute value does not contain the implicit
+     * interface group when querying the interface directly.
+     */
+    public void testNoImplicitGroupWhenQueryingInterfaceDirectly() {
+        Set<ConstraintDescriptor<?>> nameDescriptors =
+            validator.getConstraintsForClass(Person.class).getConstraintsForProperty("name").getConstraintDescriptors();
+        Assert.assertEquals("Incorrect number of descriptors", 1, nameDescriptors.size());
+        ConstraintDescriptor<?> notNullDescriptor = nameDescriptors.iterator().next();
+
+        // Check that only the default group is present
+        Class<?>[] notNullGroups = (Class<?>[]) notNullDescriptor.getAttributes().get("groups");
+        Assert.assertEquals("Incorrect number of groups", 1, notNullGroups.length);
+        Assert.assertTrue("Default group not present", notNullGroups[0].equals(Default.class));
+    }
+
+    /**
+     * Check that the implementations of
+     * {@link ElementDescriptor#getElementClass()} work as defined in the spec.
+     */
+    public void testElementDescriptorGetElementClass() {
+        BeanDescriptor beanDescriptor = validator.getConstraintsForClass(Person.class);
+        Assert.assertEquals("Incorrect class returned", Person.class, beanDescriptor.getElementClass());
+
+        PropertyDescriptor nameDescriptor = beanDescriptor.getConstraintsForProperty("name");
+        Assert.assertEquals("Incorrect class returned", String.class, nameDescriptor.getElementClass());
+    }
+
+    /**
+     * Check the correct behavior of
+     * {@link ConstraintFinder#lookingAt(javax.validation.metadata.Scope)}.
+     */
+    public void testConstraintFinderLookingAt() {
+        PropertyDescriptor nameDescriptor =
+            validator.getConstraintsForClass(Woman.class).getConstraintsForProperty("name");
+        Set<ConstraintDescriptor<?>> constraints =
+            nameDescriptor.findConstraints().lookingAt(Scope.HIERARCHY).getConstraintDescriptors();
+        Assert.assertEquals("Incorrect number of descriptors", 1, constraints.size());
+
+        constraints = nameDescriptor.findConstraints().lookingAt(Scope.LOCAL_ELEMENT).getConstraintDescriptors();
+        Assert.assertEquals("Incorrect number of descriptors", 0, constraints.size());
+        TestUtils.failOnModifiable(constraints, "constraintFinder constraintDescriptors");
+        //verify that changes to one ConstraintFinder don't affect the base:
+        constraints = nameDescriptor.getConstraintDescriptors();
+        Assert.assertEquals("Incorrect number of descriptors", 1, constraints.size());
+    }
+
+    public static class Form {
+        @NotNull
+        public String name;
+    }
+
+    public static class Account {
+        @Password(groups = { Group1.class })
+        public String password;
+    }
+
+    @NotNull(groups = {})
+    @Constraint(validatedBy = {})
+    @Documented
+    @Target( { METHOD, FIELD, TYPE })
+    @Retention(RUNTIME)
+    public static @interface Password {
+        String message() default "Invalid password";
+
+        Class<?>[] groups() default {};
+
+        Class<? extends Payload>[] payload() default {};
+    }
+
+    public static interface Group1 {
+    }
+
+    public static class Woman implements Person {
+
+        private String name;
+
+        public String getName() {
+            return this.name;
+        }
+
+        public void setName(String name) {
+            this.name = name;
+        }
+    }
+
+    public static interface Person {
+        @NotNull
+        String getName();
+    }
+
+}

Added: bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/jsr/BootstrapTest.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/jsr/BootstrapTest.java?rev=1517540&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/jsr/BootstrapTest.java (added)
+++ bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/jsr/BootstrapTest.java Mon Aug 26 13:59:15 2013
@@ -0,0 +1,186 @@
+/*
+ * 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.jsr;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.bval.constraints.NotNullValidator;
+import org.apache.bval.jsr.example.Customer;
+
+import javax.validation.Configuration;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.ConstraintValidatorFactory;
+import javax.validation.ConstraintViolation;
+import javax.validation.Validation;
+import javax.validation.ValidationException;
+import javax.validation.ValidationProviderResolver;
+import javax.validation.Validator;
+import javax.validation.ValidatorFactory;
+import javax.validation.bootstrap.ProviderSpecificBootstrap;
+import javax.validation.spi.ValidationProvider;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Locale;
+import java.util.Set;
+
+/**
+ * Description: <br/>
+ */
+public class BootstrapTest extends TestCase {
+    public void testDirectBootstrap() {
+        Validator validator = ApacheValidatorFactory.getDefault().getValidator();
+        Assert.assertNotNull(validator);
+        Assert.assertTrue(ApacheValidatorFactory.getDefault() == ApacheValidatorFactory.getDefault());
+    }
+
+    public void testEverydayBootstrap() {
+        ApacheValidatorFactory factory = (ApacheValidatorFactory) Validation.buildDefaultValidatorFactory();
+        Validator validator = factory.getValidator();
+        Assert.assertNotNull(validator);
+
+        // each call to Validation.getValidationBuilder() returns a new builder
+        // with new state
+        ApacheValidatorFactory factory2 = (ApacheValidatorFactory) Validation.buildDefaultValidatorFactory();
+        Assert.assertTrue(factory2 != factory);
+        Assert.assertTrue(factory2.getMessageInterpolator() != factory.getMessageInterpolator());
+
+    }
+
+    public void testLocalizedMessageInterpolatorFactory() {
+        Configuration<?> builder = Validation.byDefaultProvider().configure();
+        // changing the builder allows to create different factories
+        DefaultMessageInterpolator interpolator = new DefaultMessageInterpolator();
+        builder.messageInterpolator(interpolator);
+        ApacheValidatorFactory factory = (ApacheValidatorFactory) builder.buildValidatorFactory();
+
+        // ALTERNATIVE:
+        // you could do it without modifying the builder or reusing it,
+        // but then you need to use bval-core proprietary APIs:
+        ((DefaultMessageInterpolator) factory.getMessageInterpolator()).setLocale(Locale.ENGLISH);
+        // now factory's message resolver is using the english locale
+    }
+
+    /**
+     * some tests based on RI tested behaviors to ensure our implementation
+     * works as the reference implementation
+     */
+
+    public void testCustomConstraintFactory() {
+
+        Configuration<?> builder = Validation.byDefaultProvider().configure();
+        assertDefaultBuilderAndFactory(builder);
+
+        ValidatorFactory factory = builder.buildValidatorFactory();
+        Validator validator = factory.getValidator();
+
+        Customer customer = new Customer();
+        customer.setFirstName("John");
+
+        Set<ConstraintViolation<Customer>> ConstraintViolations = validator.validate(customer);
+        Assert.assertFalse(ConstraintViolations.isEmpty());
+
+        builder = Validation.byDefaultProvider().configure();
+        builder.constraintValidatorFactory(new ConstraintValidatorFactory() {
+            public <T extends ConstraintValidator<?, ?>> T getInstance(Class<T> key) {
+                if (key == NotNullValidator.class) {
+                    @SuppressWarnings("unchecked")
+                    final T result = (T) new BadlyBehavedNotNullValidator();
+                    return result;
+                }
+                return new DefaultConstraintValidatorFactory().getInstance(key);
+            }
+
+            public void releaseInstance(ConstraintValidator<?, ?> instance) {
+                // no-op
+            }
+        });
+        factory = builder.buildValidatorFactory();
+        validator = factory.getValidator();
+        Set<ConstraintViolation<Customer>> ConstraintViolations2 = validator.validate(customer);
+        Assert.assertTrue("Wrong number of constraints", ConstraintViolations.size() > ConstraintViolations2.size());
+    }
+
+    public void testCustomResolverAndType() {
+        ValidationProviderResolver resolver = new ValidationProviderResolver() {
+
+            public List<ValidationProvider<?>> getValidationProviders() {
+                List<ValidationProvider<?>> list = new ArrayList<ValidationProvider<?>>(1);
+                list.add(new ApacheValidationProvider());
+                return list;
+            }
+        };
+
+        ApacheValidatorConfiguration builder =
+            Validation.byProvider(ApacheValidationProvider.class).providerResolver(resolver).configure();
+        assertDefaultBuilderAndFactory(builder);
+    }
+
+    public void testCustomResolver() {
+        ValidationProviderResolver resolver = new ValidationProviderResolver() {
+
+            public List<ValidationProvider<?>> getValidationProviders() {
+                return Collections.<ValidationProvider<?>> singletonList(new ApacheValidationProvider());
+            }
+        };
+
+        Configuration<?> builder = Validation.byDefaultProvider().providerResolver(resolver).configure();
+        assertDefaultBuilderAndFactory(builder);
+    }
+
+    private void assertDefaultBuilderAndFactory(Configuration<?> builder) {
+        Assert.assertNotNull(builder);
+        Assert.assertTrue(builder instanceof ConfigurationImpl);
+
+        ValidatorFactory factory = builder.buildValidatorFactory();
+        Assert.assertNotNull(factory);
+        Assert.assertTrue(factory instanceof ApacheValidatorFactory);
+    }
+
+    public void testFailingCustomResolver() {
+        ValidationProviderResolver resolver = new ValidationProviderResolver() {
+
+            public List<ValidationProvider<?>> getValidationProviders() {
+                return Collections.emptyList();
+            }
+        };
+
+        ProviderSpecificBootstrap<ApacheValidatorConfiguration> type =
+            Validation.byProvider(ApacheValidationProvider.class);
+
+        final ProviderSpecificBootstrap<ApacheValidatorConfiguration> specializedBuilderFactory =
+            type.providerResolver(resolver);
+
+        try {
+            specializedBuilderFactory.configure();
+            Assert.fail();
+        } catch (ValidationException e) {
+            Assert.assertTrue("Wrong error message", e.getMessage().contains("provider")
+                && e.getMessage().contains("org.apache.bval.jsr.ApacheValidationProvider"));
+        }
+    }
+
+    class BadlyBehavedNotNullValidator extends NotNullValidator {
+        @Override
+        public boolean isValid(Object object, ConstraintValidatorContext context) {
+            return true;
+        }
+    }
+}

Added: bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/jsr/CircularReferencesTest.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/jsr/CircularReferencesTest.java?rev=1517540&view=auto
==============================================================================
--- bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/jsr/CircularReferencesTest.java (added)
+++ bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/jsr/CircularReferencesTest.java Mon Aug 26 13:59:15 2013
@@ -0,0 +1,120 @@
+/*
+ *  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.jsr;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import javax.validation.ConstraintViolation;
+import javax.validation.Valid;
+import javax.validation.Validation;
+import javax.validation.Validator;
+import javax.validation.ValidatorFactory;
+import javax.validation.constraints.Size;
+import java.util.Locale;
+import java.util.Set;
+
+/**
+ * Checks that circular references in the bean graph are correctly detected when
+ * validating.
+ * 
+ * @author Carlos Vara
+ */
+public class CircularReferencesTest extends TestCase {
+    static ValidatorFactory factory;
+
+    static {
+        factory = Validation.buildDefaultValidatorFactory();
+        ((DefaultMessageInterpolator) factory.getMessageInterpolator()).setLocale(Locale.ENGLISH);
+    }
+
+    /**
+     * Validator instance to test
+     */
+    protected Validator validator;
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        validator = createValidator();
+    }
+
+    /**
+     * Create the validator instance.
+     * 
+     * @return Validator
+     */
+    protected Validator createValidator() {
+        return factory.getValidator();
+    }
+
+    /**
+     * Checks that validation correctly stops when finding a circular
+     * dependency.
+     */
+    public void testAutoreferringBean() {
+        Person p1 = new Person();
+        p1.name = "too-long-name";
+        p1.sibling = p1;
+
+        Set<ConstraintViolation<Person>> violations = validator.validate(p1);
+
+        Assert.assertEquals("Only 1 violation should be reported", 1, violations.size());
+        ConstraintViolation<Person> violation = violations.iterator().next();
+        Assert.assertEquals("Incorrect violation path", "name", violation.getPropertyPath().toString());
+    }
+
+    /**
+     * Checks that a bean is always validated when appearing in non-circular
+     * paths inside the bean graph.
+     */
+    public void testNonCircularArrayOfSameBean() {
+        Boss boss = new Boss();
+        Person p1 = new Person();
+        p1.name = "too-long-name";
+
+        boss.employees = new Person[] { p1, p1, p1, p1 };
+
+        Set<ConstraintViolation<Boss>> violations = validator.validate(boss);
+
+        Assert.assertEquals("A total of 4 violations should be reported", 4, violations.size());
+    }
+
+    public static class Person {
+
+        @Valid
+        public Person sibling;
+
+        @Size(max = 10)
+        public String name;
+
+    }
+
+    public static class Boss {
+
+        @Valid
+        public Person[] employees;
+
+    }
+
+}



Mime
View raw message