3838import java .util .concurrent .ExecutionException ;
3939import java .util .concurrent .TimeUnit ;
4040import java .util .concurrent .TimeoutException ;
41+ import java .util .logging .Level ;
42+ import java .util .logging .Logger ;
4143
4244import org .junit .AfterClass ;
43- import org .junit .Before ;
4445import org .junit .BeforeClass ;
4546import org .junit .Test ;
4647
@@ -49,37 +50,29 @@ public class ITStorageTest {
4950 private static Storage storage ;
5051 private static RemoteGcsHelper gcsHelper ;
5152
53+ private static final Logger log = Logger .getLogger (ITStorageTest .class .getName ());
5254 private static final String bucket = RemoteGcsHelper .generateBucketName ();
5355 private static final String CONTENT_TYPE = "text/plain" ;
5456 private static final byte [] BLOB_BYTE_CONTENT = {0xD , 0xE , 0xA , 0xD };
5557 private static final String BLOB_STRING_CONTENT = "Hello Google Cloud Storage!" ;
5658
5759 @ BeforeClass
5860 public static void beforeClass () {
59- try {
60- gcsHelper = RemoteGcsHelper .create ();
61- storage = StorageFactory .instance ().get (gcsHelper .options ());
62- storage .create (BucketInfo .of (bucket ));
63- } catch (RemoteGcsHelper .GcsHelperException e ) {
64- // ignore
65- }
61+ gcsHelper = RemoteGcsHelper .create ();
62+ storage = StorageFactory .instance ().get (gcsHelper .options ());
63+ storage .create (BucketInfo .of (bucket ));
6664 }
6765
6866 @ AfterClass
6967 public static void afterClass ()
7068 throws ExecutionException , TimeoutException , InterruptedException {
71- if (storage != null ) {
72- if (! RemoteGcsHelper . deleteBucketRecursively ( storage , bucket , 5 , TimeUnit . SECONDS )) {
73- throw new RuntimeException ( "Bucket deletion timed out. Could not delete non- empty bucket" );
69+ if (! RemoteGcsHelper . forceDelete ( storage , bucket , 5 , TimeUnit . SECONDS ) ) {
70+ if (log . isLoggable ( Level . WARNING )) {
71+ log . log ( Level . WARNING , "Deletion of bucket {0} timed out, bucket is not empty" , bucket );
7472 }
7573 }
7674 }
7775
78- @ Before
79- public void beforeMethod () {
80- org .junit .Assume .assumeNotNull (storage );
81- }
82-
8376 @ Test (timeout = 5000 )
8477 public void testListBuckets () throws InterruptedException {
8578 Iterator <BucketInfo > bucketIterator =
0 commit comments