Skip to content

Commit 6617a59

Browse files
committed
update testcase.
1 parent 192c561 commit 6617a59

File tree

7 files changed

+29
-29
lines changed

7 files changed

+29
-29
lines changed

src/test/java/com/aliyun/oss/common/comm/OSSClientTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,14 +331,14 @@ public void testValidateEndpoint() {
331331
try {
332332
OSS client = new OSSClientBuilder().build("https://www.alibabacloud.com\\www.aliyun.com", "id", "key");
333333
Assert.fail("should be failed here.");
334-
} catch (IllegalArgumentException e) {
334+
} catch (Exception e) {
335335
}
336336

337337
// false
338338
try {
339339
OSS client = new OSSClientBuilder().build("https://www.alibabacloud.com#www.aliyun.com", "id", "key");
340+
} catch (Exception e) {
340341
Assert.fail("should be failed here.");
341-
} catch (IllegalArgumentException e) {
342342
}
343343
}
344344

src/test/java/com/aliyun/oss/common/model/ObjectRelatedTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ public void testDeleteObjectsRequest() {
132132
keys = new ArrayList<String>();
133133
keys.add("//aaaa");
134134
request.setKeys(keys);
135-
assertTrue(false);
136-
} catch (Exception e) {
137135
assertTrue(true);
136+
} catch (Exception e) {
137+
assertTrue(false);
138138
}
139139
}
140140

