use of com.aliyun.oss.model.GetBucketImageResult in project aliyun-oss-java-sdk by aliyun.
the class TestForImg method testPutGetBucketImage.
public void testPutGetBucketImage() {
PutBucketImageRequest request = new PutBucketImageRequest(bucketName);
clientImg.putBucketImage(request);
sleepSecond(10);
GetBucketImageResult result = clientImg.getBucketImage(bucketName);
Assert.assertEquals(result.GetBucketName(), bucketName);
Assert.assertEquals(result.GetDefault404Pic(), "");
Assert.assertFalse(result.GetIsAutoSetContentType());
Assert.assertFalse(result.GetIsForbidOrigPicAccess());
Assert.assertFalse(result.GetIsUseSrcFormat());
Assert.assertFalse(result.GetIsSetAttachName());
Assert.assertEquals(result.GetStyleDelimiters(), "!");
Assert.assertEquals(result.GetStatus(), "Enabled");
request.SetIsForbidOrigPicAccess(true);
request.SetIsUseStyleOnly(true);
request.SetIsAutoSetContentType(true);
request.SetIsUseSrcFormat(true);
request.SetIsSetAttachName(true);
String default404Pic = "index.png";
request.SetDefault404Pic(default404Pic);
String styleDelimiters = "_";
request.SetStyleDelimiters(styleDelimiters);
clientImg.putBucketImage(request);
sleepSecond(20);
result = clientImg.getBucketImage(bucketName);
Assert.assertEquals(result.GetBucketName(), bucketName);
Assert.assertEquals(result.GetDefault404Pic(), default404Pic);
Assert.assertFalse(!result.GetIsAutoSetContentType());
// TODO img's problem
Assert.assertFalse(!result.GetIsForbidOrigPicAccess());
Assert.assertFalse(!result.GetIsUseSrcFormat());
Assert.assertFalse(!result.GetIsSetAttachName());
Assert.assertEquals(result.GetStyleDelimiters(), styleDelimiters);
Assert.assertEquals(result.GetStatus(), "Enabled");
}
use of com.aliyun.oss.model.GetBucketImageResult in project aliyun-oss-java-sdk by aliyun.
the class ResponseParsers method parseBucketImage.
/**
* Unmarshall get bucket image response body to corresponding result.
*/
public static GetBucketImageResult parseBucketImage(InputStream responseBody) throws ResponseParseException {
try {
Element root = getXmlRootElement(responseBody);
GetBucketImageResult result = new GetBucketImageResult();
result.SetBucketName(root.getChildText("Name"));
result.SetDefault404Pic(root.getChildText("Default404Pic"));
result.SetStyleDelimiters(root.getChildText("StyleDelimiters"));
result.SetStatus(root.getChildText("Status"));
result.SetIsAutoSetContentType(root.getChildText("AutoSetContentType").equals("True"));
result.SetIsForbidOrigPicAccess(root.getChildText("OrigPicForbidden").equals("True"));
result.SetIsSetAttachName(root.getChildText("SetAttachName").equals("True"));
result.SetIsUseStyleOnly(root.getChildText("UseStyleOnly").equals("True"));
result.SetIsUseSrcFormat(root.getChildText("UseSrcFormat").equals("True"));
return result;
} catch (JDOMParseException e) {
throw new ResponseParseException(e.getPartialDocument() + ": " + e.getMessage(), e);
} catch (Exception e) {
throw new ResponseParseException(e.getMessage(), e);
}
}
Aggregations