|
|
|
@ -224,6 +224,29 @@ public class AllInOneTest extends TestBase { |
|
|
|
|
client.execute(requestBuilder); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 演示大文件上传,先配置网关参数:spring.servlet.multipart.max-file-size=1MB |
|
|
|
|
*/ |
|
|
|
|
public void testBigFile() { |
|
|
|
|
Client client = new Client(url, appId, privateKey); |
|
|
|
|
String root = System.getProperty("user.dir"); |
|
|
|
|
Client.RequestBuilder requestBuilder = new Client.RequestBuilder() |
|
|
|
|
.method("file.upload3") |
|
|
|
|
.version("1.0") |
|
|
|
|
.bizContent(new BizContent().add("remark", "test file upload")) |
|
|
|
|
// 添加文件
|
|
|
|
|
.addFile("image", new File(root + "/src/main/resources/large_img.png")) |
|
|
|
|
.callback((requestInfo, responseData) -> { |
|
|
|
|
System.out.println(responseData); |
|
|
|
|
JSONObject jsonObject = JSON.parseObject(responseData); |
|
|
|
|
JSONObject data = jsonObject.getJSONObject(requestInfo.getDataNode()); |
|
|
|
|
Assert.assertEquals(data.getString("sub_code"), "isv.invalid-file-size"); |
|
|
|
|
}) |
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
client.execute(requestBuilder); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 传递header |
|
|
|
|
*/ |
|
|
|
@ -330,6 +353,24 @@ public class AllInOneTest extends TestBase { |
|
|
|
|
client.execute(requestBuilder); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 单个参数绑定 |
|
|
|
|
*/ |
|
|
|
|
public void testBindParam() { |
|
|
|
|
Client.RequestBuilder requestBuilder = new Client.RequestBuilder() |
|
|
|
|
.method("story.param.bind") |
|
|
|
|
.version("1.0") |
|
|
|
|
.addSystemParam("id", "1") |
|
|
|
|
.addSystemParam("name", "葫芦娃") |
|
|
|
|
.httpMethod(HttpTool.HTTPMethod.GET) |
|
|
|
|
.callback(((requestInfo, responseData) -> { |
|
|
|
|
System.out.println(responseData); |
|
|
|
|
Assert.assertTrue(responseData.contains("参数绑定:id:1, name:葫芦娃")); |
|
|
|
|
})); |
|
|
|
|
|
|
|
|
|
client.execute(requestBuilder); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static class BizContent extends HashMap<String, Object> { |
|
|
|
|
public BizContent add(String key, Object value) { |
|
|
|
|
this.put(key, value); |
|
|
|
|