@Override protected BlobMap createMap(BlobStoreContext context, String bucket) { return createMap(context, bucket, maxResults(maxResultsForTestListings())); }
@Override @Test(groups = { "integration", "live" }) public void testValues() throws IOException, InterruptedException { String bucketName = getContainerName(); try { BlobMap map = createMap(view, 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); } }
@Test(groups = { "integration", "live" }) public void testPutAll() throws InterruptedException, ExecutionException, TimeoutException { String bucketName = getContainerName(); try { Map<String, Blob> map = createMap(view, bucketName); ImmutableMap.Builder<String, Blob> newMap = ImmutableMap.builder(); for (Map.Entry<String, InputStream> entry : fiveInputs.entrySet()) { String key = entry.getKey(); newMap.put( key, view.getBlobStore().blobBuilder(key).payload(entry.getValue()) .contentLength((long) fiveBytes.get(key).length).build()); } map.putAll(newMap.build()); assertConsistencyAwareMapSize(map, 5); assertConsistencyAwareKeySetEquals(map, ImmutableSet.copyOf(fiveInputs.keySet())); fourLeftRemovingOne(map); } finally { returnContainer(bucketName); } }
String bucketName = getContainerName(); try { final BlobMap map = createMap(view, bucketName); putFiveStrings(map); assertConsistencyAwareMapSize(map, 5);
@Override protected void addTenObjectsUnderRoot(String containerName) throws InterruptedException { BlobMap blobMap = createMap(view, containerName, ListContainerOptions.NONE); for (int i = 0; i < 10; i++) { blobMap.put(i + "", blobMap.blobBuilder().name(i + "").payload(i + "content").build()); } } }
@Test(groups = { "integration", "live" }) public void testPutMoreThanSingleListing() throws InterruptedException, ExecutionException, TimeoutException { if (maxResultsForTestListings() == 0) return; String bucketName = getContainerName(); try { BlobMap map = createMap(view, bucketName); Builder<String> keySet = ImmutableSet.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().name(key).payload(key).build()); } map.putAll(newMap); newMap.clear(); assertConsistencyAwareMapSize(map, maxResultsForTestListings() + 1); assertConsistencyAwareKeySetEquals(map, keySet.build()); map.clear(); assertConsistencyAwareMapSize(map, 0); } finally { returnContainer(bucketName); } }
@Test(groups = { "integration", "live" }) public void testRemove() throws InterruptedException, ExecutionException, TimeoutException, IOException { String bucketName = getContainerName(); try { Map<String, Blob> map = createMap(view, bucketName); putStringWithMD5(map, "one", "two"); assertConsistencyAwareContentEquals(map, "one", "two"); // TODO track how often this occurs and potentially update map implementation assertConsistencyAwareRemoveEquals(map, "one", null); assertConsistencyAwareGetEquals(map, "one", null); assertConsistencyAwareKeySize(map, 0); } finally { returnContainer(bucketName); } }
@Override protected void addTenObjectsUnderPrefix(String containerName, String prefix) throws InterruptedException { BlobMap blobMap = createMap(view, containerName, inDirectory(prefix)); for (int i = 0; i < 10; i++) { blobMap.put(i + "", blobMap.blobBuilder().name(i + "").payload(i + "content").build()); } }
@Test(groups = { "integration", "live" }) public void testContains() throws InterruptedException, ExecutionException, TimeoutException, IOException { String bucketName = getContainerName(); try { Map<String, Blob> map = createMap(view, bucketName); putStringWithMD5(map, "one", "apple"); Blob blob = view.getBlobStore().blobBuilder("one").payload("apple").calculateMD5().build(); assertConsistencyAwareContainsValue(map, blob); } finally { returnContainer(bucketName); } }
@Test(groups = { "integration", "live" }) public void testPut() throws IOException, InterruptedException { String bucketName = getContainerName(); try { Map<String, Blob> map = createMap(view, bucketName); Blob blob = view.getBlobStore().blobBuilder("one").payload(Strings2.toInputStream("apple")).calculateMD5() .build(); Blob old = map.put(blob.getMetadata().getName(), blob); getOneReturnsAppleAndOldValueIsNull(map, old); blob.setPayload(Strings2.toInputStream("bear")); Payloads.calculateMD5(blob); Blob apple = map.put(blob.getMetadata().getName(), blob); getOneReturnsBearAndOldValueIsApple(map, apple); } finally { returnContainer(bucketName); } }