Ejemplo n.º 1
0
  public void testExtractArchive() throws Exception {
    for (String regionId : regions) {
      Payload payload = new ByteSourcePayload(ByteSource.wrap(tarGz));

      ExtractArchiveResponse extractResponse =
          getApi().getBulkApi(regionId).extractArchive(containerName, payload, "tar.gz");
      assertEquals(extractResponse.getCreated(), OBJECT_COUNT);
      assertTrue(extractResponse.getErrors().isEmpty());
      assertEquals(
          getApi().getContainerApi(regionId).get(containerName).getObjectCount(),
          Long.valueOf(OBJECT_COUNT));

      // repeat the command
      extractResponse =
          getApi().getBulkApi(regionId).extractArchive(containerName, payload, "tar.gz");
      assertEquals(extractResponse.getCreated(), OBJECT_COUNT);
      assertTrue(extractResponse.getErrors().isEmpty());
    }
  }
Ejemplo n.º 2
0
 public void extractArchiveWithoutErrors() {
   assertEquals(
       gson.fromJson(
           ""
               + "{\n"
               + "  \"Response Status\": \"201 Created\",\n"
               + "  \"Response Body\": \"\",\n"
               + "  \"Errors\": [],\n"
               + "  \"Number Files Created\": 10\n"
               + "}",
           ExtractArchiveResponse.class),
       ExtractArchiveResponse.create(10, ImmutableMap.<String, String>of()));
 }
Ejemplo n.º 3
0
 public void extractArchiveWithErrorsAndDecodesPaths() {
   assertEquals(
       gson.fromJson(
           ""
               + "{\n"
               + "  \"Response Status\": \"201 Created\",\n"
               + "  \"Response Body\": \"\",\n"
               + "  \"Errors\": [\n"
               + "    [\"/v1/12345678912345/mycontainer/home/xx%3Cyy\", \"400 Bad Request\"],\n"
               + "    [\"/v1/12345678912345/mycontainer/../image.gif\", \"400 Bad Request\"]\n"
               + "  ],\n"
               + "  \"Number Files Created\": 8\n"
               + "}",
           ExtractArchiveResponse.class),
       ExtractArchiveResponse.create(
           8,
           ImmutableMap.<String, String>builder()
               .put("/v1/12345678912345/mycontainer/home/xx<yy", "400 Bad Request")
               .put("/v1/12345678912345/mycontainer/../image.gif", "400 Bad Request")
               .build()));
 }