18
18
import org .junit .jupiter .api .Test ;
19
19
import test .com .qiniu .ResCode ;
20
20
import test .com .qiniu .TestConfig ;
21
- import static org .junit .jupiter .api .Assertions .assertArrayEquals ;
22
- import static org .junit .jupiter .api .Assertions .assertEquals ;
23
- import static org .junit .jupiter .api .Assertions .assertNotEquals ;
24
- import static org .junit .jupiter .api .Assertions .assertNotNull ;
25
- import static org .junit .jupiter .api .Assertions .assertNull ;
26
- import static org .junit .jupiter .api .Assertions .assertTrue ;
27
- import static org .junit .jupiter .api .Assertions .fail ;
21
+
28
22
import java .io .IOException ;
29
23
import java .text .SimpleDateFormat ;
30
24
import java .util .*;
31
25
26
+ import static org .junit .jupiter .api .Assertions .*;
27
+
32
28
public class BucketTest {
33
29
34
30
List <Integer > batchStatusCode = Arrays .asList (200 , 298 );
@@ -264,11 +260,11 @@ public void testFile(TestConfig.TestFile file, BucketManager bucketManager) thro
264
260
265
261
// test bucket not exits or file not exists
266
262
Map <String [], Integer > entryCodeMap = new HashMap <String [], Integer >();
267
- entryCodeMap .put (new String [] { TestConfig .testBucket_z0 , TestConfig .dummyKey },
263
+ entryCodeMap .put (new String []{ TestConfig .testBucket_z0 , TestConfig .dummyKey },
268
264
TestConfig .ERROR_CODE_KEY_NOT_EXIST );
269
- entryCodeMap .put (new String [] { TestConfig .dummyBucket , TestConfig .testKey_z0 },
265
+ entryCodeMap .put (new String []{ TestConfig .dummyBucket , TestConfig .testKey_z0 },
270
266
TestConfig .ERROR_CODE_BUCKET_NOT_EXIST );
271
- entryCodeMap .put (new String [] { TestConfig .dummyBucket , TestConfig .dummyKey },
267
+ entryCodeMap .put (new String []{ TestConfig .dummyBucket , TestConfig .dummyKey },
272
268
TestConfig .ERROR_CODE_BUCKET_NOT_EXIST );
273
269
274
270
for (Map .Entry <String [], Integer > entry : entryCodeMap .entrySet ()) {
@@ -313,11 +309,11 @@ public void testFile(TestConfig.TestFile file, BucketManager bucketManager) thro
313
309
});
314
310
315
311
Map <String [], Integer > entryCodeMap = new HashMap <String [], Integer >();
316
- entryCodeMap .put (new String [] { TestConfig .testBucket_z0 , TestConfig .dummyKey },
312
+ entryCodeMap .put (new String []{ TestConfig .testBucket_z0 , TestConfig .dummyKey },
317
313
TestConfig .ERROR_CODE_KEY_NOT_EXIST );
318
- entryCodeMap .put (new String [] { TestConfig .testBucket_z0 , null }, TestConfig .ERROR_CODE_BUCKET_NOT_EXIST );
319
- entryCodeMap .put (new String [] { TestConfig .dummyBucket , null }, TestConfig .ERROR_CODE_BUCKET_NOT_EXIST );
320
- entryCodeMap .put (new String [] { TestConfig .dummyBucket , TestConfig .dummyKey },
314
+ entryCodeMap .put (new String []{ TestConfig .testBucket_z0 , null }, TestConfig .ERROR_CODE_BUCKET_NOT_EXIST );
315
+ entryCodeMap .put (new String []{ TestConfig .dummyBucket , null }, TestConfig .ERROR_CODE_BUCKET_NOT_EXIST );
316
+ entryCodeMap .put (new String []{ TestConfig .dummyBucket , TestConfig .dummyKey },
321
317
TestConfig .ERROR_CODE_BUCKET_NOT_EXIST );
322
318
323
319
for (Map .Entry <String [], Integer > entry : entryCodeMap .entrySet ()) {
@@ -558,7 +554,7 @@ public void testFile(TestConfig.TestFile file, BucketManager bucketManager) thro
558
554
assertEquals (200 , response .statusCode );
559
555
bucketInfo = bucketManager .getBucketInfo (file .getBucketName ());
560
556
assertEquals (1 , bucketInfo .getAntiLeechMode ());
561
- assertArrayEquals ((new String [] { "www.qiniu.com" }), bucketInfo .getReferWhite ());
557
+ assertArrayEquals ((new String []{ "www.qiniu.com" }), bucketInfo .getReferWhite ());
562
558
assertEquals (false , bucketInfo .isNoRefer ());
563
559
564
560
// 测试黑名单
@@ -570,7 +566,7 @@ public void testFile(TestConfig.TestFile file, BucketManager bucketManager) thro
570
566
assertEquals (200 , response .statusCode );
571
567
bucketInfo = bucketManager .getBucketInfo (file .getBucketName ());
572
568
assertEquals (2 , bucketInfo .getAntiLeechMode ());
573
- assertArrayEquals ((new String [] { "www.baidu.com" }), bucketInfo .getReferBlack ());
569
+ assertArrayEquals ((new String []{ "www.baidu.com" }), bucketInfo .getReferBlack ());
574
570
assertEquals (true , bucketInfo .isNoRefer ());
575
571
576
572
// 测试关闭
@@ -726,7 +722,7 @@ public void testFile(TestConfig.TestFile file, BucketManager bucketManager) thro
726
722
727
723
// 追加Event(invalid events)
728
724
try {
729
- rule = new BucketEventRule ("a" , new String [] {}, new String [] {});
725
+ rule = new BucketEventRule ("a" , new String []{}, new String []{});
730
726
System .out .println (rule .asQueryString ());
731
727
response = bucketManager .putBucketEvent (bucket , rule );
732
728
fail ();
@@ -736,7 +732,7 @@ public void testFile(TestConfig.TestFile file, BucketManager bucketManager) thro
736
732
737
733
// 追加Event(error:callbackURL must starts with http:// or https://)
738
734
try {
739
- rule = new BucketEventRule ("a" , new String [] { "put" , "mkfile" }, new String [] {});
735
+ rule = new BucketEventRule ("a" , new String []{ "put" , "mkfile" }, new String []{});
740
736
System .out .println (rule .asQueryString ());
741
737
response = bucketManager .putBucketEvent (bucket , rule );
742
738
fail ();
@@ -746,10 +742,10 @@ public void testFile(TestConfig.TestFile file, BucketManager bucketManager) thro
746
742
747
743
// 追加Event
748
744
rule = new BucketEventRule ("a" ,
749
- new String [] { "put" , "mkfile" , "delete" , "copy" , "move" , "append" , "disable" , "enable" ,
750
- "deleteMarkerCreate" },
751
- new String [] { "https://requestbin.fullcontact.com/1dsqext1?inspect" ,
752
- "https://requestbin.fullcontact.com/160bunp1?inspect" });
745
+ new String []{ "put" , "mkfile" , "delete" , "copy" , "move" , "append" , "disable" , "enable" ,
746
+ "deleteMarkerCreate" },
747
+ new String []{ "https://requestbin.fullcontact.com/1dsqext1?inspect" ,
748
+ "https://requestbin.fullcontact.com/160bunp1?inspect" });
753
749
System .out .println (rule .asQueryString ());
754
750
response = bucketManager .putBucketEvent (bucket , rule );
755
751
assertEquals (200 , response .statusCode );
@@ -801,7 +797,7 @@ public void testFile(TestConfig.TestFile file, BucketManager bucketManager) thro
801
797
// 更新Event
802
798
rule .setName ("b" );
803
799
rule .setPrefix ("c" );
804
- rule .setEvents (new String [] { "disable" , "enable" , "deleteMarkerCreate" });
800
+ rule .setEvents (new String []{ "disable" , "enable" , "deleteMarkerCreate" });
805
801
System .out .println (rule .asQueryString ());
806
802
response = bucketManager .updateBucketEvent (bucket , rule );
807
803
assertEquals (200 , response .statusCode );
@@ -848,9 +844,9 @@ public void testCorsRules() throws Exception {
848
844
@ Override
849
845
public void testFile (TestConfig .TestFile file , BucketManager bucketManager ) throws IOException {
850
846
String bucket = file .getBucketName ();
851
- CorsRule rule1 = new CorsRule (new String [] { "*" }, new String [] { "" });
852
- CorsRule rule2 = new CorsRule (new String [] { "*" }, new String [] { "GET" , "POST" });
853
- CorsRule rule3 = new CorsRule (new String [] { "" }, new String [] { "GET" , "POST" });
847
+ CorsRule rule1 = new CorsRule (new String []{ "*" }, new String []{ "" });
848
+ CorsRule rule2 = new CorsRule (new String []{ "*" }, new String []{ "GET" , "POST" });
849
+ CorsRule rule3 = new CorsRule (new String []{ "" }, new String []{ "GET" , "POST" });
854
850
List <CorsRule []> rulesList = new ArrayList <>();
855
851
rulesList .add (corsRules (rule1 ));
856
852
rulesList .add (corsRules (rule2 ));
@@ -989,7 +985,7 @@ public void testPutBucketMaxAge() throws Exception {
989
985
@ Override
990
986
public void testFile (TestConfig .TestFile file , BucketManager bucketManager ) throws IOException {
991
987
String bucket = file .getBucketName ();
992
- final long [] maxAges = { Integer .MIN_VALUE , -54321 , -1 , 0 , 1 , 8 , 1234567 , 11111111 , Integer .MAX_VALUE };
988
+ final long [] maxAges = {Integer .MIN_VALUE , -54321 , -1 , 0 , 1 , 8 , 1234567 , 11111111 , Integer .MAX_VALUE };
993
989
try {
994
990
for (long maxAge : maxAges ) {
995
991
// 设置max-age
@@ -1025,7 +1021,7 @@ public void testPutBucketMaxAge2() throws Exception {
1025
1021
public void testFile (TestConfig .TestFile file , BucketManager bucketManager ) throws IOException {
1026
1022
String bucket = file .getBucketName ();
1027
1023
String url = file .getTestUrl ();
1028
- final long [] maxAges = { Integer .MIN_VALUE , -54321 , -1 , 0 , 1 , 8 , 1234567 , 11111111 , Integer .MAX_VALUE };
1024
+ final long [] maxAges = {Integer .MIN_VALUE , -54321 , -1 , 0 , 1 , 8 , 1234567 , 11111111 , Integer .MAX_VALUE };
1029
1025
try {
1030
1026
for (long maxAge : maxAges ) {
1031
1027
// 设置max-age
@@ -1425,7 +1421,7 @@ public void testBatch() throws Exception {
1425
1421
public void testFile (TestConfig .TestFile file , BucketManager bucketManager ) throws IOException {
1426
1422
String bucket = file .getBucketName ();
1427
1423
String key = file .getKey ();
1428
- String [] array = { key };
1424
+ String [] array = {key };
1429
1425
String copyFromKey = "copyFrom" + Math .random ();
1430
1426
1431
1427
String moveFromKey = "moveFrom" + Math .random ();
0 commit comments