Class MockClientHttpResponse
java.lang.Object
org.springframework.mock.http.MockHttpInputMessage
org.springframework.mock.http.client.MockClientHttpResponse
- All Implemented Interfaces:
Closeable
,AutoCloseable
,ClientHttpResponse
,HttpInputMessage
,HttpMessage
Mock implementation of
ClientHttpResponse
.- Since:
- 3.2
- Author:
- Rossen Stoyanchev
-
Constructor Summary
ConstructorDescriptionMockClientHttpResponse
(byte[] body, int statusCode) Variant ofMockClientHttpResponse(byte[], HttpStatusCode)
with a custom HTTP status code.MockClientHttpResponse
(byte[] body, HttpStatusCode statusCode) Constructor with response body as a byte array.MockClientHttpResponse
(InputStream body, int statusCode) Variant ofMockClientHttpResponse(InputStream, HttpStatusCode)
with a custom HTTP status code.MockClientHttpResponse
(InputStream body, HttpStatusCode statusCode) Constructor with response body as InputStream. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close this response, freeing any resources created.int
Deprecated.Get the HTTP status code as anHttpStatusCode
.Get the HTTP status text of the response.Methods inherited from class org.springframework.mock.http.MockHttpInputMessage
getBody, getHeaders
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.http.HttpInputMessage
getBody
Methods inherited from interface org.springframework.http.HttpMessage
getHeaders
-
Constructor Details
-
MockClientHttpResponse
Constructor with response body as a byte array. -
MockClientHttpResponse
public MockClientHttpResponse(byte[] body, int statusCode) Variant ofMockClientHttpResponse(byte[], HttpStatusCode)
with a custom HTTP status code.- Since:
- 5.3.17
-
MockClientHttpResponse
Constructor with response body as InputStream. -
MockClientHttpResponse
Variant ofMockClientHttpResponse(InputStream, HttpStatusCode)
with a custom HTTP status code.- Since:
- 5.3.17
-
-
Method Details
-
getStatusCode
Description copied from interface:ClientHttpResponse
Get the HTTP status code as anHttpStatusCode
.- Specified by:
getStatusCode
in interfaceClientHttpResponse
- Returns:
- the HTTP status as
HttpStatusCode
value (nevernull
)
-
getRawStatusCode
Deprecated.Description copied from interface:ClientHttpResponse
Get the HTTP status code as an integer.- Specified by:
getRawStatusCode
in interfaceClientHttpResponse
- Returns:
- the HTTP status as an integer value
- See Also:
-
getStatusText
Description copied from interface:ClientHttpResponse
Get the HTTP status text of the response.- Specified by:
getStatusText
in interfaceClientHttpResponse
- Returns:
- the HTTP status text
-
close
public void close()Description copied from interface:ClientHttpResponse
Close this response, freeing any resources created.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceClientHttpResponse
- Specified by:
close
in interfaceCloseable
-