22
33import com .qiniu .common .QiniuException ;
44import com .qiniu .http .Response ;
5+ import com .qiniu .processing .OperationManager ;
6+ import com .qiniu .processing .OperationStatus ;
57import com .qiniu .storage .Configuration ;
68import com .qiniu .storage .UpCompletionHandler ;
79import 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