2
2
3
3
import com .qiniu .common .QiniuException ;
4
4
import com .qiniu .http .Response ;
5
+ import com .qiniu .processing .OperationManager ;
6
+ import com .qiniu .processing .OperationStatus ;
5
7
import com .qiniu .storage .Configuration ;
6
8
import com .qiniu .storage .UpCompletionHandler ;
7
9
import com .qiniu .storage .UploadManager ;
@@ -27,6 +29,56 @@ public class FormUploadTest {
27
29
28
30
UploadManager uploadManager = new UploadManager (new Configuration ());
29
31
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
+
30
82
/**
31
83
* hello上传测试
32
84
*/
0 commit comments