Class MockResponse
java.lang.Object
cloud.opencode.base.test.http.MockResponse
Mock HTTP Response — a response to be returned by
TestHttpServer for a matched route.
模拟 HTTP 响应 — TestHttpServer 为匹配路由返回的响应。
Features | 主要功能:
- Immutable HTTP response definition - 不可变HTTP响应定义
- Builder-style response construction - 构建器风格的响应构造
Usage Examples | 使用示例:
MockResponse response = MockResponse.ok("{\"status\": \"ok\"}")
.withHeader("Content-Type", "application/json");
Security | 安全性:
- Thread-safe: No - 线程安全: 否
- Since:
- JDK 25, opencode-base-test V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbody()headers()static MockResponsenotFound()static MockResponsestatic MockResponseok()static MockResponsestatic MockResponsestatic MockResponseserverError(String body) inttoString()withHeader(String name, String value) static MockResponsewithStatus(int statusCode) static MockResponsewithStatus(int statusCode, String body)
-
Method Details
-
ok
-
ok
-
notFound
-
notFound
-
serverError
-
serverError
-
withStatus
-
withStatus
-
withHeader
-
withBody
-
statusCode
public int statusCode() -
body
-
headers
-
toString
-