use of com.aliyun.oss.model.SetBucketTaggingRequest in project aliyun-oss-java-sdk by aliyun.
the class BucketTaggingTest method testSetBucketTagging.
@Test
public void testSetBucketTagging() {
try {
SetBucketTaggingRequest request = new SetBucketTaggingRequest(bucketName);
request.setTag("tk1", "tv1");
request.setTag("tk2", "tv2");
ossClient.setBucketTagging(request);
TagSet tagSet = ossClient.getBucketTagging(new GenericRequest(bucketName));
Assert.assertEquals(tagSet.getRequestId().length(), REQUEST_ID_LEN);
Map<String, String> tags = tagSet.getAllTags();
Assert.assertEquals(2, tags.size());
Assert.assertTrue(tags.containsKey("tk1"));
Assert.assertTrue(tags.containsKey("tk2"));
ossClient.deleteBucketTagging(new GenericRequest(bucketName));
waitForCacheExpiration(5);
tagSet = ossClient.getBucketTagging(new GenericRequest(bucketName));
Assert.assertEquals(tagSet.getRequestId().length(), REQUEST_ID_LEN);
tags = tagSet.getAllTags();
Assert.assertTrue(tags.isEmpty());
} catch (Exception e) {
Assert.fail(e.getMessage());
}
}
Aggregations