Skip to content

Commit 5362633

Browse files
committed
Merge branch '2.3.x' into 2.4.x
Closes gh-24973
2 parents 69fbd2f + 0b06ac9 commit 5362633

File tree

5 files changed

+41
-41
lines changed

5 files changed

+41
-41
lines changed

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfigurationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -336,7 +336,7 @@ void testOverrideParameters() {
336336
.withPropertyValues("spring.liquibase.parameters.foo:bar").run(assertLiquibase((liquibase) -> {
337337
Map<String, String> parameters = (Map<String, String>) ReflectionTestUtils.getField(liquibase,
338338
"parameters");
339-
assertThat(parameters.containsKey("foo")).isTrue();
339+
assertThat(parameters).containsKey("foo");
340340
assertThat(parameters.get("foo")).isEqualTo("bar");
341341
}));
342342
}

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/error/BasicErrorControllerIntegrationTests.java

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -84,13 +84,13 @@ void closeContext() {
8484
}
8585

8686
@Test
87-
@SuppressWarnings("rawtypes")
87+
@SuppressWarnings({ "rawtypes", "unchecked" })
8888
void testErrorForMachineClientDefault() {
8989
load();
9090
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(createUrl("?trace=true"), Map.class);
9191
assertErrorAttributes(entity.getBody(), "500", "Internal Server Error", null, "", "/");
92-
assertThat(entity.getBody().containsKey("exception")).isFalse();
93-
assertThat(entity.getBody().containsKey("trace")).isFalse();
92+
assertThat(entity.getBody()).doesNotContainKey("exception");
93+
assertThat(entity.getBody()).doesNotContainKey("trace");
9494
}
9595

9696
@Test
@@ -144,19 +144,19 @@ void testErrorForMachineClientAlwaysParamsWithoutMessage() {
144144
"No message available", "/noMessage");
145145
}
146146

147-
@SuppressWarnings("rawtypes")
147+
@SuppressWarnings({ "rawtypes", "unchecked" })
148148
private void exceptionWithStackTraceAndMessage(String path) {
149149
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(createUrl(path), Map.class);
150150
assertErrorAttributes(entity.getBody(), "500", "Internal Server Error", IllegalStateException.class,
151151
"Expected!", "/");
152-
assertThat(entity.getBody().containsKey("trace")).isTrue();
152+
assertThat(entity.getBody()).containsKey("trace");
153153
}
154154

155-
@SuppressWarnings("rawtypes")
155+
@SuppressWarnings({ "rawtypes", "unchecked" })
156156
private void exceptionWithoutStackTraceAndMessage(String path) {
157157
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(createUrl(path), Map.class);
158158
assertErrorAttributes(entity.getBody(), "500", "Internal Server Error", IllegalStateException.class, "", "/");
159-
assertThat(entity.getBody().containsKey("trace")).isFalse();
159+
assertThat(entity.getBody()).doesNotContainKey("trace");
160160
}
161161

162162
@Test
@@ -265,57 +265,57 @@ void testBindingExceptionForMachineClientNeverMessage() {
265265
bindingExceptionWithoutMessage("?message=true");
266266
}
267267

268-
@SuppressWarnings({ "rawtypes" })
268+
@SuppressWarnings({ "rawtypes", "unchecked" })
269269
private void bindingExceptionWithErrors(String param) {
270270
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(createUrl("/bind" + param), Map.class);
271271
assertErrorAttributes(entity.getBody(), "400", "Bad Request", BindException.class, "", "/bind");
272-
assertThat(entity.getBody().containsKey("errors")).isTrue();
272+
assertThat(entity.getBody()).containsKey("errors");
273273
}
274274

275-
@SuppressWarnings({ "rawtypes" })
275+
@SuppressWarnings({ "rawtypes", "unchecked" })
276276
private void bindingExceptionWithoutErrors(String param) {
277277
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(createUrl("/bind" + param), Map.class);
278278
assertErrorAttributes(entity.getBody(), "400", "Bad Request", BindException.class, "", "/bind");
279-
assertThat(entity.getBody().containsKey("errors")).isFalse();
279+
assertThat(entity.getBody()).doesNotContainKey("errors");
280280
}
281281

282-
@SuppressWarnings({ "rawtypes" })
282+
@SuppressWarnings({ "rawtypes", "unchecked" })
283283
private void bindingExceptionWithMessage(String param) {
284284
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(createUrl("/bind" + param), Map.class);
285285
assertErrorAttributes(entity.getBody(), "400", "Bad Request", BindException.class,
286286
"Validation failed for object='test'. Error count: 1", "/bind");
287-
assertThat(entity.getBody().containsKey("errors")).isFalse();
287+
assertThat(entity.getBody()).doesNotContainKey("errors");
288288
}
289289

