Hibernate SVN: r17436 - beanvalidation/tags.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-08-27 10:32:41 -0400 (Thu, 27 Aug 2009)
New Revision: 17436
Added:
beanvalidation/tags/v1_0_CR5/
Log:
[maven-scm] copy for tag v1_0_CR5
Copied: beanvalidation/tags/v1_0_CR5 (from rev 17435, beanvalidation/trunk/validation-api)
15 years, 1 month
Hibernate SVN: r17434 - beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition and 3 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-08-27 10:29:06 -0400 (Thu, 27 Aug 2009)
New Revision: 17434
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/metadata/ConstraintDescriptor.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/ConstraintDescriptorTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/XmlConfigurationTest.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/metadata/ConstraintDescriptorImpl.java
Log:
Changed Set<Class<Payload>> getPayload() to Set<Class<? extends Payload>> getPayload() in ConstraintDescriptor
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/metadata/ConstraintDescriptor.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/metadata/ConstraintDescriptor.java 2009-08-27 14:10:59 UTC (rev 17433)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/metadata/ConstraintDescriptor.java 2009-08-27 14:29:06 UTC (rev 17434)
@@ -55,7 +55,7 @@
*
* @return payload classes hosted on the constraint or an empty set if none.
*/
- Set<Class<Payload>> getPayload();
+ Set<Class<? extends Payload>> getPayload();
/**
* Immutable list of the constraint validation implementation classes.
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionTest.java 2009-08-27 14:10:59 UTC (rev 17433)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionTest.java 2009-08-27 14:29:06 UTC (rev 17434)
@@ -239,11 +239,11 @@
@SpecAssertion(section = "2.3", id = "j"),
@SpecAssertion(section = "2.3", id = "o")
})
- public void testOverridenAttributesMustMatchInType() {
+ public void testOverriddenAttributesMustMatchInType() {
Validator validator = TestUtil.getValidatorUnderTest();
try {
validator.validate( new DummyEntityWithZipCode( "foobar" ) );
- fail( "Wrong atttibute override in composite constraint. An Exception should have been thrown." );
+ fail( "Wrong attribute override in composite constraint. An Exception should have been thrown." );
}
catch ( ConstraintDefinitionException e ) {
// success
@@ -275,10 +275,10 @@
assertCorrectConstraintTypes( constraintViolations, NotNull.class );
ConstraintViolation<Friend> constraintViolation = constraintViolations.iterator().next();
- Set<Class<Payload>> payloads = constraintViolation.getConstraintDescriptor().getPayload();
+ Set<Class<? extends Payload>> payloads = constraintViolation.getConstraintDescriptor().getPayload();
assertTrue( payloads.size() == 1, "There should be one payload in the set" );
- Class<Payload> payload = payloads.iterator().next();
+ Class<? extends Payload> payload = payloads.iterator().next();
assertTrue( payload.getName().equals( Severity.Warn.class.getName() ), "Unexpected payload" );
}
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/ConstraintDescriptorTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/ConstraintDescriptorTest.java 2009-08-27 14:10:59 UTC (rev 17433)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/ConstraintDescriptorTest.java 2009-08-27 14:29:06 UTC (rev 17434)
@@ -68,16 +68,16 @@
@SpecAssertion(section = "5.5", id = "a"),
@SpecAssertion(section = "5.5", id = "c")
})
- public void testAnnotationAndMapParamtersReflectParamterOverriding() {
+ public void testAnnotationAndMapParametersReflectParameterOverriding() {
ConstraintDescriptor<?> descriptor = getConstraintDescriptor( Person.class, "firstName" );
Set<ConstraintDescriptor<?>> composingDescriptors = descriptor.getComposingConstraints();
assertEquals( composingDescriptors.size(), 2, "Wrong number of composing constraints" );
for ( ConstraintDescriptor<?> desc : composingDescriptors ) {
if ( desc.getAnnotation().annotationType().equals( Size.class ) ) {
Size sizeAnn = ( Size ) desc.getAnnotation();
- assertEquals( sizeAnn.min(), 5, "The min parameter should reflect the overriden parameter" );
+ assertEquals( sizeAnn.min(), 5, "The min parameter should reflect the overridden parameter" );
assertEquals(
- desc.getAttributes().get( "min" ), 5, "The min parameter should reflect the overriden parameter"
+ desc.getAttributes().get( "min" ), 5, "The min parameter should reflect the overridden parameter"
);
}
else if ( desc.getAnnotation().annotationType().equals( NotNull.class ) ) {
@@ -117,7 +117,7 @@
@Test
@SpecAssertion(section = "5.5", id = "d")
- public void testGetGroupsWithImplcitGroup() {
+ public void testGetGroupsWithImplicitGroup() {
ConstraintDescriptor<?> descriptor = getConstraintDescriptor( Man.class, "lastName" );
Set<Class<?>> groups = descriptor.getGroups();
assertTrue( groups.size() == 2 );
@@ -153,7 +153,7 @@
@SpecAssertion(section = "5.5", id = "g")
public void testPayload() {
ConstraintDescriptor<?> descriptor = getConstraintDescriptor( Person.class, "firstName" );
- Set<Class<Payload>> payload = descriptor.getPayload();
+ Set<Class<? extends Payload>> payload = descriptor.getPayload();
assertTrue( payload.size() == 1 );
assertEquals( payload.iterator().next(), Severity.Info.class, "Wrong payload" );
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 14:10:59 UTC (rev 17433)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/XmlConfigurationTest.java 2009-08-27 14:29:06 UTC (rev 17434)
@@ -83,7 +83,7 @@
);
ConstraintViolation<User> constraintViolation = constraintViolations.iterator().next();
- Set<Class<Payload>> payloads = constraintViolation.getConstraintDescriptor().getPayload();
+ Set<Class<? extends Payload>> payloads = constraintViolation.getConstraintDescriptor().getPayload();
assertTrue( payloads.size() == 1, "One one payload class is defined in xml" );
assertTrue( Error.class.equals( payloads.iterator().next() ) );
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/metadata/ConstraintDescriptorImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/metadata/ConstraintDescriptorImpl.java 2009-08-27 14:10:59 UTC (rev 17433)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/metadata/ConstraintDescriptorImpl.java 2009-08-27 14:29:06 UTC (rev 17434)
@@ -83,7 +83,7 @@
*/
private final Map<String, Object> attributes;
- private final Set<Class<Payload>> payloads;
+ private final Set<Class<? extends Payload>> payloads;
/**
* The composing constraints for this constraints.
@@ -120,8 +120,8 @@
this( annotation, constraintHelper, null );
}
- private Set<Class<Payload>> buildPayloadSet(T annotation) {
- Set<Class<Payload>> payloadSet = new HashSet<Class<Payload>>();
+ private Set<Class<? extends Payload>> buildPayloadSet(T annotation) {
+ Set<Class<? extends Payload>> payloadSet = new HashSet<Class<? extends Payload>>();
Class<Payload>[] payloadFromAnnotation;
try {
//TODO be extra safe and make sure this is an array of Payload
@@ -216,7 +216,7 @@
return groups;
}
- public Set<Class<Payload>> getPayload() {
+ public Set<Class< ? extends Payload>> getPayload() {
return payloads;
}
15 years, 1 month
Hibernate SVN: r17433 - beanvalidation/trunk/validation-api.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-08-27 10:10:59 -0400 (Thu, 27 Aug 2009)
New Revision: 17433
Modified:
beanvalidation/trunk/validation-api/pom.xml
Log:
[maven-release-plugin] rollback the release of hv1_0_CR5
Modified: beanvalidation/trunk/validation-api/pom.xml
===================================================================
--- beanvalidation/trunk/validation-api/pom.xml 2009-08-27 13:45:05 UTC (rev 17432)
+++ beanvalidation/trunk/validation-api/pom.xml 2009-08-27 14:10:59 UTC (rev 17433)
@@ -4,7 +4,7 @@
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
- <version>1.0.CR6-SNAPSHOT</version>
+ <version>1.0.CR5-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Bean Validation API</name>
15 years, 1 month
Hibernate SVN: r17431 - beanvalidation/tags.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-08-27 09:44:57 -0400 (Thu, 27 Aug 2009)
New Revision: 17431
Added:
beanvalidation/tags/hv1_0_CR5/
Log:
[maven-scm] copy for tag hv1_0_CR5
Copied: beanvalidation/tags/hv1_0_CR5 (from rev 17430, beanvalidation/trunk/validation-api)
15 years, 1 month
Hibernate SVN: r17429 - beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration and 6 other directories.
by hibernate-commits@lists.jboss.org
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/configuration 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/configuration 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"
15 years, 1 month
Hibernate SVN: r17428 - in beanvalidation/trunk/validation-tck/src/main: resources and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-08-27 06:40:19 -0400 (Thu, 27 Aug 2009)
New Revision: 17428
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/Name.java
beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
Log:
Mapped the payload propagation test.
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionTest.java 2009-08-27 09:47:28 UTC (rev 17427)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionTest.java 2009-08-27 10:40:19 UTC (rev 17428)
@@ -264,6 +264,7 @@
}
@Test
+ @SpecAssertion(section = "2.3", id = "p")
public void testPayloadPropagationInComposedConstraints() {
Friend john = new Friend( "John", "Doe" );
@@ -281,7 +282,6 @@
assertTrue( payload.getName().equals( Severity.Warn.class.getName() ), "Unexpected payload" );
}
-
private FrenchAddress getFrenchAddressWithoutZipCode() {
FrenchAddress address = new FrenchAddress();
address.setAddressline1( "10 rue des Treuils" );
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/Name.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/Name.java 2009-08-27 09:47:28 UTC (rev 17427)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/Name.java 2009-08-27 10:40:19 UTC (rev 17428)
@@ -33,7 +33,7 @@
* @author Hardy Ferentschik
*/
@Documented
-@NotNull
+@NotNull(payload = Severity.Error.class)
@Size
@Constraint(validatedBy = { })
@Target({ TYPE, METHOD, FIELD })
Modified: beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-08-27 09:47:28 UTC (rev 17427)
+++ beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-08-27 10:40:19 UTC (rev 17428)
@@ -58,7 +58,7 @@
<text>The default value for the payload parameter must be an empty array. </text>
</assertion>
<assertion id="j">
- <text>Each attachable payload extends ConstraintPayload. </text>
+ <text>Each attachable payload extends Payload. </text>
</assertion>
</section>
@@ -135,6 +135,9 @@
ConstraintDefinitionException is raised either at validation time or when the
metadata is requested</text>
</assertion>
+ <assertion id="p">
+ <text>Any payload definition on a composing annotation is ignored</text>
+ </assertion>
</section>
<section id="2.4" title="Constraint validation implementation">
<assertion id="a">
15 years, 1 month