@@ -21,6 +21,11 @@ public class BucketTest extends TestCase {
2121 private BucketManager bucketManagerNa0 ;
2222 private BucketManager dummyBucketManager ;
2323
24+ ArrayList <Integer > batchStatusCode = new ArrayList (){{
25+ this .add (200 );
26+ this .add (298 );
27+ }};
28+
2429 @ Override
2530 protected void setUp () throws Exception {
2631 //default config
@@ -353,15 +358,15 @@ public void testBatchCopy() {
353358 try {
354359 Response r = bucketManager .batch (ops );
355360 BatchStatus [] bs = r .jsonToObject (BatchStatus [].class );
356- assertEquals ( 200 , bs [0 ].code );
361+ Assert . assertTrue ( " 200 or 298" , batchStatusCode . contains ( bs [0 ].code ) );
357362 } catch (QiniuException e ) {
358363 fail (e .response .toString ());
359364 }
360365 ops = new BucketManager .BatchOperations ().addDeleteOp (bucket , copyToKey );
361366 try {
362367 Response r = bucketManager .batch (ops );
363368 BatchStatus [] bs = r .jsonToObject (BatchStatus [].class );
364- assertEquals ( 200 , bs [0 ].code );
369+ Assert . assertTrue ( " 200 or 298" , batchStatusCode . contains ( bs [0 ].code ) );
365370 } catch (QiniuException e ) {
366371 fail (e .response .toString ());
367372 }
@@ -388,7 +393,7 @@ public void testBatchMove() {
388393 try {
389394 Response r = bucketManager .batch (ops );
390395 BatchStatus [] bs = r .jsonToObject (BatchStatus [].class );
391- assertEquals ( 200 , bs [0 ].code );
396+ Assert . assertTrue ( " 200 or 298" , batchStatusCode . contains ( bs [0 ].code ) );
392397 } catch (QiniuException e ) {
393398 fail (e .response .toString ());
394399 }
@@ -420,7 +425,7 @@ public void testBatchRename() {
420425 try {
421426 Response r = bucketManager .batch (ops );
422427 BatchStatus [] bs = r .jsonToObject (BatchStatus [].class );
423- assertEquals ( 200 , bs [0 ].code );
428+ Assert . assertTrue ( " 200 or 298" , batchStatusCode . contains ( bs [0 ].code ) );
424429 } catch (QiniuException e ) {
425430 fail (e .response .toString ());
426431 }
@@ -449,7 +454,7 @@ public void testBatchStat() {
449454 try {
450455 Response r = bucketManager .batch (ops );
451456 BatchStatus [] bs = r .jsonToObject (BatchStatus [].class );
452- assertEquals ( 200 , bs [0 ].code );
457+ Assert . assertTrue ( " 200 or 298" , batchStatusCode . contains ( bs [0 ].code ) );
453458 } catch (QiniuException e ) {
454459 fail (e .response .toString ());
455460 }
@@ -485,7 +490,7 @@ public void testBatchChangeType() {
485490 try {
486491 Response r = bucketManager .batch (ops );
487492 BatchStatus [] bs = r .jsonToObject (BatchStatus [].class );
488- assertEquals ( 200 , bs [0 ].code );
493+ Assert . assertTrue ( " 200 or 298" , batchStatusCode . contains ( bs [0 ].code ) );
489494 } catch (QiniuException e ) {
490495 fail (e .response .toString ());
491496 } finally {
@@ -519,9 +524,10 @@ public void testBatchCopyChgmDelete() {
519524 ops .addCopyOp (bucket , key , bucket , keyArray [i ]);
520525 }
521526
527+
522528 try {
523529 Response response = bucketManager .batch (ops );
524- Assert .assertEquals ( 200 , response .statusCode );
530+ Assert .assertTrue ( " 200 or 298" , batchStatusCode . contains ( response .statusCode ) );
525531
526532 //clear ops
527533 ops .clearOps ();
@@ -531,14 +537,14 @@ public void testBatchCopyChgmDelete() {
531537 ops .addChgmOp (bucket , keyArray [i ], "image/png" );
532538 }
533539 response = bucketManager .batch (ops );
534- Assert .assertEquals ( 200 , response .statusCode );
540+ Assert .assertTrue ( " 200 or 298" , batchStatusCode . contains ( response .statusCode ) );
535541
536542 //clear ops
537543 for (int i = 0 ; i < keyArray .length ; i ++) {
538544 ops .addDeleteOp (bucket , keyArray [i ]);
539545 }
540546 response = bucketManager .batch (ops );
541- Assert .assertEquals ( 200 , response .statusCode );
547+ Assert .assertTrue ( " 200 or 298" , batchStatusCode . contains ( response .statusCode ) );
542548
543549 } catch (QiniuException e ) {
544550 fail (e .response .toString ());
@@ -580,7 +586,7 @@ public void testBatch() {
580586 Response r = bucketManager .batch (ops );
581587 BatchStatus [] bs = r .jsonToObject (BatchStatus [].class );
582588 for (BatchStatus b : bs ) {
583- assertEquals ( 200 , b .code );
589+ Assert . assertTrue ( " 200 or 298" , batchStatusCode . contains ( b .code ) );
584590 }
585591 } catch (QiniuException e ) {
586592 fail (e .response .toString ());
0 commit comments