2929import static com .tencent .cos .xml .core .TestUtils .bigPlusFilePath ;
3030import static com .tencent .cos .xml .core .TestUtils .getContext ;
3131import static com .tencent .cos .xml .core .TestUtils .smallFilePath ;
32+ import static com .tencent .qcloud .core .http .QCloudHttpClient .HTTP_LOG_TAG ;
3233
3334import android .net .Uri ;
3435import android .text .TextUtils ;
6061import com .tencent .qcloud .core .auth .COSXmlSignSourceProvider ;
6162import com .tencent .qcloud .core .http .HttpTaskMetrics ;
6263import com .tencent .qcloud .core .logger .QCloudLogger ;
64+ import com .tencent .qcloud .core .task .TaskExecutors ;
6365import com .tencent .qcloud .core .util .Base64Utils ;
6466import com .tencent .qcloud .core .util .QCloudStringUtils ;
6567
@@ -312,8 +314,9 @@ private void logMsTime(String desc, double ms) {
312314// }
313315
314316 @ Test public void testMultiUpload () {
315- int count = 2 ;
317+ int count = 20 ;
316318 long sleep = 1000 ;
319+ final TestLocker testLocker = new TestLocker ();
317320 for (int i = 0 ; i <= count ; i ++) {
318321 testUploadSmallFileByPath (i );
319322 QCloudLogger .i ("QCloudTest" , "!!!Start to sleep for %d ms" , sleep );
@@ -322,12 +325,18 @@ private void logMsTime(String desc, double ms) {
322325 } else {
323326 QCloudLogger .i ("QCloudTest" , "------ Finish Test --------" );
324327 }
328+ if (i == count ){
329+ TestUtils .sleep (60000 );
330+ Assert .assertTrue (true );
331+ testLocker .release ();
332+ }
325333 }
334+ testLocker .lock ();
326335 }
327336
328337 public void testUploadSmallFileByPath (int number ) {
329338 // String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "/youxue.jpg";
330- String path = bigFilePath ();
339+ String path = smallFilePath ();
331340 QCloudLogger .i ("QCloudTest" , "upload path is " + path );
332341
333342 TransferManager transferManager = ServiceFactory .INSTANCE .newDefaultTransferManager ();
@@ -355,21 +364,18 @@ public void onGetHttpMetrics(String requestName, HttpTaskMetrics httpTaskMetrics
355364 QCloudLogger .i ("QCloudTest" , "ip is " + httpTaskMetrics .getConnectAddress ().getHostAddress ());
356365 }
357366 });
358- final TestLocker testLocker = new TestLocker ();
359367 uploadTask .setCosXmlResultListener (new CosXmlResultListener () {
360368 @ Override
361369 public void onSuccess (CosXmlRequest request , CosXmlResult result ) {
362370 result .printResult ();
363371 TestUtils .parseBadResponseBody (result );
364- testLocker .release ();
365372 uploadTask .clearResultAndException ();
366373 }
367374
368375 @ Override
369376 public void onFail (CosXmlRequest request , CosXmlClientException clientException , CosXmlServiceException serviceException ) {
370377 TestUtils .printError (TestUtils .getCosExceptionMessage (clientException , serviceException ));
371378 Assert .fail (TestUtils .getCosExceptionMessage (clientException , serviceException ));
372- testLocker .release ();
373379 }
374380 });
375381
@@ -386,9 +392,6 @@ public void onSuccess(InitiateMultipartUpload initiateMultipartUpload) {
386392 String uploadId = initiateMultipartUpload .uploadId ;
387393 }
388394 });
389-
390- testLocker .lock ();
391- TestUtils .assertCOSXMLTaskSuccess (uploadTask );
392395 }
393396
394397 @ Test public void testUpload () {
0 commit comments