Package org.jclouds.openstack.swift.v1

Examples of org.jclouds.openstack.swift.v1.SwiftApi


      MockWebServer server = mockOpenStackServer();
      server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
      server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(204)));

      try {
         SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
         api.objectApiInRegionForContainer("DFW", "myContainer").delete("myObject");

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


      MockWebServer server = mockOpenStackServer();
      server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
      server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));

      try {
         SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
         api.objectApiInRegionForContainer("DFW", "myContainer").delete("myObject");

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

      MockWebServer server = mockOpenStackServer();
      server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
      server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201)
            .addHeader(SwiftHeaders.OBJECT_COPY_FROM, "/bar/foo.txt")));
      try {
         SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
         assertTrue(api.objectApiInRegionForContainer("DFW", "foo")
            .copy("bar.txt", "bar", "foo.txt"));
             
         assertEquals(server.getRequestCount(), 2);
         assertEquals(server.takeRequest().getRequestLine(), "POST /tokens HTTP/1.1");
        
View Full Code Here

      server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
      server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)
            .addHeader(SwiftHeaders.OBJECT_COPY_FROM, "/bogus/foo.txt")));
     
      try {
         SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
         // the following line will throw the CopyObjectException
         api.objectApiInRegionForContainer("DFW", "foo").copy("bar.txt", "bogus", "foo.txt");
      } finally {
         server.shutdown();
     
   }
View Full Code Here

      MockWebServer server = mockOpenStackServer();
      server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
      server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody("{\"Number Files Created\": 10, \"Errors\": []}")));

      try {
         SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
         Payload payload = Payloads.newByteSourcePayload(ByteSource.wrap(tarGz));
         ExtractArchiveResponse response = api.getBulkApiForRegion("DFW").extractArchive("myContainer", payload, "tar.gz");

         assertEquals(response.getCreated(), 10);
         assertTrue(response.getErrors().isEmpty());

         assertEquals(server.getRequestCount(), 2);
View Full Code Here

      MockWebServer server = mockOpenStackServer();
      server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
      server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/container_list.json"))));

      try {
         SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
         ImmutableList<Container> containers = api.getContainerApiForRegion("DFW").list().toList();
         assertEquals(containers, ImmutableList.of(
               Container.builder()
                     .name("test_container_1")
                     .objectCount(2)
                     .bytesUsed(78).build(),
View Full Code Here

      ListContainerOptions options = ListContainerOptions.Builder.marker("test");
      assertNotNull(options);
     
      try {
         SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
         ImmutableList<Container> containers = api.getContainerApiForRegion("DFW").list(options).toList();
         assertEquals(containers, ImmutableList.of(
               Container.builder()
                     .name("test_container_1")
                     .objectCount(2)
                     .bytesUsed(78).build(),
View Full Code Here

      server.enqueue(addCommonHeaders(containerResponse()
            .addHeader(CONTAINER_METADATA_PREFIX + "ApiName", "swift")
            .addHeader(CONTAINER_METADATA_PREFIX + "ApiVersion", "v1.1")));

      try {
         SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
         assertTrue(api.getContainerApiForRegion("DFW").create("myContainer", anybodyRead().metadata(metadata)));
        
         Container container = api.getContainerApiForRegion("DFW").get("myContainer");
         assertEquals(container.getName(), "myContainer");
         assertEquals(container.getObjectCount(), 42l);
         assertEquals(container.getBytesUsed(), 323479l);
         for (Entry<String, String> entry : container.getMetadata().entrySet()) {
            assertEquals(container.getMetadata().get(entry.getKey().toLowerCase()), entry.getValue());
View Full Code Here

      MockWebServer server = mockOpenStackServer();
      server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
      server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));

      try {
         SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
         assertTrue(api.getContainerApiForRegion("DFW").create("myContainer", anybodyRead().metadata(metadata)));

         // the head call will throw the ContainerNotFoundException
         api.getContainerApiForRegion("DFW").get("myContainer");
      } finally {
         server.shutdown();
      }
   }
View Full Code Here

      MockWebServer server = mockOpenStackServer();
      server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
      server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201)));

      try {
         SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
         assertTrue(api.getContainerApiForRegion("DFW").create("myContainer"));

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

TOP

Related Classes of org.jclouds.openstack.swift.v1.SwiftApi

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.