Browse Source

Merge branch '5.3.x'

pull/28550/head
Sam Brannen 4 years ago
parent
commit
279f9647ab
  1. 18
      spring-context/src/test/java/org/springframework/format/datetime/DateFormattingTests.java
  2. 20
      spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormattingTests.java

18
spring-context/src/test/java/org/springframework/format/datetime/DateFormattingTests.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2021 the original author or authors. * Copyright 2002-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -132,11 +132,11 @@ public class DateFormattingTests {
TypeMismatchException exception = fieldError.unwrap(TypeMismatchException.class); TypeMismatchException exception = fieldError.unwrap(TypeMismatchException.class);
assertThat(exception) assertThat(exception)
.hasMessageContaining("for property 'styleDate'") .hasMessageContaining("for property 'styleDate'")
.hasCauseInstanceOf(ConversionFailedException.class).getCause() .hasCauseInstanceOf(ConversionFailedException.class).cause()
.hasMessageContaining("for value '99/01/01'") .hasMessageContaining("for value '99/01/01'")
.hasCauseInstanceOf(IllegalArgumentException.class).getCause() .hasCauseInstanceOf(IllegalArgumentException.class).cause()
.hasMessageContaining("Parse attempt failed for value [99/01/01]") .hasMessageContaining("Parse attempt failed for value [99/01/01]")
.hasCauseInstanceOf(ParseException.class).getCause() .hasCauseInstanceOf(ParseException.class).cause()
// Unable to parse date time value "99/01/01" using configuration from // Unable to parse date time value "99/01/01" using configuration from
// @org.springframework.format.annotation.DateTimeFormat(pattern=, style=S-, iso=NONE, fallbackPatterns=[]) // @org.springframework.format.annotation.DateTimeFormat(pattern=, style=S-, iso=NONE, fallbackPatterns=[])
// We do not check "fallbackPatterns=[]", since the array representation in the toString() // We do not check "fallbackPatterns=[]", since the array representation in the toString()
@ -147,7 +147,7 @@ public class DateFormattingTests {
"Unable to parse date time value \"99/01/01\" using configuration from", "Unable to parse date time value \"99/01/01\" using configuration from",
"@org.springframework.format.annotation.DateTimeFormat", "@org.springframework.format.annotation.DateTimeFormat",
"style=", "S-", "iso=NONE") "style=", "S-", "iso=NONE")
.hasCauseInstanceOf(ParseException.class).getCause() .hasCauseInstanceOf(ParseException.class).cause()
.hasMessageStartingWith("Unparseable date: \"99/01/01\"") .hasMessageStartingWith("Unparseable date: \"99/01/01\"")
.hasNoCause(); .hasNoCause();
} }
@ -352,11 +352,11 @@ public class DateFormattingTests {
FieldError fieldError = bindingResult.getFieldError(propertyName); FieldError fieldError = bindingResult.getFieldError(propertyName);
assertThat(fieldError.unwrap(TypeMismatchException.class)) assertThat(fieldError.unwrap(TypeMismatchException.class))
.hasMessageContaining("for property 'patternDateWithFallbackPatterns'") .hasMessageContaining("for property 'patternDateWithFallbackPatterns'")
.hasCauseInstanceOf(ConversionFailedException.class).getCause() .hasCauseInstanceOf(ConversionFailedException.class).cause()
.hasMessageContaining("for value '210302'") .hasMessageContaining("for value '210302'")
.hasCauseInstanceOf(IllegalArgumentException.class).getCause() .hasCauseInstanceOf(IllegalArgumentException.class).cause()
.hasMessageContaining("Parse attempt failed for value [210302]") .hasMessageContaining("Parse attempt failed for value [210302]")
.hasCauseInstanceOf(ParseException.class).getCause() .hasCauseInstanceOf(ParseException.class).cause()
// Unable to parse date time value "210302" using configuration from // Unable to parse date time value "210302" using configuration from
// @org.springframework.format.annotation.DateTimeFormat( // @org.springframework.format.annotation.DateTimeFormat(
// pattern=yyyy-MM-dd, style=SS, iso=NONE, fallbackPatterns=[M/d/yy, yyyyMMdd, yyyy.MM.dd]) // pattern=yyyy-MM-dd, style=SS, iso=NONE, fallbackPatterns=[M/d/yy, yyyyMMdd, yyyy.MM.dd])
@ -364,7 +364,7 @@ public class DateFormattingTests {
"Unable to parse date time value \"210302\" using configuration from", "Unable to parse date time value \"210302\" using configuration from",
"@org.springframework.format.annotation.DateTimeFormat", "@org.springframework.format.annotation.DateTimeFormat",
"yyyy-MM-dd", "M/d/yy", "yyyyMMdd", "yyyy.MM.dd") "yyyy-MM-dd", "M/d/yy", "yyyyMMdd", "yyyy.MM.dd")
.hasCauseInstanceOf(ParseException.class).getCause() .hasCauseInstanceOf(ParseException.class).cause()
.hasMessageStartingWith("Unparseable date: \"210302\"") .hasMessageStartingWith("Unparseable date: \"210302\"")
.hasNoCause(); .hasNoCause();
} }

