Browse Source

Polishing

pull/32145/head
Juergen Hoeller 2 years ago
parent
commit
c6e9cd0c62
  1. 1
      spring-test/src/main/java/org/springframework/test/web/client/MockMvcClientHttpRequestFactory.java
  2. 6
      spring-test/src/main/java/org/springframework/test/web/servlet/MvcResult.java
  3. 47
      spring-web/src/main/java/org/springframework/web/client/RestOperations.java

1
spring-test/src/main/java/org/springframework/test/web/client/MockMvcClientHttpRequestFactory.java

@ -35,7 +35,6 @@ import org.springframework.util.Assert;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.request; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.request;
/** /**
* A {@link ClientHttpRequestFactory} for requests executed via {@link MockMvc}. * A {@link ClientHttpRequestFactory} for requests executed via {@link MockMvc}.
* *

6
spring-test/src/main/java/org/springframework/test/web/servlet/MvcResult.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2024 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.
@ -34,13 +34,13 @@ public interface MvcResult {
/** /**
* Return the performed request. * Return the performed request.
* @return the request, never {@code null} * @return the request (never {@code null})
*/ */
MockHttpServletRequest getRequest(); MockHttpServletRequest getRequest();
/** /**
* Return the resulting response. * Return the resulting response.
* @return the response, never {@code null} * @return the response (never {@code null})
*/ */
MockHttpServletResponse getResponse(); MockHttpServletResponse getResponse();

