Skip to content

Commit 465ff2f

Browse files
committed
添加 x:foo 测试
1 parent c3c037f commit 465ff2f

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/test/java/com/qiniu/storage/FormUploadTest.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,33 @@ public void complete(String key, Response r) {
196196
}
197197
}
198198

199+
@Test
200+
public void testXVar() {
201+
final String expectKey = "世/界";
202+
File f = null;
203+
try {
204+
f = TempFile.createFile(1);
205+
} catch (IOException e) {
206+
e.printStackTrace();
207+
}
208+
assert f != null;
209+
StringMap params = new StringMap().put("x:foo", "foo_val");
210+
final String returnBody = "{\"key\":\"$(key)\",\"hash\":\"$(etag)\",\"fsize\":\"$(fsize)\""
211+
+ ",\"fname\":\"$(fname)\",\"mimeType\":\"$(mimeType)\",\"foo\":\"$(x:foo)\"}";
212+
String token = TestConfig.testAuth.uploadToken(TestConfig.bucket, expectKey, 3600,
213+
new StringMap().put("returnBody", returnBody));
214+
215+
try {
216+
Response res = uploadManager.put(f, expectKey, token, params, null, true);
217+
StringMap m = res.jsonToMap();
218+
assertEquals("foo_val", m.get("foo"));
219+
} catch (QiniuException e) {
220+
fail();
221+
} finally {
222+
TempFile.remove(f);
223+
}
224+
}
225+
199226
@Test
200227
public void testFname() {
201228
final String expectKey = "世/界";

0 commit comments

Comments
 (0)