public void testRanges() throws IOException {
blobStore.createContainerInLocation(null, CONTAINER_NAME);
String input = "abcdefgh";
Payload payload;
Blob blob = blobStore.blobBuilder("test").payload(new StringPayload(input)).build();
blobStore.putBlob(CONTAINER_NAME, blob);
GetOptions getOptionsRangeStartAt = new GetOptions();
getOptionsRangeStartAt.startAt(1);
Blob blobRangeStartAt = blobStore.getBlob(CONTAINER_NAME, blob.getMetadata().getName(), getOptionsRangeStartAt);
payload = blobRangeStartAt.getPayload();
try {
assertEquals(input.substring(1), Strings2.toString(payload));
} finally {
Closeables2.closeQuietly(payload);
}
GetOptions getOptionsRangeTail = new GetOptions();
getOptionsRangeTail.tail(3);
Blob blobRangeTail = blobStore.getBlob(CONTAINER_NAME, blob.getMetadata().getName(), getOptionsRangeTail);
payload = blobRangeTail.getPayload();
try {
assertEquals(input.substring(5), Strings2.toString(payload));
} finally {
Closeables2.closeQuietly(payload);
}
GetOptions getOptionsFragment = new GetOptions();
getOptionsFragment.range(4, 6);
Blob blobFragment = blobStore.getBlob(CONTAINER_NAME, blob.getMetadata().getName(), getOptionsFragment);
payload = blobFragment.getPayload();
try {
assertEquals(input.substring(4, 7), Strings2.toString(payload));
} finally {
Closeables2.closeQuietly(payload);
}