SpringValidatorAdapter's ObjectError subclasses are serializable
Closes gh-23181
This commit is contained in:
@@ -48,6 +48,7 @@ import org.springframework.beans.BeanWrapper;
|
||||
import org.springframework.beans.BeanWrapperImpl;
|
||||
import org.springframework.context.support.StaticMessageSource;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.SerializationTestUtils;
|
||||
import org.springframework.validation.BeanPropertyBindingResult;
|
||||
import org.springframework.validation.FieldError;
|
||||
|
||||
@@ -86,7 +87,7 @@ public class SpringValidatorAdapterTests {
|
||||
}
|
||||
|
||||
@Test // SPR-13406
|
||||
public void testNoStringArgumentValue() {
|
||||
public void testNoStringArgumentValue() throws Exception {
|
||||
TestBean testBean = new TestBean();
|
||||
testBean.setPassword("pass");
|
||||
testBean.setConfirmPassword("pass");
|
||||
@@ -101,10 +102,11 @@ public class SpringValidatorAdapterTests {
|
||||
assertThat(messageSource.getMessage(error, Locale.ENGLISH), is("Size of Password must be between 8 and 128"));
|
||||
assertTrue(error.contains(ConstraintViolation.class));
|
||||
assertThat(error.unwrap(ConstraintViolation.class).getPropertyPath().toString(), is("password"));
|
||||
assertThat(SerializationTestUtils.serializeAndDeserialize(error.toString()), is(error.toString()));
|
||||
}
|
||||
|
||||
@Test // SPR-13406
|
||||
public void testApplyMessageSourceResolvableToStringArgumentValueWithResolvedLogicalFieldName() {
|
||||
public void testApplyMessageSourceResolvableToStringArgumentValueWithResolvedLogicalFieldName() throws Exception {
|
||||
TestBean testBean = new TestBean();
|
||||
testBean.setPassword("password");
|
||||
testBean.setConfirmPassword("PASSWORD");
|
||||
@@ -119,6 +121,7 @@ public class SpringValidatorAdapterTests {
|
||||
assertThat(messageSource.getMessage(error, Locale.ENGLISH), is("Password must be same value as Password(Confirm)"));
|
||||
assertTrue(error.contains(ConstraintViolation.class));
|
||||
assertThat(error.unwrap(ConstraintViolation.class).getPropertyPath().toString(), is("password"));
|
||||
assertThat(SerializationTestUtils.serializeAndDeserialize(error.toString()), is(error.toString()));
|
||||
}
|
||||
|
||||
@Test // SPR-13406
|
||||
@@ -473,10 +476,10 @@ public class SpringValidatorAdapterTests {
|
||||
.addPropertyNode(f.getName())
|
||||
.addConstraintViolation();
|
||||
}
|
||||
} catch (IllegalAccessException ex) {
|
||||
}
|
||||
catch (IllegalAccessException ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
|
||||
});
|
||||
return fieldsErros.isEmpty();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user