Author: hardy.ferentschik
Date: 2009-07-01 07:20:24 -0400 (Wed, 01 Jul 2009)
New Revision: 16985
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/Shoe.java
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionTest.java
Log:
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-06-30
16:51:13 UTC (rev 16984)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionTest.java 2009-07-01
11:20:24 UTC (rev 16985)
@@ -24,6 +24,7 @@
import javax.validation.ConstraintDefinitionException;
import javax.validation.ConstraintViolation;
import javax.validation.Validator;
+import javax.validation.UnexpectedTypeException;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
@@ -245,6 +246,19 @@
}
}
+ @Test
+ @SpecAssertion(section = "2.3", id = "f")
+ public void testAllComposingConstraintsMustBeApplicableToAnnotatedType() {
+ Validator validator = TestUtil.getDefaultValidator();
+ try {
+ validator.validate( new Shoe( 41 ) );
+ fail( "Shoe defines @NotEmpty on an int. Validation should have failed." );
+ }
+ catch ( UnexpectedTypeException e ) {
+ // success
+ }
+ }
+
private FrenchAddress getFrenchAddressWithoutZipCode() {
FrenchAddress address = new FrenchAddress();
address.setAddressline1( "10 rue des Treuils" );
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/Shoe.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/Shoe.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/Shoe.java 2009-07-01
11:20:24 UTC (rev 16985)
@@ -0,0 +1,30 @@
+// $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.constraints.constraintcomposition;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class Shoe {
+ @NotEmpty
+ int size;
+
+ public Shoe(int size) {
+ this.size = size;
+ }
+}