Author: hardy.ferentschik
Date: 2009-06-10 06:43:12 -0400 (Wed, 10 Jun 2009)
New Revision: 16733
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/ExplicitCustomProviderBootstrapTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/TCKValidationProvider.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/TCKValidatorConfiguration.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/xmldefined/
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/xmldefined/CustomProviderInXmlBootstrapTest.java
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/javax.validation.spi.ValidationProvider
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/xmldefined/
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/xmldefined/validation.xml
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider/DefaultBootstrapTest.java
Log:
Added bootstrapping tests.
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/ExplicitCustomProviderBootstrapTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/ExplicitCustomProviderBootstrapTest.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/ExplicitCustomProviderBootstrapTest.java 2009-06-10
10:43:12 UTC (rev 16733)
@@ -0,0 +1,53 @@
+// $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.bootstrap.customprovider;
+
+import javax.validation.Validation;
+import javax.validation.ValidatorFactory;
+
+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.IntegrationTest;
+import org.jboss.test.audit.annotations.SpecAssertion;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
+
+import org.hibernate.jsr303.tck.util.TestUtil;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Artifact(artifactType = ArtifactType.JSR303)
+(a)Classes(TestUtil.class)
+@Resource( source = "javax.validation.spi.ValidationProvider", destination =
"WEB-INF/classes/META-INF/services/javax.validation.spi.ValidationProvider")
+@IntegrationTest
+public class ExplicitCustomProviderBootstrapTest extends AbstractTest {
+
+ @Test
+ @SpecAssertion(section = "4.4.4.2", id = "a")
+ public void testGetFactoryByProviderSpecifiedProgrammatically() {
+ TCKValidatorConfiguration configuration = Validation.byProvider(
TCKValidatorConfiguration.class ).configure();
+ ValidatorFactory factory = configuration.buildValidatorFactory();
+ assertNotNull( factory );
+ assertTrue( factory instanceof TCKValidationProvider.DummyValidatorFactory );
+ }
+}
\ No newline at end of file
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/ExplicitCustomProviderBootstrapTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/TCKValidationProvider.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/TCKValidationProvider.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/TCKValidationProvider.java 2009-06-10
10:43:12 UTC (rev 16733)
@@ -0,0 +1,75 @@
+// $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.bootstrap.customprovider;
+
+import javax.validation.Configuration;
+import javax.validation.MessageInterpolator;
+import javax.validation.ValidationException;
+import javax.validation.Validator;
+import javax.validation.ValidatorContext;
+import javax.validation.ValidatorFactory;
+import javax.validation.spi.BootstrapState;
+import javax.validation.spi.ConfigurationState;
+import javax.validation.spi.ValidationProvider;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class TCKValidationProvider implements ValidationProvider {
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isSuitable(Class<? extends Configuration<?>> builderClass) {
+ return builderClass == TCKValidatorConfiguration.class;
+ }
+
+ public <T extends Configuration<T>> T
createSpecializedConfiguration(BootstrapState state, Class<T> configurationClass) {
+ if ( !isSuitable( configurationClass ) ) {
+ throw new ValidationException(
+ "Illegal call to createSpecializedConfiguration() for a non suitable
provider"
+ );
+ }
+ //cast protected by isSuitable call
+ return configurationClass.cast( new TCKValidatorConfiguration( this ) );
+ }
+
+
+ public Configuration<?> createGenericConfiguration(BootstrapState state) {
+ return new TCKValidatorConfiguration( this );
+ }
+
+ public ValidatorFactory buildValidatorFactory(ConfigurationState configurationState) {
+ return new DummyValidatorFactory();
+ }
+
+ public static class DummyValidatorFactory implements ValidatorFactory {
+
+ public Validator getValidator() {
+ return null;
+ }
+
+ public ValidatorContext usingContext() {
+ return null;
+ }
+
+ public MessageInterpolator getMessageInterpolator() {
+ return null;
+ }
+ }
+}
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/TCKValidationProvider.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/TCKValidatorConfiguration.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/TCKValidatorConfiguration.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/TCKValidatorConfiguration.java 2009-06-10
10:43:12 UTC (rev 16733)
@@ -0,0 +1,73 @@
+// $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.bootstrap.customprovider;
+
+import java.io.InputStream;
+import javax.validation.Configuration;
+import javax.validation.ConstraintValidatorFactory;
+import javax.validation.MessageInterpolator;
+import javax.validation.TraversableResolver;
+import javax.validation.ValidatorFactory;
+import javax.validation.spi.ValidationProvider;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class TCKValidatorConfiguration implements
Configuration<TCKValidatorConfiguration> {
+ private final ValidationProvider provider;
+
+ public TCKValidatorConfiguration(){
+ provider = null;
+ }
+
+ public TCKValidatorConfiguration(ValidationProvider provider) {
+ this.provider = provider;
+ }
+
+ public TCKValidatorConfiguration ignoreXmlConfiguration() {
+ return this;
+ }
+
+ public TCKValidatorConfiguration messageInterpolator(MessageInterpolator interpolator)
{
+ return this;
+ }
+
+ public TCKValidatorConfiguration traversableResolver(TraversableResolver resolver) {
+ return this;
+ }
+
+ public TCKValidatorConfiguration constraintValidatorFactory(ConstraintValidatorFactory
constraintValidatorFactory) {
+ return this;
+ }
+
+ public TCKValidatorConfiguration addMapping(InputStream stream) {
+ return this;
+ }
+
+ public TCKValidatorConfiguration addProperty(String name, String value) {
+ return this;
+ }
+
+ public MessageInterpolator getDefaultMessageInterpolator() {
+ return null;
+ }
+
+ public ValidatorFactory buildValidatorFactory() {
+ return provider.buildValidatorFactory( null );
+ }
+}
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/TCKValidatorConfiguration.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/xmldefined/CustomProviderInXmlBootstrapTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/xmldefined/CustomProviderInXmlBootstrapTest.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/xmldefined/CustomProviderInXmlBootstrapTest.java 2009-06-10
10:43:12 UTC (rev 16733)
@@ -0,0 +1,62 @@
+// $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.bootstrap.customprovider.xmldefined;
+
+import javax.validation.Validation;
+import javax.validation.ValidatorFactory;
+
+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.IntegrationTest;
+import org.jboss.testharness.impl.packaging.Resource;
+import org.jboss.testharness.impl.packaging.jsr303.ValidationXml;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
+
+import org.hibernate.jsr303.tck.tests.bootstrap.customprovider.TCKValidationProvider;
+import
org.hibernate.jsr303.tck.tests.bootstrap.customprovider.TCKValidatorConfiguration;
+import org.hibernate.jsr303.tck.util.TestUtil;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Artifact(artifactType = ArtifactType.JSR303)
+@Classes({
+ TestUtil.class,
+ TCKValidationProvider.class,
+ TCKValidatorConfiguration.class,
+ TCKValidationProvider.DummyValidatorFactory.class
+})
+@Resource(source =
"/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/javax.validation.spi.ValidationProvider",
+ destination =
"WEB-INF/classes/META-INF/services/javax.validation.spi.ValidationProvider")
+(a)ValidationXml("validation.xml")
+@IntegrationTest
+public class CustomProviderInXmlBootstrapTest extends AbstractTest {
+
+ @Test
+ @SpecAssertion(section = "4.4.4.2", id = "a")
+ public void testGetFactoryByProviderSpecifiedInXml() {
+ ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
+ assertNotNull( factory );
+ assertTrue( factory instanceof TCKValidationProvider.DummyValidatorFactory );
+ }
+}
\ No newline at end of file
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/xmldefined/CustomProviderInXmlBootstrapTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider/DefaultBootstrapTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider/DefaultBootstrapTest.java 2009-06-10
10:41:50 UTC (rev 16732)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider/DefaultBootstrapTest.java 2009-06-10
10:43:12 UTC (rev 16733)
@@ -86,7 +86,7 @@
@Test
@SpecAssertion(section = "4.4.4.1", id = "c")
- public void testServiceFileExista() {
+ public void testServiceFileExists() {
List<ValidationProvider> providers = readBeanValidationServiceFile();
assertTrue( !providers.isEmpty(), "There should be at least one provider" );
}
Added:
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/javax.validation.spi.ValidationProvider
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/javax.validation.spi.ValidationProvider
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/javax.validation.spi.ValidationProvider 2009-06-10
10:43:12 UTC (rev 16733)
@@ -0,0 +1 @@
+org.hibernate.jsr303.tck.tests.bootstrap.customprovider.TCKValidationProvider
\ No newline at end of file
Property changes on:
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/javax.validation.spi.ValidationProvider
___________________________________________________________________
Name: svn:eol-style
+ native
Added:
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/xmldefined/validation.xml
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/xmldefined/validation.xml
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/xmldefined/validation.xml 2009-06-10
10:43:12 UTC (rev 16733)
@@ -0,0 +1,6 @@
+<?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">
+
<default-provider>org.hibernate.jsr303.tck.tests.bootstrap.customprovider.TCKValidatorConfiguration</default-provider>
+</validation-config>
\ No newline at end of file
Property changes on:
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/xmldefined/validation.xml
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native