Automated tests against Hibernate ORM 4.3 and Hibernate Validator 5
Issue: SPR-11704
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -64,7 +64,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
* into any target dependency of type {@link org.springframework.validation.Validator}!
|
||||
*
|
||||
* <p><b>As of Spring 4.0, this class supports Bean Validation 1.0 and 1.1, with special support
|
||||
* for Hibernate Validator 4.3 and 5.0</b> (see {@link #setValidationMessageSource}).
|
||||
* for Hibernate Validator 4.3 and 5.x</b> (see {@link #setValidationMessageSource}).
|
||||
*
|
||||
* <p>Note that Bean Validation 1.1's {@code #forExecutables} method isn't supported: We do not
|
||||
* expect that method to be called by application code; consider {@link MethodValidationInterceptor}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,7 +26,7 @@ import org.springframework.context.support.MessageSourceResourceBundle;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Implementation of Hibernate Validator 4.3/5.0's {@link ResourceBundleLocator} interface,
|
||||
* Implementation of Hibernate Validator 4.3/5.x's {@link ResourceBundleLocator} interface,
|
||||
* exposing a Spring {@link MessageSource} as localized {@link MessageSourceResourceBundle}.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,7 +18,6 @@ package org.springframework.validation.beanvalidation;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.validation.ConstraintViolation;
|
||||
import javax.validation.ConstraintViolationException;
|
||||
import javax.validation.Validation;
|
||||
@@ -28,6 +27,7 @@ import javax.validation.ValidatorFactory;
|
||||
import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.hibernate.validator.HibernateValidator;
|
||||
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -47,8 +47,8 @@ import org.springframework.validation.annotation.Validated;
|
||||
* of that class. By default, JSR-303 will validate against its default group only.
|
||||
*
|
||||
* <p>As of Spring 4.0, this functionality requires either a Bean Validation 1.1 provider
|
||||
* (such as Hibernate Validator 5.0) or the Bean Validation 1.0 API with Hibernate Validator
|
||||
* 4.2 or 4.3. The actual provider will be autodetected and automatically adapted.
|
||||
* (such as Hibernate Validator 5.x) or the Bean Validation 1.0 API with Hibernate Validator
|
||||
* 4.3. The actual provider will be autodetected and automatically adapted.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @since 3.1
|
||||
@@ -147,7 +147,7 @@ public class MethodValidationInterceptor implements MethodInterceptor {
|
||||
|
||||
|
||||
/**
|
||||
* Inner class to avoid a hard-coded Hibernate Validator 4.2/4.3 dependency.
|
||||
* Inner class to avoid a hard-coded Hibernate Validator 4.3 dependency.
|
||||
*/
|
||||
private static class HibernateValidatorDelegate {
|
||||
|
||||
@@ -159,9 +159,11 @@ public class MethodValidationInterceptor implements MethodInterceptor {
|
||||
public static Object invokeWithinValidation(MethodInvocation invocation, Validator validator, Class<?>[] groups)
|
||||
throws Throwable {
|
||||
|
||||
org.hibernate.validator.method.MethodValidator methodValidator = validator.unwrap(org.hibernate.validator.method.MethodValidator.class);
|
||||
Set<org.hibernate.validator.method.MethodConstraintViolation<Object>> result = methodValidator.validateAllParameters(
|
||||
invocation.getThis(), invocation.getMethod(), invocation.getArguments(), groups);
|
||||
org.hibernate.validator.method.MethodValidator methodValidator =
|
||||
validator.unwrap(org.hibernate.validator.method.MethodValidator.class);
|
||||
Set<org.hibernate.validator.method.MethodConstraintViolation<Object>> result =
|
||||
methodValidator.validateAllParameters(
|
||||
invocation.getThis(), invocation.getMethod(), invocation.getArguments(), groups);
|
||||
if (!result.isEmpty()) {
|
||||
throw new org.hibernate.validator.method.MethodConstraintViolationException(result);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -49,8 +49,8 @@ import org.springframework.validation.annotation.Validated;
|
||||
* as well. By default, JSR-303 will validate against its default group only.
|
||||
*
|
||||
* <p>As of Spring 4.0, this functionality requires either a Bean Validation 1.1 provider
|
||||
* (such as Hibernate Validator 5.0) or the Bean Validation 1.0 API with Hibernate Validator
|
||||
* 4.2 or 4.3. The actual provider will be autodetected and automatically adapted.
|
||||
* (such as Hibernate Validator 5.x) or the Bean Validation 1.0 API with Hibernate Validator
|
||||
* 4.3. The actual provider will be autodetected and automatically adapted.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @since 3.1
|
||||
|
||||
Reference in New Issue
Block a user