290-
@SuppressWarnings({ "rawtypes" })
290+
@SuppressWarnings({ "rawtypes", "unchecked" })
291291
private void bindingExceptionWithoutMessage(String param) {
292292
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(createUrl("/bind" + param), Map.class);
293293
assertErrorAttributes(entity.getBody(), "400", "Bad Request", BindException.class, "", "/bind");
294-
assertThat(entity.getBody().containsKey("errors")).isFalse();
294+
assertThat(entity.getBody()).doesNotContainKey("errors");
295295
}
296296

297297
@Test
298-
@SuppressWarnings("rawtypes")
298+
@SuppressWarnings({ "rawtypes", "unchecked" })
299299
void testRequestBodyValidationForMachineClient() {
300300
load("--server.error.include-exception=true");
301301
RequestEntity request = RequestEntity.post(URI.create(createUrl("/bodyValidation")))
302302
.accept(MediaType.APPLICATION_JSON).contentType(MediaType.APPLICATION_JSON).body("{}");
303303
ResponseEntity<Map> entity = new TestRestTemplate().exchange(request, Map.class);
304304
assertErrorAttributes(entity.getBody(), "400", "Bad Request", MethodArgumentNotValidException.class, "",
305305
"/bodyValidation");
306-
assertThat(entity.getBody().containsKey("errors")).isFalse();
306+
assertThat(entity.getBody()).doesNotContainKey("errors");
307307
}
308308

309309
@Test
310-
@SuppressWarnings("rawtypes")
310+
@SuppressWarnings({ "rawtypes", "unchecked" })
311311
void testBindingExceptionForMachineClientDefault() {
312312
load();
313313
RequestEntity request = RequestEntity.get(URI.create(createUrl("/bind?trace=true,message=true")))
314314
.accept(MediaType.APPLICATION_JSON).build();
315315
ResponseEntity<Map> entity = new TestRestTemplate().exchange(request, Map.class);
316-
assertThat(entity.getBody().containsKey("exception")).isFalse();
317-
assertThat(entity.getBody().containsKey("trace")).isFalse();
318-
assertThat(entity.getBody().containsKey("errors")).isFalse();
316+
assertThat(entity.getBody()).doesNotContainKey("exception");
317+
assertThat(entity.getBody()).doesNotContainKey("trace");
318+
assertThat(entity.getBody()).doesNotContainKey("errors");
319319
}
320320

321321
@Test

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/undertow/FileSessionPersistenceTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -82,7 +82,7 @@ void dontRestoreExpired() {
8282
this.persistence.persistSessions("test", sessionData);
8383
Map<String, PersistentSession> restored = this.persistence.loadSessionAttributes("test", this.classLoader);
8484
assertThat(restored).isNotNull();
85-
assertThat(restored.containsKey("abc")).isFalse();
85+
assertThat(restored).doesNotContainKey("abc");
8686
}
8787

8888
@Test

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/error/DefaultErrorAttributesTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -269,8 +269,8 @@ void extractBindingResultErrorsExcludeMessageAndErrors() throws Exception {
269269
MockServerHttpRequest request = MockServerHttpRequest.get("/test").build();
270270
Map<String, Object> attributes = this.errorAttributes.getErrorAttributes(buildServerRequest(request, ex),
271271
ErrorAttributeOptions.defaults());
272-
assertThat(attributes.get("message")).isEqualTo("");
273-
assertThat(attributes.containsKey("errors")).isFalse();
272+
assertThat(attributes).containsEntry("message", "");
273+
assertThat(attributes).doesNotContainKey("errors");
274274
}
275275

276276
private ServerRequest buildServerRequest(MockServerHttpRequest request, Throwable error) {

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/error/DefaultErrorAttributesTests.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -90,7 +90,7 @@ void mvcError() {
9090
ErrorAttributeOptions.of(Include.MESSAGE));
9191
assertThat(this.errorAttributes.getError(this.webRequest)).isSameAs(ex);
9292
assertThat(modelAndView).isNull();
93-
assertThat(attributes.containsKey("exception")).isFalse();
93+
assertThat(attributes).doesNotContainKey("exception");
9494
assertThat(attributes.get("message")).isEqualTo("Test");
9595
}
9696

@@ -101,7 +101,7 @@ void servletErrorWithMessage() {
101101
Map<String, Object> attributes = this.errorAttributes.getErrorAttributes(this.webRequest,
102102
ErrorAttributeOptions.of(Include.MESSAGE));
103103
assertThat(this.errorAttributes.getError(this.webRequest)).isSameAs(ex);
104-
assertThat(attributes.containsKey("exception")).isFalse();
104+
assertThat(attributes).doesNotContainKey("exception");
105105
assertThat(attributes.get("message")).isEqualTo("Test");
106106
}
107107

