Hibernate SVN: r17340 - in core/trunk/entitymanager/src: test/java/org/hibernate/ejb/criteria/basic and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-08-17 15:09:17 -0400 (Mon, 17 Aug 2009)
New Revision: 17340
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/QueryStructure.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/basic/BasicCriteriaUsageTest.java
Log:
EJB-447 - Implement JPA 2.0 criteria apis (building)
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/QueryStructure.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/QueryStructure.java 2009-08-17 19:08:40 UTC (rev 17339)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/QueryStructure.java 2009-08-17 19:09:17 UTC (rev 17340)
@@ -27,6 +27,7 @@
import java.util.List;
import java.util.Collections;
import java.util.LinkedHashSet;
+import java.util.ArrayList;
import javax.persistence.criteria.AbstractQuery;
import javax.persistence.criteria.Root;
import javax.persistence.criteria.Predicate;
@@ -78,14 +79,18 @@
ParameterContainer.Helper.possibleParameter(selection, registry);
ParameterContainer.Helper.possibleParameter(restriction, registry);
ParameterContainer.Helper.possibleParameter(having, registry);
- for ( Subquery subquery : getSubqueries() ) {
- ParameterContainer.Helper.possibleParameter(subquery, registry);
+ if ( subqueries != null ) {
+ for ( Subquery subquery : subqueries ) {
+ ParameterContainer.Helper.possibleParameter(subquery, registry);
+ }
}
// both group-by and having expressions can (though unlikely) contain parameters...
ParameterContainer.Helper.possibleParameter(having, registry);
- for ( Expression<?> grouping : groupings ) {
- ParameterContainer.Helper.possibleParameter(grouping, registry);
+ if ( groupings != null ) {
+ for ( Expression<?> grouping : groupings ) {
+ ParameterContainer.Helper.possibleParameter(grouping, registry);
+ }
}
return parameters;
@@ -128,7 +133,7 @@
}
public <X> Root<X> from(EntityType<X> entityType) {
- RootImpl<X> root = new RootImpl( queryBuilder, entityType );
+ RootImpl<X> root = new RootImpl<X>( queryBuilder, entityType );
roots.add( root );
return root;
}
@@ -179,9 +184,16 @@
return subqueries;
}
+ public List<Subquery<?>> internalGetSubqueries() {
+ if ( subqueries == null ) {
+ subqueries = new ArrayList<Subquery<?>>();
+ }
+ return subqueries;
+ }
+
public <U> Subquery<U> subquery(Class<U> subqueryType) {
CriteriaSubqueryImpl<U> subquery = new CriteriaSubqueryImpl<U>( queryBuilder, subqueryType, owner );
- subqueries.add( subquery );
+ internalGetSubqueries().add( subquery );
return subquery;
}
}
Modified: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/basic/BasicCriteriaUsageTest.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/basic/BasicCriteriaUsageTest.java 2009-08-17 19:08:40 UTC (rev 17339)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/basic/BasicCriteriaUsageTest.java 2009-08-17 19:09:17 UTC (rev 17340)
@@ -22,7 +22,11 @@
package org.hibernate.ejb.criteria.basic;
import javax.persistence.EntityManager;
+import javax.persistence.metamodel.SingularAttribute;
import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.ParameterExpression;
+import javax.persistence.criteria.Root;
+import javax.persistence.criteria.Predicate;
import org.hibernate.ejb.test.TestCase;
@@ -37,7 +41,7 @@
return new Class[] { Wall.class };
}
- public void testSimpliestCriterias() {
+ public void testSimplestCriterias() {
EntityManager em = getOrCreateEntityManager();
em.getTransaction().begin();
CriteriaQuery criteria = em.getQueryBuilder().createQuery();
@@ -45,4 +49,21 @@
em.getTransaction().commit();
em.close();
}
+
+ public void testParameterCollection() {
+ EntityManager em = getOrCreateEntityManager();
+ em.getTransaction().begin();
+ CriteriaQuery criteria = em.getQueryBuilder().createQuery();
+ Root<Wall> from = criteria.from( Wall.class );
+ ParameterExpression param = em.getQueryBuilder().parameter( String.class );
+ SingularAttribute<? super Wall,?> colorAttribute = em.getMetamodel()
+ .entity( Wall.class )
+ .getDeclaredSingularAttribute( "color" );
+ assertNotNull( "metamodel returned null singular attribute", colorAttribute );
+ Predicate predicate = em.getQueryBuilder().equal( from.get( colorAttribute ), param );
+ criteria.where( predicate );
+ assertEquals( 1, criteria.getParameters().size() );
+ em.getTransaction().commit();
+ em.close();
+ }
}
15 years, 3 months
Hibernate SVN: r17339 - core/trunk/testsuite/src/test/java/org/hibernate/test/legacy.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-08-17 15:08:40 -0400 (Mon, 17 Aug 2009)
New Revision: 17339
Modified:
core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/ParentChildTest.java
Log:
HHH-3852 & HHH-4092 : ParentChildTest failures
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/ParentChildTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/ParentChildTest.java 2009-08-17 17:41:07 UTC (rev 17338)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/ParentChildTest.java 2009-08-17 19:08:40 UTC (rev 17339)
@@ -130,7 +130,7 @@
s.close();
}
- public void testProxyReuse() throws Exception {
+ public void testProxyReuseFailureExpected() throws Exception {
Session s = openSession();
Transaction t = s.beginTransaction();
FooProxy foo = new Foo();
@@ -179,6 +179,7 @@
s.delete(foo);
s.delete( s.get(Foo.class, id2) );
s.delete( s.get(Foo.class, "xyzid") );
+// here is the issue (HHH-4092). After the deletes above there are 2 Fees and a Glarch unexpectedly hanging around
assertEquals( 2, doDelete( s, "from java.lang.Object" ) );
t.commit();
s.close();
@@ -205,7 +206,7 @@
s.close();
}
- public void testComplexCriteria() throws Exception {
+ public void testComplexCriteriaFailureExpected() throws Exception {
Session s = openSession();
Transaction t = s.beginTransaction();
Baz baz = new Baz();
@@ -244,6 +245,8 @@
.add( Restrictions.eq("string", "a string") )
.add( Restrictions.lt("integer", new Integer(-665) ) );
crit.createCriteria("fooArray")
+ // this is the bit causing the problems; creating the criteria on fooArray does not add it to FROM,
+ // and so restriction below leads to an invalid reference.
.add( Restrictions.eq("string", "a string") )
.setLockMode(lockMode);
15 years, 3 months
Hibernate SVN: r17338 - core/trunk/testsuite/src/test/java/org/hibernate/test/hql.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-08-17 13:41:07 -0400 (Mon, 17 Aug 2009)
New Revision: 17338
Modified:
core/trunk/testsuite/src/test/java/org/hibernate/test/hql/HQLTest.java
Log:
HHH-4091 - HQLTest#testDuplicateImplicitJoinInSelect
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/hql/HQLTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/hql/HQLTest.java 2009-08-17 17:40:52 UTC (rev 17337)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/hql/HQLTest.java 2009-08-17 17:41:07 UTC (rev 17338)
@@ -1130,7 +1130,8 @@
// duplicates the condition, whereas the new parser does not. The queries are semantically the
// same however.
if ( getDialect() instanceof Oracle8iDialect ) return;
- assertTranslation( "select an.mother.bodyWeight from Animal an join an.mother m where an.mother.bodyWeight > 10" );
+// the classic translator handles this incorrectly; the explicit join and the implicit ones should create separate physical SQL joins...
+// assertTranslation( "select an.mother.bodyWeight from Animal an join an.mother m where an.mother.bodyWeight > 10" );
assertTranslation( "select an.mother.bodyWeight from Animal an where an.mother.bodyWeight > 10" );
//assertTranslation("select an.mother from Animal an where an.mother.bodyWeight is not null");
assertTranslation( "select an.mother.bodyWeight from Animal an order by an.mother.bodyWeight" );
15 years, 3 months
Hibernate SVN: r17337 - core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/hql.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-08-17 13:40:52 -0400 (Mon, 17 Aug 2009)
New Revision: 17337
Modified:
core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/hql/HQLTest.java
Log:
HHH-4091 - HQLTest#testDuplicateImplicitJoinInSelect
Modified: core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/hql/HQLTest.java
===================================================================
--- core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/hql/HQLTest.java 2009-08-17 15:22:39 UTC (rev 17336)
+++ core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/hql/HQLTest.java 2009-08-17 17:40:52 UTC (rev 17337)
@@ -1130,7 +1130,8 @@
// duplicates the condition, whereas the new parser does not. The queries are semantically the
// same however.
if ( getDialect() instanceof Oracle8iDialect ) return;
- assertTranslation( "select an.mother.bodyWeight from Animal an join an.mother m where an.mother.bodyWeight > 10" );
+// the classic translator handles this incorrectly; the explicit join and the implicit ones should create separate physical SQL joins...
+// assertTranslation( "select an.mother.bodyWeight from Animal an join an.mother m where an.mother.bodyWeight > 10" );
assertTranslation( "select an.mother.bodyWeight from Animal an where an.mother.bodyWeight > 10" );
//assertTranslation("select an.mother from Animal an where an.mother.bodyWeight is not null");
assertTranslation( "select an.mother.bodyWeight from Animal an order by an.mother.bodyWeight" );
15 years, 3 months
Hibernate SVN: r17336 - core/trunk/entitymanager/src/main/java/org/hibernate/ejb.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-08-17 11:22:39 -0400 (Mon, 17 Aug 2009)
New Revision: 17336
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AbstractEntityManagerImpl.java
Log:
EJB-456 : JPA metamodel
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AbstractEntityManagerImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AbstractEntityManagerImpl.java 2009-08-17 14:40:15 UTC (rev 17335)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AbstractEntityManagerImpl.java 2009-08-17 15:22:39 UTC (rev 17336)
@@ -464,9 +464,11 @@
return getEntityManagerFactory().getQueryBuilder();
}
+ /**
+ * {@inheritDoc}
+ */
public Metamodel getMetamodel() {
- //FIXME
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ return getEntityManagerFactory().getMetamodel();
}
public void setFlushMode(FlushModeType flushModeType) {
15 years, 3 months
Hibernate SVN: r17335 - in beanvalidation/trunk/validation-tck/src/main: resources and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-08-17 10:40:15 -0400 (Mon, 17 Aug 2009)
New Revision: 17335
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/application/ValidationRequirementTest.java
beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
Log:
HV-205
Disabled test
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/application/ValidationRequirementTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/application/ValidationRequirementTest.java 2009-08-17 14:28:29 UTC (rev 17334)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/application/ValidationRequirementTest.java 2009-08-17 14:40:15 UTC (rev 17335)
@@ -125,7 +125,8 @@
assertCorrectConstraintViolationMessages( violations, expectedMessage, expectedMessage );
}
- @Test
+ @Test(enabled = false)
+ // The spec is not clear about whether validation of static fields/properties should just be ignored or an exception should be thrown.
@SpecAssertion(section = "3.1", id = "b")
public void testIgnoreStaticFieldsAndProperties() {
StaticFieldsAndProperties entity = new StaticFieldsAndProperties();
@@ -137,7 +138,7 @@
@Test
@SpecAssertion(section = "3.1.2", id = "e")
- public void testFieldAndPropertyVisiblityIsNotConstrainted() {
+ public void testFieldAndPropertyVisibilityIsNotConstrained() {
Visibility entity = new Visibility();
Validator validator = TestUtil.getValidatorUnderTest();
Modified: beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-08-17 14:28:29 UTC (rev 17334)
+++ beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-08-17 14:40:15 UTC (rev 17335)
@@ -225,7 +225,9 @@
<text>Properties to be validated must follow the method signature conventions for
JavaBeans read properties, as defined by the JavaBeans specification</text>
</assertion>
- <assertion id="b">
+ <assertion id="b" testable="false">
+ <!-- The spec is not clear about whether validation of static fields/properties should just be ignored or an
+ exception should be thrown. -->
<text>Static fields and static methods are excluded from validation</text>
</assertion>
<assertion id="c">
15 years, 3 months
Hibernate SVN: r17334 - beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-08-17 10:28:29 -0400 (Mon, 17 Aug 2009)
New Revision: 17334
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider/BootstrapTest.java
Log:
HV-202
Updated test to really use a Configuration object to set the MessageInterpolator
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider/BootstrapTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider/BootstrapTest.java 2009-08-17 13:43:03 UTC (rev 17333)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider/BootstrapTest.java 2009-08-17 14:28:29 UTC (rev 17334)
@@ -27,6 +27,7 @@
import java.util.List;
import java.util.Locale;
import java.util.Set;
+import javax.validation.Configuration;
import javax.validation.ConstraintViolation;
import javax.validation.MessageInterpolator;
import javax.validation.Validation;
@@ -71,10 +72,9 @@
@Test
@SpecAssertion(section = "4.3.2", id = "b")
public void testCustomMessageInterpolatorViaConfiguration() {
- ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
- Validator validator = factory.usingContext()
- .messageInterpolator( new DummyMessageInterpolator() )
- .getValidator();
+ Configuration config = Validation.byDefaultProvider().configure();
+ config = config.messageInterpolator( new DummyMessageInterpolator() );
+ Validator validator = config.buildValidatorFactory().getValidator();
assertCustomMessageInterpolatorUsed( validator );
}
15 years, 3 months
Hibernate SVN: r17333 - beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck and 10 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-08-17 09:43:03 -0400 (Mon, 17 Aug 2009)
New Revision: 17333
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/common/
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/common/TCKValidationProvider.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/common/TCKValidatorConfiguration.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/UnkownProviderBootstrapTest.java
beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/validation/javax.validation.spi.ValidationProvider
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorTest.java
Removed:
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
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/Validation.java
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/ValidationProviderResolverTest.java
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/defaultprovider/BootstrapTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidationTest.java
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/validation.xml
beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
Log:
HV-99, HV-200, HV-201
Refactored and added bootstrapping tests. Also updated the tck-audit file
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/Validation.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/Validation.java 2009-08-17 10:29:14 UTC (rev 17332)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/Validation.java 2009-08-17 13:43:03 UTC (rev 17333)
@@ -17,18 +17,18 @@
*/
package javax.validation;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.Enumeration;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.net.URL;
-import java.io.InputStream;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.io.IOException;
-import java.security.PrivilegedAction;
-import java.security.AccessController;
import javax.validation.bootstrap.GenericBootstrap;
import javax.validation.bootstrap.ProviderSpecificBootstrap;
import javax.validation.spi.BootstrapState;
@@ -67,7 +67,7 @@
* <li>
* The third approach allows you to specify explicitly and in
* a type safe fashion the expected provider.
- *
+ * <p/>
* Optionally you can choose a custom <code>ValidationProviderResolver</code>.
* <pre>{@code
* ACMEConfiguration configuration = Validation
@@ -105,6 +105,7 @@
* <code>Validation.byDefaultProvider().configure().buildValidatorFactory()</code>
*
* @return <code>ValidatorFactory</code> instance.
+ *
* @throws ValidationException if the ValidatorFactory cannot be built
*/
public static ValidatorFactory buildDefaultValidatorFactory() {
@@ -126,7 +127,7 @@
* the first available provider will be returned.
*
* @return instance building a generic <code>Configuration</code>
- * compliant with the bootstrap state provided.
+ * compliant with the bootstrap state provided.
*/
public static GenericBootstrap byDefaultProvider() {
return new GenericBootstrapImpl();
@@ -152,10 +153,10 @@
* @param providerType the <code>ValidationProvider</code> implementation type
*
* @return instance building a provider specific <code>Configuration</code>
- * sub interface implementation.
+ * sub interface implementation.
*/
public static <T extends Configuration<T>, U extends ValidationProvider<T>>
- ProviderSpecificBootstrap<T> byProvider(Class<U> providerType) {
+ ProviderSpecificBootstrap<T> byProvider(Class<U> providerType) {
return new ProviderSpecificBootstrapImpl<T, U>( providerType );
}
@@ -204,7 +205,16 @@
//stay null if no resolver is defined
state.providerResolver( resolver );
}
- for ( ValidationProvider provider : resolver.getValidationProviders() ) {
+
+ List<ValidationProvider<?>> resolvers;
+ try {
+ resolvers = resolver.getValidationProviders();
+ }
+ catch ( RuntimeException re ) {
+ throw new ValidationException( "Unable to get available provider resolvers.", re );
+ }
+
+ for ( ValidationProvider provider : resolvers ) {
if ( validationProviderClass.isAssignableFrom( provider.getClass() ) ) {
ValidationProvider<T> specificProvider = validationProviderClass.cast( provider );
return specificProvider.createSpecializedConfiguration( state );
@@ -231,7 +241,7 @@
}
public ValidationProviderResolver getDefaultValidationProviderResolver() {
- if (defaultResolver == null) {
+ if ( defaultResolver == null ) {
defaultResolver = new DefaultValidationProviderResolver();
}
return defaultResolver;
@@ -242,11 +252,28 @@
getDefaultValidationProviderResolver() :
this.resolver;
- if ( resolver.getValidationProviders().size() == 0 ) {
+ List<ValidationProvider<?>> resolvers;
+ try {
+ resolvers = resolver.getValidationProviders();
+ }
+ catch ( RuntimeException re ) {
+ throw new ValidationException( "Unable to get available provider resolvers.", re );
+ }
+
+ if ( resolvers.size() == 0 ) {
//FIXME looks like an assertion error almost
throw new ValidationException( "Unable to find a default provider" );
}
- return resolver.getValidationProviders().get( 0 ).createGenericConfiguration( this );
+
+ Configuration<?> config;
+ try {
+ config = resolver.getValidationProviders().get( 0 ).createGenericConfiguration( this );
+ }
+ catch ( RuntimeException re ) {
+ throw new ValidationException( "Unable to instantiate Configuration.", re );
+ }
+
+ return config;
}
}
@@ -360,7 +387,7 @@
public static ClassLoader fromContext() {
final GetClassLoader action = new GetClassLoader( null );
- if (System.getSecurityManager() != null) {
+ if ( System.getSecurityManager() != null ) {
return AccessController.doPrivileged( action );
}
else {
@@ -369,9 +396,11 @@
}
public static ClassLoader fromClass(Class<?> clazz) {
- if ( clazz == null ) throw new IllegalArgumentException("Class is null");
+ if ( clazz == null ) {
+ throw new IllegalArgumentException( "Class is null" );
+ }
final GetClassLoader action = new GetClassLoader( clazz );
- if (System.getSecurityManager() != null) {
+ if ( System.getSecurityManager() != null ) {
return AccessController.doPrivileged( action );
}
else {
@@ -384,7 +413,7 @@
}
public ClassLoader run() {
- if (clazz != null) {
+ if ( clazz != null ) {
return clazz.getClassLoader();
}
else {
Copied: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/common/TCKValidationProvider.java (from rev 17330, 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/common/TCKValidationProvider.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/common/TCKValidationProvider.java 2009-08-17 13:43:03 UTC (rev 17333)
@@ -0,0 +1,64 @@
+// $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.common;
+
+import javax.validation.Configuration;
+import javax.validation.MessageInterpolator;
+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<TCKValidatorConfiguration> {
+
+ public TCKValidatorConfiguration createSpecializedConfiguration(BootstrapState state) {
+ return TCKValidatorConfiguration.class.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() {
+ throw new UnsupportedOperationException();
+ }
+
+ public ValidatorContext usingContext() {
+ throw new UnsupportedOperationException();
+ }
+
+ public MessageInterpolator getMessageInterpolator() {
+ throw new UnsupportedOperationException();
+ }
+
+ public <T> T unwrap(Class<T> type) {
+ throw new UnsupportedOperationException();
+ }
+ }
+}
Property changes on: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/common/TCKValidationProvider.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Copied: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/common/TCKValidatorConfiguration.java (from rev 17330, 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/common/TCKValidatorConfiguration.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/common/TCKValidatorConfiguration.java 2009-08-17 13:43:03 UTC (rev 17333)
@@ -0,0 +1,74 @@
+// $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.common;
+
+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() {
+ throw new UnsupportedOperationException();
+ }
+
+ public TCKValidatorConfiguration messageInterpolator(MessageInterpolator interpolator) {
+ throw new UnsupportedOperationException();
+ }
+
+ public TCKValidatorConfiguration traversableResolver(TraversableResolver resolver) {
+ throw new UnsupportedOperationException();
+ }
+
+ public TCKValidatorConfiguration constraintValidatorFactory(ConstraintValidatorFactory constraintValidatorFactory) {
+ throw new UnsupportedOperationException();
+ }
+
+ public TCKValidatorConfiguration addMapping(InputStream stream) {
+ throw new UnsupportedOperationException();
+ }
+
+ public TCKValidatorConfiguration addProperty(String name, String value) {
+ throw new UnsupportedOperationException();
+ }
+
+ public MessageInterpolator getDefaultMessageInterpolator() {
+ throw new UnsupportedOperationException();
+ }
+
+ public ValidatorFactory buildValidatorFactory() {
+ return provider.buildValidatorFactory( null );
+ }
+
+}
Property changes on: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/common/TCKValidatorConfiguration.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: 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 2009-08-17 10:29:14 UTC (rev 17332)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/ExplicitCustomProviderBootstrapTest.java 2009-08-17 13:43:03 UTC (rev 17333)
@@ -20,26 +20,36 @@
import javax.validation.Validation;
import javax.validation.ValidatorFactory;
+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.IntegrationTest;
import org.jboss.testharness.impl.packaging.Resource;
-import org.jboss.testharness.impl.packaging.IntegrationTest;
-import org.jboss.test.audit.annotations.SpecAssertion;
-import org.jboss.test.audit.annotations.SpecAssertions;
import static org.testng.Assert.assertNotNull;
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)
-(a)Classes({TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class})
-@Resource( source = "javax.validation.spi.ValidationProvider", destination = "WEB-INF/classes/META-INF/services/javax.validation.spi.ValidationProvider")
+@Classes({
+ TestUtil.class,
+ TestUtil.PathImpl.class,
+ TestUtil.NodeImpl.class,
+ TCKValidationProvider.class,
+ TCKValidatorConfiguration.class,
+ TCKValidationProvider.DummyValidatorFactory.class
+})
+@Resource(source = "javax.validation.spi.ValidationProvider",
+ destination = "WEB-INF/classes/META-INF/services/javax.validation.spi.ValidationProvider")
@IntegrationTest
public class ExplicitCustomProviderBootstrapTest extends AbstractTest {
Deleted: 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 2009-08-17 10:29:14 UTC (rev 17332)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/TCKValidationProvider.java 2009-08-17 13:43:03 UTC (rev 17333)
@@ -1,64 +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.bootstrap.customprovider;
-
-import javax.validation.Configuration;
-import javax.validation.MessageInterpolator;
-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<TCKValidatorConfiguration> {
-
- public TCKValidatorConfiguration createSpecializedConfiguration(BootstrapState state) {
- return TCKValidatorConfiguration.class.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() {
- throw new UnsupportedOperationException();
- }
-
- public ValidatorContext usingContext() {
- throw new UnsupportedOperationException();
- }
-
- public MessageInterpolator getMessageInterpolator() {
- throw new UnsupportedOperationException();
- }
-
- public <T> T unwrap(Class<T> type) {
- throw new UnsupportedOperationException();
- }
- }
-}
Deleted: 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 2009-08-17 10:29:14 UTC (rev 17332)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/TCKValidatorConfiguration.java 2009-08-17 13:43:03 UTC (rev 17333)
@@ -1,74 +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.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() {
- throw new UnsupportedOperationException();
- }
-
- public TCKValidatorConfiguration messageInterpolator(MessageInterpolator interpolator) {
- throw new UnsupportedOperationException();
- }
-
- public TCKValidatorConfiguration traversableResolver(TraversableResolver resolver) {
- throw new UnsupportedOperationException();
- }
-
- public TCKValidatorConfiguration constraintValidatorFactory(ConstraintValidatorFactory constraintValidatorFactory) {
- throw new UnsupportedOperationException();
- }
-
- public TCKValidatorConfiguration addMapping(InputStream stream) {
- throw new UnsupportedOperationException();
- }
-
- public TCKValidatorConfiguration addProperty(String name, String value) {
- throw new UnsupportedOperationException();
- }
-
- public MessageInterpolator getDefaultMessageInterpolator() {
- throw new UnsupportedOperationException();
- }
-
- public ValidatorFactory buildValidatorFactory() {
- return provider.buildValidatorFactory( null );
- }
-
-}
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/ValidationProviderResolverTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/ValidationProviderResolverTest.java 2009-08-17 10:29:14 UTC (rev 17332)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/ValidationProviderResolverTest.java 2009-08-17 13:43:03 UTC (rev 17333)
@@ -29,6 +29,7 @@
import javax.validation.spi.ValidationProvider;
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;
@@ -37,13 +38,18 @@
import static org.testng.FileAssert.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 })
+@Classes({
+ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class, TCKValidationProvider.class,
+ TCKValidationProvider.DummyValidatorFactory.class, TCKValidatorConfiguration.class
+})
public class ValidationProviderResolverTest extends AbstractTest {
@Test
@@ -102,8 +108,11 @@
}
}
- @Test(expectedExceptions = ValidationException.class, enabled = false)
- @SpecAssertion(section = "4.4.4.2", id = "e")
+ @Test(expectedExceptions = ValidationException.class)
+ @SpecAssertions({
+ @SpecAssertion(section = "4.4.5", id = "f"),
+ @SpecAssertion(section = "4.4.4.2", id = "e")
+ })
public void testValidationExceptionIsThrownInCaseValidatorFactoryCreationFails() {
ValidationProviderResolver resolver = new ValidationProviderResolver() {
@@ -112,11 +121,6 @@
}
};
- Configuration<?> configuration = Validation
- .byDefaultProvider()
- .providerResolver( resolver )
- .configure();
-
- configuration.buildValidatorFactory();
+ Validation.byDefaultProvider().providerResolver( resolver ).configure();
}
}
\ No newline at end of file
Modified: 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 2009-08-17 10:29:14 UTC (rev 17332)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/xmldefined/CustomProviderInXmlBootstrapTest.java 2009-08-17 13:43:03 UTC (rev 17333)
@@ -33,8 +33,8 @@
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.common.TCKValidationProvider;
+import org.hibernate.jsr303.tck.common.TCKValidatorConfiguration;
import org.hibernate.jsr303.tck.util.TestUtil;
/**
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider/BootstrapTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider/BootstrapTest.java 2009-08-17 10:29:14 UTC (rev 17332)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider/BootstrapTest.java 2009-08-17 13:43:03 UTC (rev 17333)
@@ -41,15 +41,12 @@
import org.jboss.testharness.impl.packaging.ArtifactType;
import org.jboss.testharness.impl.packaging.Classes;
import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test;
import org.hibernate.jsr303.tck.util.TestUtil;
-import static org.hibernate.jsr303.tck.util.TestUtil.assertConstraintViolation;
import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectConstraintViolationMessages;
import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectNumberOfViolations;
-import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectPropertyPaths;
/**
* @author Hardy Ferentschik
@@ -60,39 +57,15 @@
private static final String SERVICES_FILE = "META-INF/services/" + ValidationProvider.class.getName();
@Test
- public void testGetDefaultValidator() {
- ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
- Validator validator = factory.getValidator();
- assertNotNull( validator, "We should be able to get a validator." );
-
- Person person = new Person();
- person.setPersonalNumber( 12345678900l );
-
- Set<ConstraintViolation<Person>> constraintViolations = validator.validate( person );
- assertCorrectNumberOfViolations( constraintViolations, 3 );
- assertCorrectPropertyPaths(
- constraintViolations, "firstName", "lastName", "personalNumber"
- );
-
- person.setFirstName( "John" );
- person.setLastName( "Doe" );
-
- constraintViolations = validator.validate( person );
- assertCorrectNumberOfViolations( constraintViolations, 1 );
- assertConstraintViolation(
- constraintViolations.iterator().next(), Person.class, 12345678900l, "personalNumber"
- );
-
- person.setPersonalNumber( 1234567890l );
- constraintViolations = validator.validate( person );
- assertCorrectNumberOfViolations( constraintViolations, 0 );
- }
-
- @Test
@SpecAssertion(section = "4.4.4.1", id = "c")
public void testServiceFileExists() {
- List<ValidationProvider> providers = readBeanValidationServiceFile();
+ List<Class<?>> providers = readBeanValidationServiceFile();
assertTrue( !providers.isEmpty(), "There should be at least one provider" );
+
+ assertTrue(
+ providers.contains( TestUtil.getValidationProviderUnderTest().getClass() ),
+ "The validation class of the provider under test has to be in the list."
+ );
}
@Test
@@ -123,12 +96,12 @@
);
}
- private List<ValidationProvider> readBeanValidationServiceFile() {
+ private List<Class<?>> readBeanValidationServiceFile() {
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
if ( classloader == null ) {
classloader = BootstrapTest.class.getClassLoader();
}
- List<ValidationProvider> providers = new ArrayList<ValidationProvider>();
+ List<Class<?>> providers = new ArrayList<Class<?>>();
try {
Enumeration<URL> providerDefinitions = classloader.getResources( SERVICES_FILE );
@@ -153,7 +126,7 @@
assertCorrectConstraintViolationMessages( constraintViolations, "my custom message" );
}
- private void addProviderToList(List<ValidationProvider> providers, URL url)
+ private void addProviderToList(List<Class<?>> providers, URL url)
throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException {
InputStream stream = url.openStream();
try {
@@ -167,9 +140,7 @@
BootstrapTest.class
);
- providers.add(
- ( ValidationProvider ) providerClass.newInstance()
- );
+ providers.add( providerClass );
}
name = reader.readLine();
}
Copied: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/UnkownProviderBootstrapTest.java (from rev 17330, 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/validation/UnkownProviderBootstrapTest.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/UnkownProviderBootstrapTest.java 2009-08-17 13:43:03 UTC (rev 17333)
@@ -0,0 +1,47 @@
+// $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.validation;
+
+import javax.validation.Configuration;
+import javax.validation.Validation;
+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.IntegrationTest;
+import org.jboss.testharness.impl.packaging.Resource;
+import org.testng.annotations.Test;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Artifact(artifactType = ArtifactType.JSR303)
+@Resource(source = "javax.validation.spi.ValidationProvider",
+ destination = "WEB-INF/classes/META-INF/services/javax.validation.spi.ValidationProvider")
+@IntegrationTest
+public class UnkownProviderBootstrapTest extends AbstractTest {
+
+ @Test(expectedExceptions = ValidationException.class)
+ @SpecAssertion(section = "4.4.5", id = "f")
+ public void testUnkownProviderThrowsValiationException() {
+ Validation.byDefaultProvider().configure();
+ //ValidatorFactory factory = configuration.buildValidatorFactory();
+ }
+}
\ No newline at end of file
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidationTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidationTest.java 2009-08-17 10:29:14 UTC (rev 17332)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidationTest.java 2009-08-17 13:43:03 UTC (rev 17333)
@@ -22,28 +22,100 @@
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;
+import javax.validation.Configuration;
+import javax.validation.Validation;
+import javax.validation.ValidationProviderResolver;
+import javax.validation.ValidatorFactory;
+import javax.validation.bootstrap.GenericBootstrap;
+import javax.validation.bootstrap.ProviderSpecificBootstrap;
+import javax.validation.spi.ValidationProvider;
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 static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
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;
/**
- * Tests for the implementation of <code>Validator</code>.
+ * Tests for the implementation of <code>Validation</code>.
*
* @author Hardy Ferentschik
*/
@Artifact(artifactType = ArtifactType.JSR303)
-@Classes({ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class })
+@Classes({
+ TestUtil.class, TestUtil.PathImpl.class, TestUtil.NodeImpl.class, TCKValidationProvider.class,
+ TCKValidationProvider.DummyValidatorFactory.class, TCKValidatorConfiguration.class
+})
public class ValidationTest extends AbstractTest {
@Test
@SpecAssertion(section = "4.4.5", id = "a")
+ public void testBuildDefaultValidatorFactory() {
+ ValidatorFactory defaultFactory = Validation.buildDefaultValidatorFactory();
+ assertNotNull( defaultFactory, "We should be able to get a factory." );
+
+ ValidatorFactory defaultProviderFactory = Validation.byDefaultProvider().configure().buildValidatorFactory();
+ assertNotNull( defaultProviderFactory, "We should be able to get a factory." );
+
+ assertEquals( defaultFactory.getClass(), defaultFactory.getClass(), "The factories have to be identical." );
+ }
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "4.4.5", id = "b"),
+ @SpecAssertion(section = "4.4.5", id = "e")
+ })
+ public void testCustomValidationProviderResolution() {
+ ValidationProviderResolver resolver = new ValidationProviderResolver() {
+
+ public List<ValidationProvider<?>> getValidationProviders() {
+ List<ValidationProvider<?>> list = new ArrayList<ValidationProvider<?>>();
+ list.add( new TCKValidationProvider() );
+ return list;
+ }
+ };
+
+ GenericBootstrap bootstrap = Validation.byDefaultProvider();
+ Configuration<?> config = bootstrap.providerResolver( resolver ).configure();
+
+ ValidatorFactory factory = config.buildValidatorFactory();
+ assertTrue( factory instanceof TCKValidationProvider.DummyValidatorFactory );
+ }
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "4.4.5", id = "c"),
+ @SpecAssertion(section = "4.4.5", id = "e")
+ })
+ public void testSpecificValidationProvider() {
+ ValidationProviderResolver resolver = new ValidationProviderResolver() {
+
+ public List<ValidationProvider<?>> getValidationProviders() {
+ List<ValidationProvider<?>> list = new ArrayList<ValidationProvider<?>>();
+ list.add( new TCKValidationProvider() );
+ return list;
+ }
+ };
+
+ // with resolver
+ ProviderSpecificBootstrap<TCKValidatorConfiguration> bootstrap = Validation.byProvider( TCKValidationProvider.class );
+ Configuration<?> config = bootstrap.providerResolver( resolver ).configure();
+ ValidatorFactory factory = config.buildValidatorFactory();
+ assertTrue( factory instanceof TCKValidationProvider.DummyValidatorFactory );
+ }
+
+ @Test
+ @SpecAssertion(section = "4.4.5", id = "d")
public void testVerifyMethodsOfValidationObjects() {
Class<?> validatorClass = javax.validation.Validation.class;
@@ -53,7 +125,7 @@
buildDefaultValidatorFactoryMethod = validatorClass.getMethod( "buildDefaultValidatorFactory" );
}
catch ( NoSuchMethodException e ) {
- fail( "Validation class is mising bootstrap method." );
+ fail( "Validation class is missing bootstrap method." );
}
expectedValidationMethods.add( buildDefaultValidatorFactoryMethod );
@@ -62,7 +134,7 @@
byDefaultProviderMethod = validatorClass.getMethod( "byDefaultProvider" );
}
catch ( NoSuchMethodException e ) {
- fail( "Validation class is mising bootstrap method." );
+ fail( "Validation class is missing bootstrap method." );
}
expectedValidationMethods.add( byDefaultProviderMethod );
@@ -71,7 +143,7 @@
byProviderMethod = validatorClass.getMethod( "byProvider", Class.class );
}
catch ( NoSuchMethodException e ) {
- fail( "Validation class is mising bootstrap method." );
+ fail( "Validation class is missing bootstrap method." );
}
expectedValidationMethods.add( byProviderMethod );
Modified: 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 2009-08-17 10:29:14 UTC (rev 17332)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/javax.validation.spi.ValidationProvider 2009-08-17 13:43:03 UTC (rev 17333)
@@ -1 +1 @@
-org.hibernate.jsr303.tck.tests.bootstrap.customprovider.TCKValidationProvider
\ No newline at end of file
+org.hibernate.jsr303.tck.common.TCKValidationProvider
\ No newline at end of file
Modified: 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 2009-08-17 10:29:14 UTC (rev 17332)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/bootstrap/customprovider/xmldefined/validation.xml 2009-08-17 13:43:03 UTC (rev 17333)
@@ -2,5 +2,5 @@
<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">
- <default-provider>org.hibernate.jsr303.tck.tests.bootstrap.customprovider.TCKValidationProvider</default-provider>
+ <default-provider>org.hibernate.jsr303.tck.common.TCKValidationProvider</default-provider>
</validation-config>
\ No newline at end of file
Copied: beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/validation/javax.validation.spi.ValidationProvider (from rev 17330, 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/validation/javax.validation.spi.ValidationProvider (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/resources/org/hibernate/jsr303/tck/tests/validation/javax.validation.spi.ValidationProvider 2009-08-17 13:43:03 UTC (rev 17333)
@@ -0,0 +1 @@
+provider.UnkownValidationProvider
\ No newline at end of file
Modified: beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-08-17 10:29:14 UTC (rev 17332)
+++ beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-08-17 13:43:03 UTC (rev 17333)
@@ -200,8 +200,8 @@
path to the bean or property hosting the constraint</text>
</assertion>
<assertion id="q">
- <text>You can point an error to a subpath of this default path by using the er-
- ror builder fluent API.</text>
+ <text>You can point an error to a subpath of this default path by using the er- ror
+ builder fluent API.</text>
</assertion>
</section>
<section id="2.5" title="The ConstraintValidatorFactory">
@@ -752,8 +752,9 @@
</assertion>
<assertion id="d">
<text>Use the provider implementation associated with the Configuration implementation
- described in the XML configuration if defined: the value of this element is the fully qualified class name
- of the ValidationProvider implementation uniquely identifying the provider.</text>
+ described in the XML configuration if defined: the value of this element is the
+ fully qualified class name of the ValidationProvider implementation uniquely
+ identifying the provider.</text>
</assertion>
<assertion id="e">
<text>Use the first provider implementation returned by
@@ -810,23 +811,39 @@
</section>
<section id="4.4.5" title="Validation">
<assertion id="a">
+ <text> Validation.buildDefaultValidatorFactory(), is considered to be the default
+ ValidatorFactory and is equivalent to the ValidatorFactory returned by
+ Validation.byDefaultProvider().configure().buildValidatorFactory() </text>
+ </assertion>
+ <assertion id="b">
+ <text>ValidationProvider.createGenericConfiguration(BootstrapState state) is the second
+ bootstrapping entry point and let the client provide a custom
+ ValidationProviderResolution instance</text>
+ </assertion>
+ <assertion id="c">
+ <text>ValidationProvider.createGenericConfiguration(BootstrapState state) is the third
+ bootstrapping entry point and let the client define the specific Bean Validation
+ provider requested as well as a custom ValidationProviderResolver implementation if
+ needed</text>
+ </assertion>
+ <assertion id="d">
<text>The Validation implementation provided by the Bean Validation provider must not
contain any non private attribute or method aside from the three public static
bootstrap methods</text>
</assertion>
- <assertion id="b">
+ <assertion id="e">
<text>The bootstrap implementation must ensure it can bootstrap third party
providers</text>
</assertion>
- <assertion id="c">
- <text>When building the Configuration object, if the ValidationProviderResolver fais or
+ <assertion id="f">
+ <text>When building the Configuration object, if the ValidationProviderResolver fails or
if the expected provider is not found, a ValidationException is raised</text>
</assertion>
</section>
<section id="4.4.6" title="XML Configuration">
<assertion id="a">
<text>Unless explicitly ignored by calling Configuration.ignoreXMLConfiguration(), a
- Configuration takes into ac- count the configuration available in
+ Configuration takes into account the configuration available in
META-INF/validation.xml</text>
</assertion>
<assertion id="b">
Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorTest.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorTest.java 2009-08-17 13:43:03 UTC (rev 17333)
@@ -0,0 +1,52 @@
+// $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.validation.engine;
+
+import java.util.Set;
+import javax.validation.ConstraintViolation;
+import javax.validation.Validator;
+import javax.validation.constraints.NotNull;
+
+import org.testng.annotations.Test;
+
+import org.hibernate.validation.util.TestUtil;
+import static org.hibernate.validation.util.TestUtil.assertCorrectPropertyPaths;
+import static org.hibernate.validation.util.TestUtil.assertNumberOfViolations;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class ValidatorTest {
+
+ /**
+ * HV-208
+ */
+ @Test
+ public void testPropertyPathDoesNotStartWithLeadingDot() {
+ Validator validator = TestUtil.getValidator();
+ A testInstance = new A();
+ Set<ConstraintViolation<A>> constraintViolations = validator.validate( testInstance );
+ assertNumberOfViolations( constraintViolations, 1 );
+ assertCorrectPropertyPaths( constraintViolations, "b" );
+ }
+
+ class A {
+ @NotNull
+ String b;
+ }
+}
15 years, 3 months
Hibernate SVN: r17332 - core/trunk/core/src/main/java/org/hibernate/type.
by hibernate-commits@lists.jboss.org
Author: gbadner
Date: 2009-08-17 06:29:14 -0400 (Mon, 17 Aug 2009)
New Revision: 17332
Modified:
core/trunk/core/src/main/java/org/hibernate/type/TextType.java
Log:
HHH-3892 : restore original author
Modified: core/trunk/core/src/main/java/org/hibernate/type/TextType.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/type/TextType.java 2009-08-17 07:46:18 UTC (rev 17331)
+++ core/trunk/core/src/main/java/org/hibernate/type/TextType.java 2009-08-17 10:29:14 UTC (rev 17332)
@@ -30,7 +30,7 @@
/**
* <tt>text</tt>: A type that maps an SQL LONGVARCHAR to a Java String.
*
- * @author Gail Badner
+ * @author Gavin King, Bertrand Renuart
*/
public class TextType extends AbstractLongStringType {
15 years, 3 months