use of com.aliyun.oss.model.BucketList in project aliyun-oss-java-sdk by aliyun.
the class BucketInfoTest method testListBucketWithBid.
@Test
public void testListBucketWithBid() {
try {
ListBucketsRequest listBucketsRequest = new ListBucketsRequest();
listBucketsRequest.setPrefix(bucketName);
listBucketsRequest.setMaxKeys(1);
listBucketsRequest.setBid("26842");
BucketList buckets = ossClient.listBuckets(listBucketsRequest);
Assert.assertEquals(buckets.getBucketList().size(), 1);
Assert.assertEquals(buckets.getRequestId().length(), REQUEST_ID_LEN);
} catch (Exception e) {
e.printStackTrace();
Assert.fail(e.getMessage());
}
}
use of com.aliyun.oss.model.BucketList in project aliyun-oss-java-sdk by aliyun.
the class TestBase method listAllBuckets.
protected static List<String> listAllBuckets(OSSClient client, String bucketPrefix) {
List<String> bkts = new ArrayList<String>();
String nextMarker = null;
BucketList bucketList = null;
do {
ListBucketsRequest listBucketsRequest = new ListBucketsRequest(bucketPrefix, nextMarker, ListBucketsRequest.MAX_RETURNED_KEYS);
bucketList = client.listBuckets(listBucketsRequest);
nextMarker = bucketList.getNextMarker();
for (Bucket b : bucketList.getBucketList()) {
bkts.add(b.getName());
}
} while (bucketList.isTruncated());
return bkts;
}
use of com.aliyun.oss.model.BucketList in project aliyun-oss-java-sdk by aliyun.
the class BucketReplicationTest method beforeClass.
@BeforeClass
public static void beforeClass() {
if (replicationClient == null) {
replicationClient = new OSSClientBuilder().build(OSS_TEST_REPLICATION_ENDPOINT, OSS_TEST_REPLICATION_ACCESS_KEY_ID, OSS_TEST_REPLICATION_ACCESS_KEY_SECRET);
replicationClient.createBucket(targetBucketName);
BucketList buckets = replicationClient.listBuckets(targetBucketName, "", 100);
Assert.assertEquals(1, buckets.getBucketList().size());
}
}
use of com.aliyun.oss.model.BucketList in project aliyun-oss-java-sdk by aliyun.
the class CreateBucketTest method testPutWithStorageType.
@Ignore
public void testPutWithStorageType() {
final String bucketName = "bucket-with-storage-type";
CreateBucketRequest createBucketRequest = new CreateBucketRequest(bucketName);
createBucketRequest.setStorageClass(StorageClass.IA);
try {
ossClient.createBucket(createBucketRequest);
AccessControlList returnedAcl = ossClient.getBucketAcl(bucketName);
Set<Grant> grants = returnedAcl.getGrants();
Assert.assertEquals(0, grants.size());
BucketList buckets = ossClient.listBuckets(bucketName, "", 100);
Assert.assertEquals(1, buckets.getBucketList().size());
Assert.assertEquals(StorageClass.IA, buckets.getBucketList().get(0).getStorageClass());
} catch (Exception ex) {
Assert.fail(ex.getMessage());
} finally {
ossClient.deleteBucket(bucketName);
}
}
use of com.aliyun.oss.model.BucketList in project aliyun-oss-java-sdk by aliyun.
the class CreateBucketTest method testPutWithStorageTypeModify.
@Ignore
public void testPutWithStorageTypeModify() {
final String bucketName = "bucket-with-storage-type-modify";
CreateBucketRequest createBucketRequest = new CreateBucketRequest(bucketName);
try {
ossClient.createBucket(createBucketRequest);
BucketList buckets = ossClient.listBuckets(bucketName, "", 100);
Assert.assertEquals(1, buckets.getBucketList().size());
Assert.assertEquals(StorageClass.Standard, buckets.getBucketList().get(0).getStorageClass());
try {
createBucketRequest.setStorageClass(StorageClass.IA);
ossClient.createBucket(createBucketRequest);
Assert.fail("Create bucket should not be successful.");
} catch (OSSException oe) {
Assert.assertEquals(OSSErrorCode.BUCKET_ALREADY_EXISTS, oe.getErrorCode());
Assert.assertTrue(oe.getMessage().startsWith(MODIFY_STORAGE_TYPE_ERR));
}
} catch (Exception ex) {
Assert.fail(ex.getMessage());
} finally {
ossClient.deleteBucket(bucketName);
}
}
Aggregations