类 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.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
close()
Close this response, freeing any resources created.int
getRawStatusCode()
Return the HTTP status code (potentially non-standard and not resolvable through theHttpStatus
enum) as an integer.HttpStatus
getStatusCode()
Return the HTTP status code of the response.String
getStatusText()
Return 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
从接口复制的说明:ClientHttpResponse
Return the HTTP status code of the response.- 指定者:
getStatusCode
在接口中ClientHttpResponse
- 返回:
- the HTTP status as an HttpStatus enum value
- 抛出:
IOException
- in case of I/O errors- 另请参阅:
HttpStatus.valueOf(int)
getRawStatusCode
public int getRawStatusCode() throws IOException
从接口复制的说明:ClientHttpResponse
Return the HTTP status code (potentially non-standard and not resolvable through theHttpStatus
enum) as an integer.- 指定者:
getRawStatusCode
在接口中ClientHttpResponse
- 返回:
- the HTTP status as an integer
- 抛出:
IOException
- in case of I/O errors- 另请参阅:
ClientHttpResponse.getStatusCode()
getStatusText
public String getStatusText() throws IOException
从接口复制的说明:ClientHttpResponse
Return the HTTP status text of the response.- 指定者:
getStatusText
在接口中ClientHttpResponse
- 返回:
- the HTTP status text
- 抛出:
IOException
- in case of I/O errors
close
public void close()
从接口复制的说明:ClientHttpResponse
Close this response, freeing any resources created.- 指定者:
close
在接口中AutoCloseable
- 指定者:
close
在接口中ClientHttpResponse
- 指定者:
close
在接口中Closeable