@Test
  public void testPageBlobDownloadRangeTest()
      throws URISyntaxException, StorageException, IOException {
    byte[] buffer = BlobTestHelper.getRandomBuffer(2 * 1024);

    CloudPageBlob blob = this.container.getPageBlobReference("blob1");
    ByteArrayInputStream wholeBlob = new ByteArrayInputStream(buffer);
    blob.upload(wholeBlob, 2 * 1024);

    ByteArrayOutputStream blobStream = new ByteArrayOutputStream();
    try {
      blob.downloadRange(0, new Long(0), blobStream);
    } catch (IndexOutOfBoundsException ex) {

    }

    blob.downloadRange(0, new Long(1024), blobStream);
    assertEquals(blobStream.size(), 1024);
    BlobTestHelper.assertStreamsAreEqualAtIndex(
        new ByteArrayInputStream(blobStream.toByteArray()), wholeBlob, 0, 0, 1024, 2 * 1024);

    CloudPageBlob blob2 = this.container.getPageBlobReference("blob1");
    try {
      blob.downloadRange(1024, new Long(0), blobStream);
    } catch (IndexOutOfBoundsException ex) {

    }

    ByteArrayOutputStream blobStream2 = new ByteArrayOutputStream();
    blob2.downloadRange(1024, new Long(1024), blobStream2);
    BlobTestHelper.assertStreamsAreEqualAtIndex(
        new ByteArrayInputStream(blobStream2.toByteArray()), wholeBlob, 1024, 1024, 1024, 2 * 1024);

    BlobTestHelper.assertAreEqual(blob, blob2);
  }