Skip to content

Commit 8e9a88b

Browse files
committed
update test case.
1 parent 53a119c commit 8e9a88b

File tree

4 files changed

+32
-28
lines changed

4 files changed

+32
-28
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void setUp() throws Exception {
4545
super.setUp();
4646

4747
bucketName = super.bucketName + "-object-encryption";
48-
endpoint = "http://oss-cn-hongkong.aliyuncs.com";
48+
endpoint = TestConfig.OSS_TEST_ENDPOINT;
4949

5050
//create client
5151
ClientConfiguration conf = new ClientConfiguration().setSupportCname(false);

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

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
package com.aliyun.oss.integrationtests;
2121

22-
import static com.aliyun.oss.integrationtests.TestConstants.BUCKET_ACCESS_DENIED_ERR;
22+
import static com.aliyun.oss.integrationtests.TestConstants.ACCESS_DENIED_MSG_REQUESTER_PAY_BUCKET;
2323
import static com.aliyun.oss.integrationtests.TestUtils.genFixedLengthInputStream;
2424
import java.io.File;
2525
import java.io.FileInputStream;
@@ -109,7 +109,7 @@ public void testPutObject() {
109109
Assert.fail("no RequestPayer, should not be successful");
110110
} catch (OSSException e) {
111111
Assert.assertEquals(OSSErrorCode.ACCESS_DENIED, e.getErrorCode());
112-
Assert.assertTrue(e.getMessage().startsWith(BUCKET_ACCESS_DENIED_ERR));
112+
Assert.assertTrue(e.getMessage().startsWith(ACCESS_DENIED_MSG_REQUESTER_PAY_BUCKET));
113113
}
114114

115115
// Put object with payer setting, should be successful.
@@ -142,7 +142,7 @@ public void testGetObject() throws Throwable {
142142
Assert.fail("no RequestPayer, should not be successful");
143143
} catch (OSSException e) {
144144
Assert.assertEquals(OSSErrorCode.ACCESS_DENIED, e.getErrorCode());
145-
Assert.assertTrue(e.getMessage().startsWith(BUCKET_ACCESS_DENIED_ERR));
145+
Assert.assertTrue(e.getMessage().startsWith(ACCESS_DENIED_MSG_REQUESTER_PAY_BUCKET));
146146
}
147147

148148
// Get object with payer setting, should be successful.
@@ -172,7 +172,7 @@ public void testDeleteObject() {
172172
Assert.fail("no RequestPayer, should not be successful");
173173
} catch (OSSException e) {
174174
Assert.assertEquals(OSSErrorCode.ACCESS_DENIED, e.getErrorCode());
175-
Assert.assertTrue(e.getMessage().startsWith(BUCKET_ACCESS_DENIED_ERR));
175+
Assert.assertTrue(e.getMessage().startsWith(ACCESS_DENIED_MSG_REQUESTER_PAY_BUCKET));
176176
}
177177

178178
// Delete object with payer setting, should be successful.
@@ -205,7 +205,7 @@ public void testDeleteObjects() {
205205
Assert.fail("no RequestPayer, should not be successful");
206206
} catch (OSSException e) {
207207
Assert.assertEquals(OSSErrorCode.ACCESS_DENIED, e.getErrorCode());
208-
Assert.assertTrue(e.getMessage().startsWith(BUCKET_ACCESS_DENIED_ERR));
208+
Assert.assertTrue(e.getMessage().startsWith(ACCESS_DENIED_MSG_REQUESTER_PAY_BUCKET));
209209
}
210210

211211
// Delete objects with payer setting, should be successful.
@@ -235,7 +235,7 @@ public void testListObjects() {
235235
Assert.fail("no RequestPayer, should not be successful");
236236
} catch (OSSException e) {
237237
Assert.assertEquals(OSSErrorCode.ACCESS_DENIED, e.getErrorCode());
238-
Assert.assertTrue(e.getMessage().startsWith(BUCKET_ACCESS_DENIED_ERR));
238+
Assert.assertTrue(e.getMessage().startsWith(ACCESS_DENIED_MSG_REQUESTER_PAY_BUCKET));
239239
}
240240

241241
// List objects with payer setting, should be successful.
@@ -266,7 +266,7 @@ public void testSetObjectAcl() {
266266
Assert.fail("no RequestPayer, should not be successful");
267267
} catch (OSSException e) {
268268
Assert.assertEquals(OSSErrorCode.ACCESS_DENIED, e.getErrorCode());
269-
Assert.assertTrue(e.getMessage().startsWith(BUCKET_ACCESS_DENIED_ERR));
269+
Assert.assertTrue(e.getMessage().startsWith(ACCESS_DENIED_MSG_REQUESTER_PAY_BUCKET));
270270
}
271271

272272
// Set object acl with payer setting, should be successful.
@@ -300,7 +300,7 @@ public void testGetObjectAcl() {
300300
Assert.fail("no RequestPayer, should not be successful");
301301
} catch (OSSException e) {
302302
Assert.assertEquals(OSSErrorCode.ACCESS_DENIED, e.getErrorCode());
303-
Assert.assertTrue(e.getMessage().startsWith(BUCKET_ACCESS_DENIED_ERR));
303+
Assert.assertTrue(e.getMessage().startsWith(ACCESS_DENIED_MSG_REQUESTER_PAY_BUCKET));
304304
}
305305

306306
// Get object acl with payer setting, should be successful.
@@ -336,7 +336,7 @@ public void testAppendObject() {
336336
Assert.fail("no RequestPayer, should not be successful");
337337
} catch (OSSException e) {
338338
Assert.assertEquals(OSSErrorCode.ACCESS_DENIED, e.getErrorCode());
339-
Assert.assertTrue(e.getMessage().startsWith(BUCKET_ACCESS_DENIED_ERR));
339+
Assert.assertTrue(e.getMessage().startsWith(ACCESS_DENIED_MSG_REQUESTER_PAY_BUCKET));
340340
}
341341

342342
// Append object with payer setting, should be successful.
@@ -368,7 +368,7 @@ public void testCopyObject() {
368368
Assert.fail("no RequestPayer, should not be successful");
369369
} catch (OSSException e) {
370370
Assert.assertEquals(OSSErrorCode.ACCESS_DENIED, e.getErrorCode());
371-
Assert.assertTrue(e.getMessage().startsWith(BUCKET_ACCESS_DENIED_ERR));
371+
Assert.assertTrue(e.getMessage().startsWith(ACCESS_DENIED_MSG_REQUESTER_PAY_BUCKET));
372372
}
373373

374374
// Copy object with payer setting payer setting, should be successful.
@@ -404,7 +404,7 @@ public void testCreateSymlink() {
404404
Assert.fail("no RequestPayer, should not be successful");
405405
} catch (OSSException e) {
406406
Assert.assertEquals(OSSErrorCode.ACCESS_DENIED, e.getErrorCode());
407-
Assert.assertTrue(e.getMessage().startsWith(BUCKET_ACCESS_DENIED_ERR));
407+
Assert.assertTrue(e.getMessage().startsWith(ACCESS_DENIED_MSG_REQUESTER_PAY_BUCKET));
408408
}
409409

410410
// Create symlink with payer setting payer setting, should be successful.
@@ -439,7 +439,7 @@ public void testGetSymlink() {
439439
Assert.fail("no RequestPayer, should not be successful");
440440
} catch (OSSException e) {
441441
Assert.assertEquals(OSSErrorCode.ACCESS_DENIED, e.getErrorCode());
442-
Assert.assertTrue(e.getMessage().startsWith(BUCKET_ACCESS_DENIED_ERR));
442+
Assert.assertTrue(e.getMessage().startsWith(ACCESS_DENIED_MSG_REQUESTER_PAY_BUCKET));
443443
}
444444

445445
// Get symlink with payer setting payer setting, should be successful.
@@ -611,7 +611,7 @@ public void testUploadFile() throws Throwable {
611611
Assert.fail("no RequestPayer, should not be successful");
612612
} catch (OSSException e) {
613613
Assert.assertEquals(OSSErrorCode.ACCESS_DENIED, e.getErrorCode());
614-
Assert.assertTrue(e.getMessage().startsWith(BUCKET_ACCESS_DENIED_ERR));
614+
Assert.assertTrue(e.getMessage().startsWith(ACCESS_DENIED_MSG_REQUESTER_PAY_BUCKET));
615615
}
616616

617617
// Upload file with payer setting, should be successful.
@@ -679,7 +679,7 @@ public void testUploadPart() throws Throwable {
679679
Assert.fail("no RequestPayer, should not be successful");
680680
} catch (OSSException e) {
681681
Assert.assertEquals(OSSErrorCode.ACCESS_DENIED, e.getErrorCode());
682-
Assert.assertTrue(e.getMessage().startsWith(BUCKET_ACCESS_DENIED_ERR));
682+
Assert.assertTrue(e.getMessage().startsWith(ACCESS_DENIED_MSG_REQUESTER_PAY_BUCKET));
683683
}
684684

685685
// Upload part with payer setting, should be successful.
@@ -751,7 +751,7 @@ public void testUploadPartCopy() {
751751
Assert.fail("no RequestPayer, should not be successful");
752752
} catch (OSSException e) {
753753
Assert.assertEquals(OSSErrorCode.ACCESS_DENIED, e.getErrorCode());
754-
Assert.assertTrue(e.getMessage().startsWith(BUCKET_ACCESS_DENIED_ERR));
754+
Assert.assertTrue(e.getMessage().startsWith(ACCESS_DENIED_MSG_REQUESTER_PAY_BUCKET));
755755
}
756756

757757
// Upload part with payer setting, should be successful.
@@ -825,7 +825,7 @@ public void testListParts() {
825825
Assert.fail("no RequestPayer, should not be successful");
826826
} catch (OSSException e) {
827827
Assert.assertEquals(OSSErrorCode.ACCESS_DENIED, e.getErrorCode());
828-
Assert.assertTrue(e.getMessage().startsWith(BUCKET_ACCESS_DENIED_ERR));
828+
Assert.assertTrue(e.getMessage().startsWith(ACCESS_DENIED_MSG_REQUESTER_PAY_BUCKET));
829829
}
830830

831831
// List parts with payer setting, should be successful.
@@ -855,7 +855,7 @@ public void testAbortMultipartUpload() {
855855
Assert.fail("no RequestPayer, should not be successful");
856856
} catch (OSSException e) {
857857
Assert.assertEquals(OSSErrorCode.ACCESS_DENIED, e.getErrorCode());
858-
Assert.assertTrue(e.getMessage().startsWith(BUCKET_ACCESS_DENIED_ERR));
858+
Assert.assertTrue(e.getMessage().startsWith(ACCESS_DENIED_MSG_REQUESTER_PAY_BUCKET));
859859
}
860860

861861
// Abort multi part with payer setting, should be successful.
@@ -881,7 +881,7 @@ public void testListMultiUploads() {
881881
Assert.fail("no RequestPayer, should not be successful");
882882
} catch (OSSException e) {
883883
Assert.assertEquals(OSSErrorCode.ACCESS_DENIED, e.getErrorCode());
884-
Assert.assertTrue(e.getMessage().startsWith(BUCKET_ACCESS_DENIED_ERR));
884+
Assert.assertTrue(e.getMessage().startsWith(ACCESS_DENIED_MSG_REQUESTER_PAY_BUCKET));
885885
}
886886

887887
// List multi uploads with payer setting, should be successful.
@@ -920,7 +920,7 @@ public void testRestoreObject() {
920920
Assert.fail("no RequestPayer, should not be successful");
921921
} catch (OSSException e) {
922922
Assert.assertEquals(OSSErrorCode.ACCESS_DENIED, e.getErrorCode());
923-
Assert.assertTrue(e.getMessage().startsWith(BUCKET_ACCESS_DENIED_ERR));
923+
Assert.assertTrue(e.getMessage().startsWith(ACCESS_DENIED_MSG_REQUESTER_PAY_BUCKET));
924924
}
925925

926926
// Restore object with payer setting, should be successful.
@@ -966,7 +966,7 @@ public void testProcessObject() {
966966
Assert.fail("no RequestPayer, should not be successful");
967967
} catch (OSSException e) {
968968
Assert.assertEquals(OSSErrorCode.ACCESS_DENIED, e.getErrorCode());
969-
Assert.assertTrue(e.getMessage().startsWith(BUCKET_ACCESS_DENIED_ERR));
969+
Assert.assertTrue(e.getMessage().startsWith(ACCESS_DENIED_MSG_REQUESTER_PAY_BUCKET));
970970
}
971971

972972
// Process object with payer setting, should be successful.
@@ -999,7 +999,7 @@ public void testSetObjectTagging() throws Throwable {
999999
Assert.fail("no RequestPayer, should not be successful");
10001000
} catch (OSSException e) {
10011001
Assert.assertEquals(OSSErrorCode.ACCESS_DENIED, e.getErrorCode());
1002-
Assert.assertTrue(e.getMessage().startsWith(BUCKET_ACCESS_DENIED_ERR));
1002+
Assert.assertTrue(e.getMessage().startsWith(ACCESS_DENIED_MSG_REQUESTER_PAY_BUCKET));
10031003
}
10041004

10051005
// Set object tagging with payer setting, should be successful.
@@ -1040,7 +1040,7 @@ public void testGetObjectTagging() {
10401040
Assert.fail("no RequestPayer, should not be successful");
10411041
} catch (OSSException e) {
10421042
Assert.assertEquals(OSSErrorCode.ACCESS_DENIED, e.getErrorCode());
1043-
Assert.assertTrue(e.getMessage().startsWith(BUCKET_ACCESS_DENIED_ERR));
1043+
Assert.assertTrue(e.getMessage().startsWith(ACCESS_DENIED_MSG_REQUESTER_PAY_BUCKET));
10441044
}
10451045

10461046
// Set object tagging with payer setting, should be successful.
@@ -1079,7 +1079,7 @@ public void testDeleteObjectTagging() {
10791079
Assert.fail("no RequestPayer, should not be successful");
10801080
} catch (OSSException e) {
10811081
Assert.assertEquals(OSSErrorCode.ACCESS_DENIED, e.getErrorCode());
1082-
Assert.assertTrue(e.getMessage().startsWith(BUCKET_ACCESS_DENIED_ERR));
1082+
Assert.assertTrue(e.getMessage().startsWith(ACCESS_DENIED_MSG_REQUESTER_PAY_BUCKET));
10831083
}
10841084

10851085
// Delete object tagging with payer setting, should be successful.

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
package com.aliyun.oss.integrationtests;
2121

22+
import static com.aliyun.oss.integrationtests.TestConstants.ACCESS_DENIED_MSG_REQUESTER_PAY_BUCKET;
2223
import static com.aliyun.oss.integrationtests.TestConstants.BUCKET_ACCESS_DENIED_ERR;
2324
import static com.aliyun.oss.integrationtests.TestUtils.genFixedLengthInputStream;
2425
import static com.aliyun.oss.integrationtests.TestUtils.waitForCacheExpiration;
@@ -121,7 +122,7 @@ public void testDeleteVersion() {
121122
Assert.fail("no RequestPayer, should not be successful");
122123
} catch (OSSException e) {
123124
Assert.assertEquals(OSSErrorCode.ACCESS_DENIED, e.getErrorCode());
124-
Assert.assertTrue(e.getMessage().startsWith(BUCKET_ACCESS_DENIED_ERR));
125+
Assert.assertTrue(e.getMessage().startsWith(ACCESS_DENIED_MSG_REQUESTER_PAY_BUCKET));
125126
}
126127

127128
// Delete version with payer setting, should be successful.
@@ -179,7 +180,7 @@ public void testDeleteVersions() {
179180
Assert.fail("no RequestPayer, should not be successful");
180181
} catch (OSSException e) {
181182
Assert.assertEquals(OSSErrorCode.ACCESS_DENIED, e.getErrorCode());
182-
Assert.assertTrue(e.getMessage().startsWith(BUCKET_ACCESS_DENIED_ERR));
183+
Assert.assertTrue(e.getMessage().startsWith(ACCESS_DENIED_MSG_REQUESTER_PAY_BUCKET));
183184
}
184185

185186
// Delete versons with payer setting, should be successful.
@@ -229,7 +230,7 @@ public void testListVersions() {
229230
Assert.fail("no RequestPayer, should not be successful");
230231
} catch (OSSException e) {
231232
Assert.assertEquals(OSSErrorCode.ACCESS_DENIED, e.getErrorCode());
232-
Assert.assertTrue(e.getMessage().startsWith(BUCKET_ACCESS_DENIED_ERR));
233+
Assert.assertTrue(e.getMessage().startsWith(ACCESS_DENIED_MSG_REQUESTER_PAY_BUCKET));
233234
}
234235

235236
// List versons with payer setting, should be successful.

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public final class TestConstants {
4141

4242
public static final String NO_SUCH_UPLOAD_ERR = "The specified upload does not exist. The upload ID may be invalid, or the upload may have been aborted or completed.";
4343

44-
public static final String BUCKET_NOT_EMPTY_ERR = "The bucket you tried to delete is not empty.";
44+
public static final String BUCKET_NOT_EMPTY_ERR = "The bucket has objects. Please delete them first.";
4545

4646
public static final String BUCKET_ALREADY_EXIST_ERR = "The requested bucket name is not available. The bucket namespace is shared by all users of the system. Please select a different name and try again.";
4747

@@ -78,4 +78,7 @@ public final class TestConstants {
7878
public static final String MISSING_ARGUMENT_ERR = "Missing Some Required Arguments.";
7979

8080
public static final String MODIFY_STORAGE_TYPE_ERR = "Cannot modify existing bucket's storage class.";
81+
82+
public static final String ACCESS_DENIED_MSG_REQUESTER_PAY_BUCKET = "Access denied for requester pay bucket";
83+
8184
}

0 commit comments

Comments
 (0)