/** Test of blobExists method, of class FilesystemAsyncBlobStore. */
  public void testBlobExists() throws IOException {
    boolean result;
    String blobKey;

    // when location doesn't exists
    blobKey = TestUtils.createRandomBlobKey();
    try {
      blobStore.blobExists(CONTAINER_NAME, blobKey);
      fail();
    } catch (ContainerNotFoundException cnfe) {
      // expected
    }

    // when location exists
    blobStore.createContainerInLocation(null, CONTAINER_NAME);
    result = blobStore.blobExists(CONTAINER_NAME, blobKey);
    assertFalse(result, "Blob exists");

    // create blob
    TestUtils.createBlobAsFile(CONTAINER_NAME, blobKey, TestUtils.getImageForBlobPayload());
    result = blobStore.blobExists(CONTAINER_NAME, blobKey);
    assertTrue(result, "Blob doesn't exist");

    // complex path test
    blobKey = TestUtils.createRandomBlobKey("ss/asdas/", "");
    result = blobStore.blobExists(CONTAINER_NAME, blobKey);
    assertFalse(result, "Blob exists");
    TestUtils.createBlobAsFile(CONTAINER_NAME, blobKey, TestUtils.getImageForBlobPayload());
    result = blobStore.blobExists(CONTAINER_NAME, blobKey);
    assertTrue(result, "Blob doesn't exist");
  }
  /** Create a blob with putBlob method */
  private void putBlobAndCheckIt(String blobKey) {
    Blob blob;

    TestUtils.fileExists(TARGET_CONTAINER_NAME + File.separator + blobKey, false);

    // create the blob
    blob = createBlob(blobKey, TestUtils.getImageForBlobPayload());
    String eTag = blobStore.putBlob(CONTAINER_NAME, blob);
    assertNotNull(eTag, "putBlob result null");
    assertNotSame(eTag, "", "putBlob result empty");

    // checks if the blob exists
    TestUtils.fileExists(TARGET_CONTAINER_NAME + File.separator + blobKey, true);
  }
  public void testWritePayloadOnFile() throws IOException {
    String blobKey;
    File sourceFile;
    FilePayload filePayload;

    blobKey = TestUtils.createRandomBlobKey("writePayload-", ".img");
    sourceFile = TestUtils.getImageForBlobPayload();
    filePayload = new FilePayload(sourceFile);
    Blob blob = storageStrategy.newBlob(blobKey);
    blob.setPayload(filePayload);
    // write files
    storageStrategy.putBlob(CONTAINER_NAME, blob);
    // verify that the files is equal
    File blobFullPath = new File(TARGET_CONTAINER_NAME, blobKey);
    InputSupplier<FileInputStream> expectedInput = Files.newInputStreamSupplier(sourceFile);
    InputSupplier<FileInputStream> actualInput = Files.newInputStreamSupplier(blobFullPath);
    assertTrue(ByteStreams.equal(expectedInput, actualInput), "Files are not equal");
  }