Skip to content

Commit a2f07d0

Browse files
author
YangSen-qn
committed
upload: add fop test case
1 parent 01edc79 commit a2f07d0

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

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

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import com.qiniu.common.QiniuException;
44
import com.qiniu.http.Response;
5+
import com.qiniu.processing.OperationManager;
6+
import com.qiniu.processing.OperationStatus;
57
import com.qiniu.storage.Configuration;
68
import com.qiniu.storage.UpCompletionHandler;
79
import com.qiniu.storage.UploadManager;
@@ -27,6 +29,56 @@ public class FormUploadTest {
2729

2830
UploadManager uploadManager = new UploadManager(new Configuration());
2931

32+
@Test
33+
@Tag("IntegrationTest")
34+
void testUploadWithFop() {
35+
TestConfig.TestFile file = TestConfig.getTestFileArray()[0];
36+
final String expectKey = "test-fop";
37+
final String bucket = file.getBucketName();
38+
39+
String persistentOpfs = String.format("%s:vframe_test_target.jpg", bucket);
40+
StringMap policy = new StringMap();
41+
policy.put("persistentOps", persistentOpfs);
42+
policy.put("persistentType", 1);
43+
44+
Configuration config = new Configuration();
45+
config.useHttpsDomains = true;
46+
47+
Response r = null;
48+
try {
49+
String token = TestConfig.testAuth.uploadToken(bucket, expectKey, 3600, policy);
50+
UploadManager uploadManager = new UploadManager(config);
51+
StringMap params = new StringMap().put("x:foo", "foo_val");
52+
r = uploadManager.put("hello".getBytes(), expectKey, token, params, null, false);
53+
} catch (QiniuException e) {
54+
fail(e.toString());
55+
}
56+
assertEquals(200, r.statusCode);
57+
58+
StringMap map = null;
59+
try {
60+
map = r.jsonToMap();
61+
} catch (QiniuException e) {
62+
fail(e.toString());
63+
}
64+
65+
assertNotNull(map, "1. testUploadWithFop error");
66+
67+
String persistentId = (String) map.get("persistentId");
68+
assertNotNull(persistentId, "2. testUploadWithFop error");
69+
70+
try {
71+
OperationManager operationManager = new OperationManager(TestConfig.testAuth, config);
72+
OperationStatus status = operationManager.prefop(bucket, persistentId);
73+
assertNotNull(status, "3. prefop type error");
74+
assertNotNull(status.creationDate, "4. prefop type error");
75+
assertTrue(status.code == 0 || status.code == 1 || status.code == 3, "5. prefop type error");
76+
assertEquals(1, (int) status.type, "6. prefop type error");
77+
} catch (QiniuException e) {
78+
fail(e.toString());
79+
}
80+
}
81+
3082
/**
3183
* hello上传测试
3284
*/

0 commit comments

Comments
 (0)