This commit is contained in:
Looly
2024-09-28 02:01:20 +08:00
parent eecbf6ea29
commit 8eff63bc9f
35 changed files with 353 additions and 227 deletions

View File

@@ -32,7 +32,7 @@ public class IssueIAFKWPTest {
@Test
void urlWithFormTest() {
final JSONObject obj = JSONUtil.ofObj();
obj.set("fields", ListUtil.of("1", "2", "good"));
obj.putObj("fields", ListUtil.of("1", "2", "good"));
final Map<String, Object> params = new HashMap<>();
params.put("query", obj.toString());

View File

@@ -38,8 +38,8 @@ public class RestTest {
final Request request = Request.of("http://localhost:8090/rest/restTest/")
.method(Method.POST)
.body(JSONUtil.ofObj()
.set("aaa", "aaaValue")
.set("键2", "值2").toString());
.putObj("aaa", "aaaValue")
.putObj("键2", "值2").toString());
Assertions.assertEquals("application/json;charset=UTF-8", request.header(HeaderName.CONTENT_TYPE));
}
@@ -50,8 +50,8 @@ public class RestTest {
final Request request = Request.of("http://localhost:8090/rest/restTest/")
.method(Method.POST)
.body(JSONUtil.ofObj()
.set("aaa", "aaaValue")
.set("键2", "值2").toString());
.putObj("aaa", "aaaValue")
.putObj("键2", "值2").toString());
Console.log(request.send().body());
}
@@ -59,8 +59,8 @@ public class RestTest {
@Disabled
public void postTest2() {
final String result = HttpUtil.post("http://localhost:8090/rest/restTest/", JSONUtil.ofObj()//
.set("aaa", "aaaValue")
.set("键2", "值2").toString());
.putObj("aaa", "aaaValue")
.putObj("键2", "值2").toString());
Console.log(result);
}
@@ -70,8 +70,8 @@ public class RestTest {
final Request request = Request.of("http://localhost:8888/restTest")//
.header(HeaderName.CONTENT_TYPE, "application/json")
.body(JSONUtil.ofObj()
.set("aaa", "aaaValue")
.set("键2", "值2").toString());
.putObj("aaa", "aaaValue")
.putObj("键2", "值2").toString());
//noinspection resource
Console.log(request.send().body());
}

View File

@@ -44,9 +44,9 @@ public class SimpleServerTest {
// 返回JSON数据测试
.addAction("/restTest", (request, response) -> {
final String res = JSONUtil.ofObj()
.set("id", 1)
.set("method", request.getMethod())
.set("request", request.getBody())
.putObj("id", 1)
.putObj("method", request.getMethod())
.putObj("request", request.getBody())
.toStringPretty();
response.write(res, ContentType.JSON.toString());
})