Author: hardy.ferentschik
Date: 2009-08-20 09:13:36 -0400 (Thu, 20 Aug 2009)
New Revision: 17375
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/ConfigurationDefinedConstraintValidatorFactoryResolver.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/ConstraintValidatorFactorySpecifiedInValidationXmlTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/TRaversableResolverSpecifiedInValidationXmlNoDefaultConstructorTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/XmlDefinedConstraintValidatorFactory.java
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-ConstraintValidatorFactorySpecifiedInValidationXmlTest.xml
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-TraversableResolverSpecifiedInValidationXmlNoDefaultConstructorTest.xml
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/MessageInterpolatorSpecifiedInValidationXmlNoDefaultConstructorTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/XmlDefinedTraversableResolver.java
Log:
xml tests
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/ConfigurationDefinedConstraintValidatorFactoryResolver.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/ConfigurationDefinedConstraintValidatorFactoryResolver.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/ConfigurationDefinedConstraintValidatorFactoryResolver.java 2009-08-20
13:13:36 UTC (rev 17375)
@@ -0,0 +1,34 @@
+// $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.ConstraintValidator;
+import javax.validation.ConstraintValidatorFactory;
+import javax.validation.ValidationException;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class ConfigurationDefinedConstraintValidatorFactoryResolver implements
ConstraintValidatorFactory {
+ public static int numberOfIsReachableCalls = 0;
+
+ public <T extends ConstraintValidator<?, ?>> T getInstance(Class<T>
key) {
+ numberOfIsReachableCalls++;
+ throw new ValidationException( "Exception in
ConfigurationDefinedConstraintValidatorFactoryResolver" );
+ }
+}
\ No newline at end of file
Copied:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/ConstraintValidatorFactorySpecifiedInValidationXmlTest.java
(from rev 17374,
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/TraversableResolverSpecifiedInValidationXmlTest.java)
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/ConstraintValidatorFactorySpecifiedInValidationXmlTest.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/ConstraintValidatorFactorySpecifiedInValidationXmlTest.java 2009-08-20
13:13:36 UTC (rev 17375)
@@ -0,0 +1,92 @@
+// $Id: InvalidXmlConfigurationTest.java 17352 2009-08-18 17:08:59Z hardy.ferentschik $
+/*
+* 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.Configuration;
+import javax.validation.Validation;
+import javax.validation.ValidationException;
+import javax.validation.Validator;
+
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecAssertions;
+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.jsr303.ValidationXml;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
+
+import org.hibernate.jsr303.tck.common.TCKValidationProvider;
+import org.hibernate.jsr303.tck.common.TCKValidatorConfiguration;
+import org.hibernate.jsr303.tck.util.TestUtil;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Artifact(artifactType = ArtifactType.JSR303)
+@Classes({
+ TestUtil.class,
+ TestUtil.PathImpl.class,
+ TestUtil.NodeImpl.class,
+ TCKValidationProvider.class,
+ TCKValidatorConfiguration.class,
+ TCKValidationProvider.DummyValidatorFactory.class
+})
+@ValidationXml(value =
"validation-ConstraintValidatorFactorySpecifiedInValidationXmlTest.xml")
+public class ConstraintValidatorFactorySpecifiedInValidationXmlTest extends AbstractTest
{
+
+ @Test
+ @SpecAssertion(section = "4.4.6", id = "i")
+ public void testConstraintValidatorFactorySpecifiedInValidationXml() {
+ try {
+ Validator validator = TestUtil.getValidatorUnderTest();
+ validator.validate( new User() );
+ }
+ catch ( ValidationException e ) {
+ assertTrue(
+ XmlDefinedConstraintValidatorFactory.numberOfIsReachableCalls > 0,
+ "The factory should have been called at least once if it was properly picked up
by xml configuration."
+ );
+ }
+ }
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "4.4.6", id = "i"),
+ @SpecAssertion(section = "4.4.6", id = "h")
+ })
+ public void testConstraintValidatorFactorySpecifiedInValidationXmlCanBeOverridden() {
+ try {
+ Configuration<?> configuration = Validation
+ .byDefaultProvider()
+ .configure();
+
+ configuration = configuration.constraintValidatorFactory( new
ConfigurationDefinedConstraintValidatorFactoryResolver() );
+ Validator validator = configuration.buildValidatorFactory().getValidator();
+ validator.validate( new User() );
+ }
+ catch ( ValidationException e ) {
+ assertTrue(
+ ConfigurationDefinedConstraintValidatorFactoryResolver.numberOfIsReachableCalls >
0,
+ "The factory should have been called at least once if configuration settings
were applied."
+ );
+ }
+ }
+}
\ No newline at end of file
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/MessageInterpolatorSpecifiedInValidationXmlNoDefaultConstructorTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/MessageInterpolatorSpecifiedInValidationXmlNoDefaultConstructorTest.java 2009-08-20
10:39:03 UTC (rev 17374)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/MessageInterpolatorSpecifiedInValidationXmlNoDefaultConstructorTest.java 2009-08-20
13:13:36 UTC (rev 17375)
@@ -57,11 +57,10 @@
public void testMessageInterpolatorSpecifiedInValidationXmlHasNoDefaultConstructor() {
try {
TestUtil.getValidatorUnderTest();
- fail( "Bootstrapping should have failed due to mising no-arg constructor in
MessageInterpolator" );
+ fail( "Bootstrapping should have failed due to missing no-arg constructor in
MessageInterpolator" );
}
catch ( ValidationException e ) {
// success
- System.err.println( e.getMessage() );
}
}
}
\ No newline at end of file
Copied:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/TRaversableResolverSpecifiedInValidationXmlNoDefaultConstructorTest.java
(from rev 17359,
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/MessageInterpolatorSpecifiedInValidationXmlNoDefaultConstructorTest.java)
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/TRaversableResolverSpecifiedInValidationXmlNoDefaultConstructorTest.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/TRaversableResolverSpecifiedInValidationXmlNoDefaultConstructorTest.java 2009-08-20
13:13:36 UTC (rev 17375)
@@ -0,0 +1,66 @@
+// $Id: InvalidXmlConfigurationTest.java 17352 2009-08-18 17:08:59Z hardy.ferentschik $
+/*
+* 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.ValidationException;
+
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecAssertions;
+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.jsr303.ValidationXml;
+import static org.testng.Assert.fail;
+import org.testng.annotations.Test;
+
+import org.hibernate.jsr303.tck.common.TCKValidationProvider;
+import org.hibernate.jsr303.tck.common.TCKValidatorConfiguration;
+import org.hibernate.jsr303.tck.util.TestUtil;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Artifact(artifactType = ArtifactType.JSR303)
+@Classes({
+ TestUtil.class,
+ TestUtil.PathImpl.class,
+ TestUtil.NodeImpl.class,
+ TCKValidationProvider.class,
+ TCKValidatorConfiguration.class,
+ TCKValidationProvider.DummyValidatorFactory.class
+})
+@ValidationXml(value =
"validation-TraversableResolverSpecifiedInValidationXmlNoDefaultConstructorTest.xml")
+public class TraversableResolverSpecifiedInValidationXmlNoDefaultConstructorTest extends
AbstractTest {
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "4.4.6", id = "h"),
+ @SpecAssertion(section = "4.4.6", id = "q")
+ })
+ public void testTraversableResolverSpecifiedInValidationXmlHasNoDefaultConstructor() {
+ try {
+ TestUtil.getValidatorUnderTest();
+ fail( "Bootstrapping should have failed due to missing no-arg constructor in
TraversableResolver" );
+ }
+ catch ( ValidationException e ) {
+ // success
+ }
+ }
+}
\ No newline at end of file
Copied:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/XmlDefinedConstraintValidatorFactory.java
(from rev 17374,
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/XmlDefinedTraversableResolver.java)
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/XmlDefinedConstraintValidatorFactory.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/XmlDefinedConstraintValidatorFactory.java 2009-08-20
13:13:36 UTC (rev 17375)
@@ -0,0 +1,34 @@
+// $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.ConstraintValidator;
+import javax.validation.ConstraintValidatorFactory;
+import javax.validation.ValidationException;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class XmlDefinedConstraintValidatorFactory implements ConstraintValidatorFactory
{
+ public static int numberOfIsReachableCalls = 0;
+
+ public <T extends ConstraintValidator<?, ?>> T getInstance(Class<T>
key) {
+ numberOfIsReachableCalls++;
+ throw new ValidationException( "Exception in
XmlDefinedConstraintValidatorFactory" );
+ }
+}
\ No newline at end of file
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/XmlDefinedTraversableResolver.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/XmlDefinedTraversableResolver.java 2009-08-20
10:39:03 UTC (rev 17374)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/xmlconfiguration/XmlDefinedTraversableResolver.java 2009-08-20
13:13:36 UTC (rev 17375)
@@ -35,4 +35,10 @@
public boolean isCascadable(Object traversableObject, Path.Node traversableProperty,
Class<?> rootBeanType, Path pathToTraversableObject, ElementType elementType) {
return true;
}
+
+ public class NoDefaultConstructorResolver extends XmlDefinedTraversableResolver {
+ public NoDefaultConstructorResolver(String foo) {
+
+ }
+ }
}
\ No newline at end of file
Copied:
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-ConstraintValidatorFactorySpecifiedInValidationXmlTest.xml
(from rev 17374,
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-TraversableResolverSpecifiedInValidationXmlTest.xml)
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-ConstraintValidatorFactorySpecifiedInValidationXmlTest.xml
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-ConstraintValidatorFactorySpecifiedInValidationXmlTest.xml 2009-08-20
13:13:36 UTC (rev 17375)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<validation-config
+
xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configu...
validation-configuration-1.0.xsd">
+ <constraint-validator-factory>
+
org.hibernate.jsr303.tck.tests.xmlconfiguration.XmlDefinedConstraintValidatorFactory
+ </constraint-validator-factory>
+</validation-config>
\ No newline at end of file
Copied:
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-TraversableResolverSpecifiedInValidationXmlNoDefaultConstructorTest.xml
(from rev 17359,
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-MessageInterpolatorSpecifiedInValidationXmlNoDefaultConstructorTest.xml)
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-TraversableResolverSpecifiedInValidationXmlNoDefaultConstructorTest.xml
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/xmlconfiguration/validation-TraversableResolverSpecifiedInValidationXmlNoDefaultConstructorTest.xml 2009-08-20
13:13:36 UTC (rev 17375)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<validation-config
+
xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configu...
validation-configuration-1.0.xsd">
+ <traversable-resolver>
+
org.hibernate.jsr303.tck.tests.xmlconfiguration.XmlDefinedTraversableResolver.NoDefaultConstructorResolver
+ </traversable-resolver>
+</validation-config>
\ No newline at end of file