Package org.jclouds.blobstore.domain

Examples of org.jclouds.blobstore.domain.Blob$Factory


   }

   public Blob apply(AtmosObject from) {
      if (from == null)
         return null;
      Blob blob = blobFactory.create(object2BlobMd.apply(from));
      blob.setPayload(checkNotNull(from.getPayload(), "payload: " + from));
      HttpUtils.copy(from.getContentMetadata(), blob.getPayload().getContentMetadata());
      blob.setAllHeaders(from.getAllHeaders());
      return blob;
   }
View Full Code Here


      assertTrue(result, "Container exists");
   }

   public void testNewBlob() {
      String blobKey;
      Blob newBlob;

      blobKey = TestUtils.createRandomBlobKey("blobtest-", ".txt");
      newBlob = storageStrategy.newBlob(blobKey);
      assertNotNull(newBlob, "Created blob was null");
      assertNotNull(newBlob.getMetadata(), "Created blob metadata were null");
      assertEquals(newBlob.getMetadata().getName(), blobKey, "Created blob name is different");

      blobKey = TestUtils.createRandomBlobKey("blobtest-", "");
      newBlob = storageStrategy.newBlob(blobKey);
      assertEquals(newBlob.getMetadata().getName(), blobKey, "Created blob name is different");

      blobKey = TestUtils.createRandomBlobKey("asd" + FS + "asd" + FS + "asdasd" + FS + "afadsf-", "");
      newBlob = storageStrategy.newBlob(blobKey);
      assertEquals(newBlob.getMetadata().getName(), blobKey, "Created blob name is different");
   }
View Full Code Here

   public void testWritePayloadOnFile() throws IOException {
      String blobKey = TestUtils.createRandomBlobKey("writePayload-", ".img");
      File sourceFile = TestUtils.getImageForBlobPayload();
      FilePayload filePayload = new FilePayload(sourceFile);
      Blob blob = storageStrategy.newBlob(blobKey);
      blob.setPayload(filePayload);

      // write files
      storageStrategy.putBlob(CONTAINER_NAME, blob);

      // verify that the files is equal
View Full Code Here

   public void testWritePayloadOnFileInputStream() throws IOException {
      String blobKey = TestUtils.createRandomBlobKey("writePayload-", ".img");
      File sourceFile = TestUtils.getImageForBlobPayload();
      InputStreamPayload fileInputStreamPayload = new InputStreamPayload(
            new FileInputStream(sourceFile));
      Blob blob = storageStrategy.newBlob(blobKey);
      blob.setPayload(fileInputStreamPayload);

      // write files
      storageStrategy.putBlob(CONTAINER_NAME, blob);

      // verify that the files is equal
View Full Code Here

    BlobStore store = context.getBlobStore();
    if (!store.blobExists(container, name)) {
      LOG.info("Uploading '{}' to '{}' blob cache.", name, container);

      Blob blob = context.getBlobStore().newBlob(name);
      blob.setPayload(in);
      blob.getMetadata().getContentMetadata().setContentLength(contentLength);
      store.putBlob(container, blob);
    }
  }
View Full Code Here

      assertEquals(request.getFilters().size(), 0);
   }

   public void testSignPutBlob() throws ArrayIndexOutOfBoundsException, SecurityException, IllegalArgumentException,
            NoSuchMethodException, IOException {
      Blob blob = blobFactory.create(null);
      blob.getMetadata().setName("name");
      blob.setPayload("");
      blob.getPayload().getContentMetadata().setContentLength(2l);
      blob.getPayload().getContentMetadata().setContentMD5(new byte[] { 0, 2, 4, 8 });
      blob.getPayload().getContentMetadata().setContentType("text/plain");
      blob.getPayload().getContentMetadata().setExpires(new Date(1000));

      HttpRequest request = signer.signPutBlob("container", blob);

      assertRequestLineEquals(request, "PUT https://identity.blob.core.windows.net/container/name HTTP/1.1");
      assertNonPayloadHeadersEqual(
View Full Code Here

      String containerName = getContainerName();

      try {
         BlobStore blobStore = view.getBlobStore();
         blobStore.createContainerInLocation(null, containerName);
         Blob blob = blobStore.blobBuilder("const.txt").payload(file).build();
         String expected = blobStore.putBlob(containerName, blob, PutOptions.Builder.multipart());
         String etag = blobStore.blobMetadata(containerName, "const.txt").getETag();
         assertEquals(etag, expected);
      } finally {
         returnContainer(containerName);
View Full Code Here

      String containerName = getContainerName();

      try {
         BlobStore blobStore = view.getBlobStore();
         blobStore.createContainerInLocation(null, containerName);
         Blob blob = blobStore.blobBuilder("const.txt").payload(file).build();
         String expected = blobStore.putBlob(containerName, blob, PutOptions.Builder.multipart());
         String etag = blobStore.blobMetadata(containerName, "const.txt").getETag();
         assertEquals(etag, expected);
      } finally {
         returnContainer(containerName);
View Full Code Here

      assertEquals(request.getFilters().size(), 0);
   }

   public void testSignPutBlob() throws ArrayIndexOutOfBoundsException, SecurityException, IllegalArgumentException,
            NoSuchMethodException, IOException {
      Blob blob = blobFactory.get().name(blobName).forSigning().contentLength(2l).contentMD5(new byte[] { 0, 2, 4, 8 })
               .contentType("text/plain").build();

      assertEquals(blob.getPayload().getContentMetadata().getContentMD5(), new byte[] { 0, 2, 4, 8 });

      HttpRequest request = signer.signPutBlob(containerName, blob);

      assertRequestLineEquals(request, "PUT " + fullUrl + " HTTP/1.1");
      assertNonPayloadHeadersEqual(
View Full Code Here

      assertEquals(request.getFilters().size(), 0);
   }

   public void testSignPutBlobWithGenerate() throws ArrayIndexOutOfBoundsException, SecurityException,
            IllegalArgumentException, NoSuchMethodException, IOException {
      Blob blob = blobFactory.get().name(blobName).payload("foo").calculateMD5().contentType("text/plain").build();
      byte[] md5 = new byte[] { -84, -67, 24, -37, 76, -62, -8, 92, -19, -17, 101, 79, -52, -60, -92, -40 };
     
      assertEquals(blob.getPayload().getContentMetadata().getContentMD5(), md5);

      HttpRequest request = signer.signPutBlob(containerName, blob);

      assertRequestLineEquals(request, "PUT " + fullUrl + " HTTP/1.1");
      assertNonPayloadHeadersEqual(
View Full Code Here

TOP

Related Classes of org.jclouds.blobstore.domain.Blob$Factory

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.