use of com.aliyun.oss.model.BucketWebsiteResult in project aliyun-oss-java-sdk by aliyun.
the class BucketWebsiteTest method testNormalSetBucketWebsite.
@Test
public void testNormalSetBucketWebsite() {
final String bucketName = "normal-set-bucket-website";
final String indexDocument = "index.html";
final String errorDocument = "error.html";
try {
ossClient.createBucket(bucketName);
// Set both index document and error document
SetBucketWebsiteRequest request = new SetBucketWebsiteRequest(bucketName);
request.setIndexDocument(indexDocument);
request.setErrorDocument(errorDocument);
ossClient.setBucketWebsite(request);
waitForCacheExpiration(5);
BucketWebsiteResult result = ossClient.getBucketWebsite(bucketName);
Assert.assertEquals(indexDocument, result.getIndexDocument());
Assert.assertEquals(errorDocument, result.getErrorDocument());
Assert.assertEquals(result.getRequestId().length(), REQUEST_ID_LEN);
ossClient.deleteBucketWebsite(bucketName);
// Set index document only
request = new SetBucketWebsiteRequest(bucketName);
request.setIndexDocument(indexDocument);
request.setErrorDocument(null);
ossClient.setBucketWebsite(request);
waitForCacheExpiration(5);
result = ossClient.getBucketWebsite(bucketName);
Assert.assertEquals(indexDocument, result.getIndexDocument());
Assert.assertTrue(result.getErrorDocument() == null);
Assert.assertEquals(result.getRequestId().length(), REQUEST_ID_LEN);
ossClient.deleteBucketWebsite(bucketName);
} catch (Exception e) {
Assert.fail(e.getMessage());
} finally {
ossClient.deleteBucket(bucketName);
}
}
Aggregations