类 MockClientHttpResponse
- java.lang.Object
- org.springframework.mock.http.MockHttpInputMessage
- org.springframework.mock.http.client.MockClientHttpResponse
- 所有已实现的接口:
Closeable,AutoCloseable,ClientHttpResponse,HttpInputMessage,HttpMessage
public class MockClientHttpResponse extends MockHttpInputMessage implements ClientHttpResponse
Mock implementation ofClientHttpResponse.- 从以下版本开始:
- 3.2
- 作者:
- Rossen Stoyanchev
构造器概要
构造器 构造器 说明 MockClientHttpResponse(byte[] body, HttpStatus statusCode)Constructor with response body as a byte array.MockClientHttpResponse(InputStream body, HttpStatus statusCode)Constructor with response body as InputStream.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 voidclose()Close this response, freeing any resources created.intgetRawStatusCode()Get the HTTP status code (potentially non-standard and not resolvable through theHttpStatusenum) as an integer.HttpStatusgetStatusCode()Get the HTTP status code as anHttpStatusenum value.StringgetStatusText()Get the HTTP status text of the response.从类继承的方法 org.springframework.mock.http.MockHttpInputMessage
getBody, getHeaders
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 org.springframework.http.HttpInputMessage
getBody
从接口继承的方法 org.springframework.http.HttpMessage
getHeaders
构造器详细资料
MockClientHttpResponse
public MockClientHttpResponse(byte[] body, HttpStatus statusCode)
Constructor with response body as a byte array.
MockClientHttpResponse
public MockClientHttpResponse(InputStream body, HttpStatus statusCode)
Constructor with response body as InputStream.
方法详细资料
getStatusCode
public HttpStatus getStatusCode() throws IOException
从接口复制的说明:ClientHttpResponseGet the HTTP status code as anHttpStatusenum value.For status codes not supported by
HttpStatus, useClientHttpResponse.getRawStatusCode()instead.- 指定者:
getStatusCode在接口中ClientHttpResponse- 返回:
- the HTTP status as an HttpStatus enum value (never
null) - 抛出:
IOException- in case of I/O errors- 另请参阅:
HttpStatus.valueOf(int)
getRawStatusCode
public int getRawStatusCode() throws IOException
从接口复制的说明:ClientHttpResponseGet the HTTP status code (potentially non-standard and not resolvable through theHttpStatusenum) as an integer.- 指定者:
getRawStatusCode在接口中ClientHttpResponse- 返回:
- the HTTP status as an integer value
- 抛出:
IOException- in case of I/O errors- 另请参阅:
ClientHttpResponse.getStatusCode(),HttpStatus.resolve(int)
getStatusText
public String getStatusText() throws IOException
从接口复制的说明:ClientHttpResponseGet the HTTP status text of the response.- 指定者:
getStatusText在接口中ClientHttpResponse- 返回:
- the HTTP status text
- 抛出:
IOException- in case of I/O errors
close
public void close()
从接口复制的说明:ClientHttpResponseClose this response, freeing any resources created.- 指定者:
close在接口中AutoCloseable- 指定者:
close在接口中ClientHttpResponse- 指定者:
close在接口中Closeable