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

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


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

      try {
         SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift");
         Container container = api.getContainerApi("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());
         }

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


                                    SwiftHeaders.STATIC_WEB_ERROR, "__error.html");
         CreateContainerOptions opts = new CreateContainerOptions().headers(headers);

         assertNotNull(api.getContainerApi(regionId).create(name, opts));

         Container container = api.getContainerApi(regionId).get(name);
         assertNotNull(container);
         assertEquals(container.getName(), name);
         assertEquals(container.getMetadata().size(), 2);
         assertEquals(container.getMetadata().get("web-index"), "__index.html");
         assertEquals(container.getMetadata().get("web-error"), "__error.html");

         assertTrue(api.getContainerApi(regionId).deleteIfEmpty(name));
      }
   }
View Full Code Here

   public void testCreateWithSpacesAndSpecialCharacters() throws Exception {
      final String nameWithSpaces = "container # ! special";

      for (String regionId : regions) {
         assertTrue(api.getContainerApi(regionId).create(nameWithSpaces));
         Container container = api.getContainerApi(regionId).get(nameWithSpaces);
         assertNotNull(container);
         assertEquals(container.getName(), nameWithSpaces);

         assertTrue(api.getContainerApi(regionId).deleteIfEmpty(nameWithSpaces));
      }
   }
View Full Code Here

   public void testListWithOptions() throws Exception {
      String lexicographicallyBeforeName = name.substring(0, name.length() - 1);
      for (String regionId : regions) {
         ListContainerOptions options = ListContainerOptions.Builder.marker(lexicographicallyBeforeName);
         Container container = api.getContainerApi(regionId).list(options).get(0);
         assertEquals(container.getName(), name);
         assertTrue(container.getObjectCount() == 0);
         assertTrue(container.getBytesUsed() == 0);
      }
   }
View Full Code Here

                                    SwiftHeaders.STATIC_WEB_ERROR, "__error.html");
         UpdateContainerOptions opts = new UpdateContainerOptions().headers(headers);

         assertNotNull(api.getContainerApi(regionId).create(name));

         Container container = api.getContainerApi(regionId).get(name);
         assertNotNull(container);
         assertEquals(container.getName(), name);
         assertTrue(container.getMetadata().isEmpty());

         assertNotNull(api.getContainerApi(regionId).update(name, opts));

         Container updatedContainer = api.getContainerApi(regionId).get(name);
         assertNotNull(updatedContainer);
         assertEquals(updatedContainer.getName(), name);
         assertEquals(updatedContainer.getMetadata().size(), 2);
         assertEquals(updatedContainer.getMetadata().get("web-index"), "__index.html");
         assertEquals(updatedContainer.getMetadata().get("web-error"), "__error.html");

         assertTrue(api.getContainerApi(regionId).deleteIfEmpty(name));
      }
   }
View Full Code Here

      }
   }

   public void testGet() throws Exception {
      for (String regionId : regions) {
         Container container = api.getContainerApi(regionId).get(name);
         assertEquals(container.getName(), name);
         assertTrue(container.getObjectCount() == 0);
         assertTrue(container.getBytesUsed() == 0);
      }
   }
View Full Code Here

         // update
         assertTrue(containerApi.updateMetadata(name, meta));
         containerHasMetadata(containerApi, name, meta);
         // delete
         assertTrue(containerApi.deleteMetadata(name, meta));
         Container container = containerApi.get(name);
         for (Entry<String, String> entry : meta.entrySet()) {
            // note keys are returned in lower-case!
            assertFalse(container.getMetadata().containsKey(entry.getKey().toLowerCase()));
         }
      }
   }
View Full Code Here

         }
      }
   }

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

      }
   }

   public void extractArchive() throws Exception {
      for (String regionId : regions) {
         ExtractArchiveResponse extractResponse = api.bulkApiInRegion(regionId).extractArchive(containerName,
               Payloads.newPayload(tarGz), "tar.gz");
         assertEquals(extractResponse.created(), OBJECT_COUNT);
         assertTrue(extractResponse.errors().isEmpty());
         assertEquals(api.containerApiInRegion(regionId).get(containerName).objectCount(), OBJECT_COUNT);

         // repeat the command
         extractResponse = api.bulkApiInRegion(regionId).extractArchive(containerName, Payloads.newPayload(tarGz),
               "tar.gz");
         assertEquals(extractResponse.created(), OBJECT_COUNT);
         assertTrue(extractResponse.errors().isEmpty());
      }
   }
View Full Code Here

      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");
         ExtractArchiveResponse response = api.bulkApiInRegion("DFW").extractArchive("myContainer",
               newByteArrayPayload(tarGz), "tar.gz");
         assertEquals(response.created(), 10);
         assertTrue(response.errors().isEmpty());

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

TOP

Related Classes of org.jclouds.openstack.swift.v1.domain.Container$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.