Author: hardy.ferentschik
Date: 2009-08-27 07:47:24 -0400 (Thu, 27 Aug 2009)
New Revision: 17429
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/Error.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/ReservedElementNameTest.java
Removed:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/GroupIsNotAllowedAsElementNameTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/MessageIsNotAllowedAsElementNameTest.java
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/validation-GroupIsNotAllowedAsElementNameTest.xml
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/validation-MessageIsNotAllowedAsElementNameTest.xml
Modified:
beanvalidation/trunk/validation-api/src/test/resources/validation-mapping-1.0.xsd
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/XmlConfigurationTest.java
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints.xml
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/xml/XmlMappingParser.java
validator/trunk/hibernate-validator/src/main/xjb/binding-customization.xjb
validator/trunk/hibernate-validator/src/main/xsd/validation-mapping-1.0.xsd
Log:
Mapped the payload propagation test.
Modified:
beanvalidation/trunk/validation-api/src/test/resources/validation-mapping-1.0.xsd
===================================================================
---
beanvalidation/trunk/validation-api/src/test/resources/validation-mapping-1.0.xsd 2009-08-27
10:40:19 UTC (rev 17428)
+++
beanvalidation/trunk/validation-api/src/test/resources/validation-mapping-1.0.xsd 2009-08-27
11:47:24 UTC (rev 17429)
@@ -8,6 +8,11 @@
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"/>
@@ -46,6 +51,10 @@
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"
@@ -67,7 +76,10 @@
</xs:complexType>
<xs:complexType name="classType">
<xs:sequence>
- <xs:element type="groupSequenceType"
name="group-sequence" minOccurs="0"/>
+ <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"
Copied:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/Error.java
(from rev 17427,
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/Severity.java)
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/Error.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/Error.java 2009-08-27
11:47:24 UTC (rev 17429)
@@ -0,0 +1,27 @@
+// $Id:$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed 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.hibernate.jsr303.tck.tests.xmlconfiguration;
+
+import javax.validation.Payload;
+
+/**
+ * @author Hardy Ferentschik
+ */
+
+public class Error implements Payload {
+}
\ No newline at end of file
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/XmlConfigurationTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/XmlConfigurationTest.java 2009-08-27
10:40:19 UTC (rev 17428)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/XmlConfigurationTest.java 2009-08-27
11:47:24 UTC (rev 17429)
@@ -21,6 +21,7 @@
import java.util.Set;
import javax.validation.Configuration;
import javax.validation.ConstraintViolation;
+import javax.validation.Payload;
import javax.validation.Validator;
import javax.validation.constraints.Pattern;
import javax.validation.metadata.BeanDescriptor;
@@ -60,7 +61,6 @@
destination =
"WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/order-constraints-XmlConfigurationTest.xml")
}
)
-
public class XmlConfigurationTest extends AbstractTest {
@Test
@@ -82,6 +82,11 @@
constraintViolations, "Message from xml"
);
+ ConstraintViolation<User> constraintViolation =
constraintViolations.iterator().next();
+ Set<Class<Payload>> payloads =
constraintViolation.getConstraintDescriptor().getPayload();
+ assertTrue( payloads.size() == 1, "One one payload class is defined in xml"
);
+ assertTrue( Error.class.equals( payloads.iterator().next() ) );
+
user.setConsistent( true );
constraintViolations = validator.validate( user );
assertCorrectNumberOfViolations( constraintViolations, 0 );
Deleted:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/GroupIsNotAllowedAsElementNameTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/GroupIsNotAllowedAsElementNameTest.java 2009-08-27
10:40:19 UTC (rev 17428)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/GroupIsNotAllowedAsElementNameTest.java 2009-08-27
11:47:24 UTC (rev 17429)
@@ -1,57 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed 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.hibernate.jsr303.tck.tests.xmlconfiguration.constraintdeclaration;
-
-
-import javax.validation.ValidationException;
-
-import org.jboss.test.audit.annotations.SpecAssertion;
-import org.jboss.testharness.AbstractTest;
-import org.jboss.testharness.impl.packaging.Artifact;
-import org.jboss.testharness.impl.packaging.ArtifactType;
-import org.jboss.testharness.impl.packaging.Classes;
-import org.jboss.testharness.impl.packaging.Resource;
-import org.jboss.testharness.impl.packaging.jsr303.ValidationXml;
-import static org.testng.Assert.fail;
-import org.testng.annotations.Test;
-
-import org.hibernate.jsr303.tck.util.TestUtil;
-import org.hibernate.jsr303.tck.tests.constraints.groups.User;
-
-/**
- * @author Hardy Ferentschik
- */
-@Artifact(artifactType = ArtifactType.JSR303)
-@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
-@ValidationXml(value = "validation-GroupIsNotAllowedAsElementNameTest.xml")
-@Resource(source = "constraints-GroupIsNotAllowedAsElementNameTest.xml",
- destination =
"WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/constraints-GroupIsNotAllowedAsElementNameTest.xml")
-public class GroupIsNotAllowedAsElementNameTest extends AbstractTest {
-
- @Test
- @SpecAssertion(section = "7.1.1.4", id = "b")
- public void testGroupIsNotAllowedAsElementName() {
- try {
- TestUtil.getValidatorUnderTest();
- fail("Validator creation should have failed since <element
name=\"groups\"> was used.");
- }
- catch ( ValidationException e ) {
- // success
- }
- }
-}
\ No newline at end of file
Deleted:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/MessageIsNotAllowedAsElementNameTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/MessageIsNotAllowedAsElementNameTest.java 2009-08-27
10:40:19 UTC (rev 17428)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/MessageIsNotAllowedAsElementNameTest.java 2009-08-27
11:47:24 UTC (rev 17429)
@@ -1,56 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed 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.hibernate.jsr303.tck.tests.xmlconfiguration.constraintdeclaration;
-
-
-import javax.validation.ValidationException;
-
-import org.jboss.test.audit.annotations.SpecAssertion;
-import org.jboss.testharness.AbstractTest;
-import org.jboss.testharness.impl.packaging.Artifact;
-import org.jboss.testharness.impl.packaging.ArtifactType;
-import org.jboss.testharness.impl.packaging.Classes;
-import org.jboss.testharness.impl.packaging.Resource;
-import org.jboss.testharness.impl.packaging.jsr303.ValidationXml;
-import static org.testng.Assert.fail;
-import org.testng.annotations.Test;
-
-import org.hibernate.jsr303.tck.util.TestUtil;
-
-/**
- * @author Hardy Ferentschik
- */
-@Artifact(artifactType = ArtifactType.JSR303)
-@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
-@ValidationXml(value = "validation-MessageIsNotAllowedAsElementNameTest.xml")
-@Resource(source = "constraints-MessageIsNotAllowedAsElementNameTest.xml",
- destination =
"WEB-INF/classes/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/constraints-MessageIsNotAllowedAsElementNameTest.xml")
-public class MessageIsNotAllowedAsElementNameTest extends AbstractTest {
-
- @Test
- @SpecAssertion(section = "7.1.1.4", id = "b")
- public void testMessageIsNotAllowedAsElementName() {
- try {
- TestUtil.getValidatorUnderTest();
- fail("Validator creation should have failed since <element
name=\"message\"> was used.");
- }
- catch ( ValidationException e ) {
- // success
- }
- }
-}
\ No newline at end of file
Copied:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/ReservedElementNameTest.java
(from rev 17426,
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/GroupIsNotAllowedAsElementNameTest.java)
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/ReservedElementNameTest.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/ReservedElementNameTest.java 2009-08-27
11:47:24 UTC (rev 17429)
@@ -0,0 +1,81 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed 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.hibernate.jsr303.tck.tests.xmlconfiguration.constraintdeclaration;
+
+
+import javax.validation.Configuration;
+import javax.validation.ValidationException;
+
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.testharness.AbstractTest;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.ArtifactType;
+import org.jboss.testharness.impl.packaging.Classes;
+import org.jboss.testharness.impl.packaging.Resource;
+import org.jboss.testharness.impl.packaging.Resources;
+import static org.testng.Assert.fail;
+import org.testng.annotations.Test;
+
+import org.hibernate.jsr303.tck.util.TestUtil;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Artifact(artifactType = ArtifactType.JSR303)
+@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
+@Resources({
+ @Resource(source = ReservedElementNameTest.mappingFile1,
+ destination = "WEB-INF/classes" + ReservedElementNameTest.packageName +
ReservedElementNameTest.mappingFile1),
+ @Resource(source = ReservedElementNameTest.mappingFile2,
+ destination = "WEB-INF/classes" + ReservedElementNameTest.packageName +
ReservedElementNameTest.mappingFile2)
+})
+public class ReservedElementNameTest extends AbstractTest {
+
+ public final static String packageName =
"/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/";
+ public final static String mappingFile1 =
"constraints-GroupIsNotAllowedAsElementNameTest.xml";
+ public final static String mappingFile2 =
"constraints-MessageIsNotAllowedAsElementNameTest.xml";
+
+ @Test
+ @SpecAssertion(section = "7.1.1.4", id = "b")
+ public void testGroupIsNotAllowedAsElementName() {
+ try {
+ Configuration<?> config = TestUtil.getConfigurationUnderTest();
+ config.addMapping( TestUtil.getInputStreamForPath( packageName + mappingFile1 ) );
+ config.buildValidatorFactory().getValidator();
+ fail( "Validator creation should have failed since <element
name=\"groups\"> was used." );
+ }
+ catch ( ValidationException e ) {
+ // success
+ }
+ }
+
+ @Test
+ @SpecAssertion(section = "7.1.1.4", id = "b")
+ public void testMessageIsNotAllowedAsElementName() {
+ try {
+ Configuration<?> config = TestUtil.getConfigurationUnderTest();
+ config.addMapping( TestUtil.getInputStreamForPath( packageName + mappingFile2 ) );
+ config.buildValidatorFactory().getValidator();
+ fail( "Validator creation should have failed since <element
name=\"message\"> was used." );
+ }
+ catch ( ValidationException e ) {
+ // success
+ System.err.println( e.getMessage() );
+ }
+ }
+}
\ No newline at end of file
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/ReservedElementNameTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Deleted:
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/validation-GroupIsNotAllowedAsElementNameTest.xml
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/validation-GroupIsNotAllowedAsElementNameTest.xml 2009-08-27
10:40:19 UTC (rev 17428)
+++
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/validation-GroupIsNotAllowedAsElementNameTest.xml 2009-08-27
11:47:24 UTC (rev 17429)
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<validation-config
xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
-
xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configu...
validation-configuration-1.0.xsd"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <constraint-mapping>
-
/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/constraints-GroupIsNotAllowedAsElementNameTest.xml
- </constraint-mapping>
-</validation-config>
\ No newline at end of file
Deleted:
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/validation-MessageIsNotAllowedAsElementNameTest.xml
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/validation-MessageIsNotAllowedAsElementNameTest.xml 2009-08-27
10:40:19 UTC (rev 17428)
+++
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/validation-MessageIsNotAllowedAsElementNameTest.xml 2009-08-27
11:47:24 UTC (rev 17429)
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<validation-config
xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
-
xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configu...
validation-configuration-1.0.xsd"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-
<constraint-mapping>/org/hibernate/jsr303/tck/tests/xmlconfiguration/constraintdeclaration/constraints-MessageIsNotAllowedAsElementNameTest.xml</constraint-mapping>
-</validation-config>
\ No newline at end of file
Modified:
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints.xml
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints.xml 2009-08-27
10:40:19 UTC (rev 17428)
+++
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/user-constraints.xml 2009-08-27
11:47:24 UTC (rev 17429)
@@ -13,6 +13,9 @@
<groups>
<value>javax.validation.groups.Default</value>
</groups>
+ <payload>
+
<value>org.hibernate.jsr303.tck.tests.xmlconfiguration.Error</value>
+ </payload>
<element name="stringParam">foobar</element>
<element
name="classParam">java.lang.String</element>
<element name="stringArrayParam">
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/xml/XmlMappingParser.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/xml/XmlMappingParser.java 2009-08-27
10:40:19 UTC (rev 17428)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/xml/XmlMappingParser.java 2009-08-27
11:47:24 UTC (rev 17429)
@@ -27,6 +27,7 @@
import java.net.URL;
import java.security.AccessController;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -35,6 +36,7 @@
import java.util.Set;
import javax.validation.Constraint;
import javax.validation.ConstraintValidator;
+import javax.validation.Payload;
import javax.validation.ValidationException;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
@@ -71,6 +73,7 @@
private static final String VALIDATION_MAPPING_XSD =
"META-INF/validation-mapping-1.0.xsd";
private static final String MESSAGE_PARAM = "message";
private static final String GROUPS_PARAM = "groups";
+ private static final String PAYLOAD_PARAM = "payload";
private static final String PACKAGE_SEPARATOR = ".";
private final Set<Class<?>> processedClasses = new
HashSet<Class<?>>();
@@ -120,7 +123,7 @@
if ( constraintMap.containsKey( beanClass ) ) {
for ( MetaConstraint<?, ? extends Annotation> metaConstraint :
constraintMap.get( beanClass ) ) {
@SuppressWarnings("unchecked") // safe cast since the list of meta
constraints is always specific to the bean type
- MetaConstraint<T, ? extends Annotation> boundMetaConstraint = (
MetaConstraint<T, ? extends Annotation> ) metaConstraint;
+ MetaConstraint<T, ? extends Annotation> boundMetaConstraint = (
MetaConstraint<T, ? extends Annotation> ) metaConstraint;
list.add( boundMetaConstraint );
}
return list;
@@ -203,13 +206,7 @@
Class<? extends ConstraintValidator<?, ?>>[] validatedBy = annotationType
.getAnnotation( Constraint.class )
.validatedBy();
- for ( Class<? extends ConstraintValidator<?, ?>> validator : validatedBy )
{
- //FIXME does this create a CCE at runtime?
- //FIXME if yes wrap into VE, if no we need to test the type here
- //Once resolved,we can @SuppressWarning("unchecked") on the cast
- Class<? extends ConstraintValidator<? extends Annotation, ?>>
safeValidator = validator;
- constraintValidatorDefinitionClasses.add( safeValidator );
- }
+ constraintValidatorDefinitionClasses.addAll( Arrays.asList( validatedBy ) );
}
return constraintValidatorDefinitionClasses;
}
@@ -387,6 +384,7 @@
annotationDescriptor.setValue( MESSAGE_PARAM, constraint.getMessage() );
}
annotationDescriptor.setValue( GROUPS_PARAM, getGroups( constraint.getGroups(),
defaultPackage ) );
+ annotationDescriptor.setValue( PAYLOAD_PARAM, getPayload( constraint.getPayload(),
defaultPackage ) );
for ( ElementType elementType : constraint.getElement() ) {
String name = elementType.getName();
@@ -589,7 +587,7 @@
private void checkNameIsValid(String name) {
if ( MESSAGE_PARAM.equals( name ) || GROUPS_PARAM.equals( name ) ) {
- throw new ValidationException( MESSAGE_PARAM + " and " + GROUPS_PARAM +
" are reserved parameter names." );
+ throw new ValidationException( MESSAGE_PARAM + ", " + GROUPS_PARAM + ",
" + PAYLOAD_PARAM + " are reserved parameter names." );
}
}
@@ -605,6 +603,25 @@
return groupList.toArray( new Class[groupList.size()] );
}
+ @SuppressWarnings("unchecked")
+ private Class<? extends Payload>[] getPayload(PayloadType payloadType, String
defaultPackage) {
+ if ( payloadType == null ) {
+ return new Class[] { };
+ }
+
+ List<Class<? extends Payload>> payloadList = new ArrayList<Class<?
extends Payload>>();
+ for ( JAXBElement<String> groupClass : payloadType.getValue() ) {
+ Class<?> payload = getClass( groupClass.getValue(), defaultPackage );
+ if ( !Payload.class.isAssignableFrom( payload ) ) {
+ throw new ValidationException( "Specified payload class " +
payload.getName() + " does not implement javax.validation.Payload" );
+ }
+ else {
+ payloadList.add( ( Class<? extends Payload> ) payload );
+ }
+ }
+ return payloadList.toArray( new Class[payloadList.size()] );
+ }
+
private Class<?> getClass(String clazz, String defaultPackage) {
String fullyQualifiedClass;
if ( isQualifiedClass( clazz ) ) {
Modified: validator/trunk/hibernate-validator/src/main/xjb/binding-customization.xjb
===================================================================
--- validator/trunk/hibernate-validator/src/main/xjb/binding-customization.xjb 2009-08-27
10:40:19 UTC (rev 17428)
+++ validator/trunk/hibernate-validator/src/main/xjb/binding-customization.xjb 2009-08-27
11:47:24 UTC (rev 17429)
@@ -7,7 +7,7 @@
adapter="javax.xml.bind.annotation.adapters.CollapsedStringAdapter"/>
</jxb:globalBindings>
- <jxb:bindings
node="//xs:complexType[8]/xs:sequence[1]/xs:element[1]">
+ <jxb:bindings
node="//xs:complexType[9]/xs:sequence[1]/xs:element[1]">
<jxb:property name="classType"/>
</jxb:bindings>
</jxb:bindings>
Modified: validator/trunk/hibernate-validator/src/main/xsd/validation-mapping-1.0.xsd
===================================================================
--- validator/trunk/hibernate-validator/src/main/xsd/validation-mapping-1.0.xsd 2009-08-27
10:40:19 UTC (rev 17428)
+++ validator/trunk/hibernate-validator/src/main/xsd/validation-mapping-1.0.xsd 2009-08-27
11:47:24 UTC (rev 17429)
@@ -2,13 +2,17 @@
<xs:schema attributeFormDefault="unqualified"
elementFormDefault="qualified"
targetNamespace="http://jboss.org/xml/ns/javax/validation/mapping"
-
xmlns="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"/>
@@ -47,6 +51,10 @@
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"
@@ -68,7 +76,10 @@
</xs:complexType>
<xs:complexType name="classType">
<xs:sequence>
- <xs:element type="groupSequenceType"
name="group-sequence" minOccurs="0"/>
+ <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"