Search in sources :

Example 1 with SetBucketStorageCapacityRequest

use of com.aliyun.oss.model.SetBucketStorageCapacityRequest in project aliyun-oss-java-sdk by aliyun.

the class BucketUserQosTest method testSetBucketStorageCapacityNegative.

@Test
public void testSetBucketStorageCapacityNegative() {
    try {
        UserQos userQos = new UserQos(-2);
        ossClient.setBucketStorageCapacity(bucketName, userQos);
        Assert.fail("Set bucket storage capacity should not be successful");
    } catch (OSSException e) {
        Assert.assertEquals(OSSErrorCode.INVALID_ARGUMENT, e.getErrorCode());
    }
    try {
        UserQos userQos = new UserQos(-3);
        ossClient.setBucketStorageCapacity(new SetBucketStorageCapacityRequest(bucketName).withUserQos(userQos));
        Assert.fail("Set bucket storage capacity should not be successful");
    } catch (OSSException e) {
        Assert.assertEquals(OSSErrorCode.INVALID_ARGUMENT, e.getErrorCode());
    }
}
Also used : SetBucketStorageCapacityRequest(com.aliyun.oss.model.SetBucketStorageCapacityRequest) UserQos(com.aliyun.oss.model.UserQos) OSSException(com.aliyun.oss.OSSException) Test(org.junit.Test)

Example 2 with SetBucketStorageCapacityRequest

use of com.aliyun.oss.model.SetBucketStorageCapacityRequest in project aliyun-oss-java-sdk by aliyun.

the class BucketUserQosTest method testSetBucketStorageCapacity.

@Test
public void testSetBucketStorageCapacity() {
    try {
        UserQos userQos = new UserQos(-1);
        ossClient.setBucketStorageCapacity(bucketName, userQos);
        userQos = ossClient.getBucketStorageCapacity(bucketName);
        Assert.assertEquals(userQos.getStorageCapacity(), -1);
        Assert.assertEquals(userQos.getRequestId().length(), REQUEST_ID_LEN);
        userQos.setStorageCapacity(10000);
        ossClient.setBucketStorageCapacity(new SetBucketStorageCapacityRequest(bucketName).withUserQos(userQos));
        userQos = ossClient.getBucketStorageCapacity(bucketName);
        Assert.assertEquals(userQos.getStorageCapacity(), 10000);
        Assert.assertEquals(userQos.getRequestId().length(), REQUEST_ID_LEN);
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }
}
Also used : SetBucketStorageCapacityRequest(com.aliyun.oss.model.SetBucketStorageCapacityRequest) UserQos(com.aliyun.oss.model.UserQos) OSSException(com.aliyun.oss.OSSException) Test(org.junit.Test)

Aggregations

OSSException (com.aliyun.oss.OSSException)2 SetBucketStorageCapacityRequest (com.aliyun.oss.model.SetBucketStorageCapacityRequest)2 UserQos (com.aliyun.oss.model.UserQos)2 Test (org.junit.Test)2