コード例 #1
0
 @Override
 protected void addTenObjectsUnderRoot(String containerName) throws InterruptedException {
   BlobMap blobMap = createMap(context, containerName, ListContainerOptions.NONE);
   for (int i = 0; i < 10; i++) {
     blobMap.put(i + "", blobMap.blobBuilder().payload(i + "content").build());
   }
 }
コード例 #2
0
  @Test(groups = {"integration", "live"})
  public void testPutMoreThanSingleListing()
      throws InterruptedException, ExecutionException, TimeoutException {
    if (maxResultsForTestListings() == 0) return;
    String bucketName = getContainerName();
    try {
      BlobMap map = createMap(context, bucketName);
      Builder<String> keySet = ImmutableSet.<String>builder();
      for (int i = 0; i < maxResultsForTestListings() + 1; i++) {
        keySet.add(i + "");
      }

      Map<String, Blob> newMap = Maps.newLinkedHashMap();
      for (String key : keySet.build()) {
        newMap.put(key, map.blobBuilder().payload(key).build());
      }
      map.putAll(newMap);
      newMap.clear();

      assertConsistencyAwareMapSize(map, maxResultsForTestListings() + 1);
      assertConsistencyAwareKeySetEquals(map, keySet.build());
      map.clear();
      assertConsistencyAwareMapSize(map, 0);
    } finally {
      returnContainer(bucketName);
    }
  }
コード例 #3
0
  @Override
  @Test(groups = {"integration", "live"})
  public void testEntrySet() throws IOException, InterruptedException {
    String bucketName = getContainerName();
    try {
      final BlobMap map = createMap(context, bucketName);
      putFiveStrings(map);
      assertConsistencyAwareMapSize(map, 5);
      Set<Entry<String, Blob>> entries = map.entrySet();
      assertEquals(entries.size(), 5);
      for (Entry<String, Blob> entry : entries) {
        assertEquals(
            fiveStrings.get(entry.getKey()), getContentAsStringOrNullAndClose(entry.getValue()));
        Blob blob = entry.getValue();
        blob.setPayload("");
        Payloads.calculateMD5(blob);
        entry.setValue(blob);
      }
      assertConsistencyAware(
          new Runnable() {
            public void run() {
              for (Blob blob : map.values()) {
                try {
                  assertEquals(getContentAsStringOrNullAndClose(blob), "");
                } catch (IOException e) {
                  Throwables.propagate(e);
                }
              }
            }
          });

    } finally {
      returnContainer(bucketName);
    }
  }
コード例 #4
0
 @Override
 protected void addTenObjectsUnderPrefix(String containerName, String prefix)
     throws InterruptedException {
   BlobMap blobMap = createMap(context, containerName, inDirectory(prefix));
   for (int i = 0; i < 10; i++) {
     blobMap.put(i + "", blobMap.blobBuilder().payload(i + "content").build());
   }
 }
コード例 #5
0
  @Override
  @Test(groups = {"integration", "live"})
  public void testValues() throws IOException, InterruptedException {
    String bucketName = getContainerName();
    try {
      BlobMap map = createMap(context, bucketName);

      putFiveStrings(map);
      putFiveStringsUnderPath(map);

      Collection<Blob> blobs = map.values();
      assertConsistencyAwareMapSize(map, 5);
      Set<String> blobsAsString = Sets.newLinkedHashSet();
      for (Blob blob : blobs) {
        blobsAsString.add(getContentAsStringOrNullAndClose(blob));
      }
      blobsAsString.removeAll(fiveStrings.values());
      assert blobsAsString.size() == 0 : blobsAsString.size() + ": " + blobs + ": " + blobsAsString;
    } finally {
      returnContainer(bucketName);
    }
  }
コード例 #6
0
 @Override
 public Blob apply(String arg0) {
   return map.blobBuilder().payload(arg0).build();
 }
コード例 #7
0
 protected void putFiveStringsUnderPath(BlobMap map) {
   map.putAll(Maps.transformValues(fiveStringsUnderPath, new StringToBlob(map)));
 }