Author: hardy.ferentschik
Date: 2009-08-19 10:38:34 -0400 (Wed, 19 Aug 2009)
New Revision: 17361
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/MessageInterpolatorSpecifiedInValidationXmlTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/XmlConfigurationTest.java
Log:
xml mapping tests
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/MessageInterpolatorSpecifiedInValidationXmlTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/MessageInterpolatorSpecifiedInValidationXmlTest.java 2009-08-19
14:38:01 UTC (rev 17360)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/MessageInterpolatorSpecifiedInValidationXmlTest.java 2009-08-19
14:38:34 UTC (rev 17361)
@@ -75,7 +75,8 @@
public void testMessageInterpolatorSpecifiedInValidationXmlCanBeOverridden() {
Configuration<?> configuration = Validation
.byDefaultProvider()
- .configure().messageInterpolator( new ConfigurationDefinedMessageInterpolator() );
+ .configure();
+ configuration = configuration.messageInterpolator( new
ConfigurationDefinedMessageInterpolator() );
Validator validator = configuration.buildValidatorFactory().getValidator();
User user = new User();
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-19
14:38:01 UTC (rev 17360)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/XmlConfigurationTest.java 2009-08-19
14:38:34 UTC (rev 17361)
@@ -21,6 +21,9 @@
import javax.validation.Configuration;
import javax.validation.ConstraintViolation;
import javax.validation.Validator;
+import javax.validation.constraints.Pattern;
+import javax.validation.metadata.BeanDescriptor;
+import javax.validation.metadata.ConstraintDescriptor;
import org.jboss.test.audit.annotations.SpecAssertion;
import org.jboss.test.audit.annotations.SpecAssertions;
@@ -31,6 +34,8 @@
import org.jboss.testharness.impl.packaging.Resource;
import org.jboss.testharness.impl.packaging.Resources;
import org.jboss.testharness.impl.packaging.jsr303.ValidationXml;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test;
import org.hibernate.jsr303.tck.util.TestUtil;
@@ -57,6 +62,7 @@
@SpecAssertions({
@SpecAssertion(section = "4.4.6", id = "a"),
@SpecAssertion(section = "4.4.6", id = "l"),
+ @SpecAssertion(section = "4.4.6", id = "k"),
@SpecAssertion(section = "7.1.1", id = "a"),
@SpecAssertion(section = "7.1.2", id = "a")
})
@@ -79,6 +85,7 @@
@SpecAssertions({
@SpecAssertion(section = "4.4.6", id = "b"),
@SpecAssertion(section = "4.4.6", id = "l"),
+ @SpecAssertion(section = "4.4.6", id = "k"),
@SpecAssertion(section = "7.1.1", id = "a"),
@SpecAssertion(section = "7.1.2", id = "a")
})
@@ -95,6 +102,7 @@
@SpecAssertions({
@SpecAssertion(section = "4.4.6", id = "a"),
@SpecAssertion(section = "4.4.6", id = "l"),
+ @SpecAssertion(section = "4.4.6", id = "k"),
@SpecAssertion(section = "7.1.1", id = "a"),
@SpecAssertion(section = "7.1.2", id = "a")
})
@@ -118,6 +126,7 @@
@SpecAssertions({
@SpecAssertion(section = "4.4.6", id = "a"),
@SpecAssertion(section = "4.4.6", id = "l"),
+ @SpecAssertion(section = "4.4.6", id = "k"),
@SpecAssertion(section = "7.1.1", id = "a"),
@SpecAssertion(section = "7.1.2", id = "a")
})
@@ -144,6 +153,7 @@
@SpecAssertions({
@SpecAssertion(section = "4.4.6", id = "a"),
@SpecAssertion(section = "4.4.6", id = "l"),
+ @SpecAssertion(section = "4.4.6", id = "k"),
@SpecAssertion(section = "7.1.1", id = "a"),
@SpecAssertion(section = "7.1.2", id = "a")
})
@@ -169,6 +179,7 @@
@SpecAssertions({
@SpecAssertion(section = "4.4.6", id = "a"),
@SpecAssertion(section = "4.4.6", id = "l"),
+ @SpecAssertion(section = "4.4.6", id = "k"),
@SpecAssertion(section = "7.1.1", id = "a"),
@SpecAssertion(section = "7.1.2", id = "a")
})
@@ -189,4 +200,25 @@
constraintViolations = validator.validate( user );
assertCorrectNumberOfViolations( constraintViolations, 0 );
}
+
+ @Test
+ @SpecAssertion(section = "7.1", id = "a")
+ public void testXmlConfiguredConstraintExposesCorrespondingAnnotationViaMetadata() {
+ Validator validator = TestUtil.getValidatorUnderTest();
+
+
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( User.class );
+ Set<ConstraintDescriptor<?>> constraintDescriptors =
beanDescriptor.getConstraintDescriptors();
+ assertEquals( constraintDescriptors.size(), 1, "There should be one class level
constraint defined in xml" );
+
+ ConstraintDescriptor<?> descriptor = constraintDescriptors.iterator().next();
+ assertTrue( descriptor.getAnnotation() instanceof ConsistentUserInformation );
+
+
+ constraintDescriptors = beanDescriptor.getConstraintsForProperty( "lastname"
)
+ .getConstraintDescriptors();
+ assertEquals( constraintDescriptors.size(), 1, "There should be one constraint
defined in xml for 'lastname'" );
+ descriptor = constraintDescriptors.iterator().next();
+ assertTrue( descriptor.getAnnotation() instanceof Pattern );
+ }
}