Hibernate SVN: r16271 - in validator/trunk/hibernate-validator/src: main/java/org/hibernate/validation/util and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-04-07 16:20:12 -0400 (Tue, 07 Apr 2009)
New Revision: 16271
Added:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/TestGroup.java
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaData.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorFactoryImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/ReflectionHelper.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/XmlConfigurationTest.java
validator/trunk/hibernate-validator/src/test/resources/META-INF/validation/user-constraints.xml
Log:
HV-112
Parsing and applying class, field and property level constraints.
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaData.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaData.java 2009-04-07 17:40:07 UTC (rev 16270)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaData.java 2009-04-07 20:20:12 UTC (rev 16271)
@@ -33,12 +33,6 @@
public interface BeanMetaData<T> {
/**
- * Initalises the given meta data bean taken its current state into account. An instance of <code>BeanMetaData</code>
- * won't have any useful state information prior to calling this method.
- */
- void init();
-
- /**
* @return the class of the bean.
*/
Class<T> getBeanClass();
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java 2009-04-07 17:40:07 UTC (rev 16270)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java 2009-04-07 20:20:12 UTC (rev 16271)
@@ -93,9 +93,6 @@
public BeanMetaDataImpl(Class<T> beanClass, ConstraintHelper constraintHelper) {
this.beanClass = beanClass;
this.constraintHelper = constraintHelper;
- }
-
- public void init() {
createMetaData();
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorFactoryImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorFactoryImpl.java 2009-04-07 17:40:07 UTC (rev 16270)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorFactoryImpl.java 2009-04-07 20:20:12 UTC (rev 16271)
@@ -24,6 +24,7 @@
import java.lang.reflect.Array;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
+import java.lang.reflect.Field;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
@@ -113,8 +114,7 @@
*/
public ValidatorContext usingContext() {
return new ValidatorContextImpl(
- constraintValidatorFactory, messageInterpolator, traversableResolver,
- constraintHelper
+ constraintValidatorFactory, messageInterpolator, traversableResolver, constraintHelper
);
}
@@ -143,8 +143,8 @@
Boolean ignoreAnnotations = bean.isIgnoreAnnotations() == null ? false : bean.isIgnoreAnnotations();
ignoreAnnotationDefaults.put( beanClass, ignoreAnnotations );
parseClassLevelOverrides( bean.getClassType(), beanClass, defaultPackage );
- parseFieldLevelOverrides( bean.getField() );
- parsePropertyLevelOverrides( bean.getGetter() );
+ parseFieldLevelOverrides( bean.getField(), beanClass, defaultPackage );
+ parsePropertyLevelOverrides( bean.getGetter(), beanClass, defaultPackage );
processedClasses.add( beanClass );
}
}
@@ -165,15 +165,39 @@
}
}
- private void parseFieldLevelOverrides(List<FieldType> fields) {
- for ( FieldType field : fields ) {
- boolean ignoreFieldAnnotation = field.isIgnoreAnnotations() == null ? false : field.isIgnoreAnnotations();
+ private void parseFieldLevelOverrides(List<FieldType> fields, Class<?> beanClass, String defaultPackage) {
+ for ( FieldType fieldType : fields ) {
+ String fieldName = fieldType.getName();
+ if ( !ReflectionHelper.containsField( beanClass, fieldName ) ) {
+ throw new ValidationException( beanClass.getName() + " does not contain the fieldType " + fieldName );
+ }
+ Field field = ReflectionHelper.getField( beanClass, fieldName );
+ boolean ignoreFieldAnnotation = fieldType.isIgnoreAnnotations() == null ? false : fieldType.isIgnoreAnnotations();
+ if ( ignoreFieldAnnotation ) {
+ ignoreAnnotationOnMember.put( beanClass, null );
+ }
+ for ( ConstraintType constraint : fieldType.getConstraint() ) {
+ MetaConstraint<?, ?> metaConstraint = createMetaConstraint( constraint, beanClass, field, defaultPackage );
+ addMetaConstraint( beanClass, metaConstraint );
+ }
}
}
- private void parsePropertyLevelOverrides(List<GetterType> getters) {
+ private void parsePropertyLevelOverrides(List<GetterType> getters, Class<?> beanClass, String defaultPackage) {
for ( GetterType getter : getters ) {
+ String getterName = getter.getName();
+ if ( !ReflectionHelper.containsMethod( beanClass, getterName ) ) {
+ throw new ValidationException( beanClass.getName() + " does not contain the property " + getterName );
+ }
+ Method method = ReflectionHelper.getMethod( beanClass, getterName );
boolean ignoreGetterAnnotation = getter.isIgnoreAnnotations() == null ? false : getter.isIgnoreAnnotations();
+ if ( ignoreGetterAnnotation ) {
+ ignoreAnnotationOnMember.put( beanClass, null );
+ }
+ for ( ConstraintType constraint : getter.getConstraint() ) {
+ MetaConstraint<?, ?> metaConstraint = createMetaConstraint( constraint, beanClass, method, defaultPackage );
+ addMetaConstraint( beanClass, metaConstraint );
+ }
}
}
@@ -186,7 +210,7 @@
ignoreAnnotationOnClass.add( beanClass );
}
for ( ConstraintType constraint : classType.getConstraint() ) {
- MetaConstraint<?, ?> metaConstraint = createMetaConstraint( constraint, beanClass, defaultPackage );
+ MetaConstraint<?, ?> metaConstraint = createMetaConstraint( constraint, beanClass, null, defaultPackage );
addMetaConstraint( beanClass, metaConstraint );
}
}
@@ -202,7 +226,7 @@
}
}
- private <A extends Annotation, T> MetaConstraint<?, ?> createMetaConstraint(ConstraintType constraint, Class<T> beanClass, String defaultPackage) {
+ private <A extends Annotation, T> MetaConstraint<?, ?> createMetaConstraint(ConstraintType constraint, Class<T> beanClass, Member member, String defaultPackage) {
@SuppressWarnings("unchecked")
Class<A> annotationClass = ( Class<A> ) getClass( constraint.getAnnotation(), defaultPackage );
AnnotationDescriptor<A> annotationDescriptor = new AnnotationDescriptor<A>( annotationClass );
@@ -224,7 +248,15 @@
ConstraintDescriptorImpl<A> constraintDescriptor = new ConstraintDescriptorImpl<A>(
annotation, new Class[] { }, constraintHelper
);
- return new MetaConstraint<T, A>( beanClass, constraintDescriptor );
+
+ MetaConstraint<T, A> metaConstraint;
+ if ( member == null ) {
+ metaConstraint = new MetaConstraint<T, A>( beanClass, constraintDescriptor );
+ }
+ else {
+ metaConstraint = new MetaConstraint<T, A>( member, beanClass, constraintDescriptor );
+ }
+ return metaConstraint;
}
private void checkNameIsValid(String name) {
@@ -423,7 +455,6 @@
for ( MetaConstraint<?, ?> metaConstraint : entry.getValue() ) {
metaData.addMetaConstraint( metaConstraint );
}
- metaData.init();
BeanMetaDataCache.addBeanMetaData( entry.getKey(), metaData );
}
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java 2009-04-07 17:40:07 UTC (rev 16270)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java 2009-04-07 20:20:12 UTC (rev 16271)
@@ -554,7 +554,6 @@
BeanMetaDataImpl<T> metadata = BeanMetaDataCache.getBeanMetaData( beanClass );
if ( metadata == null ) {
metadata = new BeanMetaDataImpl<T>( beanClass, constraintHelper );
- metadata.init();
BeanMetaDataCache.addBeanMetaData( beanClass, metadata );
}
return metadata;
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/ReflectionHelper.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/ReflectionHelper.java 2009-04-07 17:40:07 UTC (rev 16270)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/ReflectionHelper.java 2009-04-07 20:20:12 UTC (rev 16271)
@@ -50,24 +50,6 @@
private ReflectionHelper() {
}
-
- /**
- * Checks whether the given annotation is a builtin constraint annotation defined as defined by the specs.
- *
- * @param annotation the annotation to check
- *
- * @return <code>true</code> if the annotation is a builtin constraint, <code>false</code> otherwise.
- */
- public static boolean isBuiltInConstraintAnnotation(Annotation annotation) {
- boolean isBuiltInConstraintAnnotation = false;
-
- String packageName = annotation.annotationType().getPackage().getName();
- if ( "javax.validation.constraints".equals( packageName ) ) {
- isBuiltInConstraintAnnotation = true;
- }
- return isBuiltInConstraintAnnotation;
- }
-
@SuppressWarnings("unchecked")
public static <T> T getAnnotationParameter(Annotation annotation, String parameterName, Class<T> type) {
try {
@@ -269,10 +251,7 @@
}
if ( type instanceof WildcardType ) {
Type[] upperBounds = ( ( WildcardType ) type ).getUpperBounds();
- if ( upperBounds.length == 0 ) {
- return false;
- }
- return isIterable( upperBounds[0] );
+ return upperBounds.length != 0 && isIterable( upperBounds[0] );
}
return false;
}
@@ -291,10 +270,7 @@
}
if ( type instanceof WildcardType ) {
Type[] upperBounds = ( ( WildcardType ) type ).getUpperBounds();
- if ( upperBounds.length == 0 ) {
- return false;
- }
- return isMap( upperBounds[0] );
+ return upperBounds.length != 0 && isMap( upperBounds[0] );
}
return false;
}
@@ -357,7 +333,7 @@
}
/**
- * Checks whether the specified class contains a field or member which matches a given property.
+ * Checks whether the specified class contains a field or property matching the given name.
*
* @param clazz The class to check.
* @param property The property name.
@@ -366,24 +342,83 @@
* false</code> otherwise.
*/
public static boolean containsMember(Class<?> clazz, String property) {
+ return containsField( clazz, property ) || containsMethod( clazz, property );
+ }
+
+ /**
+ * Checks whether the specified class contains a field matching the specified name.
+ *
+ * @param clazz The class to check.
+ * @param fieldName The field name.
+ *
+ * @return Returns <code>true</code> if the cass contains a field for the specified name, <code>
+ * false</code> otherwise.
+ */
+ public static boolean containsField(Class<?> clazz, String fieldName) {
try {
- clazz.getField( property );
+ clazz.getDeclaredField( fieldName );
return true;
}
catch ( NoSuchFieldException e ) {
- // ignore
+ return false;
}
+ }
+ /**
+ * Returns the field with the specified name or <code>null</code> if it does not exist.
+ *
+ * @param clazz The class to check.
+ * @param fieldName The field name.
+ *
+ * @return Returns the field with the specified name or <code>null</code> if it does not exist.
+ */
+ public static Field getField(Class<?> clazz, String fieldName) {
try {
- clazz.getMethod( "get" + property.substring( 0, 1 ).toUpperCase() + property.substring( 1 ) );
+ Field field = clazz.getDeclaredField( fieldName );
+ setAccessibility( field );
+ return field;
+ }
+ catch ( NoSuchFieldException e ) {
+ return null;
+ }
+ }
+
+ /**
+ * Checks whether the specified class contains a method matching the specified name.
+ *
+ * @param clazz The class to check.
+ * @param methodName The method name.
+ *
+ * @return Returns <code>true</code> if the cass contains a property for the specified name, <code>
+ * false</code> otherwise.
+ */
+ public static boolean containsMethod(Class<?> clazz, String methodName) {
+ try {
+ clazz.getMethod( "get" + methodName.substring( 0, 1 ).toUpperCase() + methodName.substring( 1 ) );
return true;
}
catch ( NoSuchMethodException e ) {
- // ignore
+ return false;
}
- return false;
}
+ /**
+ * Returns the method with the specified name or <code>null</code> if it does not exist.
+ *
+ * @param clazz The class to check.
+ * @param methodName The method name.
+ *
+ * @return Returns the method with the specified name or <code>null</code> if it does not exist.
+ */
+ public static Method getMethod(Class<?> clazz, String methodName) {
+ try {
+ return clazz.getMethod( "get" + methodName.substring( 0, 1 ).toUpperCase() + methodName.substring( 1 ) );
+ }
+ catch ( NoSuchMethodException e ) {
+ return null;
+ }
+ }
+
public static Class<?> classForName(String name, Class<?> caller) throws ClassNotFoundException {
try {
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/TestGroup.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/TestGroup.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/TestGroup.java 2009-04-07 20:20:12 UTC (rev 16271)
@@ -0,0 +1,24 @@
+// $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.xml;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public interface TestGroup {
+}
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/XmlConfigurationTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/XmlConfigurationTest.java 2009-04-07 17:40:07 UTC (rev 16270)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/XmlConfigurationTest.java 2009-04-07 20:20:12 UTC (rev 16271)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
@@ -23,9 +23,9 @@
import org.testng.annotations.Test;
+import org.hibernate.validation.util.TestUtil;
import static org.hibernate.validation.util.TestUtil.assertNumberOfViolations;
import static org.hibernate.validation.util.TestUtil.getValidator;
-import org.hibernate.validation.util.TestUtil;
/**
* @author Hardy Ferentschik
@@ -33,7 +33,7 @@
public class XmlConfigurationTest {
@Test
- public void testValidatorResolutionForMinMax() {
+ public void testClassConstraintDefinedInXml() {
Validator validator = getValidator();
User user = new User();
@@ -45,4 +45,41 @@
constraintViolations = validator.validate( user );
assertNumberOfViolations( constraintViolations, 0 );
}
+
+ @Test
+ public void testPropertyConstraintDefinedInXml() {
+ Validator validator = getValidator();
+
+ User user = new User();
+ user.setConsistent( true );
+ user.setFirstname( "Wolfeschlegelsteinhausenbergerdorff" );
+
+ Set<ConstraintViolation<User>> constraintViolations = validator.validate( user );
+ assertNumberOfViolations( constraintViolations, 1 );
+ TestUtil.assertConstraintViolation( constraintViolations.iterator().next(), "Size is limited!" );
+
+ user.setFirstname( "Wolfgang" );
+ constraintViolations = validator.validate( user );
+ assertNumberOfViolations( constraintViolations, 0 );
+ }
+
+ @Test
+ public void testFieldConstraintDefinedInXml() {
+ Validator validator = getValidator();
+
+ User user = new User();
+ user.setConsistent( true );
+ user.setFirstname( "Wolfgang" );
+ user.setLastname( "doe" );
+
+ Set<ConstraintViolation<User>> constraintViolations = validator.validate( user );
+ assertNumberOfViolations( constraintViolations, 1 );
+ TestUtil.assertConstraintViolation(
+ constraintViolations.iterator().next(), "Last name has to start with with a capital letter."
+ );
+
+ user.setLastname( "Doe" );
+ constraintViolations = validator.validate( user );
+ assertNumberOfViolations( constraintViolations, 0 );
+ }
}
Modified: validator/trunk/hibernate-validator/src/test/resources/META-INF/validation/user-constraints.xml
===================================================================
--- validator/trunk/hibernate-validator/src/test/resources/META-INF/validation/user-constraints.xml 2009-04-07 17:40:07 UTC (rev 16270)
+++ validator/trunk/hibernate-validator/src/test/resources/META-INF/validation/user-constraints.xml 2009-04-07 20:20:12 UTC (rev 16271)
@@ -22,9 +22,11 @@
</element>
</constraint>
</class>
- <field name="firstName">
- <constraint annotation="com.acme.app.constraint.LooksLike">
- <element name="patterns">
+ <field name="lastname">
+ <constraint annotation="javax.validation.constraints.Pattern">
+ <message>Last name has to start with with a capital letter.</message>
+ <element name="regexp">^[A-Z].*</element>
+ <!--element name="patterns">
<annotation>
<element name="value">myRegExp</element>
<element name="flag">
@@ -34,27 +36,18 @@
<annotation>
<element name="value">my2ndRegExp</element>
</annotation>
- </element>
+ </element-->
</constraint>
</field>
- <field name="orders">
+ <getter name="firstname">
<valid/>
- <constraint annotation="com.acme.app.constraint.DiscreteSize">
- <element name="value">
- <value>0</value>
- <value>20</value>
- </element>
- </constraint>
- </field>
- <getter name="orders">
- <valid/>
- <constraint annotation="javax.validation.constraint.Size">
- <message>Size is limited</message>
+ <constraint annotation="javax.validation.constraints.Size">
+ <message>Size is limited!</message>
<groups>
- <value>com.acme.app.model.LightValidation</value>
- <value>javax.persistence.Default</value>
+ <value>org.hibernate.validation.engine.xml.TestGroup</value>
+ <value>javax.validation.groups.Default</value>
</groups>
- <element name="max">30</element>
+ <element name="max">10</element>
</constraint>
</getter>
</bean>
15 years, 7 months
Hibernate SVN: r16270 - in validator/trunk/hibernate-validator/src: test/java/org/hibernate/validation/engine/xml and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-04-07 13:40:07 -0400 (Tue, 07 Apr 2009)
New Revision: 16270
Added:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataCache.java
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaData.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorFactoryImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/ConsistentUserInformation.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/ConsistentUserValidator.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/User.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/XmlConfigurationTest.java
validator/trunk/hibernate-validator/src/test/resources/META-INF/validation/user-constraints.xml
validator/trunk/hibernate-validator/src/test/suite/unit-tests.xml
Log:
HV-112
Parsing successfully some xml class level constraints
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaData.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaData.java 2009-04-07 16:31:07 UTC (rev 16269)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaData.java 2009-04-07 17:40:07 UTC (rev 16270)
@@ -33,6 +33,12 @@
public interface BeanMetaData<T> {
/**
+ * Initalises the given meta data bean taken its current state into account. An instance of <code>BeanMetaData</code>
+ * won't have any useful state information prior to calling this method.
+ */
+ void init();
+
+ /**
* @return the class of the bean.
*/
Class<T> getBeanClass();
@@ -43,16 +49,6 @@
BeanDescriptor getBeanDescriptor();
/**
- * @return A list of all cascaded fields (fields annotated with @Valid).
- */
- List<Field> getCascadedFields();
-
- /**
- * @return A list of all cascaded methods (methods annotated with @Valid).
- */
- List<Method> getCascadedMethods();
-
- /**
* @return A list of all cascaded methods and fields (methods/fields annotated with @Valid).
*/
List<Member> getCascadedMembers();
Added: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataCache.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataCache.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataCache.java 2009-04-07 17:40:07 UTC (rev 16270)
@@ -0,0 +1,46 @@
+// $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.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class BeanMetaDataCache {
+ /**
+ * A map for the meta data for each entity. The key is the class and the value the bean meta data for this
+ * entity.
+ */
+ private static Map<Class<?>, BeanMetaDataImpl<?>> metadataProviders
+ = new ConcurrentHashMap<Class<?>, BeanMetaDataImpl<?>>( 10 );
+
+ public static <T> BeanMetaDataImpl<T> getBeanMetaData(Class<T> beanClass) {
+ if ( beanClass == null ) {
+ throw new IllegalArgumentException( "Class cannot be null" );
+ }
+ @SuppressWarnings("unchecked")
+ BeanMetaDataImpl<T> metadata = ( BeanMetaDataImpl<T> ) metadataProviders.get( beanClass );
+ return metadata;
+ }
+
+ static void addBeanMetaData(Class<?> beanClass, BeanMetaDataImpl<?> metaData) {
+ metadataProviders.put( beanClass, metaData );
+ }
+}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java 2009-04-07 16:31:07 UTC (rev 16269)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java 2009-04-07 17:40:07 UTC (rev 16270)
@@ -26,10 +26,10 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.HashSet;
import javax.validation.BeanDescriptor;
import javax.validation.GroupSequence;
import javax.validation.PropertyDescriptor;
@@ -48,6 +48,7 @@
* instantiate an instance of this class and delegate the metadata extraction to it.
*
* @author Hardy Ferentschik
+ * @todo check the unchecked assignment warnings in this class
*/
public class BeanMetaDataImpl<T> implements BeanMetaData<T> {
@@ -70,16 +71,11 @@
private List<MetaConstraint<T, ?>> metaConstraintList = new ArrayList<MetaConstraint<T, ?>>();
/**
- * List of cascaded fields.
+ * List of cascaded members.
*/
- private List<Field> cascadedFields = new ArrayList<Field>();
+ private List<Member> cascadedMembers = new ArrayList<Member>();
/**
- * List of cascaded methods.
- */
- private List<Method> cascadedMethods = new ArrayList<Method>();
-
- /**
* Maps field and method names to their <code>ElementDescriptorImpl</code>.
*/
private Map<String, PropertyDescriptor> propertyDescriptors = new HashMap<String, PropertyDescriptor>();
@@ -97,9 +93,44 @@
public BeanMetaDataImpl(Class<T> beanClass, ConstraintHelper constraintHelper) {
this.beanClass = beanClass;
this.constraintHelper = constraintHelper;
+ }
+
+ public void init() {
createMetaData();
}
+ public Class<T> getBeanClass() {
+ return beanClass;
+ }
+
+ public BeanDescriptor getBeanDescriptor() {
+ return beanDescriptor;
+ }
+
+ public List<Member> getCascadedMembers() {
+ return cascadedMembers;
+ }
+
+ public List<MetaConstraint<T, ?>> geMetaConstraintList() {
+ return metaConstraintList;
+ }
+
+ public void addMetaConstraint(MetaConstraint<?, ?> metaConstraint) {
+ metaConstraintList.add( ( MetaConstraint<T, ?> ) metaConstraint );
+ }
+
+ public PropertyDescriptor getPropertyDescriptor(String property) {
+ return propertyDescriptors.get( property );
+ }
+
+ public List<Class<?>> getDefaultGroupSequence() {
+ return defaultGroupSequence;
+ }
+
+ public Set<PropertyDescriptor> getConstrainedProperties() {
+ return Collections.unmodifiableSet( new HashSet<PropertyDescriptor>( propertyDescriptors.values() ) );
+ }
+
/**
* Create bean desciptor, find all classes/subclasses/interfaces which have to be taken in consideration
* for this validator and create meta data.
@@ -187,7 +218,7 @@
}
if ( field.isAnnotationPresent( Valid.class ) ) {
ReflectionHelper.setAccessibility( field );
- cascadedFields.add( field );
+ cascadedMembers.add( field );
addPropertyDescriptorForMember( field );
}
}
@@ -205,7 +236,7 @@
}
if ( method.isAnnotationPresent( Valid.class ) ) {
ReflectionHelper.setAccessibility( method );
- cascadedMethods.add( method );
+ cascadedMembers.add( method );
addPropertyDescriptorForMember( method );
}
}
@@ -327,43 +358,4 @@
}
return metadata;
}
-
- public Class<T> getBeanClass() {
- return beanClass;
- }
-
- public BeanDescriptor getBeanDescriptor() {
- return beanDescriptor;
- }
-
- public List<Field> getCascadedFields() {
- return cascadedFields;
- }
-
- public List<Method> getCascadedMethods() {
- return cascadedMethods;
- }
-
- public List<Member> getCascadedMembers() {
- List<Member> cascadedMembers = new ArrayList<Member>();
- cascadedMembers.addAll( getCascadedFields() );
- cascadedMembers.addAll( getCascadedMethods() );
- return cascadedMembers;
- }
-
- public List<MetaConstraint<T, ?>> geMetaConstraintList() {
- return metaConstraintList;
- }
-
- public PropertyDescriptor getPropertyDescriptor(String property) {
- return propertyDescriptors.get( property );
- }
-
- public List<Class<?>> getDefaultGroupSequence() {
- return defaultGroupSequence;
- }
-
- public Set<PropertyDescriptor> getConstrainedProperties() {
- return Collections.unmodifiableSet( new HashSet<PropertyDescriptor>(propertyDescriptors.values() ) );
- }
}
\ No newline at end of file
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorFactoryImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorFactoryImpl.java 2009-04-07 16:31:07 UTC (rev 16269)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorFactoryImpl.java 2009-04-07 17:40:07 UTC (rev 16270)
@@ -19,9 +19,17 @@
import java.io.IOException;
import java.io.InputStream;
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Array;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import javax.validation.ConstraintValidatorFactory;
import javax.validation.MessageInterpolator;
@@ -44,21 +52,27 @@
import org.hibernate.validation.util.LoggerFactory;
import org.hibernate.validation.util.ReflectionHelper;
+import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
+import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
import org.hibernate.validation.xml.BeanType;
import org.hibernate.validation.xml.ClassType;
import org.hibernate.validation.xml.ConstraintMappingsType;
+import org.hibernate.validation.xml.ConstraintType;
+import org.hibernate.validation.xml.ElementType;
import org.hibernate.validation.xml.FieldType;
import org.hibernate.validation.xml.GetterType;
+import org.hibernate.validation.xml.GroupsType;
/**
* @author Emmanuel Bernard
* @author Hardy Ferentschik
- * @todo Is this the right place to parse the mapping files?
*/
public class ValidatorFactoryImpl implements ValidatorFactory {
private static final Logger log = LoggerFactory.make();
private static final String VALIDATION_MAPPING_XSD = "META-INF/validation-mapping-1.0.xsd";
+ private static final String MESSAGE_PARAM = "message";
+ private static final String GROUPS_PARAM = "groups";
private final MessageInterpolator messageInterpolator;
private final TraversableResolver traversableResolver;
@@ -66,13 +80,18 @@
private final ConstraintHelper constraintHelper = new ConstraintHelper();
private static final String PACKAGE_SEPERATOR = ".";
+ private final Map<Class<?>, Boolean> ignoreAnnotationDefaults = new HashMap<Class<?>, Boolean>();
+ private final Map<Class<?>, List<Member>> ignoreAnnotationOnMember = new HashMap<Class<?>, List<Member>>();
+ private final List<Class<?>> ignoreAnnotationOnClass = new ArrayList<Class<?>>();
+ private final Map<Class<?>, List<MetaConstraint<?, ?>>> constraintMap = new HashMap<Class<?>, List<MetaConstraint<?, ?>>>();
+
public ValidatorFactoryImpl(ConfigurationState configurationState) {
this.messageInterpolator = configurationState.getMessageInterpolator();
this.constraintValidatorFactory = configurationState.getConstraintValidatorFactory();
this.traversableResolver = configurationState.getTraversableResolver();
parseMappingFiles( configurationState.getMappingStreams() );
-
+ initBeanMetaData();
}
/**
@@ -99,7 +118,7 @@
);
}
- public Schema getMappingSchema() {
+ private Schema getMappingSchema() {
URL schemaUrl = this.getClass().getClassLoader().getResource( VALIDATION_MAPPING_XSD );
SchemaFactory sf = SchemaFactory.newInstance( javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI );
Schema schema = null;
@@ -119,16 +138,13 @@
ConstraintMappingsType mappings = getValidationConfig( in );
String defaultPackage = mappings.getDefaultPackage();
for ( BeanType bean : mappings.getBean() ) {
- Class<?> beanClass = getBeanClass( bean.getClazz(), defaultPackage );
- if ( processedClasses.contains( beanClass ) ) {
- throw new ValidationException( beanClass.getName() + " has already be configured in xml." );
- }
- boolean ignoreAnnotations = bean.isIgnoreAnnotations();
- @SuppressWarnings("unchecked")
- BeanMetaDataImpl<?> metaData = new BeanMetaDataImpl( beanClass, constraintHelper );
- parseClassLevelOverrides( metaData, bean.getClassType() );
- parseFieldLevelOverrides( metaData, bean.getField() );
- parsePropertyLevelOverrides( metaData, bean.getGetter() );
+ Class<?> beanClass = getClass( bean.getClazz(), defaultPackage );
+ checkClassHasNotBeenProcessed( processedClasses, beanClass );
+ Boolean ignoreAnnotations = bean.isIgnoreAnnotations() == null ? false : bean.isIgnoreAnnotations();
+ ignoreAnnotationDefaults.put( beanClass, ignoreAnnotations );
+ parseClassLevelOverrides( bean.getClassType(), beanClass, defaultPackage );
+ parseFieldLevelOverrides( bean.getField() );
+ parsePropertyLevelOverrides( bean.getGetter() );
processedClasses.add( beanClass );
}
}
@@ -143,19 +159,226 @@
}
}
- private void parseFieldLevelOverrides(BeanMetaDataImpl<?> metaData, List<FieldType> field) {
- //To change body of created methods use File | Settings | File Templates.
+ private void checkClassHasNotBeenProcessed(Set<Class<?>> processedClasses, Class<?> beanClass) {
+ if ( processedClasses.contains( beanClass ) ) {
+ throw new ValidationException( beanClass.getName() + " has already be configured in xml." );
+ }
}
- private void parsePropertyLevelOverrides(BeanMetaDataImpl<?> metaData, List<GetterType> getter) {
- //To change body of created methods use File | Settings | File Templates.
+ private void parseFieldLevelOverrides(List<FieldType> fields) {
+ for ( FieldType field : fields ) {
+ boolean ignoreFieldAnnotation = field.isIgnoreAnnotations() == null ? false : field.isIgnoreAnnotations();
+ }
}
- private void parseClassLevelOverrides(BeanMetaDataImpl<?> metaData, ClassType classType) {
- //To change body of created methods use File | Settings | File Templates.
+ private void parsePropertyLevelOverrides(List<GetterType> getters) {
+ for ( GetterType getter : getters ) {
+ boolean ignoreGetterAnnotation = getter.isIgnoreAnnotations() == null ? false : getter.isIgnoreAnnotations();
+ }
}
- private Class getBeanClass(String clazz, String defaultPackage) {
+ private void parseClassLevelOverrides(ClassType classType, Class<?> beanClass, String defaultPackage) {
+ if ( classType == null ) {
+ return;
+ }
+ boolean ignoreClassAnnotation = classType.isIgnoreAnnotations() == null ? false : classType.isIgnoreAnnotations();
+ if ( ignoreClassAnnotation ) {
+ ignoreAnnotationOnClass.add( beanClass );
+ }
+ for ( ConstraintType constraint : classType.getConstraint() ) {
+ MetaConstraint<?, ?> metaConstraint = createMetaConstraint( constraint, beanClass, defaultPackage );
+ addMetaConstraint( beanClass, metaConstraint );
+ }
+ }
+
+ private void addMetaConstraint(Class<?> beanClass, MetaConstraint<?, ?> metaConstraint) {
+ if ( constraintMap.containsKey( beanClass ) ) {
+ constraintMap.get( beanClass ).add( metaConstraint );
+ }
+ else {
+ List<MetaConstraint<?, ?>> constraintList = new ArrayList<MetaConstraint<?, ?>>();
+ constraintList.add( metaConstraint );
+ constraintMap.put( beanClass, constraintList );
+ }
+ }
+
+ private <A extends Annotation, T> MetaConstraint<?, ?> createMetaConstraint(ConstraintType constraint, Class<T> beanClass, String defaultPackage) {
+ @SuppressWarnings("unchecked")
+ Class<A> annotationClass = ( Class<A> ) getClass( constraint.getAnnotation(), defaultPackage );
+ AnnotationDescriptor<A> annotationDescriptor = new AnnotationDescriptor<A>( annotationClass );
+
+ if ( constraint.getMessage() != null ) {
+ annotationDescriptor.setValue( MESSAGE_PARAM, constraint.getMessage() );
+ }
+ annotationDescriptor.setValue( GROUPS_PARAM, getGroups( constraint.getGroups(), defaultPackage ) );
+
+ for ( ElementType elementType : constraint.getElement() ) {
+ String name = elementType.getName();
+ checkNameIsValid( name );
+ Class<?> returnType = getAnnotationParamterType( annotationClass, name );
+ Object elementValue = getElementValue( elementType, returnType );
+ annotationDescriptor.setValue( name, elementValue );
+ }
+
+ A annotation = AnnotationFactory.create( annotationDescriptor );
+ ConstraintDescriptorImpl<A> constraintDescriptor = new ConstraintDescriptorImpl<A>(
+ annotation, new Class[] { }, constraintHelper
+ );
+ return new MetaConstraint<T, A>( beanClass, constraintDescriptor );
+ }
+
+ private void checkNameIsValid(String name) {
+ if ( MESSAGE_PARAM.equals( name ) || GROUPS_PARAM.equals( name ) ) {
+ throw new ValidationException( MESSAGE_PARAM + " and " + GROUPS_PARAM + " are reserved paramter names." );
+ }
+ }
+
+ private <A extends Annotation> Class<?> getAnnotationParamterType(Class<A> annotationClass, String name) {
+ Method m;
+ try {
+ m = annotationClass.getMethod( name );
+ }
+ catch ( NoSuchMethodException e ) {
+ throw new ValidationException( "Annotation of type " + annotationClass.getName() + " does not contain a paramter " + name + "." );
+ }
+ return m.getReturnType();
+ }
+
+ private Object getElementValue(ElementType elementType, Class<?> returnType) {
+ removeEmptyContentElements( elementType );
+
+ boolean isArray = returnType.isArray();
+ if ( !isArray ) {
+ if ( elementType.getContent().size() != 1 ) {
+ throw new ValidationException( "Attempt to specify an array where single value is expected." );
+ }
+ return getSingleValue( elementType.getContent().get( 0 ), returnType );
+ }
+ else {
+ List<Object> values = new ArrayList<Object>();
+ for ( Serializable s : elementType.getContent() ) {
+ values.add( getSingleValue( s, returnType.getComponentType() ) );
+ }
+ return values.toArray( ( Object[] ) Array.newInstance( returnType.getComponentType(), values.size() ) );
+ }
+ }
+
+ private void removeEmptyContentElements(ElementType elementType) {
+ List<Serializable> contentToDelete = new ArrayList<Serializable>();
+ for ( Serializable content : elementType.getContent() ) {
+ if ( content instanceof String && ( ( String ) content ).matches( "[\\n ].*" ) ) {
+ contentToDelete.add( content );
+ }
+ }
+ elementType.getContent().removeAll( contentToDelete );
+ }
+
+ private Object getSingleValue(Serializable serializable, Class<?> returnType) {
+ String value;
+ if ( serializable instanceof String ) {
+ value = ( String ) serializable;
+ }
+ else if ( serializable instanceof JAXBElement ) {
+ JAXBElement<?> elem = ( JAXBElement<?> ) serializable;
+ // this is safe due to the underlying schema
+ value = ( String ) elem.getValue();
+ }
+ else {
+ throw new ValidationException( "Unexpected paramter value" );
+ }
+
+ return convertStringToReturnType( returnType, value );
+ }
+
+ private Object convertStringToReturnType(Class<?> returnType, String value) {
+ Object returnValue;
+ if ( returnType.isPrimitive() && returnType.getName().equals( byte.class.getName() ) ) {
+ try {
+ returnValue = Byte.parseByte( value );
+ }
+ catch ( NumberFormatException e ) {
+ throw new ValidationException( "Invalid byte format", e );
+ }
+ }
+ else if ( returnType.isPrimitive() && returnType.getName().equals( short.class.getName() ) ) {
+ try {
+ returnValue = Short.parseShort( value );
+ }
+ catch ( NumberFormatException e ) {
+ throw new ValidationException( "Invalid short format", e );
+ }
+ }
+ else if ( returnType.isPrimitive() && returnType.getName().equals( int.class.getName() ) ) {
+ try {
+ returnValue = Integer.parseInt( value );
+ }
+ catch ( NumberFormatException e ) {
+ throw new ValidationException( "Invalid int format", e );
+ }
+ }
+ else if ( returnType.isPrimitive() && returnType.getName().equals( long.class.getName() ) ) {
+ try {
+ returnValue = Long.parseLong( value );
+ }
+ catch ( NumberFormatException e ) {
+ throw new ValidationException( "Invalid long format", e );
+ }
+ }
+ else if ( returnType.isPrimitive() && returnType.getName().equals( float.class.getName() ) ) {
+ try {
+ returnValue = Float.parseFloat( value );
+ }
+ catch ( NumberFormatException e ) {
+ throw new ValidationException( "Invalid float format", e );
+ }
+ }
+ else if ( returnType.isPrimitive() && returnType.getName().equals( double.class.getName() ) ) {
+ try {
+ returnValue = Double.parseDouble( value );
+ }
+ catch ( NumberFormatException e ) {
+ throw new ValidationException( "Invalid double format", e );
+ }
+ }
+ else if ( returnType.isPrimitive() && returnType.getName().equals( boolean.class.getName() ) ) {
+ returnValue = Boolean.parseBoolean( value );
+ }
+ else if ( returnType.isPrimitive() && returnType.getName().equals( char.class.getName() ) ) {
+ if ( value.length() != 1 ) {
+ throw new ValidationException( "Invalid char value: " + value );
+ }
+ returnValue = value.charAt( 0 );
+ }
+ else if ( returnType.getName().equals( String.class.getName() ) ) {
+ returnValue = value;
+ }
+ else if ( returnType.getName().equals( Class.class.getName() ) ) {
+ try {
+ returnValue = ReflectionHelper.classForName( value, this.getClass() );
+ }
+ catch ( ClassNotFoundException e ) {
+ throw new ValidationException( "Unable to instantiate class: " + value );
+ }
+ }
+ else {
+ throw new ValidationException( "Invalid return type: " + returnType );
+ }
+ return returnValue;
+ }
+
+ private Class<?>[] getGroups(GroupsType groupsType, String defaultPackage) {
+ if ( groupsType == null ) {
+ return new Class[] { };
+ }
+
+ List<Class<?>> groupList = new ArrayList<Class<?>>();
+ for ( String groupClass : groupsType.getValue() ) {
+ groupList.add( getClass( groupClass, defaultPackage ) );
+ }
+ return groupList.toArray( new Class[groupList.size()] );
+ }
+
+ private Class<?> getClass(String clazz, String defaultPackage) {
String fullyQualifiedClass;
if ( isQualifiedClass( clazz ) ) {
fullyQualifiedClass = clazz;
@@ -193,4 +416,15 @@
}
return constraintMappings;
}
+
+ private void initBeanMetaData() {
+ for ( Map.Entry<Class<?>, List<MetaConstraint<?, ?>>> entry : constraintMap.entrySet() ) {
+ BeanMetaDataImpl<?> metaData = new BeanMetaDataImpl( entry.getKey(), constraintHelper );
+ for ( MetaConstraint<?, ?> metaConstraint : entry.getValue() ) {
+ metaData.addMetaConstraint( metaConstraint );
+ }
+ metaData.init();
+ BeanMetaDataCache.addBeanMetaData( entry.getKey(), metaData );
+ }
+ }
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java 2009-04-07 16:31:07 UTC (rev 16269)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java 2009-04-07 17:40:07 UTC (rev 16270)
@@ -27,7 +27,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
import javax.validation.BeanDescriptor;
import javax.validation.ConstraintValidatorFactory;
import javax.validation.ConstraintViolation;
@@ -73,13 +72,6 @@
private static final Class<?>[] DEFAULT_GROUP_ARRAY = new Class<?>[] { Default.class };
/**
- * A map for the meta data for each entity. The key is the class and the value the bean meta data for this
- * entity.
- */
- private static Map<Class<?>, BeanMetaDataImpl<?>> metadataProviders
- = new ConcurrentHashMap<Class<?>, BeanMetaDataImpl<?>>( 10 );
-
- /**
* Used to resolve the group execution order for a validate call.
*/
private GroupChainGenerator groupChainGenerator;
@@ -559,14 +551,11 @@
* {@inheritDoc}
*/
private <T> BeanMetaData<T> getBeanMetaData(Class<T> beanClass) {
- if ( beanClass == null ) {
- throw new IllegalArgumentException( "Class cannot be null" );
- }
- @SuppressWarnings("unchecked")
- BeanMetaDataImpl<T> metadata = ( BeanMetaDataImpl<T> ) metadataProviders.get( beanClass );
+ BeanMetaDataImpl<T> metadata = BeanMetaDataCache.getBeanMetaData( beanClass );
if ( metadata == null ) {
metadata = new BeanMetaDataImpl<T>( beanClass, constraintHelper );
- metadataProviders.put( beanClass, metadata );
+ metadata.init();
+ BeanMetaDataCache.addBeanMetaData( beanClass, metadata );
}
return metadata;
}
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/ConsistentUserInformation.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/ConsistentUserInformation.java 2009-04-07 16:31:07 UTC (rev 16269)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/ConsistentUserInformation.java 2009-04-07 17:40:07 UTC (rev 16270)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
@@ -38,4 +38,10 @@
public abstract String message() default "User information is not consistent.";
public abstract Class<?>[] groups() default { };
+
+ public abstract String stringParam() default "";
+
+ public abstract String[] stringArrayParam() default { };
+
+ public abstract int intParam() default 0;
}
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/ConsistentUserValidator.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/ConsistentUserValidator.java 2009-04-07 16:31:07 UTC (rev 16269)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/ConsistentUserValidator.java 2009-04-07 17:40:07 UTC (rev 16270)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
@@ -29,6 +29,6 @@
}
public boolean isValid(User user, ConstraintValidatorContext constraintValidatorContext) {
- return true;
+ return user.isConsistent();
}
}
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/User.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/User.java 2009-04-07 16:31:07 UTC (rev 16269)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/User.java 2009-04-07 17:40:07 UTC (rev 16270)
@@ -5,6 +5,8 @@
*/
public class User {
+ private boolean isConsistent;
+
private String firstname;
//@NotNull(groups = Default.class)
@@ -37,4 +39,12 @@
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
+
+ public void setConsistent(boolean consistent) {
+ isConsistent = consistent;
+ }
+
+ public boolean isConsistent() {
+ return isConsistent;
+ }
}
\ No newline at end of file
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/XmlConfigurationTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/XmlConfigurationTest.java 2009-04-07 16:31:07 UTC (rev 16269)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/XmlConfigurationTest.java 2009-04-07 17:40:07 UTC (rev 16270)
@@ -25,6 +25,7 @@
import static org.hibernate.validation.util.TestUtil.assertNumberOfViolations;
import static org.hibernate.validation.util.TestUtil.getValidator;
+import org.hibernate.validation.util.TestUtil;
/**
* @author Hardy Ferentschik
@@ -38,5 +39,10 @@
User user = new User();
Set<ConstraintViolation<User>> constraintViolations = validator.validate( user );
assertNumberOfViolations( constraintViolations, 1 );
+ TestUtil.assertConstraintViolation( constraintViolations.iterator().next(), "Message from xml" );
+
+ user.setConsistent( true );
+ constraintViolations = validator.validate( user );
+ assertNumberOfViolations( constraintViolations, 0 );
}
}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/XmlConfigurationTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: validator/trunk/hibernate-validator/src/test/resources/META-INF/validation/user-constraints.xml
===================================================================
--- validator/trunk/hibernate-validator/src/test/resources/META-INF/validation/user-constraints.xml 2009-04-07 16:31:07 UTC (rev 16269)
+++ validator/trunk/hibernate-validator/src/test/resources/META-INF/validation/user-constraints.xml 2009-04-07 17:40:07 UTC (rev 16270)
@@ -8,13 +8,17 @@
<value>value0</value>
</group-sequence>
<constraint annotation="org.hibernate.validation.engine.xml.ConsistentUserInformation">
- <message>message0</message>
+ <message>Message from xml</message>
<groups>
+ <value>javax.validation.groups.Default</value>
+ </groups>
+ <element name="stringParam">foobar</element>
+ <element name="stringArrayParam">
<value>foo</value>
- </groups>
- <element name="name1">
+ <value>bar</value>
</element>
- <element name="name3">
+ <element name="intParam">
+ <value>42</value>
</element>
</constraint>
</class>
Modified: validator/trunk/hibernate-validator/src/test/suite/unit-tests.xml
===================================================================
--- validator/trunk/hibernate-validator/src/test/suite/unit-tests.xml 2009-04-07 16:31:07 UTC (rev 16269)
+++ validator/trunk/hibernate-validator/src/test/suite/unit-tests.xml 2009-04-07 17:40:07 UTC (rev 16270)
@@ -12,6 +12,7 @@
<package name="org.hibernate.validation.engine.groups"/>
<package name="org.hibernate.validation.engine.metadata"/>
<package name="org.hibernate.validation.engine.validatorresolution"/>
+ <package name="org.hibernate.validation.engine.xml"/>
<package name="org.hibernate.validation.util"/>
<package name="org.hibernate.validation.util.annotationfactory"/>
</packages>
15 years, 7 months
Hibernate SVN: r16269 - in search/trunk/src: main/java/org/hibernate/search/cfg and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-04-07 12:31:07 -0400 (Tue, 07 Apr 2009)
New Revision: 16269
Added:
search/trunk/src/main/java/org/hibernate/search/cfg/ConcatStringBridge.java
search/trunk/src/main/java/org/hibernate/search/cfg/FieldBridgeMapping.java
Modified:
search/trunk/src/main/java/org/hibernate/search/annotations/Field.java
search/trunk/src/main/java/org/hibernate/search/annotations/FieldBridge.java
search/trunk/src/main/java/org/hibernate/search/cfg/FieldMapping.java
search/trunk/src/main/java/org/hibernate/search/impl/MappingModelMetadataProvider.java
search/trunk/src/test/java/org/hibernate/search/test/configuration/ProgrammaticMappingTest.java
Log:
HSEARCH-352 boost and field bridge support on field()
Modified: search/trunk/src/main/java/org/hibernate/search/annotations/Field.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/annotations/Field.java 2009-04-06 21:43:00 UTC (rev 16268)
+++ search/trunk/src/main/java/org/hibernate/search/annotations/Field.java 2009-04-07 16:31:07 UTC (rev 16269)
@@ -51,7 +51,7 @@
/**
- * Field bridge used. Default is autowired.
+ * Boost factor, default 1
*/
Boost boost() default @Boost( value = 1.0F );
Modified: search/trunk/src/main/java/org/hibernate/search/annotations/FieldBridge.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/annotations/FieldBridge.java 2009-04-06 21:43:00 UTC (rev 16268)
+++ search/trunk/src/main/java/org/hibernate/search/annotations/FieldBridge.java 2009-04-07 16:31:07 UTC (rev 16269)
@@ -17,7 +17,7 @@
@Documented
public @interface FieldBridge {
//default to embed @FieldBridge in @Field
- public Class impl() default void.class;
+ public Class<?> impl() default void.class;
public Parameter[] params() default {};
}
Added: search/trunk/src/main/java/org/hibernate/search/cfg/ConcatStringBridge.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/ConcatStringBridge.java (rev 0)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/ConcatStringBridge.java 2009-04-07 16:31:07 UTC (rev 16269)
@@ -0,0 +1,28 @@
+package org.hibernate.search.cfg;
+
+import java.util.Map;
+
+import org.hibernate.search.bridge.ParameterizedBridge;
+import org.hibernate.search.bridge.StringBridge;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class ConcatStringBridge implements StringBridge, ParameterizedBridge{
+ public static final String SIZE = "size";
+ private int size;
+
+ public String objectToString(Object object) {
+ if (object == null) return "";
+ if ( ! (object instanceof String) ) {
+ throw new RuntimeException( "not a string" );
+ }
+ String string = object.toString();
+ int maxSize = string.length() >= size ? size : string.length();
+ return string.substring( 0, maxSize );
+ }
+
+ public void setParameterValues(Map parameters) {
+ size = Integer.valueOf( (String) parameters.get( SIZE ) );
+ }
+}
Added: search/trunk/src/main/java/org/hibernate/search/cfg/FieldBridgeMapping.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/FieldBridgeMapping.java (rev 0)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/FieldBridgeMapping.java 2009-04-07 16:31:07 UTC (rev 16269)
@@ -0,0 +1,94 @@
+package org.hibernate.search.cfg;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.lang.annotation.ElementType;
+
+import org.apache.solr.analysis.TokenizerFactory;
+
+import org.hibernate.search.annotations.Store;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.TermVector;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class FieldBridgeMapping {
+ private final SearchMapping mapping;
+ private final EntityDescriptor entity;
+ private final PropertyDescriptor property;
+ private final FieldMapping fieldMapping;
+ private final Map<String, Object> bridge = new HashMap<String, Object>();;
+
+ public FieldBridgeMapping(Class<?> impl, Map<String, Object> field,
+ FieldMapping fieldMapping,
+ PropertyDescriptor property,
+ EntityDescriptor entity,
+ SearchMapping mapping) {
+ this.mapping = mapping;
+ this.entity = entity;
+ this.property = property;
+ this.fieldMapping = fieldMapping;
+ bridge.put( "impl", impl );
+ field.put( "bridge", bridge );
+ }
+
+ public FieldBridgeMapping param(String name, String value) {
+ Map<String, Object> param = SearchMapping.addElementToAnnotationArray(bridge, "params");
+ param.put("name", name);
+ param.put("value", value);
+ return this;
+ }
+
+ //FieldMapping level
+ public FieldMapping name(String fieldName) {
+ return fieldMapping.name( fieldName );
+ }
+
+ public FieldMapping store(Store store) {
+ return fieldMapping.store( store );
+ }
+
+ public FieldMapping index(Index index) {
+ return fieldMapping.index( index );
+ }
+
+ public FieldMapping termVector(TermVector termVector) {
+ return fieldMapping.termVector( termVector );
+ }
+
+ public FieldMapping boost(float boost) {
+ return fieldMapping.boost( boost );
+ }
+
+ public FieldMapping analyzer(Class<?> analyzerClass) {
+ return fieldMapping.analyzer( analyzerClass );
+ }
+
+ public FieldMapping analyzer(String analyzerDef) {
+ return fieldMapping.analyzer( analyzerDef );
+ }
+
+ //PropertyMapping level
+ public FieldMapping field() {
+ return new FieldMapping(property, entity, mapping);
+ }
+
+ //EntityMapping level
+ public PropertyMapping property(String name, ElementType type) {
+ return new PropertyMapping(name, type, entity, mapping);
+ }
+
+ //Global level
+ public AnalyzerDefMapping analyzerDef(String name, Class<? extends TokenizerFactory> tokenizerFactory) {
+ return new AnalyzerDefMapping(name, tokenizerFactory, mapping);
+ }
+
+ public EntityMapping indexedClass(Class<?> entityType) {
+ return new EntityMapping(entityType, null, mapping);
+ }
+
+ public EntityMapping indexedClass(Class<?> entityType, String indexName) {
+ return new EntityMapping(entityType, indexName, mapping);
+ }
+}
Modified: search/trunk/src/main/java/org/hibernate/search/cfg/FieldMapping.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/FieldMapping.java 2009-04-06 21:43:00 UTC (rev 16268)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/FieldMapping.java 2009-04-07 16:31:07 UTC (rev 16269)
@@ -8,20 +8,20 @@
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Store;
+import org.hibernate.search.annotations.TermVector;
/**
* @author Emmanuel Bernard
*/
public class FieldMapping {
- private SearchMapping mapping;
- private EntityDescriptor entity;
- private PropertyDescriptor property;
- private Map<String, Object> field = new HashMap<String, Object>();
+ private final SearchMapping mapping;
+ private final EntityDescriptor entity;
+ private final PropertyDescriptor property;
+ private final Map<String, Object> field = new HashMap<String, Object>();
public FieldMapping(PropertyDescriptor property, EntityDescriptor entity, SearchMapping mapping) {
this.mapping = mapping;
this.entity = entity;
- this.mapping = mapping;
this.property = property;
property.addField(field);
}
@@ -41,6 +41,22 @@
return this;
}
+ public FieldMapping termVector(TermVector termVector) {
+ field.put( "termVector", termVector );
+ return this;
+ }
+
+ public FieldMapping boost(float boost) {
+ final Map<String, Object> boostAnn = new HashMap<String, Object>();
+ boostAnn.put( "value", boost );
+ field.put( "boost", boostAnn );
+ return this;
+ }
+
+ public FieldBridgeMapping bridge(Class<?> impl) {
+ return new FieldBridgeMapping( impl, field, this, property, entity, mapping );
+ }
+
public FieldMapping analyzer(Class<?> analyzerClass) {
final Map<String, Object> analyzer = new HashMap<String, Object>();
analyzer.put( "impl", analyzerClass );
Modified: search/trunk/src/main/java/org/hibernate/search/impl/MappingModelMetadataProvider.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/impl/MappingModelMetadataProvider.java 2009-04-06 21:43:00 UTC (rev 16268)
+++ search/trunk/src/main/java/org/hibernate/search/impl/MappingModelMetadataProvider.java 2009-04-07 16:31:07 UTC (rev 16269)
@@ -2,7 +2,6 @@
import java.util.Map;
import java.util.List;
-import java.util.Set;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Collection;
@@ -31,6 +30,8 @@
import org.hibernate.search.annotations.Parameter;
import org.hibernate.search.annotations.TokenFilterDef;
import org.hibernate.search.annotations.AnalyzerDefs;
+import org.hibernate.search.annotations.Boost;
+import org.hibernate.search.annotations.FieldBridge;
/**
* @author Emmanuel Bernard
@@ -96,8 +97,7 @@
Map<String, Object> tokenizer = (Map<String, Object>) entry.getValue();
for( Map.Entry<String, Object> tokenizerEntry : tokenizer.entrySet() ) {
if ( tokenizerEntry.getKey().equals( "params" ) ) {
- Parameter[] paramsArray = createParams( (List<Map<String, Object>>) tokenizerEntry.getValue() );
- tokenizerAnnotation.setValue( "params", paramsArray );
+ addParamsToAnnotation( tokenizerAnnotation, tokenizerEntry );
}
else {
tokenizerAnnotation.setValue( tokenizerEntry.getKey(), tokenizerEntry.getValue() );
@@ -116,6 +116,11 @@
return AnnotationFactory.create( analyzerDefAnnotation );
}
+ static private void addParamsToAnnotation(AnnotationDescriptor annotationDescriptor, Map.Entry<String, Object> entry) {
+ Parameter[] paramsArray = createParams( ( List<Map<String, Object>> ) entry.getValue() );
+ annotationDescriptor.setValue( "params", paramsArray );
+ }
+
private TokenFilterDef[] createFilters(List<Map<String, Object>> filters) {
TokenFilterDef[] filtersArray = new TokenFilterDef[filters.size()];
int index = 0;
@@ -123,8 +128,7 @@
AnnotationDescriptor filterAnn = new AnnotationDescriptor( TokenFilterDef.class );
for ( Map.Entry<String, Object> filterEntry : filter.entrySet() ) {
if ( filterEntry.getKey().equals( "params" ) ) {
- Parameter[] paramsArray = createParams( (List<Map<String, Object>>) filterEntry.getValue() );
- filterAnn.setValue( "params", paramsArray );
+ addParamsToAnnotation( filterAnn, filterEntry );
}
else {
filterAnn.setValue( filterEntry.getKey(), filterEntry.getValue() );
@@ -136,7 +140,7 @@
return filtersArray;
}
- private Parameter[] createParams(List<Map<String, Object>> params) {
+ private static Parameter[] createParams(List<Map<String, Object>> params) {
Parameter[] paramArray = new Parameter[ params.size() ];
int index = 0;
for ( Map<String, Object> entry : params) {
@@ -249,6 +253,29 @@
}
fieldAnnotation.setValue( "analyzer", AnnotationFactory.create( analyzerAnnotation ) );
}
+ else if ( entry.getKey().equals( "boost" ) ) {
+ AnnotationDescriptor boostAnnotation = new AnnotationDescriptor( Boost.class );
+ @SuppressWarnings( "unchecked" )
+ Map<String, Object> boost = (Map<String, Object>) entry.getValue();
+ for( Map.Entry<String, Object> boostEntry : boost.entrySet() ) {
+ boostAnnotation.setValue( boostEntry.getKey(), boostEntry.getValue() );
+ }
+ fieldAnnotation.setValue( "boost", AnnotationFactory.create( boostAnnotation ) );
+ }
+ else if ( entry.getKey().equals( "bridge" ) ) {
+ AnnotationDescriptor bridgeAnnotation = new AnnotationDescriptor( FieldBridge.class );
+ @SuppressWarnings( "unchecked" )
+ Map<String, Object> bridge = (Map<String, Object>) entry.getValue();
+ for( Map.Entry<String, Object> bridgeEntry : bridge.entrySet() ) {
+ if ( bridgeEntry.getKey().equals( "params" ) ) {
+ addParamsToAnnotation( bridgeAnnotation, bridgeEntry );
+ }
+ else {
+ bridgeAnnotation.setValue( bridgeEntry.getKey(), bridgeEntry.getValue() );
+ }
+ }
+ fieldAnnotation.setValue( "bridge", AnnotationFactory.create( bridgeAnnotation ) );
+ }
else {
fieldAnnotation.setValue( entry.getKey(), entry.getValue() );
}
Modified: search/trunk/src/test/java/org/hibernate/search/test/configuration/ProgrammaticMappingTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/configuration/ProgrammaticMappingTest.java 2009-04-06 21:43:00 UTC (rev 16268)
+++ search/trunk/src/test/java/org/hibernate/search/test/configuration/ProgrammaticMappingTest.java 2009-04-07 16:31:07 UTC (rev 16269)
@@ -1,6 +1,7 @@
package org.hibernate.search.test.configuration;
import java.lang.annotation.ElementType;
+import java.util.List;
import org.apache.solr.analysis.StandardTokenizerFactory;
import org.apache.solr.analysis.SnowballPorterFilterFactory;
@@ -11,6 +12,7 @@
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.hibernate.search.cfg.SearchMapping;
+import org.hibernate.search.cfg.ConcatStringBridge;
import org.hibernate.search.annotations.Store;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.test.analyzer.inheritance.ISOLatin1Analyzer;
@@ -18,6 +20,7 @@
import org.hibernate.search.FullTextSession;
import org.hibernate.search.Search;
import org.hibernate.search.FullTextQuery;
+import org.hibernate.search.bridge.builtin.StringBridge;
import org.hibernate.search.store.RAMDirectoryProvider;
import org.hibernate.search.store.FSDirectoryProvider;
import org.hibernate.cfg.Configuration;
@@ -52,7 +55,6 @@
s.delete( firstResult[1] );
tx.commit();
s.close();
-
}
public void testAnalyzerDef() throws Exception{
@@ -71,7 +73,7 @@
QueryParser parser = new QueryParser( "id", new StandardAnalyzer( ) );
org.apache.lucene.search.Query luceneQuery = parser.parse( "street1_ngram:pea" );
- System.out.print( luceneQuery.toString() );
+
final FullTextQuery query = s.createFullTextQuery( luceneQuery );
assertEquals( "Analyzer inoperant", 1, query.getResultSize() );
@@ -81,6 +83,71 @@
}
+ public void testBridgeMapping() throws Exception{
+ Address address = new Address();
+ address.setStreet1( "Peachtree Rd NE" );
+ address.setStreet2( "JBoss" );
+
+ FullTextSession s = Search.getFullTextSession( openSession() );
+ Transaction tx = s.beginTransaction();
+ s.persist( address );
+ tx.commit();
+
+ s.clear();
+
+ tx = s.beginTransaction();
+
+ QueryParser parser = new QueryParser( "id", new StandardAnalyzer( ) );
+ org.apache.lucene.search.Query luceneQuery = parser.parse( "street1:peac" );
+ FullTextQuery query = s.createFullTextQuery( luceneQuery );
+ assertEquals( "PrefixQuery should not be on", 0, query.getResultSize() );
+
+ luceneQuery = parser.parse( "street1_abridged:peac" );
+ query = s.createFullTextQuery( luceneQuery );
+ assertEquals( "Bridge not used", 1, query.getResultSize() );
+
+ s.delete( query.list().get( 0 ) );
+ tx.commit();
+ s.close();
+ }
+
+ public void testBoost() throws Exception{
+ FullTextSession s = Search.getFullTextSession( openSession() );
+ Transaction tx = s.beginTransaction();
+
+ Address address = new Address();
+ address.setStreet1( "Peachtree Rd NE" );
+ address.setStreet2( "Peachtnot Rd NE" );
+ s.persist( address );
+
+ address = new Address();
+ address.setStreet1( "Peachtnot Rd NE" );
+ address.setStreet2( "Peachtree Rd NE" );
+ s.persist( address );
+
+ tx.commit();
+
+ s.clear();
+
+ tx = s.beginTransaction();
+
+ QueryParser parser = new QueryParser( "id", new StandardAnalyzer( ) );
+ org.apache.lucene.search.Query luceneQuery = parser.parse( "street1:peachtree OR idx_street2:peachtree" );
+ FullTextQuery query = s.createFullTextQuery( luceneQuery ).setProjection( FullTextQuery.THIS, FullTextQuery.SCORE );
+ assertEquals( "expecting two results", 2, query.getResultSize() );
+
+ @SuppressWarnings( "unchecked" )
+ List<Object[]> results = query.list();
+
+ assertTrue( "first result should be strictly higher", (Float) results.get( 0 )[1] > (Float) results.get( 1 )[1]*1.9f );
+ assertEquals( "Wrong result ordered", address.getStreet1(), ( (Address) results.get( 0 )[0] ).getStreet1() );
+ for( Object[] result : results ) {
+ s.delete( result[0] );
+ }
+ tx.commit();
+ s.close();
+ }
+
@Override
protected void configure(Configuration cfg) {
super.configure( cfg );
@@ -96,8 +163,11 @@
.property( "street1", ElementType.FIELD )
.field()
.field().name( "street1_ngram" ).analyzer( "ngram" )
+ .field()
+ .name( "street1_abridged" )
+ .bridge( ConcatStringBridge.class ).param( ConcatStringBridge.SIZE, "4" )
.property( "street2", ElementType.METHOD )
- .field().name( "idx_street2" ).store( Store.YES );
+ .field().name( "idx_street2" ).store( Store.YES ).boost( 2 );
cfg.getProperties().put( "hibernate.search.mapping_model", mapping );
}
15 years, 7 months
Hibernate SVN: r16268 - search/trunk.
by hibernate-commits@lists.jboss.org
Author: sannegrinovero
Date: 2009-04-06 17:43:00 -0400 (Mon, 06 Apr 2009)
New Revision: 16268
Modified:
search/trunk/pom.xml
Log:
HSEARCH-348 (upgrading to Lucene 2.4.1) and align slf4j versions with hibernate core
Modified: search/trunk/pom.xml
===================================================================
--- search/trunk/pom.xml 2009-04-06 21:31:26 UTC (rev 16267)
+++ search/trunk/pom.xml 2009-04-06 21:43:00 UTC (rev 16268)
@@ -57,12 +57,12 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>${hibernateVersion}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>${hibernateVersion}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
@@ -72,12 +72,12 @@
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
- <version>2.4.0</version>
+ <version>${luceneVersion}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
- <version>1.4.2</version>
+ <version>${slf4jVersion}</version>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
@@ -109,7 +109,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
- <version>1.4.2</version>
+ <version>${slf4jVersion}</version>
<scope>test</scope>
</dependency>
</dependencies>
@@ -306,13 +306,13 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>${hibernateVersion}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
- <version>3.5.0-SNAPSHOT</version>
+ <version>${hibernateVersion}</version>
<optional>true</optional>
</dependency>
<dependency>
@@ -326,17 +326,39 @@
<artifactId>solr-core</artifactId>
<version>1.3.0</version>
<optional>true</optional>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.solr</groupId>
+ <artifactId>solr-solrj</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>net.java.dev.stax-utils</groupId>
+ <artifactId>stax-utils</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-snowball</artifactId>
- <version>2.4.0</version>
+ <version>${luceneVersion}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-analyzers</artifactId>
- <version>2.4.0</version>
+ <version>${luceneVersion}</version>
<optional>true</optional>
</dependency>
<dependency>
@@ -411,4 +433,11 @@
</build>
</profile>
</profiles>
+
+ <properties>
+ <slf4jVersion>1.5.6</slf4jVersion>
+ <luceneVersion>2.4.1</luceneVersion>
+ <hibernateVersion>3.5.0-SNAPSHOT</hibernateVersion>
+ </properties>
+
</project>
15 years, 7 months
Hibernate SVN: r16267 - search/trunk/src/main/java/org/hibernate/search/impl.
by hibernate-commits@lists.jboss.org
Author: sannegrinovero
Date: 2009-04-06 17:31:26 -0400 (Mon, 06 Apr 2009)
New Revision: 16267
Modified:
search/trunk/src/main/java/org/hibernate/search/impl/SearchFactoryImpl.java
Log:
HSEARCH-352 add analyzerDef support
Modified: search/trunk/src/main/java/org/hibernate/search/impl/SearchFactoryImpl.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/impl/SearchFactoryImpl.java 2009-04-06 20:51:40 UTC (rev 16266)
+++ search/trunk/src/main/java/org/hibernate/search/impl/SearchFactoryImpl.java 2009-04-06 21:31:26 UTC (rev 16267)
@@ -458,11 +458,12 @@
private void initProgrammaticAnalyzers(InitContext context, ReflectionManager reflectionManager) {
final Map defaults = reflectionManager.getDefaults();
-
if (defaults != null) {
AnalyzerDef[] defs = (AnalyzerDef[]) defaults.get( AnalyzerDefs.class );
- for (AnalyzerDef def : defs) {
- context.addAnalyzerDef( def );
+ if ( defs != null ) {
+ for (AnalyzerDef def : defs) {
+ context.addAnalyzerDef( def );
+ }
}
}
}
15 years, 7 months
Hibernate SVN: r16266 - annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/inheritance/joined.
by hibernate-commits@lists.jboss.org
Author: gbadner
Date: 2009-04-06 16:51:40 -0400 (Mon, 06 Apr 2009)
New Revision: 16266
Modified:
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/inheritance/joined/File.java
Log:
JBPAPP-1069 : Annotations - MSSQL/Oracle - Reserved word "File" causes test to fail
Modified: annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/inheritance/joined/File.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/inheritance/joined/File.java 2009-04-06 20:29:19 UTC (rev 16265)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/inheritance/joined/File.java 2009-04-06 20:51:40 UTC (rev 16266)
@@ -6,14 +6,17 @@
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.ManyToOne;
+import javax.persistence.Column;
+import javax.persistence.Table;
/**
* @author Emmanuel Bernard
*/
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
+@Table(name="joined_file")
public abstract class File {
- @Id
+ @Id @Column(name="filename")
private String name;
@ManyToOne
private Folder parent;
15 years, 7 months
Hibernate SVN: r16265 - annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/onetomany.
by hibernate-commits@lists.jboss.org
Author: gbadner
Date: 2009-04-06 16:29:19 -0400 (Mon, 06 Apr 2009)
New Revision: 16265
Modified:
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/onetomany/City.java
Log:
JBPAPP-1070 : Annotations - MSSQL/Sybase - Duplicate fields in "order by"
Modified: annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/onetomany/City.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/onetomany/City.java 2009-04-06 15:10:53 UTC (rev 16264)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/onetomany/City.java 2009-04-06 20:29:19 UTC (rev 16265)
@@ -42,7 +42,7 @@
}
@OneToMany(mappedBy = "city")
- @OrderBy("streetNameCopy, streetName, id")
+ @OrderBy("streetNameCopy, id")
public synchronized List<Street> getStreets() {
return streets;
}
15 years, 7 months
Hibernate SVN: r16264 - in validator/trunk/hibernate-validator/src/test: java/org/hibernate/validation/bootstrap and 12 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-04-06 11:10:53 -0400 (Mon, 06 Apr 2009)
New Revision: 16264
Added:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/ConsistentUserInformation.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/ConsistentUserValidator.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/User.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/XmlConfigurationTest.java
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/ValidationMessages.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/bootstrap/ValidationTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/AssertTrueValidatorTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForCalendarTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForDateTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForNumberTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForStringTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForNumberTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForStringTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotEmptyValidatorTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NullValidatorTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/FrenchZipcode.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/validatorcontext/ConstraintValidatorContextTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/All.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/First.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Last.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ResourceBundleMessageInterpolatorTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Second.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorImplTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/Address.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/GraphNavigationTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/Order.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/OrderLine.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Auditable.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Book.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/CreditCard.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/CyclicGroupSequence2.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Dictonary.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupChainGeneratorTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Order.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/ZipCodeCoherenceChecker.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/ZipCodeCoherenceValidator.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/Account.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/AccountChecker.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/AccountValidator.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/BeanDescriptorTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/ConstraintDescriptorTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/Customer.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/ElementDescriptorTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/PropertyDescriptorTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/PostCodeListValidatorForNumber.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/PostCodeListValidatorForString.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/ValidatorResolutionTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/ReflectionHelperTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/TestUtil.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/annotationfactory/AnnotationFactoryTest.java
validator/trunk/hibernate-validator/src/test/resources/META-INF/validation/user-constraints.xml
Log:
HV-112
* Reversed the arguments in assertEquals calls
* import cleanup
* code formatting
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/ValidationMessages.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/ValidationMessages.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/ValidationMessages.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/bootstrap/ValidationTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/bootstrap/ValidationTest.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/bootstrap/ValidationTest.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -84,12 +84,12 @@
customer.setFirstName( "John" );
Set<ConstraintViolation<Customer>> constraintViolations = validator.validate( customer );
- assertEquals( 1, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 1, "Wrong number of constraints" );
customer.setLastName( "Doe" );
constraintViolations = validator.validate( customer );
- assertEquals( 0, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 0, "Wrong number of constraints" );
}
@Test
@@ -106,7 +106,7 @@
customer.setFirstName( "John" );
Set<ConstraintViolation<Customer>> constraintViolations = validator.validate( customer );
- assertEquals( 1, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 1, "Wrong number of constraints" );
ConstraintViolation<Customer> constraintViolation = constraintViolations.iterator().next();
assertEquals( "may not be null", constraintViolation.getMessage(), "Wrong message" );
@@ -126,7 +126,7 @@
factory = configuration.buildValidatorFactory();
validator = factory.getValidator();
constraintViolations = validator.validate( customer );
- assertEquals( 1, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 1, "Wrong number of constraints" );
constraintViolation = constraintViolations.iterator().next();
assertEquals( "my custom message", constraintViolation.getMessage(), "Wrong message" );
}
@@ -144,7 +144,7 @@
customer.setFirstName( "John" );
Set<ConstraintViolation<Customer>> constraintViolations = validator.validate( customer );
- assertEquals( 1, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 1, "Wrong number of constraints" );
ConstraintViolation<Customer> constraintViolation = constraintViolations.iterator().next();
assertEquals( "may not be null", constraintViolation.getMessage(), "Wrong message" );
@@ -164,7 +164,7 @@
factory = configuration.buildValidatorFactory();
validator = factory.getValidator();
constraintViolations = validator.validate( customer );
- assertEquals( 0, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 0, "Wrong number of constraints" );
}
@Test
@@ -265,7 +265,7 @@
customer.setFirstName( "John" );
Set<ConstraintViolation<Customer>> constraintViolations = validator.validate( customer );
- assertEquals( 1, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 1, "Wrong number of constraints" );
ConstraintViolation<Customer> constraintViolation = constraintViolations.iterator().next();
assertEquals( "may not be null", constraintViolation.getMessage(), "Wrong message" );
@@ -281,6 +281,6 @@
factory = configuration.buildValidatorFactory();
validator = factory.getValidator();
constraintViolations = validator.validate( customer );
- assertEquals( 0, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 0, "Wrong number of constraints" );
}
}
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/AssertTrueValidatorTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/AssertTrueValidatorTest.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/AssertTrueValidatorTest.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -19,8 +19,8 @@
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import org.testng.annotations.BeforeClass;
/**
* @author Alaa Nassef
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForCalendarTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForCalendarTest.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForCalendarTest.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -21,8 +21,8 @@
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import org.testng.annotations.BeforeClass;
/**
* @author Alaa Nassef
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForDateTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForDateTest.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForDateTest.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -21,8 +21,8 @@
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import org.testng.annotations.BeforeClass;
public class FutureValidatorForDateTest {
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForNumberTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForNumberTest.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForNumberTest.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -23,8 +23,8 @@
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import org.testng.annotations.BeforeClass;
import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForStringTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForStringTest.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForStringTest.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -21,8 +21,8 @@
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import org.testng.annotations.BeforeClass;
import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForNumberTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForNumberTest.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForNumberTest.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -23,8 +23,8 @@
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import org.testng.annotations.BeforeClass;
import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForStringTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForStringTest.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForStringTest.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -21,8 +21,8 @@
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import org.testng.annotations.BeforeClass;
import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotEmptyValidatorTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotEmptyValidatorTest.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotEmptyValidatorTest.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -19,8 +19,8 @@
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import org.testng.annotations.BeforeClass;
/**
* @author Hardy Ferentschik
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NullValidatorTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NullValidatorTest.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NullValidatorTest.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -19,8 +19,8 @@
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import org.testng.annotations.BeforeClass;
/**
* @author Alaa Nassef
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/FrenchZipcode.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/FrenchZipcode.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/composition/FrenchZipcode.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -27,8 +27,8 @@
import javax.validation.Constraint;
import javax.validation.OverridesAttribute;
import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
-import javax.validation.constraints.Pattern;
/**
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/validatorcontext/ConstraintValidatorContextTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/validatorcontext/ConstraintValidatorContextTest.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/validatorcontext/ConstraintValidatorContextTest.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -23,9 +23,9 @@
import javax.validation.ConstraintViolation;
import javax.validation.Validator;
+import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
-import static org.testng.Assert.assertEquals;
import org.testng.annotations.Test;
import org.hibernate.validation.util.TestUtil;
@@ -45,7 +45,7 @@
DummyBean bean = new DummyBean( "foobar" );
Set<ConstraintViolation<DummyBean>> constraintViolations = validator.validate( bean );
- assertEquals( 1, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 1, "Wrong number of constraints" );
ConstraintViolation constraintViolation = constraintViolations.iterator().next();
assertEquals( "dummy message", constraintViolation.getMessage(), "Wrong message" );
}
@@ -64,7 +64,7 @@
DummyBean bean = new DummyBean( "foobar" );
Set<ConstraintViolation<DummyBean>> constraintViolations = validator.validate( bean );
- assertEquals( 0, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 0, "Wrong number of constraints" );
}
@Test
@@ -79,7 +79,7 @@
DummyBean bean = new DummyBean( "foobar" );
Set<ConstraintViolation<DummyBean>> constraintViolations = validator.validate( bean );
- assertEquals( 1, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 1, "Wrong number of constraints" );
ConstraintViolation constraintViolation = constraintViolations.iterator().next();
assertEquals( "message1", constraintViolation.getMessage(), "Wrong message" );
assertEquals( "property1", constraintViolation.getPropertyPath(), "Wrong property" );
@@ -96,7 +96,7 @@
bean.setNestedDummy( new DummyBean( "bar" ) );
Set<ConstraintViolation<DummyBean>> constraintViolations = validator.validate( bean );
- assertEquals( 2, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 2, "Wrong number of constraints" );
boolean validatedNestedBean = false;
for ( ConstraintViolation<DummyBean> violation : constraintViolations ) {
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/All.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/All.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/All.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -2,6 +2,7 @@
/**
* Groups including all validations
+ *
* @author Emmanuel Bernard
*/
public interface All {
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/First.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/First.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/First.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -2,7 +2,7 @@
/**
* Group executed first in the validation
- *
+ *
* @author Emmanuel Bernard
*/
public interface First {
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Last.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Last.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Last.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -2,7 +2,7 @@
/**
* Group executed Last in the validation
- *
+ *
* @author Emmanuel Bernard
*/
public interface Last {
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ResourceBundleMessageInterpolatorTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ResourceBundleMessageInterpolatorTest.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ResourceBundleMessageInterpolatorTest.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -67,19 +67,19 @@
MessageInterpolator.Context context = new MessageInterpolatorContext( descriptor, null );
String expected = "replacement worked";
String actual = interpolator.interpolate( "{foo}", context );
- assertEquals( expected, actual, "Wrong substitution" );
+ assertEquals( actual, expected, "Wrong substitution" );
expected = "replacement worked replacement worked";
actual = interpolator.interpolate( "{foo} {foo}", context );
- assertEquals( expected, actual, "Wrong substitution" );
+ assertEquals( actual, expected, "Wrong substitution" );
expected = "This replacement worked just fine";
actual = interpolator.interpolate( "This {foo} just fine", context );
- assertEquals( expected, actual, "Wrong substitution" );
+ assertEquals( actual, expected, "Wrong substitution" );
expected = "{} { replacement worked }";
actual = interpolator.interpolate( "{} { {foo} }", context );
- assertEquals( expected, actual, "Wrong substitution" );
+ assertEquals( actual, expected, "Wrong substitution" );
}
@Test
@@ -93,11 +93,11 @@
String expected = "foo"; // missing {}
String actual = interpolator.interpolate( "foo", context );
- assertEquals( expected, actual, "Wrong substitution" );
+ assertEquals( actual, expected, "Wrong substitution" );
expected = "#{foo {}";
actual = interpolator.interpolate( "#{foo {}", context );
- assertEquals( expected, actual, "Wrong substitution" );
+ assertEquals( actual, expected, "Wrong substitution" );
}
@Test
@@ -111,7 +111,7 @@
String expected = "{bar}"; // unkown token {}
String actual = interpolator.interpolate( "{bar}", context );
- assertEquals( expected, actual, "Wrong substitution" );
+ assertEquals( actual, expected, "Wrong substitution" );
}
@Test
@@ -125,7 +125,7 @@
String expected = "may not be null";
String actual = interpolator.interpolate( notNull.message(), context );
- assertEquals( expected, actual, "Wrong substitution" );
+ assertEquals( actual, expected, "Wrong substitution" );
ConstraintDescriptorImpl<Size> sizeDescriptor = new ConstraintDescriptorImpl<Size>(
size, new Class<?>[] { }, new ConstraintHelper()
@@ -133,7 +133,7 @@
expected = "size must be between 0 and 2147483647"; // unkown token {}
context = new MessageInterpolatorContext( sizeDescriptor, null );
actual = interpolator.interpolate( size.message(), context );
- assertEquals( expected, actual, "Wrong substitution" );
+ assertEquals( actual, expected, "Wrong substitution" );
}
@Test
@@ -147,7 +147,7 @@
String expected = "kann nicht null sein";
MessageInterpolator.Context context = new MessageInterpolatorContext( descriptor, null );
String actual = interpolator.interpolate( notNull.message(), context, Locale.GERMAN );
- assertEquals( expected, actual, "Wrong substitution" );
+ assertEquals( actual, expected, "Wrong substitution" );
}
@Test
@@ -161,7 +161,7 @@
String expected = "may not be null";
String actual = interpolator.interpolate( notNull.message(), context, Locale.JAPAN );
- assertEquals( expected, actual, "Wrong substitution" );
+ assertEquals( actual, expected, "Wrong substitution" );
}
@Test
@@ -175,7 +175,7 @@
String expected = "no puede ser null";
String actual = interpolator.interpolate( notNull.message(), context, new Locale( "es", "ES" ) );
- assertEquals( expected, actual, "Wrong substitution" );
+ assertEquals( actual, expected, "Wrong substitution" );
}
/**
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Second.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Second.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/Second.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -2,7 +2,7 @@
/**
* Group executed second during the validation
- *
+ *
* @author Emmanuel Bernard
*/
public interface Second {
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorImplTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorImplTest.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorImplTest.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -139,12 +139,12 @@
customer.setFirstName( "John" );
Set<ConstraintViolation<Customer>> constraintViolations = validator.validate( customer );
- assertEquals( 1, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 1, "Wrong number of constraints" );
customer.setLastName( "Doe" );
constraintViolations = validator.validate( customer );
- assertEquals( 0, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 0, "Wrong number of constraints" );
}
@Test
@@ -158,29 +158,29 @@
Set<ConstraintViolation<Address>> constraintViolations = validator.validate( address );
assertEquals(
+ constraintViolations.size(),
3,
- constraintViolations.size(),
"we should have been 2 not null violation for addresslines and one lenth violation for city"
);
constraintViolations = validator.validateProperty( address, "city" );
assertEquals(
+ constraintViolations.size(),
1,
- constraintViolations.size(),
"only city should be validated"
);
constraintViolations = validator.validateProperty( address, "city" );
assertEquals(
+ constraintViolations.size(),
1,
- constraintViolations.size(),
"only city should be validated"
);
constraintViolations = validator.validateValue( Address.class, "city", "Paris" );
assertEquals(
+ constraintViolations.size(),
0,
- constraintViolations.size(),
"Paris should be a valid city name."
);
}
@@ -194,17 +194,17 @@
customer.setLastName( "Doe" );
Set<ConstraintViolation<Customer>> constraintViolations = validator.validate( customer );
- assertEquals( 0, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 0, "Wrong number of constraints" );
Order order = new Order();
customer.addOrder( order );
constraintViolations = validator.validate( customer );
ConstraintViolation constraintViolation = constraintViolations.iterator().next();
- assertEquals( 1, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 1, "Wrong number of constraints" );
assertEquals( "may not be null", constraintViolation.getMessage(), "Wrong message" );
- assertEquals( customer, constraintViolation.getRootBean(), "Wrong root entity" );
- assertEquals( order.getOrderNumber(), constraintViolation.getInvalidValue(), "Wrong value" );
+ assertEquals( constraintViolation.getRootBean(), customer, "Wrong root entity" );
+ assertEquals( constraintViolation.getInvalidValue(), order.getOrderNumber(), "Wrong value" );
assertEquals( "orderList[0].orderNumber", constraintViolation.getPropertyPath(), "Wrong propertyName" );
}
@@ -215,15 +215,15 @@
Engine engine = new Engine();
engine.setSerialNumber( "mail(a)foobar.com" );
Set<ConstraintViolation<Engine>> constraintViolations = validator.validate( engine );
- assertEquals( 2, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 2, "Wrong number of constraints" );
engine.setSerialNumber( "ABCDEFGH1234" );
constraintViolations = validator.validate( engine );
- assertEquals( 1, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 1, "Wrong number of constraints" );
engine.setSerialNumber( "ABCD-EFGH-1234" );
constraintViolations = validator.validate( engine );
- assertEquals( 0, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 0, "Wrong number of constraints" );
}
@Test
@@ -244,10 +244,10 @@
Set<ConstraintViolation<Actor>> constraintViolations = validator.validate( clint );
ConstraintViolation constraintViolation = constraintViolations.iterator().next();
- assertEquals( 1, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 1, "Wrong number of constraints" );
assertEquals( "may not be empty", constraintViolation.getMessage(), "Wrong message" );
- assertEquals( clint, constraintViolation.getRootBean(), "Wrong root entity" );
- assertEquals( morgan.getLastName(), constraintViolation.getInvalidValue(), "Wrong value" );
+ assertEquals( constraintViolation.getRootBean(), clint, "Wrong root entity" );
+ assertEquals( constraintViolation.getInvalidValue(), morgan.getLastName(), "Wrong value" );
assertEquals(
"playedWith[0].playedWith[1].lastName", constraintViolation.getPropertyPath(), "Wrong propertyName"
);
@@ -260,17 +260,17 @@
Set<ConstraintViolation<Customer>> constraintViolations = validator.validateValue(
Customer.class, "orderList[0].orderNumber", null
);
- assertEquals( 1, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 1, "Wrong number of constraints" );
ConstraintViolation constraintViolation = constraintViolations.iterator().next();
- assertEquals( 1, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 1, "Wrong number of constraints" );
assertEquals( "may not be null", constraintViolation.getMessage(), "Wrong message" );
- assertEquals( null, constraintViolation.getRootBean(), "Wrong root entity" );
- assertEquals( null, constraintViolation.getInvalidValue(), "Wrong value" );
+ assertEquals( constraintViolation.getRootBean(), null, "Wrong root entity" );
+ assertEquals( constraintViolation.getInvalidValue(), null, "Wrong value" );
assertEquals( "orderList[0].orderNumber", constraintViolation.getPropertyPath(), "Wrong propertyName" );
constraintViolations = validator.validateValue( Customer.class, "orderList[0].orderNumber", "1234" );
- assertEquals( 0, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 0, "Wrong number of constraints" );
}
@Test
@@ -313,18 +313,18 @@
Set<ConstraintViolation<Customer>> constraintViolations = validator.validateProperty(
customer, "orderList[0].orderNumber"
);
- assertEquals( 1, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 1, "Wrong number of constraints" );
ConstraintViolation constraintViolation = constraintViolations.iterator().next();
- assertEquals( 1, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 1, "Wrong number of constraints" );
assertEquals( "may not be null", constraintViolation.getMessage(), "Wrong message" );
- assertEquals( customer, constraintViolation.getRootBean(), "Wrong root entity" );
- assertEquals( order.getOrderNumber(), constraintViolation.getInvalidValue(), "Wrong value" );
+ assertEquals( constraintViolation.getRootBean(), customer, "Wrong root entity" );
+ assertEquals( constraintViolation.getInvalidValue(), order.getOrderNumber(), "Wrong value" );
assertEquals( "orderList[0].orderNumber", constraintViolation.getPropertyPath(), "Wrong propertyName" );
order.setOrderNumber( 1234 );
constraintViolations = validator.validateProperty( customer, "orderList[0].orderNumber" );
- assertEquals( 0, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 0, "Wrong number of constraints" );
}
@Test
@@ -385,7 +385,7 @@
Person person = customer;
Set<ConstraintViolation<Person>> constraintViolations = validator.validate( person );
- assertEquals( 1, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 1, "Wrong number of constraints" );
assertConstraintViolation(
constraintViolations.iterator().next(),
@@ -398,7 +398,7 @@
order.setOrderNumber( 123 );
constraintViolations = validator.validate( person );
- assertEquals( 0, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 0, "Wrong number of constraints" );
}
@Test
@@ -417,7 +417,7 @@
Set<ConstraintViolation<Customer>> constraintViolations = validator.validate(
customer, Default.class, First.class, Second.class, Last.class
);
- assertEquals( 100, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 100, "Wrong number of constraints" );
}
/**
@@ -431,13 +431,13 @@
PropertyDescriptor propertyDescriptor = beanDescriptor.getConstraintsForProperty( "orderNumber" );
Set<ConstraintDescriptor<?>> descriptors = propertyDescriptor.getConstraintDescriptors();
- assertEquals( 1, descriptors.size(), "There should be only one constraint descriptor" );
+ assertEquals( descriptors.size(), 1, "There should be only one constraint descriptor" );
ConstraintDescriptor<?> descriptor = descriptors.iterator().next();
Set<Class<?>> groups = descriptor.getGroups();
assertTrue( groups.size() == 1, "There should be only one group" );
assertEquals(
+ groups.iterator().next(),
Default.class,
- groups.iterator().next(),
"The declared constraint does not explicitly define a group, hence Default is expected"
);
}
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/Address.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/Address.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/Address.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/GraphNavigationTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/GraphNavigationTest.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/GraphNavigationTest.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -61,7 +61,7 @@
Validator validator = TestUtil.getValidator();
Set<ConstraintViolation<Order>> constraintViolations = validator.validate( order );
- assertEquals( 3, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 3, "Wrong number of constraints" );
List<String> expectedErrorMessages = new ArrayList<String>();
expectedErrorMessages.add( "shippingAddress.addressline1" );
@@ -85,7 +85,7 @@
Validator validator = TestUtil.getValidator();
Set<ConstraintViolation<User>> constraintViolations = validator.validate( john );
- assertEquals( 1, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 1, "Wrong number of constraints" );
TestUtil.assertConstraintViolation(
constraintViolations.iterator().next(), "may not be null", User.class, null, "lastName"
);
@@ -96,19 +96,19 @@
john.knows( jane );
constraintViolations = validator.validate( john );
- assertEquals( 1, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 1, "Wrong number of constraints" );
TestUtil.assertConstraintViolation(
constraintViolations.iterator().next(), "may not be null", User.class, null, "lastName"
);
constraintViolations = validator.validate( jane );
- assertEquals( 1, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 1, "Wrong number of constraints" );
TestUtil.assertConstraintViolation(
constraintViolations.iterator().next(), "may not be null", User.class, null, "knowsUser[0].lastName"
);
john.setLastName( "Doe" );
constraintViolations = validator.validate( john );
- assertEquals( 0, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 0, "Wrong number of constraints" );
}
}
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/Order.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/Order.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/Order.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/OrderLine.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/OrderLine.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/graphnavigation/OrderLine.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
@@ -17,8 +17,8 @@
*/
package org.hibernate.validation.engine.graphnavigation;
+import javax.validation.Valid;
import javax.validation.constraints.NotNull;
-import javax.validation.Valid;
/**
* @author Hardy Ferentschik
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Auditable.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Auditable.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Auditable.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Book.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Book.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Book.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -26,7 +26,6 @@
import org.hibernate.validation.engine.First;
import org.hibernate.validation.engine.Last;
import org.hibernate.validation.engine.Second;
-import org.hibernate.validation.engine.groups.Author;
/**
* @author Hardy Ferentschik
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/CreditCard.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/CreditCard.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/CreditCard.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/CyclicGroupSequence2.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/CyclicGroupSequence2.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/CyclicGroupSequence2.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -22,6 +22,6 @@
/**
* @author Hardy Ferentschik
*/
-@GroupSequence( value = CyclicGroupSequence1.class)
+@GroupSequence(value = CyclicGroupSequence1.class)
public interface CyclicGroupSequence2 {
}
\ No newline at end of file
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Dictonary.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Dictonary.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Dictonary.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -20,7 +20,6 @@
import javax.validation.constraints.NotNull;
import org.hibernate.validation.constraints.NotEmpty;
-import org.hibernate.validation.engine.groups.Book;
/**
* @author Hardy Ferentschik
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupChainGeneratorTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupChainGeneratorTest.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupChainGeneratorTest.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -83,14 +83,14 @@
groups.add( Last.class );
GroupChain chain = generator.getGroupChainFor( groups );
int count = countGroups( chain );
- assertEquals( 3, count, "Wrong number of groups" );
+ assertEquals( count, 3, "Wrong number of groups" );
groups.clear();
groups.add( First.class );
groups.add( First.class );
chain = generator.getGroupChainFor( groups );
count = countGroups( chain );
- assertEquals( 1, count, "Wrong number of groups" );
+ assertEquals( count, 1, "Wrong number of groups" );
groups.clear();
groups.add( First.class );
@@ -98,7 +98,7 @@
groups.add( First.class );
chain = generator.getGroupChainFor( groups );
count = countGroups( chain );
- assertEquals( 2, count, "Wrong number of groups" );
+ assertEquals( count, 2, "Wrong number of groups" );
}
private int countGroups(GroupChain chain) {
@@ -119,7 +119,7 @@
Iterator<List<Group>> sequences = chain.getSequenceIterator();
List<Group> sequence = sequences.next();
- assertEquals( Default.class, sequence.get( 0 ).getGroup(), "Wrong group" );
- assertEquals( Address.HighLevelCoherence.class, sequence.get( 1 ).getGroup(), "Wrong group" );
+ assertEquals( sequence.get( 0 ).getGroup(), Default.class, "Wrong group" );
+ assertEquals( sequence.get( 1 ).getGroup(), Address.HighLevelCoherence.class, "Wrong group" );
}
}
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupTest.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupTest.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -58,28 +58,28 @@
Set<ConstraintViolation<Book>> constraintViolations = validator.validate(
book, First.class, Second.class, Last.class
);
- assertEquals( 3, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 3, "Wrong number of constraints" );
author.setFirstName( "Gavin" );
author.setLastName( "King" );
constraintViolations = validator.validate( book, First.class, Second.class, Last.class );
ConstraintViolation constraintViolation = constraintViolations.iterator().next();
- assertEquals( 1, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 1, "Wrong number of constraints" );
assertEquals( "may not be empty", constraintViolation.getMessage(), "Wrong message" );
- assertEquals( book, constraintViolation.getRootBean(), "Wrong root entity" );
- assertEquals( book.getTitle(), constraintViolation.getInvalidValue(), "Wrong value" );
+ assertEquals( constraintViolation.getRootBean(), book, "Wrong root entity" );
+ assertEquals( constraintViolation.getInvalidValue(), book.getTitle(), "Wrong value" );
assertEquals( "title", constraintViolation.getPropertyPath(), "Wrong propertyName" );
book.setTitle( "Hibernate Persistence with JPA" );
book.setSubtitle( "Revised Edition of Hibernate in Action" );
constraintViolations = validator.validate( book, First.class, Second.class, Last.class );
- assertEquals( 1, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 1, "Wrong number of constraints" );
constraintViolation = constraintViolations.iterator().next();
assertEquals( "length must be between 0 and 30", constraintViolation.getMessage(), "Wrong message" );
- assertEquals( book, constraintViolation.getRootBean(), "Wrong root entity" );
- assertEquals( book.getSubtitle(), constraintViolation.getInvalidValue(), "Wrong value" );
+ assertEquals( constraintViolation.getRootBean(), book, "Wrong root entity" );
+ assertEquals( constraintViolation.getInvalidValue(), book.getSubtitle(), "Wrong value" );
assertEquals( "subtitle", constraintViolation.getPropertyPath(), "Wrong propertyName" );
book.setSubtitle( "Revised Edition" );
@@ -87,16 +87,16 @@
constraintViolations = validator.validate( book, First.class, Second.class, Last.class );
constraintViolation = constraintViolations.iterator().next();
- assertEquals( 1, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 1, "Wrong number of constraints" );
assertEquals( "length must be between 0 and 20", constraintViolation.getMessage() );
- assertEquals( book, constraintViolation.getRootBean(), "Wrong root entity" );
- assertEquals( author.getCompany(), constraintViolation.getInvalidValue(), "Wrong value" );
+ assertEquals( constraintViolation.getRootBean(), book, "Wrong root entity" );
+ assertEquals( constraintViolation.getInvalidValue(), author.getCompany(), "Wrong value" );
assertEquals( "author.company", constraintViolation.getPropertyPath(), "Wrong propertyName" );
author.setCompany( "JBoss" );
constraintViolations = validator.validate( book, First.class, Second.class, Last.class );
- assertEquals( 0, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 0, "Wrong number of constraints" );
}
@Test
@@ -110,35 +110,35 @@
book.setAuthor( author );
Set<ConstraintViolation<Book>> constraintViolations = validator.validate( book, Book.All.class );
- assertEquals( 2, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 2, "Wrong number of constraints" );
author.setFirstName( "Gavin" );
author.setLastName( "King" );
constraintViolations = validator.validate( book, Book.All.class );
ConstraintViolation constraintViolation = constraintViolations.iterator().next();
- assertEquals( 1, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 1, "Wrong number of constraints" );
assertEquals( "may not be null", constraintViolation.getMessage(), "Wrong message" );
- assertEquals( book, constraintViolation.getRootBean(), "Wrong root entity" );
- assertEquals( book.getTitle(), constraintViolation.getInvalidValue(), "Wrong value" );
+ assertEquals( constraintViolation.getRootBean(), book, "Wrong root entity" );
+ assertEquals( constraintViolation.getInvalidValue(), book.getTitle(), "Wrong value" );
assertEquals( "title", constraintViolation.getPropertyPath(), "Wrong propertyName" );
book.setTitle( "Hibernate Persistence with JPA" );
book.setSubtitle( "Revised Edition of Hibernate in Action" );
constraintViolations = validator.validate( book, Book.All.class );
- assertEquals( 1, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 1, "Wrong number of constraints" );
book.setSubtitle( "Revised Edition" );
author.setCompany( "JBoss a divison of RedHat" );
constraintViolations = validator.validate( book, Book.All.class );
- assertEquals( 1, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 1, "Wrong number of constraints" );
author.setCompany( "JBoss" );
constraintViolations = validator.validate( book, Book.All.class );
- assertEquals( 0, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 0, "Wrong number of constraints" );
}
@Test
@@ -154,7 +154,7 @@
dictonary.setAuthor( author );
Set<ConstraintViolation<Dictonary>> constraintViolations = validator.validate( dictonary, DefaultAlias.class );
- assertEquals( 0, constraintViolations.size(), "Wrong number of constraints" );
+ assertEquals( constraintViolations.size(), 0, "Wrong number of constraints" );
}
@Test
@@ -168,8 +168,8 @@
elepfant, First.class, Second.class
);
assertEquals(
+ constraintViolations.size(),
1,
- constraintViolations.size(),
"The should be two invalid constraints since the same propertyName gets validated in both groups"
);
}
@@ -184,64 +184,64 @@
Set<ConstraintViolation<User>> constraintViolations = validator.validate( user );
assertEquals(
+ constraintViolations.size(),
2,
- constraintViolations.size(),
"There should be two violations against the implicit default group"
);
constraintViolations = validator.validate( user, Default.class );
assertEquals(
+ constraintViolations.size(),
2,
- constraintViolations.size(),
"There should be two violations against the explicit defualt group"
);
constraintViolations = validator.validate( user, Billable.class );
assertEquals(
+ constraintViolations.size(),
1,
- constraintViolations.size(),
"There should be one violation against Billable"
);
constraintViolations = validator.validate( user, Default.class, Billable.class );
assertEquals(
+ constraintViolations.size(),
3,
- constraintViolations.size(),
"There should be 3 violation against Default and Billable"
);
constraintViolations = validator.validate( user, BuyInOneClick.class );
assertEquals(
+ constraintViolations.size(),
3,
- constraintViolations.size(),
"Three violations expected since BuyInOneClick extends Default and Billable"
);
constraintViolations = validator.validate( user, BuyInOneClick.class, Billable.class );
assertEquals(
+ constraintViolations.size(),
3,
- constraintViolations.size(),
"BuyInOneClick already contains all other groups. Adding Billable does not change the number of violations"
);
constraintViolations = validator.validate( user, BuyInOneClick.class, Default.class );
assertEquals(
+ constraintViolations.size(),
3,
- constraintViolations.size(),
"BuyInOneClick already contains all other groups. Adding Default does not change the number of violations"
);
constraintViolations = validator.validate( user, BuyInOneClick.class, Default.class, Billable.class );
assertEquals(
+ constraintViolations.size(),
3,
- constraintViolations.size(),
"BuyInOneClick already contains all other groups. Adding Billable and Default does not change the number of violations"
);
constraintViolations = validator.validate( user, Billable.class, Billable.class );
assertEquals(
+ constraintViolations.size(),
1,
- constraintViolations.size(),
"Adding the same group twice is still only leads to a single violation"
);
}
@@ -262,8 +262,8 @@
user, BuyInOneClick.class, Optional.class
);
assertEquals(
+ constraintViolations.size(),
2,
- constraintViolations.size(),
"There should be two violations against the implicit default group"
);
@@ -305,8 +305,8 @@
Set<ConstraintViolation<Address>> constraintViolations = validator.validate( address );
assertEquals(
+ constraintViolations.size(),
1,
- constraintViolations.size(),
"There should only be one violation for zipcode"
);
@@ -318,8 +318,8 @@
// now the second group in the re-defined default group causes an error
constraintViolations = validator.validate( address );
assertEquals(
+ constraintViolations.size(),
1,
- constraintViolations.size(),
"There should only be one violation for zipcode"
);
@@ -339,8 +339,8 @@
Set<ConstraintViolation<Car>> constraintViolations = validator.validate( car );
assertEquals(
+ constraintViolations.size(),
1,
- constraintViolations.size(),
"There should be one violations due to the re-defintion of the default group"
);
assertEquals(
@@ -351,8 +351,8 @@
constraintViolations = validator.validateProperty( car, "type" );
assertEquals(
+ constraintViolations.size(),
1,
- constraintViolations.size(),
"There should be one violations due to the re-defintion of the default group"
);
assertEquals(
@@ -363,8 +363,8 @@
constraintViolations = validator.validateValue( Car.class, "type", "A" );
assertEquals(
+ constraintViolations.size(),
1,
- constraintViolations.size(),
"There should be one violations due to the re-defintion of the default group"
);
assertEquals(
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Order.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Order.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/Order.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/ZipCodeCoherenceChecker.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/ZipCodeCoherenceChecker.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/ZipCodeCoherenceChecker.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -1,15 +1,13 @@
package org.hibernate.validation.engine.groups;
-import java.lang.annotation.Target;
-import java.lang.annotation.Retention;
import java.lang.annotation.Documented;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.TYPE;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
import javax.validation.Constraint;
-import org.hibernate.validation.constraints.PatternValidator;
-
/**
* @author Emmanuel Bernard
*/
@@ -19,5 +17,6 @@
@Constraint(validatedBy = ZipCodeCoherenceValidator.class)
public @interface ZipCodeCoherenceChecker {
public abstract String message() default "{validator.zipCodeCoherenceChecker}";
- public abstract Class<?>[] groups() default {};
+
+ public abstract Class<?>[] groups() default { };
}
\ No newline at end of file
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/ZipCodeCoherenceValidator.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/ZipCodeCoherenceValidator.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/ZipCodeCoherenceValidator.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/Account.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/Account.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/Account.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -18,10 +18,7 @@
package org.hibernate.validation.engine.metadata;
import javax.validation.Valid;
-import javax.validation.constraints.NotNull;
-import org.hibernate.validation.engine.metadata.Customer;
-
/**
* Class with no constraints but with a cascade @Valid annotation
*/
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/AccountChecker.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/AccountChecker.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/AccountChecker.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
@@ -27,7 +27,6 @@
import javax.validation.Constraint;
-
/**
* @author Hardy Ferentschik
*/
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/AccountValidator.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/AccountValidator.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/AccountValidator.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/BeanDescriptorTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/BeanDescriptorTest.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/BeanDescriptorTest.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -76,13 +76,13 @@
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
PropertyDescriptor propertyDescriptor = beanDescriptor.getConstraintsForProperty( "orderNumber" );
assertEquals(
- 1, propertyDescriptor.getConstraintDescriptors().size(), "There should be one constraint descriptor"
+ propertyDescriptor.getConstraintDescriptors().size(), 1, "There should be one constraint descriptor"
);
beanDescriptor = validator.getConstraintsForClass( Customer.class );
propertyDescriptor = beanDescriptor.getConstraintsForProperty( "orderList" );
assertEquals(
- 0, propertyDescriptor.getConstraintDescriptors().size(), "There should be no constraint descriptors"
+ propertyDescriptor.getConstraintDescriptors().size(), 0, "There should be no constraint descriptors"
);
assertTrue( propertyDescriptor.isCascaded(), "The property should be cascaded" );
}
@@ -93,7 +93,7 @@
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Customer.class );
PropertyDescriptor propertyDescriptor = beanDescriptor.getConstraintsForProperty( "orderList" );
assertEquals(
- 0, propertyDescriptor.getConstraintDescriptors().size(), "There should be no constraint descriptors"
+ propertyDescriptor.getConstraintDescriptors().size(), 0, "There should be no constraint descriptors"
);
assertTrue( propertyDescriptor.isCascaded(), "The property should be cascaded" );
}
@@ -123,7 +123,7 @@
Validator validator = TestUtil.getValidator();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
Set<PropertyDescriptor> constraintProperties = beanDescriptor.getConstrainedProperties();
- assertEquals( 1, constraintProperties.size(), "There should be only one property" );
+ assertEquals( constraintProperties.size(), 1, "There should be only one property" );
boolean hasOrderNumber = false;
for ( PropertyDescriptor pd : constraintProperties ) {
hasOrderNumber |= pd.getPropertyName().equals( "orderNumber" );
@@ -164,6 +164,6 @@
Validator validator = TestUtil.getValidator();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( UnconstraintEntity.class );
Set<PropertyDescriptor> constraintProperties = beanDescriptor.getConstrainedProperties();
- assertEquals( 0, constraintProperties.size(), "We should get the empty set." );
+ assertEquals( constraintProperties.size(), 0, "We should get the empty set." );
}
}
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/ConstraintDescriptorTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/ConstraintDescriptorTest.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/ConstraintDescriptorTest.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -105,7 +105,7 @@
ConstraintDescriptor<?> descriptor = TestUtil.getSingleConstraintDescriptorFor(
GermanAddress.class, "zipCode"
);
- assertEquals( 1, descriptor.getComposingConstraints().size(), "Wrong number of composing constraints" );
+ assertEquals( descriptor.getComposingConstraints().size(), 1, "Wrong number of composing constraints" );
}
@Test
@@ -121,13 +121,13 @@
ConstraintDescriptor<?> descriptor = TestUtil.getSingleConstraintDescriptorFor( Order.class, "orderNumber" );
Set<Class<?>> groups = descriptor.getGroups();
assertTrue( groups.size() == 1 );
- assertEquals( Default.class, groups.iterator().next(), "Wrong group" );
+ assertEquals( groups.iterator().next(), Default.class, "Wrong group" );
}
@Test
public void testGetConstraintValidatorClasses() {
ConstraintDescriptor<?> descriptor = TestUtil.getSingleConstraintDescriptorFor( Order.class, "orderNumber" );
- assertEquals( NotNullValidator.class, descriptor.getConstraintValidatorClasses().get( 0 ), "Wrong classes" );
+ assertEquals( descriptor.getConstraintValidatorClasses().get( 0 ), NotNullValidator.class, "Wrong classes" );
}
@Test
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/Customer.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/Customer.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/Customer.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -21,8 +21,8 @@
import java.util.List;
import javax.validation.Valid;
+import org.hibernate.validation.engine.Order;
import org.hibernate.validation.engine.Person;
-import org.hibernate.validation.engine.Order;
/**
* @author Hardy Ferentschik
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/ElementDescriptorTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/ElementDescriptorTest.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/ElementDescriptorTest.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -45,13 +45,13 @@
public void testGetTypeForConstrainedBean() {
Validator validator = TestUtil.getValidator();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Customer.class );
- assertEquals( Customer.class, beanDescriptor.getType(), "Wrong type." );
+ assertEquals( beanDescriptor.getType(), Customer.class, "Wrong type." );
}
@Test
public void testGetTypeForConstrainedProperty() {
ElementDescriptor elementDescriptor = TestUtil.getPropertyDescriptor( Order.class, "orderNumber" );
- assertEquals( Integer.class, elementDescriptor.getType(), "Wrong type." );
+ assertEquals( elementDescriptor.getType(), Integer.class, "Wrong type." );
}
/**
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/PropertyDescriptorTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/PropertyDescriptorTest.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/PropertyDescriptorTest.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -48,6 +48,6 @@
public void testPropertyName() {
String propertyName = "orderList";
PropertyDescriptor descriptor = TestUtil.getPropertyDescriptor( Customer.class, propertyName );
- assertEquals( propertyName, descriptor.getPropertyName(), "Wrong property name" );
+ assertEquals( descriptor.getPropertyName(), propertyName, "Wrong property name" );
}
}
\ No newline at end of file
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/PostCodeListValidatorForNumber.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/PostCodeListValidatorForNumber.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/PostCodeListValidatorForNumber.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/PostCodeListValidatorForString.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/PostCodeListValidatorForString.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/PostCodeListValidatorForString.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
@@ -29,7 +29,7 @@
}
public boolean isValid(Collection<String> value, ConstraintValidatorContext constraintValidatorContext) {
- if(value == null) {
+ if ( value == null ) {
return true;
}
return false;
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/ValidatorResolutionTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/ValidatorResolutionTest.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/validatorresolution/ValidatorResolutionTest.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -84,7 +84,7 @@
Suburb suburb = new Suburb();
List<Integer> postcodes = new ArrayList<Integer>();
- postcodes.add(12345);
+ postcodes.add( 12345 );
suburb.setIncludedPostCodes( postcodes );
// all values are null and should pass
Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/ConsistentUserInformation.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/ConsistentUserInformation.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/ConsistentUserInformation.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -0,0 +1,41 @@
+// $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.xml;
+
+import java.lang.annotation.Documented;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+import javax.validation.Constraint;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Constraint(validatedBy = ConsistentUserValidator.class)
+@Documented
+@Target({ METHOD, FIELD, TYPE })
+@Retention(RUNTIME)
+public @interface ConsistentUserInformation {
+ public abstract String message() default "User information is not consistent.";
+
+ public abstract Class<?>[] groups() default { };
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/ConsistentUserInformation.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/ConsistentUserValidator.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/ConsistentUserValidator.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/ConsistentUserValidator.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -0,0 +1,34 @@
+// $Id:$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.engine.xml;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class ConsistentUserValidator implements ConstraintValidator<ConsistentUserInformation, User> {
+
+ public void initialize(ConsistentUserInformation parameters) {
+ }
+
+ public boolean isValid(User user, ConstraintValidatorContext constraintValidatorContext) {
+ return true;
+ }
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/ConsistentUserValidator.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/User.java (from rev 16263, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/User.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/User.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/User.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -0,0 +1,40 @@
+package org.hibernate.validation.engine.xml;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class User {
+
+ private String firstname;
+
+ //@NotNull(groups = Default.class)
+ private String lastname;
+
+ //@Pattern(regexp = "[0-9 -]?", groups = Optional.class)
+ private String phoneNumber;
+
+
+ public String getFirstname() {
+ return firstname;
+ }
+
+ public void setFirstname(String firstname) {
+ this.firstname = firstname;
+ }
+
+ public String getLastname() {
+ return lastname;
+ }
+
+ public void setLastname(String lastname) {
+ this.lastname = lastname;
+ }
+
+ public String getPhoneNumber() {
+ return phoneNumber;
+ }
+
+ public void setPhoneNumber(String phoneNumber) {
+ this.phoneNumber = phoneNumber;
+ }
+}
\ No newline at end of file
Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/XmlConfigurationTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/XmlConfigurationTest.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/xml/XmlConfigurationTest.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -0,0 +1,42 @@
+// $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.xml;
+
+import java.util.Set;
+import javax.validation.ConstraintViolation;
+import javax.validation.Validator;
+
+import org.testng.annotations.Test;
+
+import static org.hibernate.validation.util.TestUtil.assertNumberOfViolations;
+import static org.hibernate.validation.util.TestUtil.getValidator;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class XmlConfigurationTest {
+
+ @Test
+ public void testValidatorResolutionForMinMax() {
+ Validator validator = getValidator();
+
+ User user = new User();
+ Set<ConstraintViolation<User>> constraintViolations = validator.validate( user );
+ assertNumberOfViolations( constraintViolations, 1 );
+ }
+}
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/ReflectionHelperTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/ReflectionHelperTest.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/ReflectionHelperTest.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -93,11 +93,11 @@
map.put( key, testObject );
Object value = ReflectionHelper.getIndexedValue( map, key );
- assertEquals( testObject, value, "We should be able to retrieve the indexed object" );
+ assertEquals( value, testObject, "We should be able to retrieve the indexed object" );
// try to get to the value by integer index
value = ReflectionHelper.getIndexedValue( map, "0" );
- assertEquals( testObject, value, "We should be able to retrieve the indexed object" );
+ assertEquals( value, testObject, "We should be able to retrieve the indexed object" );
value = ReflectionHelper.getIndexedValue( map, "foo" );
assertNull( value, "A non existent index should return the null value" );
@@ -113,7 +113,7 @@
list.add( testObject );
Object value = ReflectionHelper.getIndexedValue( list, "0" );
- assertEquals( testObject, value, "We should be able to retrieve the indexed object" );
+ assertEquals( value, testObject, "We should be able to retrieve the indexed object" );
value = ReflectionHelper.getIndexedValue( list, "2" );
assertNull( value, "A non existent index should return the null value" );
@@ -144,7 +144,7 @@
assertEquals( "test", message, "Wrong message" );
Class<?>[] group = ReflectionHelper.getAnnotationParameter( testAnnotation, "groups", Class[].class );
- assertEquals( Default.class, group[0], "Wrong message" );
+ assertEquals( group[0], Default.class, "Wrong message" );
try {
ReflectionHelper.getAnnotationParameter( testAnnotation, "message", Integer.class );
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/TestUtil.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/TestUtil.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/TestUtil.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -73,8 +73,8 @@
public static void assertConstraintViolation(ConstraintViolation violation, String errorMessage, Class rootBean, Object invalidValue, String propertyPath, Class leafBean) {
assertEquals(
+ violation.getLeafBean().getClass(),
leafBean,
- violation.getLeafBean().getClass(),
"Wrong leaf bean type"
);
assertConstraintViolation( violation, errorMessage, rootBean, invalidValue, propertyPath );
@@ -82,8 +82,8 @@
public static void assertConstraintViolation(ConstraintViolation violation, String errorMessage, Class rootBean, Object invalidValue, String propertyPath) {
assertEquals(
+ violation.getPropertyPath(),
propertyPath,
- violation.getPropertyPath(),
"Wrong propertyPath"
);
assertConstraintViolation( violation, errorMessage, rootBean, invalidValue );
@@ -91,8 +91,8 @@
public static void assertConstraintViolation(ConstraintViolation violation, String errorMessage, Class rootBean, Object invalidValue) {
assertEquals(
+ violation.getInvalidValue(),
invalidValue,
- violation.getInvalidValue(),
"Wrong invalid value"
);
assertConstraintViolation( violation, errorMessage, rootBean );
@@ -100,18 +100,18 @@
public static void assertConstraintViolation(ConstraintViolation violation, String errorMessage, Class rootBean) {
assertEquals(
+ violation.getRootBean().getClass(),
rootBean,
- violation.getRootBean().getClass(),
"Wrong root bean type"
);
assertConstraintViolation( violation, errorMessage );
}
public static void assertConstraintViolation(ConstraintViolation violation, String message) {
- assertEquals( message, violation.getMessage(), "Wrong message" );
+ assertEquals( violation.getMessage(), message, "Wrong message" );
}
public static void assertNumberOfViolations(Set violations, int expectedViolations) {
- assertEquals( expectedViolations, violations.size(), "Wrong number of constraint violations" );
+ assertEquals( violations.size(), expectedViolations, "Wrong number of constraint violations" );
}
}
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/annotationfactory/AnnotationFactoryTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/annotationfactory/AnnotationFactoryTest.java 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/annotationfactory/AnnotationFactoryTest.java 2009-04-06 15:10:53 UTC (rev 16264)
@@ -37,8 +37,8 @@
Size size = AnnotationFactory.create( descriptor );
- assertEquals( 5, size.min(), "Wrong parameter value" );
- assertEquals( 10, size.max(), "Wrong parameter value" );
+ assertEquals( size.min(), 5, "Wrong parameter value" );
+ assertEquals( size.max(), 10, "Wrong parameter value" );
}
@Test(expectedExceptions = IllegalArgumentException.class)
Modified: validator/trunk/hibernate-validator/src/test/resources/META-INF/validation/user-constraints.xml
===================================================================
--- validator/trunk/hibernate-validator/src/test/resources/META-INF/validation/user-constraints.xml 2009-04-05 18:12:23 UTC (rev 16263)
+++ validator/trunk/hibernate-validator/src/test/resources/META-INF/validation/user-constraints.xml 2009-04-06 15:10:53 UTC (rev 16264)
@@ -1,8 +1,23 @@
<constraint-mappings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/mapping validation-mapping-1.0.xsd"
xmlns="http://jboss.org/xml/ns/javax/validation/mapping">
- <default-package>org.hibernate.validation.engine.groups</default-package>
+ <default-package>org.hibernate.validation.engine.xml</default-package>
<bean class="User" ignore-annotations="false">
+ <class ignore-annotations="false">
+ <group-sequence>
+ <value>value0</value>
+ </group-sequence>
+ <constraint annotation="org.hibernate.validation.engine.xml.ConsistentUserInformation">
+ <message>message0</message>
+ <groups>
+ <value>foo</value>
+ </groups>
+ <element name="name1">
+ </element>
+ <element name="name3">
+ </element>
+ </constraint>
+ </class>
<field name="firstName">
<constraint annotation="com.acme.app.constraint.LooksLike">
<element name="patterns">
15 years, 7 months
Hibernate SVN: r16263 - search/branches/Branch_3_1/src/test/org/hibernate/search/test/util.
by hibernate-commits@lists.jboss.org
Author: sannegrinovero
Date: 2009-04-05 14:12:23 -0400 (Sun, 05 Apr 2009)
New Revision: 16263
Modified:
search/branches/Branch_3_1/src/test/org/hibernate/search/test/util/FileHelperTest.java
Log:
merging 16216 from trunk (Remove working directory at tearDown())
Modified: search/branches/Branch_3_1/src/test/org/hibernate/search/test/util/FileHelperTest.java
===================================================================
--- search/branches/Branch_3_1/src/test/org/hibernate/search/test/util/FileHelperTest.java 2009-04-05 17:58:10 UTC (rev 16262)
+++ search/branches/Branch_3_1/src/test/org/hibernate/search/test/util/FileHelperTest.java 2009-04-05 18:12:23 UTC (rev 16263)
@@ -57,11 +57,12 @@
}
protected void tearDown() throws Exception {
- super.setUp();
+ super.tearDown();
File dir = new File( root, srcDir );
FileHelper.delete( dir );
dir = new File( root, destDir );
FileHelper.delete( dir );
+ FileHelper.delete( root );
}
public void testSynchronize() throws Exception {
15 years, 8 months
Hibernate SVN: r16262 - in search/branches/Branch_3_1: src/java/org/hibernate/search/jpa and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: sannegrinovero
Date: 2009-04-05 13:58:10 -0400 (Sun, 05 Apr 2009)
New Revision: 16262
Modified:
search/branches/Branch_3_1/doc/reference/en/modules/getting-started.xml
search/branches/Branch_3_1/src/java/org/hibernate/search/jpa/FullTextQuery.java
Log:
merging 15845 from trunk (HSEARCH-332 and some other JPA/hibernate mismatch related documentation fixes)
Modified: search/branches/Branch_3_1/doc/reference/en/modules/getting-started.xml
===================================================================
--- search/branches/Branch_3_1/doc/reference/en/modules/getting-started.xml 2009-04-05 17:49:12 UTC (rev 16261)
+++ search/branches/Branch_3_1/doc/reference/en/modules/getting-started.xml 2009-04-05 17:58:10 UTC (rev 16262)
@@ -477,7 +477,7 @@
// create native Lucene query
String[] fields = new String[]{"title", "subtitle", "authors.name", "publicationDate"};
MultiFieldQueryParser parser = new MultiFieldQueryParser(fields, new StandardAnalyzer());
-Query query = parser.parse( "Java rocks!" );
+org.apache.lucene.search.Query query = parser.parse( "Java rocks!" );
// wrap Lucene query in a org.hibernate.Query
org.hibernate.Query hibQuery = fullTextSession.createFullTextQuery(query, Book.class);
@@ -502,18 +502,17 @@
// create native Lucene query
String[] fields = new String[]{"title", "subtitle", "authors.name", "publicationDate"};
MultiFieldQueryParser parser = new MultiFieldQueryParser(fields, new StandardAnalyzer());
-Query query = parser.parse( "Java rocks!" );
+org.apache.lucene.search.Query query = parser.parse( "Java rocks!" );
-// wrap Lucene query in a org.hibernate.Query
-org.hibernate.Query hibQuery = fullTextEntityManager.createFullTextQuery(query, Book.class);
+// wrap Lucene query in a javax.persistence.Query
+javax.persistence.Query persistenceQuery = fullTextEntityManager.createFullTextQuery(query, Book.class);
// execute search
-List result = hibQuery.list();
+List result = persistenceQuery.getResultList();
em.getTransaction().commit();
em.close();
-
</programlisting>
</example>
</section>
Modified: search/branches/Branch_3_1/src/java/org/hibernate/search/jpa/FullTextQuery.java
===================================================================
--- search/branches/Branch_3_1/src/java/org/hibernate/search/jpa/FullTextQuery.java 2009-04-05 17:49:12 UTC (rev 16261)
+++ search/branches/Branch_3_1/src/java/org/hibernate/search/jpa/FullTextQuery.java 2009-04-05 17:58:10 UTC (rev 16262)
@@ -46,8 +46,8 @@
*
* Caution:
* The number of results might be slightly different from
- * <code>list().size()</code> because list() if the index is
- * not in sync with the database at the time of query.
+ * <code>getResultList().size()</code> because getResultList()
+ * may be not in sync with the database at the time of query.
*/
int getResultSize();
15 years, 8 months