assertNull(service.getWebsiteConfig(bucketName).getErrorDocumentKey());
assertNull(service.getWebsiteConfig(bucketName).getIndexDocumentSuffix());
// Set index document
service.setWebsiteConfig(bucketName,
new GSWebsiteConfig("index.html"));
// Confirm index document set
GSWebsiteConfig config = service.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);
service.putObject(bucketName, indexObject);
// Confirm index document is served at explicit path
getMethod = new HttpGet(websiteURL + "/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(websiteURL + "/");
response = httpClient.execute(getMethod);
assertEquals(200, response.getStatusLine().getStatusCode());
assertEquals("index.html contents", EntityUtils.toString(response.getEntity()));
// Set index document and error document
service.setWebsiteConfig(bucketName,
new GSWebsiteConfig("index.html", "error.html"));
// Confirm index document and error document set
config = service.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);
service.putObject(bucketName, errorObject);