Suppress deprecation warnings in tests
This commit is contained in:
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,10 +31,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Marcel Overdijk
|
||||
* @author Kazuki Shimizu
|
||||
*/
|
||||
public class ResponseEntityTests {
|
||||
class ResponseEntityTests {
|
||||
|
||||
@Test
|
||||
public void normal() {
|
||||
void normal() {
|
||||
String headerName = "My-Custom-Header";
|
||||
String headerValue1 = "HeaderValue1";
|
||||
String headerValue2 = "HeaderValue2";
|
||||
@@ -54,7 +54,7 @@ public class ResponseEntityTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void okNoBody() {
|
||||
void okNoBody() {
|
||||
ResponseEntity<Void> responseEntity = ResponseEntity.ok().build();
|
||||
|
||||
assertThat(responseEntity).isNotNull();
|
||||
@@ -63,7 +63,7 @@ public class ResponseEntityTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void okEntity() {
|
||||
void okEntity() {
|
||||
Integer entity = 42;
|
||||
ResponseEntity<Integer> responseEntity = ResponseEntity.ok(entity);
|
||||
|
||||
@@ -73,7 +73,7 @@ public class ResponseEntityTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ofOptional() {
|
||||
void ofOptional() {
|
||||
Integer entity = 42;
|
||||
ResponseEntity<Integer> responseEntity = ResponseEntity.of(Optional.of(entity));
|
||||
|
||||
@@ -83,7 +83,7 @@ public class ResponseEntityTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ofEmptyOptional() {
|
||||
void ofEmptyOptional() {
|
||||
ResponseEntity<Integer> responseEntity = ResponseEntity.of(Optional.empty());
|
||||
|
||||
assertThat(responseEntity).isNotNull();
|
||||
@@ -92,7 +92,7 @@ public class ResponseEntityTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createdLocation() throws URISyntaxException {
|
||||
void createdLocation() throws URISyntaxException {
|
||||
URI location = new URI("location");
|
||||
ResponseEntity<Void> responseEntity = ResponseEntity.created(location).build();
|
||||
|
||||
@@ -106,7 +106,7 @@ public class ResponseEntityTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void acceptedNoBody() throws URISyntaxException {
|
||||
void acceptedNoBody() throws URISyntaxException {
|
||||
ResponseEntity<Void> responseEntity = ResponseEntity.accepted().build();
|
||||
|
||||
assertThat(responseEntity).isNotNull();
|
||||
@@ -115,7 +115,7 @@ public class ResponseEntityTests {
|
||||
}
|
||||
|
||||
@Test // SPR-14939
|
||||
public void acceptedNoBodyWithAlternativeBodyType() throws URISyntaxException {
|
||||
void acceptedNoBodyWithAlternativeBodyType() throws URISyntaxException {
|
||||
ResponseEntity<String> responseEntity = ResponseEntity.accepted().build();
|
||||
|
||||
assertThat(responseEntity).isNotNull();
|
||||
@@ -124,7 +124,7 @@ public class ResponseEntityTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noContent() throws URISyntaxException {
|
||||
void noContent() throws URISyntaxException {
|
||||
ResponseEntity<Void> responseEntity = ResponseEntity.noContent().build();
|
||||
|
||||
assertThat(responseEntity).isNotNull();
|
||||
@@ -133,7 +133,7 @@ public class ResponseEntityTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void badRequest() throws URISyntaxException {
|
||||
void badRequest() throws URISyntaxException {
|
||||
ResponseEntity<Void> responseEntity = ResponseEntity.badRequest().build();
|
||||
|
||||
assertThat(responseEntity).isNotNull();
|
||||
@@ -142,7 +142,7 @@ public class ResponseEntityTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notFound() throws URISyntaxException {
|
||||
void notFound() throws URISyntaxException {
|
||||
ResponseEntity<Void> responseEntity = ResponseEntity.notFound().build();
|
||||
|
||||
assertThat(responseEntity).isNotNull();
|
||||
@@ -151,7 +151,7 @@ public class ResponseEntityTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unprocessableEntity() throws URISyntaxException {
|
||||
void unprocessableEntity() throws URISyntaxException {
|
||||
ResponseEntity<String> responseEntity = ResponseEntity.unprocessableEntity().body("error");
|
||||
|
||||
assertThat(responseEntity).isNotNull();
|
||||
@@ -160,7 +160,7 @@ public class ResponseEntityTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void internalServerError() throws URISyntaxException {
|
||||
void internalServerError() throws URISyntaxException {
|
||||
ResponseEntity<String> responseEntity = ResponseEntity.internalServerError().body("error");
|
||||
|
||||
assertThat(responseEntity).isNotNull();
|
||||
@@ -169,7 +169,7 @@ public class ResponseEntityTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void headers() throws URISyntaxException {
|
||||
void headers() throws URISyntaxException {
|
||||
URI location = new URI("location");
|
||||
long contentLength = 67890;
|
||||
MediaType contentType = MediaType.TEXT_PLAIN;
|
||||
@@ -197,7 +197,7 @@ public class ResponseEntityTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void Etagheader() throws URISyntaxException {
|
||||
void Etagheader() throws URISyntaxException {
|
||||
|
||||
ResponseEntity<Void> responseEntity = ResponseEntity.ok().eTag("\"foo\"").build();
|
||||
assertThat(responseEntity.getHeaders().getETag()).isEqualTo("\"foo\"");
|
||||
@@ -210,7 +210,7 @@ public class ResponseEntityTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void headersCopy() {
|
||||
void headersCopy() {
|
||||
HttpHeaders customHeaders = new HttpHeaders();
|
||||
customHeaders.set("X-CustomHeader", "vale");
|
||||
|
||||
@@ -225,7 +225,7 @@ public class ResponseEntityTests {
|
||||
}
|
||||
|
||||
@Test // SPR-12792
|
||||
public void headersCopyWithEmptyAndNull() {
|
||||
void headersCopyWithEmptyAndNull() {
|
||||
ResponseEntity<Void> responseEntityWithEmptyHeaders =
|
||||
ResponseEntity.ok().headers(new HttpHeaders()).build();
|
||||
ResponseEntity<Void> responseEntityWithNullHeaders =
|
||||
@@ -237,7 +237,7 @@ public class ResponseEntityTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void emptyCacheControl() {
|
||||
void emptyCacheControl() {
|
||||
Integer entity = 42;
|
||||
|
||||
ResponseEntity<Integer> responseEntity =
|
||||
@@ -252,7 +252,7 @@ public class ResponseEntityTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cacheControl() {
|
||||
void cacheControl() {
|
||||
Integer entity = 42;
|
||||
|
||||
ResponseEntity<Integer> responseEntity =
|
||||
@@ -271,7 +271,7 @@ public class ResponseEntityTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cacheControlNoCache() {
|
||||
void cacheControlNoCache() {
|
||||
Integer entity = 42;
|
||||
|
||||
ResponseEntity<Integer> responseEntity =
|
||||
@@ -289,7 +289,7 @@ public class ResponseEntityTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void statusCodeAsInt() {
|
||||
void statusCodeAsInt() {
|
||||
Integer entity = 42;
|
||||
ResponseEntity<Integer> responseEntity = ResponseEntity.status(200).body(entity);
|
||||
|
||||
@@ -298,7 +298,8 @@ public class ResponseEntityTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customStatusCode() {
|
||||
@SuppressWarnings("deprecation")
|
||||
void customStatusCode() {
|
||||
Integer entity = 42;
|
||||
ResponseEntity<Integer> responseEntity = ResponseEntity.status(299).body(entity);
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Arjen Poutsma
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class InterceptingClientHttpRequestFactoryTests {
|
||||
class InterceptingClientHttpRequestFactoryTests {
|
||||
|
||||
private RequestFactoryMock requestFactoryMock = new RequestFactoryMock();
|
||||
|
||||
@@ -52,7 +52,7 @@ public class InterceptingClientHttpRequestFactoryTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void basic() throws Exception {
|
||||
void basic() throws Exception {
|
||||
List<ClientHttpRequestInterceptor> interceptors = new ArrayList<>();
|
||||
interceptors.add(new NoOpInterceptor());
|
||||
interceptors.add(new NoOpInterceptor());
|
||||
@@ -70,7 +70,7 @@ public class InterceptingClientHttpRequestFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noExecution() throws Exception {
|
||||
void noExecution() throws Exception {
|
||||
List<ClientHttpRequestInterceptor> interceptors = new ArrayList<>();
|
||||
interceptors.add((request, body, execution) -> responseMock);
|
||||
|
||||
@@ -86,7 +86,7 @@ public class InterceptingClientHttpRequestFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void changeHeaders() throws Exception {
|
||||
void changeHeaders() throws Exception {
|
||||
final String headerName = "Foo";
|
||||
final String headerValue = "Bar";
|
||||
final String otherValue = "Baz";
|
||||
@@ -116,7 +116,7 @@ public class InterceptingClientHttpRequestFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void changeURI() throws Exception {
|
||||
void changeURI() throws Exception {
|
||||
final URI changedUri = new URI("https://example.com/2");
|
||||
|
||||
ClientHttpRequestInterceptor interceptor = (request, body, execution) -> execution.execute(new HttpRequestWrapper(request) {
|
||||
@@ -142,7 +142,7 @@ public class InterceptingClientHttpRequestFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void changeMethod() throws Exception {
|
||||
void changeMethod() throws Exception {
|
||||
final HttpMethod changedMethod = HttpMethod.POST;
|
||||
|
||||
ClientHttpRequestInterceptor interceptor = (request, body, execution) -> execution.execute(new HttpRequestWrapper(request) {
|
||||
@@ -168,7 +168,7 @@ public class InterceptingClientHttpRequestFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void changeBody() throws Exception {
|
||||
void changeBody() throws Exception {
|
||||
final byte[] changedBody = "Foo".getBytes();
|
||||
|
||||
ClientHttpRequestInterceptor interceptor = (request, body, execution) -> execution.execute(request, changedBody);
|
||||
@@ -277,6 +277,7 @@ public class InterceptingClientHttpRequestFactoryTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public int getRawStatusCode() throws IOException {
|
||||
return statusCode.value();
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -756,6 +756,7 @@ class RestTemplateTests {
|
||||
given(request.getHeaders()).willReturn(requestHeaders);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void mockResponseStatus(HttpStatus responseStatus) throws Exception {
|
||||
given(request.execute()).willReturn(response);
|
||||
given(errorHandler.hasError(response)).willReturn(responseStatus.isError());
|
||||
|
||||
Reference in New Issue
Block a user