@@ -112,7 +112,7 @@ void servletErrorWithoutMessage() {
112112
Map<String, Object> attributes = this.errorAttributes.getErrorAttributes(this.webRequest,
113113
ErrorAttributeOptions.defaults());
114114
assertThat(this.errorAttributes.getError(this.webRequest)).isSameAs(ex);
115-
assertThat(attributes.containsKey("exception")).isFalse();
115+
assertThat(attributes).doesNotContainKey("exception");
116116
assertThat(attributes.get("message").toString()).contains("");
117117
}
118118

@@ -121,7 +121,7 @@ void servletMessageWithMessage() {
121121
this.request.setAttribute("javax.servlet.error.message", "Test");
122122
Map<String, Object> attributes = this.errorAttributes.getErrorAttributes(this.webRequest,
123123
ErrorAttributeOptions.of(Include.MESSAGE));
124-
assertThat(attributes.containsKey("exception")).isFalse();
124+
assertThat(attributes).doesNotContainKey("exception");
125125
assertThat(attributes.get("message")).isEqualTo("Test");
126126
}
127127

@@ -130,7 +130,7 @@ void servletMessageWithoutMessage() {
130130
this.request.setAttribute("javax.servlet.error.message", "Test");
131131
Map<String, Object> attributes = this.errorAttributes.getErrorAttributes(this.webRequest,
132132
ErrorAttributeOptions.defaults());
133-
assertThat(attributes.containsKey("exception")).isFalse();
133+
assertThat(attributes).doesNotContainKey("exception");
134134
assertThat(attributes.get("message")).asString().contains("");
135135
}
136136

@@ -140,7 +140,7 @@ void nullExceptionMessage() {
140140
this.request.setAttribute("javax.servlet.error.message", "Test");
141141
Map<String, Object> attributes = this.errorAttributes.getErrorAttributes(this.webRequest,
142142
ErrorAttributeOptions.of(Include.MESSAGE));
143-
assertThat(attributes.containsKey("exception")).isFalse();
143+
assertThat(attributes).doesNotContainKey("exception");
144144
assertThat(attributes.get("message")).isEqualTo("Test");
145145
}
146146

@@ -149,7 +149,7 @@ void nullExceptionMessageAndServletMessage() {
149149
this.request.setAttribute("javax.servlet.error.exception", new RuntimeException());
150150
Map<String, Object> attributes = this.errorAttributes.getErrorAttributes(this.webRequest,
151151
ErrorAttributeOptions.of(Include.MESSAGE));
152-
assertThat(attributes.containsKey("exception")).isFalse();
152+
assertThat(attributes).doesNotContainKey("exception");
153153
assertThat(attributes.get("message")).isEqualTo("No message available");
154154
}
155155

@@ -161,7 +161,7 @@ void unwrapServletException() {
161161
Map<String, Object> attributes = this.errorAttributes.getErrorAttributes(this.webRequest,
162162
ErrorAttributeOptions.of(Include.MESSAGE));
163163
assertThat(this.errorAttributes.getError(this.webRequest)).isSameAs(wrapped);
164-
assertThat(attributes.containsKey("exception")).isFalse();
164+
assertThat(attributes).doesNotContainKey("exception");
165165
assertThat(attributes.get("message")).isEqualTo("Test");
166166
}
167167

@@ -172,7 +172,7 @@ void getError() {
172172
Map<String, Object> attributes = this.errorAttributes.getErrorAttributes(this.webRequest,
173173
ErrorAttributeOptions.of(Include.MESSAGE));
174174
assertThat(this.errorAttributes.getError(this.webRequest)).isSameAs(error);
175-
assertThat(attributes.containsKey("exception")).isFalse();
175+
assertThat(attributes).doesNotContainKey("exception");
176176
assertThat(attributes.get("message")).isEqualTo("Test error");
177177
}
178178

@@ -216,7 +216,7 @@ private void testBindingResult(BindingResult bindingResult, Exception ex, ErrorA
216216
assertThat(attributes.get("errors")).isEqualTo(bindingResult.getAllErrors());
217217
}
218218
else {
219-
assertThat(attributes.containsKey("errors")).isFalse();
219+
assertThat(attributes).doesNotContainKey("errors");
220220
}
221221
}
222222

@@ -257,7 +257,7 @@ void withoutStackTraceAttribute() {
257257
this.request.setAttribute("javax.servlet.error.exception", ex);
258258
Map<String, Object> attributes = this.errorAttributes.getErrorAttributes(this.webRequest,
259259
ErrorAttributeOptions.defaults());
260-
assertThat(attributes.containsKey("trace")).isFalse();
260+
assertThat(attributes).doesNotContainKey("trace");
261261
}
262262

263263
@Test

0 commit comments

Comments
 (0)