Package org.jclouds.openstack.swift.v1.domain

Examples of org.jclouds.openstack.swift.v1.domain.SwiftObject$Builder


      for (String regionId : regions) {
         assertNotNull(api.getContainerApiForRegion(regionId).create(containerName));
         assertNotNull(api.getObjectApiForRegionAndContainer(regionId, containerName).put(objectName, PAYLOAD));

         SwiftObject object = api.getObjectApiForRegionAndContainer(regionId, containerName).get(objectName);
         assertEquals(object.getName(), objectName);
         checkObject(object);
         assertEquals(toStringAndClose(object.getPayload().openStream()), "swifty");

         api.getObjectApiForRegionAndContainer(regionId, containerName).delete(objectName);
         api.getContainerApiForRegion(regionId).deleteIfEmpty(containerName);
      }
   }
View Full Code Here


         ObjectApi srcApi = api.getObjectApiForRegionAndContainer(regionId, sourceContainer);
         ObjectApi destApi = api.getObjectApiForRegionAndContainer(regionId, destinationContainer);
        
         // Create source object
         assertNotNull(srcApi.put(sourceObjectName, PAYLOAD));
         SwiftObject sourceObject = srcApi.get(sourceObjectName);
         checkObject(sourceObject);

         // Create the destination object
         assertNotNull(destApi.put(destinationObject, PAYLOAD));
         SwiftObject object = destApi.get(destinationObject);
         checkObject(object);

         // check the copy operation
         assertTrue(destApi.copy(destinationObject, sourceContainer, sourceObjectName));
         assertNotNull(destApi.get(destinationObject));
        
         // now get a real SwiftObject
         SwiftObject destSwiftObject = destApi.get(destinationObject);
         assertEquals(Strings2.toString(destSwiftObject.getPayload()), "swifty");
        
         // test exception thrown on bad source name
         try {
            destApi.copy(destinationObject, badSource, sourceObjectName);
            fail("Expected CopyObjectException");
View Full Code Here

      }
   }

   public void testMetadata() throws Exception {
      for (String regionId : regions) {
         SwiftObject object = api.getObjectApiForRegionAndContainer(regionId, containerName).get(name);
         assertEquals(object.getName(), name);
         checkObject(object);
         assertEquals(toStringAndClose(object.getPayload().openStream()), "swifty");
      }
   }
View Full Code Here

         ObjectApi objectApi = api.getObjectApiForRegionAndContainer(regionId, containerName);
        
         Map<String, String> meta = ImmutableMap.of("MyAdd1", "foo", "MyAdd2", "bar");
         assertTrue(objectApi.updateMetadata(name, meta));
        
         SwiftObject object = objectApi.get(name);
         for (Entry<String, String> entry : meta.entrySet()) {
            // note keys are returned in lower-case!
            assertEquals(object.getMetadata().get(entry.getKey().toLowerCase()), entry.getValue(),
                  object + " didn't have metadata: " + entry);
         }
      }
   }
View Full Code Here

      }
   }

   public void testGet() throws Exception {
      for (String regionId : regions) {
         SwiftObject object = api.getObjectApiForRegionAndContainer(regionId, containerName).get(name, GetOptions.NONE);
         assertEquals(object.getName(), name);
         checkObject(object);
         assertEquals(toStringAndClose(object.getPayload().openStream()), "swifty");
      }
   }
View Full Code Here

      }
   }

   public void testPrivateByDefault() throws Exception {
      for (String regionId : regions) {
         SwiftObject object = api.getObjectApiForRegionAndContainer(regionId, containerName).get(name);
         try {
            object.getUri().toURL().openStream();
            fail("shouldn't be able to access " + object);
         } catch (IOException expected) {
         }
      }
   }
View Full Code Here

      }
   }

   public void testGetOptions() throws Exception {
      for (String regionId : regions) {
         SwiftObject object = api.getObjectApiForRegionAndContainer(regionId, containerName).get(name, tail(1));
         assertEquals(object.getName(), name);
         checkObject(object);
         assertEquals(toStringAndClose(object.getPayload().openStream()), "y");
      }
   }
View Full Code Here

   }

   public void testListOptions() throws Exception {
      String lexicographicallyBeforeName = name.substring(0, name.length() - 1);
      for (String regionId : regions) {
         SwiftObject object = api.getObjectApiForRegionAndContainer(regionId, containerName)
               .list(marker(lexicographicallyBeforeName)).get(0);
         assertEquals(object.getName(), name);
         checkObject(object);
      }
   }
View Full Code Here

            .addHeader(OBJECT_METADATA_PREFIX + "Apiname", "swift")
            .addHeader(OBJECT_METADATA_PREFIX + "Apiversion", "v1.1")));

      try {
         SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
         SwiftObject object = api.getObjectApiForRegionAndContainer("DFW", "myContainer").getWithoutBody("myObject");
         assertEquals(object.getName(), "myObject");
         assertEquals(object.getETag(), "8a964ee2a5e88be344f36c22562a6486");
         assertEquals(object.getLastModified(), dates.rfc822DateParse("Fri, 12 Jun 2010 13:40:18 GMT"));
         for (Entry<String, String> entry : object.getMetadata().entrySet()) {
            assertEquals(object.getMetadata().get(entry.getKey().toLowerCase()), entry.getValue());
         }
         assertEquals(object.getPayload().getContentMetadata().getContentLength(), new Long(4));
         assertEquals(object.getPayload().getContentMetadata().getContentType(), "text/plain; charset=UTF-8");
         assertEquals(toStringAndClose(object.getPayload().openStream()), "");

         assertEquals(server.getRequestCount(), 2);
         assertAuthentication(server);
         assertRequest(server.takeRequest(), "HEAD", "/v1/MossoCloudFS_5bcf396e-39dd-45ff-93a1-712b9aba90a9/myContainer/myObject");
      } finally {
View Full Code Here

            .addHeader(OBJECT_METADATA_PREFIX + "Apiname", "swift")
            .addHeader(OBJECT_METADATA_PREFIX + "Apiversion", "v1.1")));

      try {
         SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
         SwiftObject object = api.getObjectApiForRegionAndContainer("DFW", "myContainer").get("myObject", tail(1));
         assertEquals(object.getName(), "myObject");
         assertEquals(object.getETag(), "8a964ee2a5e88be344f36c22562a6486");
         assertEquals(object.getLastModified(), dates.rfc822DateParse("Fri, 12 Jun 2010 13:40:18 GMT"));
         for (Entry<String, String> entry : object.getMetadata().entrySet()) {
            assertEquals(object.getMetadata().get(entry.getKey().toLowerCase()), entry.getValue());
         }
         assertEquals(object.getPayload().getContentMetadata().getContentLength(), new Long(4));
         assertEquals(object.getPayload().getContentMetadata().getContentType(), "text/plain; charset=UTF-8");
         // note MWS doesn't process Range header at the moment
         assertEquals(toStringAndClose(object.getPayload().openStream()), "ABCD");

         assertEquals(server.getRequestCount(), 2);
         assertEquals(server.takeRequest().getRequestLine(), "POST /tokens HTTP/1.1");
         RecordedRequest get = server.takeRequest();
         assertEquals(get.getRequestLine(),
View Full Code Here

TOP

Related Classes of org.jclouds.openstack.swift.v1.domain.SwiftObject$Builder

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.