@@ -49,9 +49,16 @@ public void testList() {
4949 @ Test
5050 public void testListIterator () {
5151 BucketManager .FileListIterator it = bucketManager .createFileListIterator (TestConfig .bucket , null , 2 , null );
52+
53+ assertTrue (it .hasNext ());
54+ FileInfo [] items0 = it .next ();
55+ assertNotNull (items0 [0 ]);
56+
5257 while (it .hasNext ()) {
5358 FileInfo [] items = it .next ();
54- assertNotNull (items [0 ]);
59+ if (items .length > 1 ) {
60+ assertNotNull (items [0 ]);
61+ }
5562 }
5663 }
5764
@@ -147,11 +154,12 @@ public void testFetch() {
147154 }
148155 }
149156
157+
150158 @ Test
151159 public void testBatchCopy () {
152160 String key = "copyTo" + Math .random ();
153- StringMap x = new StringMap (). put ( TestConfig . key , key );
154- BucketManager . Batch ops = BucketManager . Batch . copy (TestConfig .bucket , x , TestConfig .bucket );
161+ BucketManager . Batch ops = new BucketManager . Batch ().
162+ copy (TestConfig .bucket , TestConfig . key , TestConfig .bucket , key );
155163 try {
156164 Response r = bucketManager .batch (ops );
157165 BatchStatus [] bs = r .jsonToObject (BatchStatus [].class );
@@ -160,8 +168,7 @@ public void testBatchCopy() {
160168 e .printStackTrace ();
161169 fail ();
162170 }
163- String [] array = {key };
164- ops = BucketManager .Batch .delete (TestConfig .bucket , array );
171+ ops = new BucketManager .Batch ().delete (TestConfig .bucket , key );
165172 try {
166173 Response r = bucketManager .batch (ops );
167174 BatchStatus [] bs = r .jsonToObject (BatchStatus [].class );
@@ -182,10 +189,8 @@ public void testBatchMove() {
182189 }
183190 String key2 = key + "to" ;
184191 StringMap x = new StringMap ().put (key , key2 );
185- BucketManager .Batch ops = BucketManager .Batch .move (TestConfig .bucket ,
186- x ,
187- TestConfig .bucket
188- );
192+ BucketManager .Batch ops = new BucketManager .Batch ().move (TestConfig .bucket ,
193+ key , TestConfig .bucket , key2 );
189194 try {
190195 Response r = bucketManager .batch (ops );
191196 BatchStatus [] bs = r .jsonToObject (BatchStatus [].class );
@@ -212,8 +217,7 @@ public void testBatchRename() {
212217 fail ();
213218 }
214219 String key2 = key + "to" ;
215- StringMap x = new StringMap ().put (key , key2 );
216- BucketManager .Batch ops = BucketManager .Batch .rename (TestConfig .bucket , x );
220+ BucketManager .Batch ops = new BucketManager .Batch ().rename (TestConfig .bucket , key , key2 );
217221 try {
218222 Response r = bucketManager .batch (ops );
219223 BatchStatus [] bs = r .jsonToObject (BatchStatus [].class );
@@ -233,7 +237,7 @@ public void testBatchRename() {
233237 @ Test
234238 public void testBatchStat () {
235239 String [] array = {"java-sdk.html" };
236- BucketManager .Batch ops = BucketManager .Batch .stat (TestConfig .bucket , array );
240+ BucketManager .Batch ops = new BucketManager .Batch () .stat (TestConfig .bucket , array );
237241 try {
238242 Response r = bucketManager .batch (ops );
239243 BatchStatus [] bs = r .jsonToObject (BatchStatus [].class );
@@ -243,4 +247,41 @@ public void testBatchStat() {
243247 fail ();
244248 }
245249 }
250+
251+ @ Test
252+ public void testBatch () {
253+ String [] array = {"java-sdk.html" };
254+ String key = "copyFrom" + Math .random ();
255+
256+ String key1 = "moveFrom" + Math .random ();
257+ String key2 = "moveTo" + Math .random ();
258+
259+ String key3 = "moveFrom" + Math .random ();
260+ String key4 = "moveTo" + Math .random ();
261+
262+ try {
263+ bucketManager .copy (TestConfig .bucket , TestConfig .key , TestConfig .bucket , key1 );
264+ bucketManager .copy (TestConfig .bucket , TestConfig .key , TestConfig .bucket , key3 );
265+ } catch (QiniuException e ) {
266+ e .printStackTrace ();
267+ fail ();
268+ }
269+
270+ BucketManager .Batch ops = new BucketManager .Batch ()
271+ .copy (TestConfig .bucket , TestConfig .key , TestConfig .bucket , key )
272+ .move (TestConfig .bucket , key1 , TestConfig .bucket , key2 )
273+ .rename (TestConfig .bucket , key3 , key4 )
274+ .stat (TestConfig .bucket , array )
275+ .stat (TestConfig .bucket , array [0 ]);
276+ try {
277+ Response r = bucketManager .batch (ops );
278+ BatchStatus [] bs = r .jsonToObject (BatchStatus [].class );
279+ for (BatchStatus b : bs ) {
280+ assertEquals (200 , b .code );
281+ }
282+ } catch (QiniuException e ) {
283+ e .printStackTrace ();
284+ fail ();
285+ }
286+ }
246287}
0 commit comments