Search in sources :

Example 6 with GenericRequest

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

the class OSSClientRequestTest method testBucketAclRequests.

@SuppressWarnings("serial")
@Test
public void testBucketAclRequests() {
    // Put Bucket ACL
    // expected acl: private
    TestAction test1 = new TestAction() {

        public void run() throws Exception {
            bucketOp.setBucketAcl(new SetBucketAclRequest(bucketName, null));
        }
    };
    executeTest(test1, HttpMethod.PUT, bucketName + "." + endpoint.getHost(), "?acl", new HashMap<String, String>() {

        {
        }
    });
    // expected acl: public-read
    TestAction test2 = new TestAction() {

        public void run() throws Exception {
            bucketOp.setBucketAcl(new SetBucketAclRequest(bucketName, CannedAccessControlList.PublicRead));
        }
    };
    executeTest(test2, HttpMethod.PUT, bucketName + "." + endpoint.getHost(), "?acl", new HashMap<String, String>() {

        {
            put("x-oss-acl", "public-read");
        }
    });
    // expected acl: public-read-write
    TestAction test3 = new TestAction() {

        public void run() throws Exception {
            bucketOp.setBucketAcl(new SetBucketAclRequest(bucketName, CannedAccessControlList.PublicReadWrite));
        }
    };
    executeTest(test3, HttpMethod.PUT, bucketName + "." + endpoint.getHost(), "?acl", new HashMap<String, String>() {

        {
            put("x-oss-acl", "public-read-write");
        }
    });
    // expected acl: private
    TestAction test4 = new TestAction() {

        public void run() throws Exception {
            bucketOp.setBucketAcl(new SetBucketAclRequest(bucketName, CannedAccessControlList.Private));
        }
    };
    executeTest(test4, HttpMethod.PUT, bucketName + "." + endpoint.getHost(), "?acl", new HashMap<String, String>() {

        {
            put("x-oss-acl", "private");
        }
    });
    // Get Bucket ACL
    // expected acl: private
    TestAction test5 = new TestAction() {

        public void run() throws Exception {
            bucketOp.getBucketAcl(new GenericRequest(bucketName));
        }
    };
    executeTest(test5, HttpMethod.GET, bucketName + "." + endpoint.getHost(), "?acl", null);
}
Also used : SetBucketAclRequest(com.aliyun.oss.model.SetBucketAclRequest) GenericRequest(com.aliyun.oss.model.GenericRequest) Test(org.junit.Test)

Aggregations

GenericRequest (com.aliyun.oss.model.GenericRequest)6 Test (org.junit.Test)4 OSSException (com.aliyun.oss.OSSException)2 BucketProcess (com.aliyun.oss.model.BucketProcess)1 ImageProcess (com.aliyun.oss.model.ImageProcess)1 PutBucketImageRequest (com.aliyun.oss.model.PutBucketImageRequest)1 PutImageStyleRequest (com.aliyun.oss.model.PutImageStyleRequest)1 SetBucketAclRequest (com.aliyun.oss.model.SetBucketAclRequest)1 SetBucketProcessRequest (com.aliyun.oss.model.SetBucketProcessRequest)1 SetBucketTaggingRequest (com.aliyun.oss.model.SetBucketTaggingRequest)1 TagSet (com.aliyun.oss.model.TagSet)1