Package org.jclouds.io.payloads

Examples of org.jclouds.io.payloads.ByteSourcePayload


        //Utility Class
    }

    @Converter
    public static Payload toPayload(byte[] bytes) {
        return new ByteSourcePayload(ByteSource.wrap(bytes));
    }
View Full Code Here


        return toPayload(str, null);
    }

    @Converter
    public static Payload toPayload(File file) {
        return new ByteSourcePayload(Files.asByteSource(file));
    }
View Full Code Here

   public static final long GiB = 1L << 30;
   public static final long TiB = 1L << 40;

   public static Payload buildPayload(long size) {
      ByteSource data = buildData(size);
      Payload payload = new ByteSourcePayload(data);
      payload.getContentMetadata().setContentType(PLAIN_TEXT_UTF_8.toString());
      payload.getContentMetadata().setContentLength(size);
      return payload;
   }
View Full Code Here

@Test(groups = "unit", testName = "TreeHasherTest")
public class TreeHashTest {

   @Test
   public void testTreeHasherWith1MBPayload() throws IOException {
      TreeHash th = TreeHash.buildTreeHashFromPayload(new ByteSourcePayload(buildData(1 * MiB)));
      assertThat(th.getLinearHash())
              .isEqualTo(HashCode.fromString("9bc1b2a288b26af7257a36277ae3816a7d4f16e89c1e7e77d0a5c48bad62b360"));
      assertThat(th.getTreeHash())
              .isEqualTo(HashCode.fromString("9bc1b2a288b26af7257a36277ae3816a7d4f16e89c1e7e77d0a5c48bad62b360"));
   }
View Full Code Here

              .isEqualTo(HashCode.fromString("9bc1b2a288b26af7257a36277ae3816a7d4f16e89c1e7e77d0a5c48bad62b360"));
   }

   @Test
   public void testTreeHasherWith2MBPayload() throws IOException {
      TreeHash th = TreeHash.buildTreeHashFromPayload(new ByteSourcePayload(buildData(2 * MiB)));
      assertThat(th.getLinearHash())
              .isEqualTo(HashCode.fromString("5256ec18f11624025905d057d6befb03d77b243511ac5f77ed5e0221ce6d84b5"));
      assertThat(th.getTreeHash())
              .isEqualTo(HashCode.fromString("560c2c9333c719cb00cfdffee3ba293db17f58743cdd1f7e4055373ae6300afa"));
   }
View Full Code Here

              .isEqualTo(HashCode.fromString("560c2c9333c719cb00cfdffee3ba293db17f58743cdd1f7e4055373ae6300afa"));
   }

   @Test
   public void testTreeHasherWith3MBPayload() throws IOException {
      TreeHash th = TreeHash.buildTreeHashFromPayload(new ByteSourcePayload(buildData(3 * MiB)));
      assertThat(th.getLinearHash())
              .isEqualTo(HashCode.fromString("6f850bc94ae6f7de14297c01616c36d712d22864497b28a63b81d776b035e656"));
      assertThat(th.getTreeHash())
              .isEqualTo(HashCode.fromString("70239f4f2ead7561f69d48b956b547edef52a1280a93c262c0b582190be7db17"));
   }
View Full Code Here

              .isEqualTo(HashCode.fromString("70239f4f2ead7561f69d48b956b547edef52a1280a93c262c0b582190be7db17"));
   }

   @Test
   public void testTreeHasherWithMoreThan3MBPayload() throws IOException {
      TreeHash th = TreeHash.buildTreeHashFromPayload(new ByteSourcePayload(buildData(3 * MiB + 512 * 1024)));
      assertThat(th.getLinearHash())
              .isEqualTo(HashCode.fromString("34c8bdd269f89a091cf17d5d23503940e0abf61c4b6544e42854b9af437f31bb"));
      assertThat(th.getTreeHash())
              .isEqualTo(HashCode.fromString("daede4eb580f914dacd5e0bdf7015c937fd615c1e6c6552d25cb04a8b7219828"));
   }
View Full Code Here

   public static ByteArrayPayload newByteArrayPayload(byte[] data) {
      return new ByteArrayPayload(checkNotNull(data, "data"));
   }

   public static ByteSourcePayload newByteSourcePayload(ByteSource data) {
      return new ByteSourcePayload(checkNotNull(data, "data"));
   }
View Full Code Here

   private void uploadByteSource(String container, String name, String contentDisposition,
         ByteSource byteSource) throws IOException {
      BlobStore blobStore = view.getBlobStore();
      blobStore.putBlob(container, blobStore.blobBuilder(name)
            .payload(new ByteSourcePayload(byteSource))
            .contentType("text/plain")
            .contentMD5(byteSource.hash(md5()))
            .contentLength(byteSource.size())
            .contentDisposition(contentDisposition)
            .build());
View Full Code Here

   }

   @Test(groups = { "integration", "live" })
   public void testPutObjectStream() throws InterruptedException, IOException, ExecutionException {
      PayloadBlobBuilder blobBuilder = view.getBlobStore().blobBuilder("streaming").payload(
               new ByteSourcePayload(ByteSource.wrap("foo".getBytes())));
      addContentMetadata(blobBuilder);

      Blob blob = blobBuilder.build();

      String container = getContainerName();
View Full Code Here

TOP

Related Classes of org.jclouds.io.payloads.ByteSourcePayload

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.