47
spring-web/src/main/java/org/springframework/web/client/RestOperations.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2023 the original author or authors. * Copyright 2002-2024 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.
@ -145,7 +145,7 @@ public interface RestOperations {
// POST // POST
/** /**
* Create a new resource by POSTing the given object to the URI template, and returns the value of * Create a new resource by POSTing the given object to the URI template, and return the value of
* the {@code Location} header. This header typically indicates where the new resource is stored. * the {@code Location} header. This header typically indicates where the new resource is stored.
* <p>URI Template variables are expanded using the given URI variables, if any. * <p>URI Template variables are expanded using the given URI variables, if any.
* <p>The {@code request} parameter can be a {@link HttpEntity} in order to * <p>The {@code request} parameter can be a {@link HttpEntity} in order to
@ -165,7 +165,7 @@ public interface RestOperations {
URI postForLocation(String url, @Nullable Object request, Object... uriVariables) throws RestClientException; URI postForLocation(String url, @Nullable Object request, Object... uriVariables) throws RestClientException;
/** /**
* Create a new resource by POSTing the given object to the URI template, and returns the value of * Create a new resource by POSTing the given object to the URI template, and return the value of
* the {@code Location} header. This header typically indicates where the new resource is stored. * the {@code Location} header. This header typically indicates where the new resource is stored.
* <p>URI Template variables are expanded using the given map. * <p>URI Template variables are expanded using the given map.
* <p>The {@code request} parameter can be a {@link HttpEntity} in order to * <p>The {@code request} parameter can be a {@link HttpEntity} in order to
@ -186,7 +186,7 @@ public interface RestOperations {
throws RestClientException; throws RestClientException;
/** /**
* Create a new resource by POSTing the given object to the URL, and returns the value of the * Create a new resource by POSTing the given object to the URL, and return the value of the
* {@code Location} header. This header typically indicates where the new resource is stored. * {@code Location} header. This header typically indicates where the new resource is stored.
* <p>The {@code request} parameter can be a {@link HttpEntity} in order to * <p>The {@code request} parameter can be a {@link HttpEntity} in order to
* add additional HTTP headers to the request. * add additional HTTP headers to the request.
@ -205,7 +205,7 @@ public interface RestOperations {
/** /**
* Create a new resource by POSTing the given object to the URI template, * Create a new resource by POSTing the given object to the URI template,
* and returns the representation found in the response. * and return the representation found in the response.
* <p>URI Template variables are expanded using the given URI variables, if any. * <p>URI Template variables are expanded using the given URI variables, if any.
* <p>The {@code request} parameter can be a {@link HttpEntity} in order to * <p>The {@code request} parameter can be a {@link HttpEntity} in order to
* add additional HTTP headers to the request. * add additional HTTP headers to the request.
@ -227,7 +227,7 @@ public interface RestOperations {
/** /**
* Create a new resource by POSTing the given object to the URI template, * Create a new resource by POSTing the given object to the URI template,
* and returns the representation found in the response. * and return the representation found in the response.
* <p>URI Template variables are expanded using the given map. * <p>URI Template variables are expanded using the given map.
* <p>The {@code request} parameter can be a {@link HttpEntity} in order to * <p>The {@code request} parameter can be a {@link HttpEntity} in order to
* add additional HTTP headers to the request. * add additional HTTP headers to the request.
@ -249,7 +249,7 @@ public interface RestOperations {
/** /**
* Create a new resource by POSTing the given object to the URL, * Create a new resource by POSTing the given object to the URL,
* and returns the representation found in the response. * and return the representation found in the response.
* <p>The {@code request} parameter can be a {@link HttpEntity} in order to * <p>The {@code request} parameter can be a {@link HttpEntity} in order to
* add additional HTTP headers to the request. * add additional HTTP headers to the request.
* <p>The body of the entity, or {@code request} itself, can be a * <p>The body of the entity, or {@code request} itself, can be a
@ -268,7 +268,7 @@ public interface RestOperations {
/** /**
* Create a new resource by POSTing the given object to the URI template, * Create a new resource by POSTing the given object to the URI template,
* and returns the response as {@link ResponseEntity}. * and return the response as {@link ResponseEntity}.
* <p>URI Template variables are expanded using the given URI variables, if any. * <p>URI Template variables are expanded using the given URI variables, if any.
* <p>The {@code request} parameter can be a {@link HttpEntity} in order to * <p>The {@code request} parameter can be a {@link HttpEntity} in order to
* add additional HTTP headers to the request. * add additional HTTP headers to the request.
@ -289,7 +289,7 @@ public interface RestOperations {
/** /**
* Create a new resource by POSTing the given object to the URI template, * Create a new resource by POSTing the given object to the URI template,
* and returns the response as {@link HttpEntity}. * and return the response as {@link HttpEntity}.
* <p>URI Template variables are expanded using the given map. * <p>URI Template variables are expanded using the given map.
* <p>The {@code request} parameter can be a {@link HttpEntity} in order to * <p>The {@code request} parameter can be a {@link HttpEntity} in order to
* add additional HTTP headers to the request. * add additional HTTP headers to the request.
@ -310,7 +310,7 @@ public interface RestOperations {
/** /**
* Create a new resource by POSTing the given object to the URL, * Create a new resource by POSTing the given object to the URL,
* and returns the response as {@link ResponseEntity}. * and return the response as {@link ResponseEntity}.
* <p>The {@code request} parameter can be a {@link HttpEntity} in order to * <p>The {@code request} parameter can be a {@link HttpEntity} in order to
* add additional HTTP headers to the request. * add additional HTTP headers to the request.
* <p>The body of the entity, or {@code request} itself, can be a * <p>The body of the entity, or {@code request} itself, can be a
@ -374,7 +374,7 @@ public interface RestOperations {
* <p>The {@code request} parameter can be a {@link HttpEntity} in order to * <p>The {@code request} parameter can be a {@link HttpEntity} in order to
* add additional HTTP headers to the request. * add additional HTTP headers to the request.
* <p><b>NOTE: The standard JDK HTTP library does not support HTTP PATCH. * <p><b>NOTE: The standard JDK HTTP library does not support HTTP PATCH.
* You need to use the Apache HttpComponents or OkHttp request factory.</b> * You need to use e.g. the Apache HttpComponents request factory.</b>
* @param url the URL * @param url the URL
* @param request the object to be PATCHed (may be {@code null}) * @param request the object to be PATCHed (may be {@code null})
* @param responseType the type of the return value * @param responseType the type of the return value
@ -384,7 +384,6 @@ public interface RestOperations {
* @see HttpEntity * @see HttpEntity
* @see RestTemplate#setRequestFactory * @see RestTemplate#setRequestFactory
* @see org.springframework.http.client.HttpComponentsClientHttpRequestFactory * @see org.springframework.http.client.HttpComponentsClientHttpRequestFactory
* @see org.springframework.http.client.OkHttp3ClientHttpRequestFactory
*/ */
@Nullable @Nullable
<T> T patchForObject(String url, @Nullable Object request, Class<T> responseType, Object... uriVariables) <T> T patchForObject(String url, @Nullable Object request, Class<T> responseType, Object... uriVariables)
@ -397,7 +396,7 @@ public interface RestOperations {
* <p>The {@code request} parameter can be a {@link HttpEntity} in order to * <p>The {@code request} parameter can be a {@link HttpEntity} in order to
* add additional HTTP headers to the request. * add additional HTTP headers to the request.
* <p><b>NOTE: The standard JDK HTTP library does not support HTTP PATCH. * <p><b>NOTE: The standard JDK HTTP library does not support HTTP PATCH.
* You need to use the Apache HttpComponents or OkHttp request factory.</b> * You need to use e.g. the Apache HttpComponents request factory.</b>
* @param url the URL * @param url the URL
* @param request the object to be PATCHed (may be {@code null}) * @param request the object to be PATCHed (may be {@code null})
* @param responseType the type of the return value * @param responseType the type of the return value
@ -407,7 +406,6 @@ public interface RestOperations {
* @see HttpEntity * @see HttpEntity
* @see RestTemplate#setRequestFactory * @see RestTemplate#setRequestFactory
* @see org.springframework.http.client.HttpComponentsClientHttpRequestFactory * @see org.springframework.http.client.HttpComponentsClientHttpRequestFactory
* @see org.springframework.http.client.OkHttp3ClientHttpRequestFactory
*/ */
@Nullable @Nullable
<T> T patchForObject(String url, @Nullable Object request, Class<T> responseType, <T> T patchForObject(String url, @Nullable Object request, Class<T> responseType,
@ -419,7 +417,7 @@ public interface RestOperations {
* <p>The {@code request} parameter can be a {@link HttpEntity} in order to * <p>The {@code request} parameter can be a {@link HttpEntity} in order to
* add additional HTTP headers to the request. * add additional HTTP headers to the request.
* <p><b>NOTE: The standard JDK HTTP library does not support HTTP PATCH. * <p><b>NOTE: The standard JDK HTTP library does not support HTTP PATCH.
* You need to use the Apache HttpComponents or OkHttp request factory.</b> * You need to use e.g. the Apache HttpComponents request factory.</b>
* @param url the URL * @param url the URL
* @param request the object to be PATCHed (may be {@code null}) * @param request the object to be PATCHed (may be {@code null})
* @param responseType the type of the return value * @param responseType the type of the return value
@ -428,7 +426,6 @@ public interface RestOperations {
* @see HttpEntity * @see HttpEntity
* @see RestTemplate#setRequestFactory * @see RestTemplate#setRequestFactory
* @see org.springframework.http.client.HttpComponentsClientHttpRequestFactory * @see org.springframework.http.client.HttpComponentsClientHttpRequestFactory
* @see org.springframework.http.client.OkHttp3ClientHttpRequestFactory
*/ */
@Nullable @Nullable
<T> T patchForObject(URI url, @Nullable Object request, Class<T> responseType) <T> T patchForObject(URI url, @Nullable Object request, Class<T> responseType)
@ -492,8 +489,8 @@ public interface RestOperations {
// exchange // exchange
/** /**
* Execute the HTTP method to the given URI template, writing the given request entity to the request, and * Execute the HTTP method to the given URI template, writing the given request entity to the request,
* returns the response as {@link ResponseEntity}. * and return the response as {@link ResponseEntity}.
* <p>URI Template variables are expanded using the given URI variables, if any. * <p>URI Template variables are expanded using the given URI variables, if any.
* @param url the URL * @param url the URL
* @param method the HTTP method (GET, POST, etc) * @param method the HTTP method (GET, POST, etc)
@ -508,8 +505,8 @@ public interface RestOperations {
Class<T> responseType, Object... uriVariables) throws RestClientException; Class<T> responseType, Object... uriVariables) throws RestClientException;
/** /**
* Execute the HTTP method to the given URI template, writing the given request entity to the request, and * Execute the HTTP method to the given URI template, writing the given request entity to the request,
* returns the response as {@link ResponseEntity}. * and return the response as {@link ResponseEntity}.
* <p>URI Template variables are expanded using the given URI variables, if any. * <p>URI Template variables are expanded using the given URI variables, if any.
* @param url the URL * @param url the URL
* @param method the HTTP method (GET, POST, etc) * @param method the HTTP method (GET, POST, etc)
@ -524,8 +521,8 @@ public interface RestOperations {
Class<T> responseType, Map<String, ?> uriVariables) throws RestClientException; Class<T> responseType, Map<String, ?> uriVariables) throws RestClientException;
/** /**
* Execute the HTTP method to the given URI template, writing the given request entity to the request, and * Execute the HTTP method to the given URI template, writing the given request entity to the request,
* returns the response as {@link ResponseEntity}. * and return the response as {@link ResponseEntity}.
* @param url the URL * @param url the URL
* @param method the HTTP method (GET, POST, etc) * @param method the HTTP method (GET, POST, etc)
* @param requestEntity the entity (headers and/or body) to write to the request * @param requestEntity the entity (headers and/or body) to write to the request
@ -539,7 +536,7 @@ public interface RestOperations {
/** /**
* Execute the HTTP method to the given URI template, writing the given * Execute the HTTP method to the given URI template, writing the given
* request entity to the request, and returns the response as {@link ResponseEntity}. * request entity to the request, and return the response as {@link ResponseEntity}.
* The given {@link ParameterizedTypeReference} is used to pass generic type information: * The given {@link ParameterizedTypeReference} is used to pass generic type information:
* <pre class="code"> * <pre class="code">
* ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt; myBean = * ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt; myBean =
@ -562,7 +559,7 @@ public interface RestOperations {
/** /**
* Execute the HTTP method to the given URI template, writing the given * Execute the HTTP method to the given URI template, writing the given
* request entity to the request, and returns the response as {@link ResponseEntity}. * request entity to the request, and return the response as {@link ResponseEntity}.
* The given {@link ParameterizedTypeReference} is used to pass generic type information: * The given {@link ParameterizedTypeReference} is used to pass generic type information:
* <pre class="code"> * <pre class="code">
* ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt; myBean = * ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt; myBean =
@ -585,7 +582,7 @@ public interface RestOperations {
/** /**
* Execute the HTTP method to the given URI template, writing the given * Execute the HTTP method to the given URI template, writing the given
* request entity to the request, and returns the response as {@link ResponseEntity}. * request entity to the request, and return the response as {@link ResponseEntity}.
* The given {@link ParameterizedTypeReference} is used to pass generic type information: * The given {@link ParameterizedTypeReference} is used to pass generic type information:
* <pre class="code"> * <pre class="code">
* ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt; myBean = * ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt; myBean =

Loading…
Cancel
Save