Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
53626330
Commit
53626330
authored
Jan 22, 2021
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.3.x' into 2.4.x
Closes gh-24973
parents
69fbd2f8
0b06ac99
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
41 deletions
+41
-41
LiquibaseAutoConfigurationTests.java
...oconfigure/liquibase/LiquibaseAutoConfigurationTests.java
+2
-2
BasicErrorControllerIntegrationTests.java
...b/servlet/error/BasicErrorControllerIntegrationTests.java
+22
-22
FileSessionPersistenceTests.java
...ot/web/embedded/undertow/FileSessionPersistenceTests.java
+2
-2
DefaultErrorAttributesTests.java
.../boot/web/reactive/error/DefaultErrorAttributesTests.java
+3
-3
DefaultErrorAttributesTests.java
...k/boot/web/servlet/error/DefaultErrorAttributesTests.java
+12
-12
No files found.
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfigurationTests.java
View file @
53626330
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
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.
...
...
@@ -336,7 +336,7 @@ class LiquibaseAutoConfigurationTests {
.
withPropertyValues
(
"spring.liquibase.parameters.foo:bar"
).
run
(
assertLiquibase
((
liquibase
)
->
{
Map
<
String
,
String
>
parameters
=
(
Map
<
String
,
String
>)
ReflectionTestUtils
.
getField
(
liquibase
,
"parameters"
);
assertThat
(
parameters
.
containsKey
(
"foo"
)).
isTrue
(
);
assertThat
(
parameters
).
containsKey
(
"foo"
);
assertThat
(
parameters
.
get
(
"foo"
)).
isEqualTo
(
"bar"
);
}));
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/error/BasicErrorControllerIntegrationTests.java
View file @
53626330
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
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.
...
...
@@ -84,13 +84,13 @@ class BasicErrorControllerIntegrationTests {
}
@Test
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
{
"rawtypes"
,
"unchecked"
}
)
void
testErrorForMachineClientDefault
()
{
load
();
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
().
getForEntity
(
createUrl
(
"?trace=true"
),
Map
.
class
);
assertErrorAttributes
(
entity
.
getBody
(),
"500"
,
"Internal Server Error"
,
null
,
""
,
"/"
);
assertThat
(
entity
.
getBody
()
.
containsKey
(
"exception"
)).
isFalse
(
);
assertThat
(
entity
.
getBody
()
.
containsKey
(
"trace"
)).
isFalse
(
);
assertThat
(
entity
.
getBody
()
).
doesNotContainKey
(
"exception"
);
assertThat
(
entity
.
getBody
()
).
doesNotContainKey
(
"trace"
);
}
@Test
...
...
@@ -144,19 +144,19 @@ class BasicErrorControllerIntegrationTests {
"No message available"
,
"/noMessage"
);
}
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
{
"rawtypes"
,
"unchecked"
}
)
private
void
exceptionWithStackTraceAndMessage
(
String
path
)
{
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
().
getForEntity
(
createUrl
(
path
),
Map
.
class
);
assertErrorAttributes
(
entity
.
getBody
(),
"500"
,
"Internal Server Error"
,
IllegalStateException
.
class
,
"Expected!"
,
"/"
);
assertThat
(
entity
.
getBody
()
.
containsKey
(
"trace"
)).
isTrue
(
);
assertThat
(
entity
.
getBody
()
).
containsKey
(
"trace"
);
}
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
{
"rawtypes"
,
"unchecked"
}
)
private
void
exceptionWithoutStackTraceAndMessage
(
String
path
)
{
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
().
getForEntity
(
createUrl
(
path
),
Map
.
class
);
assertErrorAttributes
(
entity
.
getBody
(),
"500"
,
"Internal Server Error"
,
IllegalStateException
.
class
,
""
,
"/"
);
assertThat
(
entity
.
getBody
()
.
containsKey
(
"trace"
)).
isFalse
(
);
assertThat
(
entity
.
getBody
()
).
doesNotContainKey
(
"trace"
);
}
@Test
...
...
@@ -265,37 +265,37 @@ class BasicErrorControllerIntegrationTests {
bindingExceptionWithoutMessage
(
"?message=true"
);
}
@SuppressWarnings
({
"rawtypes"
})
@SuppressWarnings
({
"rawtypes"
,
"unchecked"
})
private
void
bindingExceptionWithErrors
(
String
param
)
{
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
().
getForEntity
(
createUrl
(
"/bind"
+
param
),
Map
.
class
);
assertErrorAttributes
(
entity
.
getBody
(),
"400"
,
"Bad Request"
,
BindException
.
class
,
""
,
"/bind"
);
assertThat
(
entity
.
getBody
()
.
containsKey
(
"errors"
)).
isTrue
(
);
assertThat
(
entity
.
getBody
()
).
containsKey
(
"errors"
);
}
@SuppressWarnings
({
"rawtypes"
})
@SuppressWarnings
({
"rawtypes"
,
"unchecked"
})
private
void
bindingExceptionWithoutErrors
(
String
param
)
{
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
().
getForEntity
(
createUrl
(
"/bind"
+
param
),
Map
.
class
);
assertErrorAttributes
(
entity
.
getBody
(),
"400"
,
"Bad Request"
,
BindException
.
class
,
""
,
"/bind"
);
assertThat
(
entity
.
getBody
()
.
containsKey
(
"errors"
)).
isFalse
(
);
assertThat
(
entity
.
getBody
()
).
doesNotContainKey
(
"errors"
);
}
@SuppressWarnings
({
"rawtypes"
})
@SuppressWarnings
({
"rawtypes"
,
"unchecked"
})
private
void
bindingExceptionWithMessage
(
String
param
)
{
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
().
getForEntity
(
createUrl
(
"/bind"
+
param
),
Map
.
class
);
assertErrorAttributes
(
entity
.
getBody
(),
"400"
,
"Bad Request"
,
BindException
.
class
,
"Validation failed for object='test'. Error count: 1"
,
"/bind"
);
assertThat
(
entity
.
getBody
()
.
containsKey
(
"errors"
)).
isFalse
(
);
assertThat
(
entity
.
getBody
()
).
doesNotContainKey
(
"errors"
);
}
@SuppressWarnings
({
"rawtypes"
})
@SuppressWarnings
({
"rawtypes"
,
"unchecked"
})
private
void
bindingExceptionWithoutMessage
(
String
param
)
{
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
().
getForEntity
(
createUrl
(
"/bind"
+
param
),
Map
.
class
);
assertErrorAttributes
(
entity
.
getBody
(),
"400"
,
"Bad Request"
,
BindException
.
class
,
""
,
"/bind"
);
assertThat
(
entity
.
getBody
()
.
containsKey
(
"errors"
)).
isFalse
(
);
assertThat
(
entity
.
getBody
()
).
doesNotContainKey
(
"errors"
);
}
@Test
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
{
"rawtypes"
,
"unchecked"
}
)
void
testRequestBodyValidationForMachineClient
()
{
load
(
"--server.error.include-exception=true"
);
RequestEntity
request
=
RequestEntity
.
post
(
URI
.
create
(
createUrl
(
"/bodyValidation"
)))
...
...
@@ -303,19 +303,19 @@ class BasicErrorControllerIntegrationTests {
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
().
exchange
(
request
,
Map
.
class
);
assertErrorAttributes
(
entity
.
getBody
(),
"400"
,
"Bad Request"
,
MethodArgumentNotValidException
.
class
,
""
,
"/bodyValidation"
);
assertThat
(
entity
.
getBody
()
.
containsKey
(
"errors"
)).
isFalse
(
);
assertThat
(
entity
.
getBody
()
).
doesNotContainKey
(
"errors"
);
}
@Test
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
{
"rawtypes"
,
"unchecked"
}
)
void
testBindingExceptionForMachineClientDefault
()
{
load
();
RequestEntity
request
=
RequestEntity
.
get
(
URI
.
create
(
createUrl
(
"/bind?trace=true,message=true"
)))
.
accept
(
MediaType
.
APPLICATION_JSON
).
build
();
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
().
exchange
(
request
,
Map
.
class
);
assertThat
(
entity
.
getBody
()
.
containsKey
(
"exception"
)).
isFalse
(
);
assertThat
(
entity
.
getBody
()
.
containsKey
(
"trace"
)).
isFalse
(
);
assertThat
(
entity
.
getBody
()
.
containsKey
(
"errors"
)).
isFalse
(
);
assertThat
(
entity
.
getBody
()
).
doesNotContainKey
(
"exception"
);
assertThat
(
entity
.
getBody
()
).
doesNotContainKey
(
"trace"
);
assertThat
(
entity
.
getBody
()
).
doesNotContainKey
(
"errors"
);
}
@Test
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/undertow/FileSessionPersistenceTests.java
View file @
53626330
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
21
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.
...
...
@@ -82,7 +82,7 @@ class FileSessionPersistenceTests {
this
.
persistence
.
persistSessions
(
"test"
,
sessionData
);
Map
<
String
,
PersistentSession
>
restored
=
this
.
persistence
.
loadSessionAttributes
(
"test"
,
this
.
classLoader
);
assertThat
(
restored
).
isNotNull
();
assertThat
(
restored
.
containsKey
(
"abc"
)).
isFalse
(
);
assertThat
(
restored
).
doesNotContainKey
(
"abc"
);
}
@Test
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/error/DefaultErrorAttributesTests.java
View file @
53626330
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
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.
...
...
@@ -269,8 +269,8 @@ class DefaultErrorAttributesTests {
MockServerHttpRequest
request
=
MockServerHttpRequest
.
get
(
"/test"
).
build
();
Map
<
String
,
Object
>
attributes
=
this
.
errorAttributes
.
getErrorAttributes
(
buildServerRequest
(
request
,
ex
),
ErrorAttributeOptions
.
defaults
());
assertThat
(
attributes
.
get
(
"message"
)).
isEqualTo
(
""
);
assertThat
(
attributes
.
containsKey
(
"errors"
)).
isFalse
(
);
assertThat
(
attributes
).
containsEntry
(
"message"
,
""
);
assertThat
(
attributes
).
doesNotContainKey
(
"errors"
);
}
private
ServerRequest
buildServerRequest
(
MockServerHttpRequest
request
,
Throwable
error
)
{
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/error/DefaultErrorAttributesTests.java
View file @
53626330
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
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.
...
...
@@ -90,7 +90,7 @@ class DefaultErrorAttributesTests {
ErrorAttributeOptions
.
of
(
Include
.
MESSAGE
));
assertThat
(
this
.
errorAttributes
.
getError
(
this
.
webRequest
)).
isSameAs
(
ex
);
assertThat
(
modelAndView
).
isNull
();
assertThat
(
attributes
.
containsKey
(
"exception"
)).
isFalse
(
);
assertThat
(
attributes
).
doesNotContainKey
(
"exception"
);
assertThat
(
attributes
.
get
(
"message"
)).
isEqualTo
(
"Test"
);
}
...
...
@@ -101,7 +101,7 @@ class DefaultErrorAttributesTests {
Map
<
String
,
Object
>
attributes
=
this
.
errorAttributes
.
getErrorAttributes
(
this
.
webRequest
,
ErrorAttributeOptions
.
of
(
Include
.
MESSAGE
));
assertThat
(
this
.
errorAttributes
.
getError
(
this
.
webRequest
)).
isSameAs
(
ex
);
assertThat
(
attributes
.
containsKey
(
"exception"
)).
isFalse
(
);
assertThat
(
attributes
).
doesNotContainKey
(
"exception"
);
assertThat
(
attributes
.
get
(
"message"
)).
isEqualTo
(
"Test"
);
}
...
...
@@ -112,7 +112,7 @@ class DefaultErrorAttributesTests {
Map
<
String
,
Object
>
attributes
=
this
.
errorAttributes
.
getErrorAttributes
(
this
.
webRequest
,
ErrorAttributeOptions
.
defaults
());
assertThat
(
this
.
errorAttributes
.
getError
(
this
.
webRequest
)).
isSameAs
(
ex
);
assertThat
(
attributes
.
containsKey
(
"exception"
)).
isFalse
(
);
assertThat
(
attributes
).
doesNotContainKey
(
"exception"
);
assertThat
(
attributes
.
get
(
"message"
).
toString
()).
contains
(
""
);
}
...
...
@@ -121,7 +121,7 @@ class DefaultErrorAttributesTests {
this
.
request
.
setAttribute
(
"javax.servlet.error.message"
,
"Test"
);
Map
<
String
,
Object
>
attributes
=
this
.
errorAttributes
.
getErrorAttributes
(
this
.
webRequest
,
ErrorAttributeOptions
.
of
(
Include
.
MESSAGE
));
assertThat
(
attributes
.
containsKey
(
"exception"
)).
isFalse
(
);
assertThat
(
attributes
).
doesNotContainKey
(
"exception"
);
assertThat
(
attributes
.
get
(
"message"
)).
isEqualTo
(
"Test"
);
}
...
...
@@ -130,7 +130,7 @@ class DefaultErrorAttributesTests {
this
.
request
.
setAttribute
(
"javax.servlet.error.message"
,
"Test"
);
Map
<
String
,
Object
>
attributes
=
this
.
errorAttributes
.
getErrorAttributes
(
this
.
webRequest
,
ErrorAttributeOptions
.
defaults
());
assertThat
(
attributes
.
containsKey
(
"exception"
)).
isFalse
(
);
assertThat
(
attributes
).
doesNotContainKey
(
"exception"
);
assertThat
(
attributes
.
get
(
"message"
)).
asString
().
contains
(
""
);
}
...
...
@@ -140,7 +140,7 @@ class DefaultErrorAttributesTests {
this
.
request
.
setAttribute
(
"javax.servlet.error.message"
,
"Test"
);
Map
<
String
,
Object
>
attributes
=
this
.
errorAttributes
.
getErrorAttributes
(
this
.
webRequest
,
ErrorAttributeOptions
.
of
(
Include
.
MESSAGE
));
assertThat
(
attributes
.
containsKey
(
"exception"
)).
isFalse
(
);
assertThat
(
attributes
).
doesNotContainKey
(
"exception"
);
assertThat
(
attributes
.
get
(
"message"
)).
isEqualTo
(
"Test"
);
}
...
...
@@ -149,7 +149,7 @@ class DefaultErrorAttributesTests {
this
.
request
.
setAttribute
(
"javax.servlet.error.exception"
,
new
RuntimeException
());
Map
<
String
,
Object
>
attributes
=
this
.
errorAttributes
.
getErrorAttributes
(
this
.
webRequest
,
ErrorAttributeOptions
.
of
(
Include
.
MESSAGE
));
assertThat
(
attributes
.
containsKey
(
"exception"
)).
isFalse
(
);
assertThat
(
attributes
).
doesNotContainKey
(
"exception"
);
assertThat
(
attributes
.
get
(
"message"
)).
isEqualTo
(
"No message available"
);
}
...
...
@@ -161,7 +161,7 @@ class DefaultErrorAttributesTests {
Map
<
String
,
Object
>
attributes
=
this
.
errorAttributes
.
getErrorAttributes
(
this
.
webRequest
,
ErrorAttributeOptions
.
of
(
Include
.
MESSAGE
));
assertThat
(
this
.
errorAttributes
.
getError
(
this
.
webRequest
)).
isSameAs
(
wrapped
);
assertThat
(
attributes
.
containsKey
(
"exception"
)).
isFalse
(
);
assertThat
(
attributes
).
doesNotContainKey
(
"exception"
);
assertThat
(
attributes
.
get
(
"message"
)).
isEqualTo
(
"Test"
);
}
...
...
@@ -172,7 +172,7 @@ class DefaultErrorAttributesTests {
Map
<
String
,
Object
>
attributes
=
this
.
errorAttributes
.
getErrorAttributes
(
this
.
webRequest
,
ErrorAttributeOptions
.
of
(
Include
.
MESSAGE
));
assertThat
(
this
.
errorAttributes
.
getError
(
this
.
webRequest
)).
isSameAs
(
error
);
assertThat
(
attributes
.
containsKey
(
"exception"
)).
isFalse
(
);
assertThat
(
attributes
).
doesNotContainKey
(
"exception"
);
assertThat
(
attributes
.
get
(
"message"
)).
isEqualTo
(
"Test error"
);
}
...
...
@@ -216,7 +216,7 @@ class DefaultErrorAttributesTests {
assertThat
(
attributes
.
get
(
"errors"
)).
isEqualTo
(
bindingResult
.
getAllErrors
());
}
else
{
assertThat
(
attributes
.
containsKey
(
"errors"
)).
isFalse
(
);
assertThat
(
attributes
).
doesNotContainKey
(
"errors"
);
}
}
...
...
@@ -257,7 +257,7 @@ class DefaultErrorAttributesTests {
this
.
request
.
setAttribute
(
"javax.servlet.error.exception"
,
ex
);
Map
<
String
,
Object
>
attributes
=
this
.
errorAttributes
.
getErrorAttributes
(
this
.
webRequest
,
ErrorAttributeOptions
.
defaults
());
assertThat
(
attributes
.
containsKey
(
"trace"
)).
isFalse
(
);
assertThat
(
attributes
).
doesNotContainKey
(
"trace"
);
}
@Test
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment