Author: hardy.ferentschik
Date: 2010-05-06 06:31:32 -0400 (Thu, 06 May 2010)
New Revision: 19380
Added:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/traversableresolver/Author.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/traversableresolver/AuthorBusinessRules.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/traversableresolver/Book.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/traversableresolver/BookBusinessRules.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/traversableresolver/JpaTraversableResolverTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/util/DummyTraversableResolver.java
Modified:
validator/trunk/hibernate-validator/pom.xml
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ValidatorImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/resolver/JPATraversableResolver.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/util/TestUtil.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/InheritanceMappingsTest.java
validator/trunk/hibernate-validator/src/test/resources/log4j.properties
validator/trunk/pom.xml
Log:
HV-305 The call to is reachable should only be made for property level constraints. For
class level constraints true should be returned.
Modified: validator/trunk/hibernate-validator/pom.xml
===================================================================
--- validator/trunk/hibernate-validator/pom.xml 2010-05-06 10:02:10 UTC (rev 19379)
+++ validator/trunk/hibernate-validator/pom.xml 2010-05-06 10:31:32 UTC (rev 19380)
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>hibernate-validator-parent</artifactId>
<groupId>org.hibernate</groupId>
@@ -81,6 +83,12 @@
<scope>test</scope>
<classifier>jdk15</classifier>
</dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
+ <version>3.5.0-Final</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<defaultGoal>test</defaultGoal>
@@ -189,7 +197,7 @@
</relocation>
</relocations>
<transformers>
- <transformer
implementation="org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer"
/>
+ <transformer
implementation="org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer"/>
</transformers>
</configuration>
</execution>
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ValidatorImpl.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ValidatorImpl.java 2010-05-06
10:02:10 UTC (rev 19379)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ValidatorImpl.java 2010-05-06
10:31:32 UTC (rev 19380)
@@ -547,15 +547,15 @@
constraintValidatorFactory,
cachedTraversableResolver
);
- ValueContext<U, V> localContext = ValueContext.getLocalExecutionContext(
+ ValueContext<U, V> valueContext = ValueContext.getLocalExecutionContext(
hostingBeanInstance
);
- localContext.setPropertyPath( path );
- localContext.setCurrentGroup( groupClass );
- if ( isValidationRequired( context, localContext, metaConstraint ) ) {
- Object valueToValidate = metaConstraint.getValue( localContext.getCurrentBean() );
- localContext.setCurrentValidatedValue( ( V ) valueToValidate );
- metaConstraint.validateConstraint( context, localContext );
+ valueContext.setPropertyPath( path );
+ valueContext.setCurrentGroup( groupClass );
+ if ( isValidationRequired( context, valueContext, metaConstraint ) ) {
+ Object valueToValidate = metaConstraint.getValue( valueContext.getCurrentBean() );
+ valueContext.setCurrentValidatedValue( ( V ) valueToValidate );
+ metaConstraint.validateConstraint( context, valueContext );
failingConstraintViolations.addAll( context.getFailingConstraints() );
}
}
@@ -640,12 +640,12 @@
ValidationContext<U> context = ValidationContext.getContextForValidateValue(
beanType, messageInterpolator, constraintValidatorFactory,
cachedTraversableResolver
);
- ValueContext<U, V> localContext = ValueContext.getLocalExecutionContext(
beanType );
- localContext.setPropertyPath( path );
- localContext.setCurrentGroup( groupClass );
- localContext.setCurrentValidatedValue( value );
- if ( isValidationRequired( context, localContext, metaConstraint ) ) {
- metaConstraint.validateConstraint( context, localContext );
+ ValueContext<U, V> valueContext = ValueContext.getLocalExecutionContext(
beanType );
+ valueContext.setPropertyPath( path );
+ valueContext.setCurrentGroup( groupClass );
+ valueContext.setCurrentValidatedValue( value );
+ if ( isValidationRequired( context, valueContext, metaConstraint ) ) {
+ metaConstraint.validateConstraint( context, valueContext );
failingConstraintViolations.addAll( context.getFailingConstraints() );
}
}
@@ -741,22 +741,22 @@
return new SingleThreadCachedTraversableResolver( traversableResolver );
}
- private boolean isValidationRequired(ValidationContext validationContext, ValueContext
localContext, MetaConstraint metaConstraint) {
- if ( !metaConstraint.getGroupList().contains( localContext.getCurrentGroup() ) ) {
+ private boolean isValidationRequired(ValidationContext validationContext, ValueContext
valueContext, MetaConstraint metaConstraint) {
+ if ( !metaConstraint.getGroupList().contains( valueContext.getCurrentGroup() ) ) {
return false;
}
boolean isReachable;
- Path pathToObject = localContext.getPropertyPath().getPathWithoutLeafNode();
+ Path pathToObject = valueContext.getPropertyPath().getPathWithoutLeafNode();
if ( pathToObject == null ) {
pathToObject = PathImpl.createNewPath( null );
}
try {
isReachable = validationContext.getTraversableResolver().isReachable(
- localContext.getCurrentBean(),
- localContext.getPropertyPath().getLeafNode(),
+ valueContext.getCurrentBean(),
+ valueContext.getPropertyPath().getLeafNode(),
validationContext.getRootBeanClass(),
pathToObject,
metaConstraint.getElementType()
@@ -769,20 +769,20 @@
return isReachable;
}
- private boolean isCascadeRequired(ValidationContext validationContext, ValueContext
localContext, Member member) {
+ private boolean isCascadeRequired(ValidationContext validationContext, ValueContext
valueContext, Member member) {
final ElementType type = member instanceof Field ? ElementType.FIELD :
ElementType.METHOD;
boolean isReachable;
boolean isCascadable;
- Path pathToObject = localContext.getPropertyPath().getPathWithoutLeafNode();
+ Path pathToObject = valueContext.getPropertyPath().getPathWithoutLeafNode();
if ( pathToObject == null ) {
pathToObject = PathImpl.createNewPath( null );
}
try {
isReachable = validationContext.getTraversableResolver().isReachable(
- localContext.getCurrentBean(),
- localContext.getPropertyPath().getLeafNode(),
+ valueContext.getCurrentBean(),
+ valueContext.getPropertyPath().getLeafNode(),
validationContext.getRootBeanClass(),
pathToObject,
type
@@ -794,8 +794,8 @@
try {
isCascadable = validationContext.getTraversableResolver().isCascadable(
- localContext.getCurrentBean(),
- localContext.getPropertyPath().getLeafNode(),
+ valueContext.getCurrentBean(),
+ valueContext.getPropertyPath().getLeafNode(),
validationContext.getRootBeanClass(),
pathToObject,
type
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/resolver/JPATraversableResolver.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/resolver/JPATraversableResolver.java 2010-05-06
10:02:10 UTC (rev 19379)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/resolver/JPATraversableResolver.java 2010-05-06
10:31:32 UTC (rev 19380)
@@ -19,19 +19,48 @@
import java.lang.annotation.ElementType;
import javax.persistence.Persistence;
+import javax.validation.Path;
import javax.validation.TraversableResolver;
-import javax.validation.Path;
+import org.slf4j.Logger;
+
+import org.hibernate.validator.util.LoggerFactory;
+
/**
+ * An implementation of {@code TraversableResolver} which is aware of JPA 2 and utilizes
{@code PersistenceUtil} to get
+ * query the reachability of a property.
+ * This resolver will be automatically enabled if JPA 2 is on the classpath and the
{@code DefaultTraversableResolver} is
+ * used.
+ *
* @author Hardy Ferentschik
* @author Emmanuel Bernard
*/
public class JPATraversableResolver implements TraversableResolver {
+ private static final Logger log = LoggerFactory.make();
- // we have to check traversableProperty.getName() against null to check the root gets
validated (see HV-266)
- public boolean isReachable(Object traversableObject, Path.Node traversableProperty,
Class<?> rootBeanType, Path pathToTraversableObject, ElementType elementType) {
- return traversableObject == null || traversableProperty.getName() == null ||
Persistence.getPersistenceUtil()
- .isLoaded( traversableObject, traversableProperty.getName() );
+ public boolean isReachable(Object traversableObject,
+ Path.Node traversableProperty,
+ Class<?> rootBeanType,
+ Path pathToTraversableObject,
+ ElementType elementType) {
+ if ( log.isTraceEnabled() ) {
+ log.trace(
+ "Calling isReachable on object {} with node name {}",
+ traversableObject,
+ traversableProperty.getName()
+ );
+ }
+
+ // we have to check traversableProperty.getName() against null to check the root gets
validated (see HV-266)
+ // also check the element type, if it is ElementType.TYPE then we don't have to
call is reachable since we have
+ // a class level constraint (HV-305)
+ if ( traversableObject == null || traversableProperty.getName() == null
+ || ElementType.TYPE.equals( elementType ) ) {
+ return true;
+ }
+ else {
+ return Persistence.getPersistenceUtil().isLoaded( traversableObject,
traversableProperty.getName() );
+ }
}
public boolean isCascadable(Object traversableObject, Path.Node traversableProperty,
Class<?> rootBeanType, Path pathToTraversableObject, ElementType elementType) {
Added:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/traversableresolver/Author.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/traversableresolver/Author.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/traversableresolver/Author.java 2010-05-06
10:31:32 UTC (rev 19380)
@@ -0,0 +1,42 @@
+// $Id:$
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates, 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.validator.engine.traversableresolver;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.validation.Valid;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+@AuthorBusinessRules
+public class Author {
+ @Id
+ public Long id;
+
+ @Valid
+ @OneToMany(mappedBy = "author")
+ public List<Book> books = new ArrayList<Book>();
+}
+
+
Property changes on:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/traversableresolver/Author.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/traversableresolver/AuthorBusinessRules.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/traversableresolver/AuthorBusinessRules.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/traversableresolver/AuthorBusinessRules.java 2010-05-06
10:31:32 UTC (rev 19380)
@@ -0,0 +1,38 @@
+// $Id:$
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates, 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.validator.engine.traversableresolver;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import javax.validation.Constraint;
+import javax.validation.Payload;
+
+@Constraint(validatedBy = {})
+@Documented
+(a)Target(ElementType.TYPE)
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface AuthorBusinessRules {
+ String message() default "";
+
+ Class<?>[] groups() default {};
+
+ Class<? extends Payload>[] payload() default {};
+}
\ No newline at end of file
Property changes on:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/traversableresolver/AuthorBusinessRules.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/traversableresolver/Book.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/traversableresolver/Book.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/traversableresolver/Book.java 2010-05-06
10:31:32 UTC (rev 19380)
@@ -0,0 +1,39 @@
+// $Id:$
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates, 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.validator.engine.traversableresolver;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@BookBusinessRules
+@Entity
+public class Book {
+ @Id
+ public Long id;
+
+ @ManyToOne
+ @NotNull
+ public Author author;
+}
+
+
Property changes on:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/traversableresolver/Book.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/traversableresolver/BookBusinessRules.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/traversableresolver/BookBusinessRules.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/traversableresolver/BookBusinessRules.java 2010-05-06
10:31:32 UTC (rev 19380)
@@ -0,0 +1,39 @@
+// $Id:$
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates, 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.validator.engine.traversableresolver;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.validation.Constraint;
+import javax.validation.Payload;
+
+@Constraint(validatedBy = {})
+@Documented
+(a)Target(ElementType.TYPE)
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface BookBusinessRules {
+ String message() default "";
+
+ Class<?>[] groups() default {};
+
+ Class<? extends Payload>[] payload() default {};
+}
Property changes on:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/traversableresolver/BookBusinessRules.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/traversableresolver/JpaTraversableResolverTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/traversableresolver/JpaTraversableResolverTest.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/traversableresolver/JpaTraversableResolverTest.java 2010-05-06
10:31:32 UTC (rev 19380)
@@ -0,0 +1,67 @@
+// $Id:$
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates, 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.validator.engine.traversableresolver;
+
+import java.util.Set;
+import javax.validation.Configuration;
+import javax.validation.ConstraintViolation;
+import javax.validation.Validator;
+
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import org.hibernate.validator.engine.resolver.DefaultTraversableResolver;
+import org.hibernate.validator.util.TestUtil;
+
+import static org.testng.Assert.assertTrue;
+
+
+/**
+ * See HV-305
+ *
+ * @author Hardy Ferentschik
+ */
+public class JpaTraversableResolverTest {
+ private Validator validator;
+
+ @BeforeTest
+ public void setUp() {
+ Configuration<?> configuration = TestUtil.getConfiguration();
+ configuration.traversableResolver( new DefaultTraversableResolver() );
+ validator = configuration.buildValidatorFactory().getValidator();
+ }
+
+ @Test
+ public void testWithBooks() {
+ Author author = new Author();
+ author.books.add( new Book() );
+ Set<ConstraintViolation<Author>> results = validator.validate( author );
+ assertTrue( results.isEmpty() );
+ }
+
+ @Test
+ public void testWithoutBooks() {
+ Author author = new Author();
+
+ // If the "books" collection is empty, everything works as expected.
+ Set<ConstraintViolation<Author>> results = validator.validate( author );
+ assertTrue( results.isEmpty() );
+ }
+}
+
+
Property changes on:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/traversableresolver/JpaTraversableResolverTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/util/DummyTraversableResolver.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/util/DummyTraversableResolver.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/util/DummyTraversableResolver.java 2010-05-06
10:31:32 UTC (rev 19380)
@@ -0,0 +1,39 @@
+// $Id:$
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates, 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.validator.util;
+
+import java.lang.annotation.ElementType;
+import javax.validation.Path;
+import javax.validation.TraversableResolver;
+
+/**
+ * A dummy traversable resolver which returns always {@code true}. This resolver is used
by default by all test cases.
+ *
+ * @author Hardy Ferentschik
+ */
+public class DummyTraversableResolver implements TraversableResolver {
+ public boolean isReachable(Object traversableObject, Path.Node traversableProperty,
Class<?> rootBeanType, Path pathToTraversableObject, ElementType elementType) {
+ return true;
+ }
+
+ public boolean isCascadable(Object traversableObject, Path.Node traversableProperty,
Class<?> rootBeanType, Path pathToTraversableObject, ElementType elementType) {
+ return true;
+ }
+}
+
+
Property changes on:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/util/DummyTraversableResolver.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/util/TestUtil.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/util/TestUtil.java 2010-05-06
10:02:10 UTC (rev 19379)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/util/TestUtil.java 2010-05-06
10:31:32 UTC (rev 19380)
@@ -33,14 +33,15 @@
import javax.validation.metadata.PropertyDescriptor;
import org.slf4j.Logger;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-import static org.testng.FileAssert.fail;
import org.hibernate.validator.HibernateValidator;
import org.hibernate.validator.HibernateValidatorConfiguration;
import org.hibernate.validator.engine.PathImpl;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.FileAssert.fail;
+
/**
* Tests for the <code>ReflectionHelper</code>.
*
@@ -57,6 +58,7 @@
public static Validator getValidator() {
if ( hibernateValidator == null ) {
Configuration configuration = getConfiguration();
+ configuration.traversableResolver( new DummyTraversableResolver() );
hibernateValidator = configuration.buildValidatorFactory().getValidator();
}
return hibernateValidator;
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/InheritanceMappingsTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/InheritanceMappingsTest.java 2010-05-06
10:02:10 UTC (rev 19379)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/xml/mixedconfiguration/InheritanceMappingsTest.java 2010-05-06
10:31:32 UTC (rev 19380)
@@ -25,13 +25,15 @@
import javax.validation.ValidatorFactory;
import javax.validation.constraints.NotNull;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.FileAssert.fail;
import org.testng.annotations.Test;
+import org.hibernate.validator.util.DummyTraversableResolver;
import org.hibernate.validator.util.TestUtil;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.FileAssert.fail;
+
/**
* See HV-265
*
@@ -43,7 +45,7 @@
public void defaultConfigurationNoExplicitAnnotationDefinition1() {
validateAnnotatedFixture(
new org.hibernate.validator.xml.mixedconfiguration.annotation.PersonCompetition(),
- configure()
+ TestUtil.getValidator()
);
}
@@ -51,7 +53,7 @@
public void defaultConfigurationNoExplicitAnnotationDefinition2() {
validateAnnotatedFixture(
new org.hibernate.validator.xml.mixedconfiguration.annotation.TeamCompetition(),
- configure()
+ TestUtil.getValidator()
);
}
@@ -87,12 +89,9 @@
);
}
- private Validator configure() {
- return TestUtil.getValidator();
- }
-
private Validator configure(String mappingsUrl) {
Configuration<?> configuration = TestUtil.getConfiguration();
+ configuration.traversableResolver( new DummyTraversableResolver() );
configuration.addMapping( InheritanceMappingsTest.class.getResourceAsStream(
mappingsUrl ) );
ValidatorFactory validatorFactory = configuration.buildValidatorFactory();
Modified: validator/trunk/hibernate-validator/src/test/resources/log4j.properties
===================================================================
--- validator/trunk/hibernate-validator/src/test/resources/log4j.properties 2010-05-06
10:02:10 UTC (rev 19379)
+++ validator/trunk/hibernate-validator/src/test/resources/log4j.properties 2010-05-06
10:31:32 UTC (rev 19380)
@@ -21,5 +21,6 @@
log4j.rootLogger=debug, stdout
log4j.logger.org.hibernate.validator.engine.ValidatorImpl=trace
+#log4j.logger.org.hibernate.validator.engine.resolver.JPATraversableResolver=trace
#log4j.logger.org.hibernate.validatorengine.ConstraintTree=trace
log4j.logger.org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator=info
Modified: validator/trunk/pom.xml
===================================================================
--- validator/trunk/pom.xml 2010-05-06 10:02:10 UTC (rev 19379)
+++ validator/trunk/pom.xml 2010-05-06 10:31:32 UTC (rev 19380)
@@ -58,7 +58,7 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
- <version>${project.parent.version}</version>
+ <version>${version}</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>