コード例 #1
0
  public void testDirectoryExists() throws IOException {
    final String SUBDIRECTORY_NAME = "ad" + FS + "sda" + FS + "asd";
    boolean result;

    result = storageStrategy.directoryExists(CONTAINER_NAME, null);
    assertFalse(result, "Directory exist");

    // create the container
    TestUtils.createContainerAsDirectory(CONTAINER_NAME);
    // check if exists
    result = storageStrategy.directoryExists(CONTAINER_NAME, null);
    assertTrue(result, "Directory doesn't exist");
    result = storageStrategy.directoryExists(CONTAINER_NAME + FS, null);
    assertTrue(result, "Directory doesn't exist");

    result = storageStrategy.directoryExists(CONTAINER_NAME, SUBDIRECTORY_NAME);
    assertFalse(result, "Directory exist");

    // create subdirs inside the container
    TestUtils.createContainerAsDirectory(CONTAINER_NAME + FS + SUBDIRECTORY_NAME);
    // check if exists
    result = storageStrategy.directoryExists(CONTAINER_NAME, SUBDIRECTORY_NAME);
    assertTrue(result, "Directory doesn't exist");
    result = storageStrategy.directoryExists(CONTAINER_NAME, FS + SUBDIRECTORY_NAME);
    assertTrue(result, "Directory doesn't exist");
    result = storageStrategy.directoryExists(CONTAINER_NAME, SUBDIRECTORY_NAME + FS);
    assertTrue(result, "Directory doesn't exist");
    result = storageStrategy.directoryExists(CONTAINER_NAME + FS, FS + SUBDIRECTORY_NAME);
    assertTrue(result, "Directory doesn't exist");
  }
コード例 #2
0
  public void testDeleteDirectory() throws IOException {
    TestUtils.createContainerAsDirectory(CONTAINER_NAME);
    TestUtils.createBlobsInContainer(
        CONTAINER_NAME,
        new String[] {
          TestUtils.createRandomBlobKey("lev1" + FS + "lev2" + FS + "lev3" + FS, ".txt"),
          TestUtils.createRandomBlobKey("lev1" + FS + "lev2" + FS + "lev4" + FS, ".jpg")
        });

    // delete directory in different ways
    storageStrategy.deleteDirectory(CONTAINER_NAME, "lev1" + FS + "lev2" + FS + "lev4");
    TestUtils.directoryExists(
        TARGET_CONTAINER_NAME + FS + "lev1" + FS + "lev2" + FS + "lev4", false);
    TestUtils.directoryExists(TARGET_CONTAINER_NAME + FS + "lev1" + FS + "lev2", true);

    storageStrategy.deleteDirectory(CONTAINER_NAME, "lev1" + FS + "lev2" + FS + "lev3" + FS);
    TestUtils.directoryExists(
        TARGET_CONTAINER_NAME + FS + "lev1" + FS + "lev2" + FS + "lev3", false);
    TestUtils.directoryExists(TARGET_CONTAINER_NAME + FS + "lev1" + FS + "lev2", true);

    storageStrategy.deleteDirectory(CONTAINER_NAME, FS + "lev1");
    TestUtils.directoryExists(TARGET_CONTAINER_NAME + FS + "lev1", false);
    TestUtils.directoryExists(TARGET_CONTAINER_NAME, true);

    // delete the directory and all the files inside
    TestUtils.createBlobsInContainer(
        CONTAINER_NAME,
        new String[] {
          TestUtils.createRandomBlobKey("lev1" + FS + "lev2" + FS + "lev3" + FS, ".txt"),
          TestUtils.createRandomBlobKey("lev1" + FS + "lev2" + FS + "lev4" + FS, ".jpg")
        });
    storageStrategy.deleteDirectory(CONTAINER_NAME, null);
    TestUtils.directoryExists(TARGET_CONTAINER_NAME, false);
  }
コード例 #3
0
  /** Test of containerExists method, of class FilesystemAsyncBlobStore. */
  public void testContainerExists() throws IOException {
    boolean result;

    result = blobStore.containerExists(CONTAINER_NAME);
    assertFalse(result, "Container exists");

    // create container
    TestUtils.createContainerAsDirectory(CONTAINER_NAME);

    result = blobStore.containerExists(CONTAINER_NAME);
    assertTrue(result, "Container doesn't exist");
  }