Examples of SwiftObject


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

            .addHeader("X-Object-Meta-Apiname", "swift") //
            .addHeader("X-Object-Meta-Apiversion", "v1.1"));

      try {
         SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
         SwiftObject object = api.objectApiInRegionForContainer("DFW", "myContainer").get("myObject", tail(1));
         assertEquals(object.name(), "myObject");
         assertEquals(object.etag(), "8a964ee2a5e88be344f36c22562a6486");
         assertEquals(object.lastModified(), dates.rfc822DateParse("Fri, 12 Jun 2010 13:40:18 GMT"));
         for (Entry<String, String> entry : object.metadata().entrySet()) {
            assertEquals(object.metadata().get(entry.getKey().toLowerCase()), entry.getValue());
         }
         assertEquals(object.payload().getContentMetadata().getContentLength(), new Long(4));
         assertEquals(object.payload().getContentMetadata().getContentType(), "text/plain; charset=UTF-8");
         // note MWS doesn't process Range header at the moment
         assertEquals(Strings2.toStringAndClose(object.payload().getInput()), "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

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

   private String name = getClass().getSimpleName();
   private String containerName = getClass().getSimpleName() + "Container";

   public void signForPublicAccess() throws Exception {
      for (String regionId : api.configuredRegions()) {
         SwiftObject object = api.objectApiInRegionForContainer(regionId, containerName).head(name);

         long expires = System.currentTimeMillis() / 1000 + 5;
         String signature = TemporaryUrlSigner.checkApiEvery(api.accountApiInRegion(regionId), 5) //
               .sign("GET", object.uri().getPath(), expires);

         URI signed = URI.create(format("%s?temp_url_sig=%s&temp_url_expires=%s", object.uri(), signature, expires));

         InputStream publicStream = signed.toURL().openStream();
         assertEquals(Strings2.toStringAndClose(publicStream), "swifty");

         // let it expire
View Full Code Here

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

      assertNotNull(object.payload().getContentMetadata().getContentType());
   }

   public void metadata() throws Exception {
      for (String regionId : api.configuredRegions()) {
         SwiftObject object = api.objectApiInRegionForContainer(regionId, containerName).head(name);
         assertEquals(object.name(), name);
         checkObject(object);
         assertEquals(toStringAndClose(object.payload().getInput()), "");
      }
   }
View Full Code Here

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

      }
   }

   public void get() throws Exception {
      for (String regionId : api.configuredRegions()) {
         SwiftObject object = api.objectApiInRegionForContainer(regionId, containerName).get(name, GetOptions.NONE);
         assertEquals(object.name(), name);
         checkObject(object);
         assertEquals(toStringAndClose(object.payload().getInput()), "swifty");
      }
   }
View Full Code Here

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

      }
   }

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

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

      }
   }

   public void getOptions() throws Exception {
      for (String regionId : api.configuredRegions()) {
         SwiftObject object = api.objectApiInRegionForContainer(regionId, containerName).get(name, tail(1));
         assertEquals(object.name(), name);
         checkObject(object);
         assertEquals(toStringAndClose(object.payload().getInput()), "y");
      }
   }
View Full Code Here

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

   }

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

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

         assertTrue(objectApi.updateMetadata(name, meta));
         containerHasMetadata(objectApi, name, meta);

         assertTrue(objectApi.deleteMetadata(name, meta));
         SwiftObject object = objectApi.head(name);
         for (Entry<String, String> entry : meta.entrySet()) {
            // note keys are returned in lower-case!
            assertFalse(object.metadata().containsKey(entry.getKey().toLowerCase()));
         }
      }
   }
View Full Code Here

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

         }
      }
   }

   static void containerHasMetadata(ObjectApi objectApi, String name, Map<String, String> meta) {
      SwiftObject object = objectApi.head(name);
      for (Entry<String, String> entry : meta.entrySet()) {
         // note keys are returned in lower-case!
         assertEquals(object.metadata().get(entry.getKey().toLowerCase()), entry.getValue(), //
               object + " didn't have metadata: " + entry);
      }
   }
View Full Code Here

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

         String etagOfEtags = api.staticLargeObjectApiInRegionForContainer(regionId, containerName).replaceManifest(
               name, segments, ImmutableMap.of("myfoo", "Bar"));

         assertNotNull(etagOfEtags);

         SwiftObject bigObject = api.objectApiInRegionForContainer(regionId, containerName).head(name);
         assertNotEquals(bigObject.etag(), etagOfEtags);
         assertEquals(bigObject.payload().getContentMetadata().getContentLength(), new Long(2 * 1024 * 1024));
         assertEquals(bigObject.metadata(), ImmutableMap.of("myfoo", "Bar"));

         // segments are visible
         assertEquals(api.containerApiInRegion(regionId).get(containerName).objectCount(), 3);
      }
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.