Class MockClientHttpResponse
java.lang.Object
org.springframework.mock.http.MockHttpInputMessage
org.springframework.mock.http.client.MockClientHttpResponse
- All Implemented Interfaces:
Closeable,AutoCloseable,org.springframework.http.client.ClientHttpResponse,org.springframework.http.HttpInputMessage,org.springframework.http.HttpMessage
public class MockClientHttpResponse
extends MockHttpInputMessage
implements org.springframework.http.client.ClientHttpResponse
Mock implementation of
ClientHttpResponse.- Since:
- 3.2
- Author:
- Rossen Stoyanchev
-
Constructor Summary
ConstructorsConstructorDescriptionMockClientHttpResponse(byte[] body, int statusCode) Variant ofMockClientHttpResponse(byte[], HttpStatusCode)with a custom HTTP status code.MockClientHttpResponse(byte[] body, org.springframework.http.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, org.springframework.http.HttpStatusCode statusCode) Constructor with response body as InputStream. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()intDeprecated.org.springframework.http.HttpStatusCodeMethods inherited from class org.springframework.mock.http.MockHttpInputMessage
getBody, getHeadersMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.http.HttpInputMessage
getBodyMethods inherited from interface org.springframework.http.HttpMessage
getHeaders
-
Constructor Details
-
MockClientHttpResponse
public MockClientHttpResponse(byte[] body, org.springframework.http.HttpStatusCode statusCode) 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
public org.springframework.http.HttpStatusCode getStatusCode()- Specified by:
getStatusCodein interfaceorg.springframework.http.client.ClientHttpResponse
-
getRawStatusCode
Deprecated.- Specified by:
getRawStatusCodein interfaceorg.springframework.http.client.ClientHttpResponse
-
getStatusText
- Specified by:
getStatusTextin interfaceorg.springframework.http.client.ClientHttpResponse
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceorg.springframework.http.client.ClientHttpResponse- Specified by:
closein interfaceCloseable
-