Package org.jclouds.atmos.domain

Examples of org.jclouds.atmos.domain.AtmosObject


      }
   }

   @Test(timeOut = 5 * 60 * 1000, dependsOnMethods = { "testFileOperations" })
   public void testPutZeroLengthBlob() throws Exception {
      AtmosObject object = getApi().newObject();
      object.getContentMetadata().setName("object");
      byte[] payload = new byte[0];
      object.setPayload(Payloads.newPayload(payload));
      object.getContentMetadata().setContentLength(Long.valueOf(payload.length));
      replaceObject(object);
   }
View Full Code Here


      return stream ? Strings2.toInputStream(in) : in;
   }

   private void createOrReplaceObject(String name, Object data, HashCode hashCode, String metadataValue) throws Exception {
      // Test PUT with string data, ETag hash, and a piece of metadata
      AtmosObject object = getApi().newObject();
      object.getContentMetadata().setName(name);
      object.setPayload(Payloads.newPayload(data));
      object.getContentMetadata().setContentLength(16l);
      object.getContentMetadata().setContentMD5(hashCode.asBytes());
      object.getContentMetadata().setContentType("text/plain");
      object.getUserMetadata().getMetadata().put("Metadata", metadataValue);
      replaceObject(object);
   }
View Full Code Here

      assertEventually(new HeadMatches(getApi(), privateDirectory + "/" + name, metadataValue));
   }

   private static void verifyHeadObject(AtmosClient connection, String path, String metadataValue)
            throws InterruptedException, ExecutionException, TimeoutException, IOException {
      AtmosObject getBlob = connection.headFile(path);
      assertEquals(Strings2.toStringAndClose(getBlob.getPayload().openStream()), "");
      verifyMetadata(metadataValue, getBlob);
   }
View Full Code Here

      verifyMetadata(metadataValue, getBlob);
   }

   private static void verifyObject(AtmosClient connection, String path, String compare, String metadataValue)
            throws InterruptedException, ExecutionException, TimeoutException, IOException {
      AtmosObject getBlob = connection.readFile(path);
      assertEquals(Strings2.toStringAndClose(getBlob.getPayload().openStream()), compare);
      verifyMetadata(metadataValue, getBlob);
   }
View Full Code Here

   private static final Factory BLOB_FACTORY = Guice.createInjector().getInstance(AtmosObject.Factory.class);

   @Test
   public void testCorrectContentMetadataName() throws SecurityException, NoSuchMethodException {

      AtmosObject blob = BLOB_FACTORY.create(null);
      blob.getContentMetadata().setName("foo");

      assertEquals(fn.apply(blob), "foo");
   }
View Full Code Here

   }

   @Test
   public void testCorrectSystemMetadataObjectName() throws SecurityException, NoSuchMethodException {

      AtmosObject blob = BLOB_FACTORY.create(new SystemMetadata(null, null, null, null, null, null, 0, null, "foo",
            null, 0, null, null), new UserMetadata());
      assertEquals(fn.apply(blob), "foo");
   }
View Full Code Here

   }

   public void test() {
      ParseObjectFromHeadersAndHttpContent parser = Guice.createInjector().getInstance(
            ParseObjectFromHeadersAndHttpContent.class);
      AtmosObject data = parser.apply(RESPONSE);

      assertEquals(data, EXPECTED);
   }
View Full Code Here

   }

   public static String putBlob(final AtmosClient sync, Crypto crypto, BlobToObject blob2Object, String container,
            Blob blob, PutOptions options) {
      final String path = container + "/" + blob.getMetadata().getName();
      final AtmosObject object = blob2Object.apply(blob);
     
      try {
         sync.createFile(container, object, options);
        
      } catch (KeyAlreadyExistsException e) {
View Full Code Here

    *
    * @throws org.jclouds.http.HttpException
    */
   public AtmosObject apply(HttpResponse from) {
      checkNotNull(from, "http response");
      AtmosObject object = objectProvider.create(systemMetadataParser.apply(from), userMetadataParser.apply(from));
      object.getContentMetadata().setName(object.getSystemMetadata().getObjectName());
      object.getContentMetadata().setPath(path);
      object.getContentMetadata().setUri(uri);
      object.getAllHeaders().putAll(from.getHeaders());
      object.setPayload(from.getPayload());
      object.getContentMetadata().setContentLength(attemptToParseSizeAndRangeFromHeaders(from));
      return object;
   }
View Full Code Here

   }

   public AtmosObject apply(Blob from) {
      if (from == null)
         return null;
      AtmosObject object = blobMd2Object.apply(from.getMetadata());
      object.setPayload(checkNotNull(from.getPayload(), "payload: " + from));
      object.setAllHeaders(from.getAllHeaders());
      return object;
   }
View Full Code Here

TOP

Related Classes of org.jclouds.atmos.domain.AtmosObject

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.