48
48
import java .io .InputStream ;
49
49
import java .net .URL ;
50
50
import java .net .URLConnection ;
51
+ import java .util .ArrayList ;
51
52
import java .util .HashSet ;
52
53
import java .util .Iterator ;
53
54
import java .util .List ;
@@ -64,6 +65,7 @@ public class ITStorageSnippets {
64
65
65
66
private static Storage storage ;
66
67
private static StorageSnippets storageSnippets ;
68
+ private static List <String > bucketsToCleanUp ;
67
69
68
70
@ Rule
69
71
public ExpectedException thrown = ExpectedException .none ();
@@ -75,20 +77,35 @@ public class ITStorageSnippets {
75
77
public static void beforeClass () {
76
78
RemoteStorageHelper helper = RemoteStorageHelper .create ();
77
79
storage = helper .getOptions ().getService ();
80
+ bucketsToCleanUp = new ArrayList <String >();
78
81
storageSnippets = new StorageSnippets (storage );
79
82
storageSnippets .createBucket (BUCKET );
83
+ bucketsToCleanUp .add (BUCKET );
80
84
}
81
85
82
86
@ AfterClass
83
87
public static void afterClass () throws ExecutionException , InterruptedException {
84
88
if (storage != null ) {
85
- boolean wasDeleted = RemoteStorageHelper .forceDelete (storage , BUCKET , 5 , TimeUnit .SECONDS );
86
- if (!wasDeleted && log .isLoggable (Level .WARNING )) {
87
- log .log (Level .WARNING , "Deletion of bucket {0} timed out, bucket is not empty" , BUCKET );
89
+ for (String bucket : bucketsToCleanUp ) {
90
+ boolean wasDeleted = RemoteStorageHelper .forceDelete (storage , bucket , 5 , TimeUnit .SECONDS );
91
+ if (!wasDeleted && log .isLoggable (Level .WARNING )) {
92
+ log .log (Level .WARNING , "Deletion of bucket {0} timed out, bucket is not empty" , bucket );
93
+ }
88
94
}
89
95
}
90
96
}
91
97
98
+ @ Test
99
+ public void testCreateBucketWithStorageClassAndLocation ()
100
+ throws ExecutionException , InterruptedException {
101
+ String tempBucket = RemoteStorageHelper .generateBucketName ();
102
+ bucketsToCleanUp .add (tempBucket );
103
+
104
+ Bucket bucket = storageSnippets .createBucketWithStorageClassAndLocation (tempBucket );
105
+
106
+ assertNotNull (bucket );
107
+ }
108
+
92
109
@ Test
93
110
public void testBlob () throws InterruptedException {
94
111
String blobName = "directory/test-blob" ;
0 commit comments