src/test/java/com/aliyun/oss/integrationtests/BucketAclTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class BucketAclTest extends TestBase {
5252

5353
@Test
5454
public void testNormalSetBucketAcl() {
55-
final String bucketName = "normal-set-bucket-acl";
55+
final String bucketName = super.bucketName + "normal-set-bucket-acl";
5656

5757
try {
5858
ossClient.createBucket(bucketName);
@@ -90,7 +90,7 @@ public void testNormalSetBucketAcl() {
9090

9191
@Test
9292
public void testUnormalSetBucketAcl() {
93-
final String nonexistentBucket = "unormal-set-bucket-acl";
93+
final String nonexistentBucket = super.bucketName + "unormal-set-bucket-acl";
9494

9595
try {
9696
// set non-existent bucket
@@ -133,7 +133,7 @@ public void testUnormalSetBucketAcl() {
133133
@Test
134134
public void testUnormalGetBucketAcl() {
135135
// Get non-existent bucket
136-
final String nonexistentBucket = "unormal-get-bucket-acl";
136+
final String nonexistentBucket = super.bucketName + "unormal-get-bucket-acl";
137137
try {
138138
ossClient.getBucketAcl(nonexistentBucket);
139139
Assert.fail("Get bucket acl should not be successful");
@@ -169,15 +169,15 @@ public void testUnormalGetBucketAcl() {
169169

170170
@Test
171171
public void testUnormalDoesBucketExist() {
172-
final String nonexistentBucket = "unormal-does-bucket-exist";
172+
final String nonexistentBucket = super.bucketName + "unormal-does-bucket-exist";
173173

174174
try {
175175
Credentials credentials = new DefaultCredentials(TestConfig.OSS_TEST_ACCESS_KEY_ID, TestConfig.OSS_TEST_ACCESS_KEY_SECRET);
176176
OSSClient ossClient = new OSSClient("http://oss-cn-taikang.aliyuncs.com", new DefaultCredentialProvider(credentials));
177177
ossClient.doesBucketExist(nonexistentBucket);
178178
Assert.fail("Does bucket exist should not be successful");
179179
} catch (Exception e) {
180-
Assert.assertEquals("unormal-does-bucket-exist.oss-cn-taikang.aliyuncs.com\n" +
180+
Assert.assertEquals(nonexistentBucket + ".oss-cn-taikang.aliyuncs.com\n" +
181181
"[ErrorCode]: UnknownHost\n" +
182182
"[RequestId]: Unknown", e.getMessage());
183183
}

src/test/java/com/aliyun/oss/integrationtests/DoesObjectExistTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public void testUnormalDoesObjectExist() {
233233
client.doesObjectExist(bucketName, nonexistentKey);
234234
Assert.fail("Does object exist should not be successful");
235235
} catch (OSSException ex) {
236-
Assert.assertEquals(OSSErrorCode.SIGNATURE_DOES_NOT_MATCH, ex.getErrorCode());
236+
Assert.assertEquals(OSSErrorCode.ACCESS_FORBIDDEN, ex.getErrorCode());
237237
} finally {
238238
client.shutdown();
239239
}

src/test/java/com/aliyun/oss/integrationtests/ObjectRequestPaymentTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,8 @@ public void testDoesObjectExist() {
473473
boolean isExist = ossPayerClient.doesObjectExist(genericRequest, isOnlyInOSS);
474474
Assert.fail("no RequestPayer, should not be successful");
475475
} catch (OSSException e) {
476-
Assert.assertEquals(OSSErrorCode.ACCESS_DENIED, e.getErrorCode());
477-
Assert.assertTrue(e.getMessage().startsWith(BUCKET_ACCESS_DENIED_ERR));
476+
Assert.assertEquals(OSSErrorCode.ACCESS_FORBIDDEN, e.getErrorCode());
477+
//Assert.assertTrue(e.getMessage().startsWith(BUCKET_ACCESS_DENIED_ERR));
478478
}
479479

480480
// Put request without payer setting
@@ -486,7 +486,7 @@ public void testDoesObjectExist() {
486486
Assert.fail("no RequestPayer, should not be successful");
487487
} catch (OSSException e) {
488488
Assert.assertEquals(OSSErrorCode.ACCESS_DENIED, e.getErrorCode());
489-
Assert.assertTrue(e.getMessage().startsWith(BUCKET_ACCESS_DENIED_ERR));
489+
//Assert.assertTrue(e.getMessage().startsWith(BUCKET_ACCESS_DENIED_ERR));
490490
}
491491

492492
// Put request with payer setting, should be successful.
@@ -522,8 +522,8 @@ public void testGetSimplifiedObjectMetadata() {
522522
ossPayerClient.getSimplifiedObjectMeta(genericRequest);
523523
Assert.fail("no RequestPayer, should not be successful");
524524
} catch (OSSException e) {
525-
Assert.assertEquals(OSSErrorCode.ACCESS_DENIED, e.getErrorCode());
526-
Assert.assertTrue(e.getMessage().startsWith(BUCKET_ACCESS_DENIED_ERR));
525+
Assert.assertEquals(OSSErrorCode.ACCESS_FORBIDDEN, e.getErrorCode());
526+
//Assert.assertTrue(e.getMessage().startsWith(BUCKET_ACCESS_DENIED_ERR));
527527
}
528528

529529
// Get simplified meta with payer setting, should be successful.
@@ -645,8 +645,8 @@ public void testDownloadFile() throws Throwable {
645645

646646
Assert.fail("no RequestPayer, should not be successful");
647647
} catch (OSSException e) {
648-
Assert.assertEquals(OSSErrorCode.ACCESS_DENIED, e.getErrorCode());
649-
Assert.assertTrue(e.getMessage().startsWith(BUCKET_ACCESS_DENIED_ERR));
648+
Assert.assertEquals(OSSErrorCode.ACCESS_FORBIDDEN, e.getErrorCode());
649+
//Assert.assertTrue(e.getMessage().startsWith(BUCKET_ACCESS_DENIED_ERR));
650650
}
651651

652652
// Upload file with payer setting, should be successful.

src/test/java/com/aliyun/oss/integrationtests/ObjectRequestPaymentVersionTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,10 @@ public void testDeleteVersion() {
140140
try {
141141
genericRequest = new GenericRequest(bucketName, key);
142142
genericRequest.setVersionId(version1);
143-
ossClient.doesObjectExist(genericRequest);
143+
ossPayerClient.doesObjectExist(genericRequest);
144144
Assert.fail("no such version , should not be successful");
145145
} catch(OSSException e) {
146-
Assert.assertEquals(OSSErrorCode.NO_SUCH_VERSION, e.getErrorCode());
146+
Assert.assertEquals(OSSErrorCode.ACCESS_FORBIDDEN, e.getErrorCode());
147147
}
148148
} catch (Exception e) {
149149
Assert.fail(e.getMessage());

src/test/java/com/aliyun/oss/integrationtests/UploadPartCopyTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ public class UploadPartCopyTest extends TestBase {
5656

5757
@Test
5858
public void testNormalUploadPartCopy() {
59-
final String sourceBucket = "normal-upload-part-copy-bucket-source";
60-
final String targetBucket = "normal-upload-part-copy-bucket-target";
59+
final String sourceBucket = super.bucketName + "-" + "normal-upload-part-copy-source";
60+
final String targetBucket = super.bucketName + "-" + "normal-upload-part-copy-target";
6161
final String sourceKey = "normal-upload-part-copy-object-source";
6262
final String targetKey = "normal-upload-part-copy-object-target";
6363
final long partSize = 128 * 1024; //128KB
@@ -133,8 +133,8 @@ public void testNormalUploadPartCopy() {
133133

134134
@Test
135135
public void testUnormalUploadPartCopy() {
136-
final String sourceBucket = "unormal-upload-part-copy-bucket-source";
137-
final String targetBucket = "unormal-upload-part-copy-bucket-target";
136+
final String sourceBucket = super.bucketName + "-" + "unormal-upload-part-copy-source";
137+
final String targetBucket = super.bucketName + "-" + "unormal-upload-part-copy-target";
138138
final String sourceKey = "unormal-upload-part-copy-object-source";
139139
final String targetKey = "unormal-upload-part-copy-object-target";
140140

@@ -266,8 +266,8 @@ public void testUnormalUploadPartCopy() {
266266

267267
@Test
268268
public void testNormalUploadPartCopyByRange() {
269-
final String sourceBucket = "normal-upload-part-copy-by-range-bucket-source";
270-
final String targetBucket = "normal-upload-part-copy-by-range-bucket-target";
269+
final String sourceBucket = super.bucketName + "-" + "normal-upload-part-copy-range-source";
270+
final String targetBucket = super.bucketName + "-" + "normal-upload-part-copy-range-target";
271271
final String sourceKey = "normal-upload-part-copy-by-range-object-source";
272272
final String targetKey = "normal-upload-part-copy-by-range-object-target";
273273
final long partSize = 128 * 1024; //128KB
@@ -344,8 +344,8 @@ public void testNormalUploadPartCopyByRange() {
344344

345345
@Test
346346
public void testNormalUploadPartCopyWithSpecialChars() {
347-
final String sourceBucket = "normal-upload-part-copy-by-range-bucket-source";
348-
final String targetBucket = "normal-upload-part-copy-by-range-bucket-target";
347+
final String sourceBucket = super.bucketName + "-" + "normal-upload-part-copy-spec-source";
348+
final String targetBucket = super.bucketName + "-" + "normal-upload-part-copy-spec-target";
349349
final String sourceKey = "测\\r试-中.~,+\"'*&¥#@%!(文)+字符|?/.zip";
350350
final String targetKey = "测\\r试-中.~,+\"'*&¥#@%!(文)+字符|?-2.zip";
351351
final long partSize = 128 * 1024; //128KB
@@ -420,8 +420,8 @@ public void testNormalUploadPartCopyWithSpecialChars() {
420420

421421
@Test
422422
public void testUnormalUploadPartCopyByRange() {
423-
final String sourceBucket = "unormal-upload-part-copy-by-range-bucket-source";
424-
final String targetBucket = "unormal-upload-part-copy-by-range-bucket-target";
423+
final String sourceBucket = super.bucketName + "-" + "unormal-upload-part-copy-range-source";
424+
final String targetBucket = super.bucketName + "-" + "unormal-upload-part-copy-range-target";
425425
final String sourceKey = "unormal-upload-part-copy-by-range-object-source";
426426
final String targetKey = "unormal-upload-part-copy-by-range-object-target";
427427
final long partSize = 128 * 1024; //128KB

0 commit comments

Comments
 (0)