assertEquals(404, e.getResponseCode());
}
// Set index document
s3Service.setWebsiteConfig(bucketName,
new S3WebsiteConfig("index.html"));
Thread.sleep(5000);
// Confirm index document set
S3WebsiteConfig config = s3Service.getWebsiteConfig(bucketName);
assertTrue(config.isWebsiteConfigActive());
assertEquals("index.html", config.getIndexDocumentSuffix());
assertNull(config.getErrorDocumentKey());
// Upload public index document
S3Object indexObject = new S3Object("index.html", "index.html contents");
indexObject.setAcl(AccessControlList.REST_CANNED_PUBLIC_READ);
s3Service.putObject(bucketName, indexObject);
// Confirm index document is served at explicit path
getMethod = new HttpGet(s3WebsiteURL + "/index.html");
HttpResponse response = httpClient.execute(getMethod);
assertEquals(200, response.getStatusLine().getStatusCode());
assertEquals("index.html contents", EntityUtils.toString(response.getEntity()));
// Confirm index document is served at root path
// (i.e. website config is effective)
getMethod = new HttpGet(s3WebsiteURL + "/");
response = httpClient.execute(getMethod);
assertEquals(200, response.getStatusLine().getStatusCode());
assertEquals("index.html contents", EntityUtils.toString(response.getEntity()));
// Set index document and error document
s3Service.setWebsiteConfig(bucketName,
new S3WebsiteConfig("index.html", "error.html"));
Thread.sleep(10000); // Config updates can take a long time... ugh!
// Confirm index document and error document set
config = s3Service.getWebsiteConfig(bucketName);
assertTrue(config.isWebsiteConfigActive());
assertEquals("index.html", config.getIndexDocumentSuffix());
assertEquals("error.html", config.getErrorDocumentKey());
// Upload public error document
S3Object errorObject = new S3Object("error.html", "error.html contents");
errorObject.setAcl(AccessControlList.REST_CANNED_PUBLIC_READ);
s3Service.putObject(bucketName, errorObject);