20
spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormattingTests.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2021 the original author or authors. * Copyright 2002-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -333,11 +333,11 @@ class DateTimeFormattingTests {
FieldError fieldError = bindingResult.getFieldError(propertyName); FieldError fieldError = bindingResult.getFieldError(propertyName);
assertThat(fieldError.unwrap(TypeMismatchException.class)) assertThat(fieldError.unwrap(TypeMismatchException.class))
.hasMessageContaining("for property 'isoLocalDate'") .hasMessageContaining("for property 'isoLocalDate'")
.hasCauseInstanceOf(ConversionFailedException.class).getCause() .hasCauseInstanceOf(ConversionFailedException.class).cause()
.hasMessageContaining("for value '2009-31-10'") .hasMessageContaining("for value '2009-31-10'")
.hasCauseInstanceOf(IllegalArgumentException.class).getCause() .hasCauseInstanceOf(IllegalArgumentException.class).cause()
.hasMessageContaining("Parse attempt failed for value [2009-31-10]") .hasMessageContaining("Parse attempt failed for value [2009-31-10]")
.hasCauseInstanceOf(DateTimeParseException.class).getCause() .hasCauseInstanceOf(DateTimeParseException.class).cause()
// Unable to parse date time value "2009-31-10" using configuration from // Unable to parse date time value "2009-31-10" using configuration from
// @org.springframework.format.annotation.DateTimeFormat(pattern=, style=SS, iso=DATE, fallbackPatterns=[]) // @org.springframework.format.annotation.DateTimeFormat(pattern=, style=SS, iso=DATE, fallbackPatterns=[])
// We do not check "fallbackPatterns=[]", since the array representation in the toString() // We do not check "fallbackPatterns=[]", since the array representation in the toString()
@ -345,9 +345,9 @@ class DateTimeFormattingTests {
.hasMessageContainingAll( .hasMessageContainingAll(
"Unable to parse date time value \"2009-31-10\" using configuration from", "Unable to parse date time value \"2009-31-10\" using configuration from",
"@org.springframework.format.annotation.DateTimeFormat", "iso=DATE") "@org.springframework.format.annotation.DateTimeFormat", "iso=DATE")
.hasCauseInstanceOf(DateTimeParseException.class).getCause() .hasCauseInstanceOf(DateTimeParseException.class).cause()
.hasMessageStartingWith("Text '2009-31-10'") .hasMessageStartingWith("Text '2009-31-10'")
.hasCauseInstanceOf(DateTimeException.class).getCause() .hasCauseInstanceOf(DateTimeException.class).cause()
.hasMessageContaining("Invalid value for MonthOfYear (valid values 1 - 12): 31") .hasMessageContaining("Invalid value for MonthOfYear (valid values 1 - 12): 31")
.hasNoCause(); .hasNoCause();
} }
@ -569,11 +569,11 @@ class DateTimeFormattingTests {
FieldError fieldError = bindingResult.getFieldError(propertyName); FieldError fieldError = bindingResult.getFieldError(propertyName);
assertThat(fieldError.unwrap(TypeMismatchException.class)) assertThat(fieldError.unwrap(TypeMismatchException.class))
.hasMessageContaining("for property 'patternLocalDateWithFallbackPatterns'") .hasMessageContaining("for property 'patternLocalDateWithFallbackPatterns'")
.hasCauseInstanceOf(ConversionFailedException.class).getCause() .hasCauseInstanceOf(ConversionFailedException.class).cause()
.hasMessageContaining("for value '210302'") .hasMessageContaining("for value '210302'")
.hasCauseInstanceOf(IllegalArgumentException.class).getCause() .hasCauseInstanceOf(IllegalArgumentException.class).cause()
.hasMessageContaining("Parse attempt failed for value [210302]") .hasMessageContaining("Parse attempt failed for value [210302]")
.hasCauseInstanceOf(DateTimeParseException.class).getCause() .hasCauseInstanceOf(DateTimeParseException.class).cause()
// Unable to parse date time value "210302" using configuration from // Unable to parse date time value "210302" using configuration from
// @org.springframework.format.annotation.DateTimeFormat( // @org.springframework.format.annotation.DateTimeFormat(
// pattern=yyyy-MM-dd, style=SS, iso=NONE, fallbackPatterns=[M/d/yy, yyyyMMdd, yyyy.MM.dd]) // pattern=yyyy-MM-dd, style=SS, iso=NONE, fallbackPatterns=[M/d/yy, yyyyMMdd, yyyy.MM.dd])
@ -581,7 +581,7 @@ class DateTimeFormattingTests {
"Unable to parse date time value \"210302\" using configuration from", "Unable to parse date time value \"210302\" using configuration from",
"@org.springframework.format.annotation.DateTimeFormat", "@org.springframework.format.annotation.DateTimeFormat",
"yyyy-MM-dd", "M/d/yy", "yyyyMMdd", "yyyy.MM.dd") "yyyy-MM-dd", "M/d/yy", "yyyyMMdd", "yyyy.MM.dd")
.hasCauseInstanceOf(DateTimeParseException.class).getCause() .hasCauseInstanceOf(DateTimeParseException.class).cause()
.hasMessageStartingWith("Text '210302'") .hasMessageStartingWith("Text '210302'")
.hasNoCause(); .hasNoCause();
} }

Loading…
Cancel
Save