@@ -410,45 +410,42 @@ public void testListBlobsEmptySelectedFields() throws InterruptedException {
410410
411411 @ Test (timeout = 5000 )
412412 public void testListBlobRequesterPays () throws InterruptedException {
413- String [] blobNames = {"test-list-blobs-empty-selected-fields-blob1" ,
414- "test-list-blobs-empty-selected-fields-blob2" };
415- BlobInfo blob1 = BlobInfo .newBuilder (BUCKET , blobNames [0 ])
416- .setContentType (CONTENT_TYPE )
417- .build ();
418- BlobInfo blob2 = BlobInfo .newBuilder (BUCKET , blobNames [1 ])
419- .setContentType (CONTENT_TYPE )
420- .build ();
421- Blob remoteBlob1 = storage .create (blob1 );
422- Blob remoteBlob2 = storage .create (blob2 );
423- assertNotNull (remoteBlob1 );
424- assertNotNull (remoteBlob2 );
425-
426- Page <Blob > page = storage .list (BUCKET ,
427- Storage .BlobListOption .prefix ("test-list-blobs-empty-selected-fields-blob" ),
428- Storage .BlobListOption .fields ());
413+ BlobInfo blob1 =
414+ BlobInfo .newBuilder (BUCKET , "test-list-blobs-empty-selected-fields-blob1" )
415+ .setContentType (CONTENT_TYPE )
416+ .build ();
417+ assertNotNull (storage .create (blob1 ));
429418
430419 // Test listing a Requester Pays bucket.
431420 Bucket remoteBucket = storage .get (BUCKET , Storage .BucketGetOption .fields (BucketField .ID ));
432421 assertNull (remoteBucket .requesterPays ());
433422 remoteBucket = remoteBucket .toBuilder ().setRequesterPays (true ).build ();
434423 Bucket updatedBucket = storage .update (remoteBucket );
435424 assertTrue (updatedBucket .requesterPays ());
436- String projectId = remoteStorageHelper .getOptions ().getProjectId ();
437425 try {
438- page = storage .list (BUCKET ,
426+ storage .list (
427+ BUCKET ,
439428 Storage .BlobListOption .prefix ("test-list-blobs-empty-selected-fields-blob" ),
440429 Storage .BlobListOption .fields (),
441430 Storage .BlobListOption .userProject ("fakeBillingProjectId" ));
442431 fail ("Expected bad user project error." );
443432 } catch (StorageException e ) {
444433 assertTrue (e .getMessage ().contains ("User project specified in the request is invalid" ));
445434 }
446- while (Iterators .size (page .iterateAll ().iterator ()) != 2 ) {
435+
436+ String projectId = remoteStorageHelper .getOptions ().getProjectId ();
437+ for (; ; ) {
438+ Page <Blob > page =
439+ storage .list (
440+ BUCKET ,
441+ Storage .BlobListOption .prefix ("test-list-blobs-empty-selected-fields-blob" ),
442+ Storage .BlobListOption .fields (),
443+ Storage .BlobListOption .userProject (projectId ));
444+ int size = Iterators .size (page .iterateAll ().iterator ());
445+ if (size == 1 ) {
446+ break ;
447+ }
447448 Thread .sleep (500 );
448- page = storage .list (BUCKET ,
449- Storage .BlobListOption .prefix ("test-list-blobs-empty-selected-fields-blob" ),
450- Storage .BlobListOption .fields (),
451- Storage .BlobListOption .userProject (projectId ));
452449 }
453450 }
454451
0 commit comments