Example #1
0
  @Test
  public void deleteInodeTest() throws Exception {
    InodeTree.CreatePathResult createResult = mTree.createPath(NESTED_URI, sNestedDirectoryOptions);
    List<Inode> created = createResult.getCreated();

    // all inodes under root
    List<Inode> inodes = mTree.getInodeChildrenRecursive((InodeDirectory) mTree.getInodeById(0));
    // /nested, /nested/test
    Assert.assertEquals(2, inodes.size());
    // delete the nested inode
    mTree.deleteInode(created.get(created.size() - 1));
    inodes = mTree.getInodeChildrenRecursive((InodeDirectory) mTree.getInodeById(0));
    // only /nested left
    Assert.assertEquals(1, inodes.size());
  }
Example #2
0
  @Test
  public void getInodeByInvalidIdTest() throws Exception {
    mThrown.expect(FileDoesNotExistException.class);
    mThrown.expectMessage("Inode id 1 does not exist");

    mTree.getInodeById(1);
  }
Example #3
0
  @Test
  public void getInodeChildrenRecursiveTest() throws Exception {
    mTree.createPath(TEST_URI, sDirectoryOptions);
    mTree.createPath(NESTED_URI, sNestedDirectoryOptions);
    // add nested file
    mTree.createPath(NESTED_FILE_URI, sNestedFileOptions);

    // all inodes under root
    List<Inode> inodes = mTree.getInodeChildrenRecursive((InodeDirectory) mTree.getInodeById(0));
    // /test, /nested, /nested/test, /nested/test/file
    Assert.assertEquals(4, inodes.size());
  }
Example #4
0
  @Test
  public void getPathTest() throws Exception {
    Inode root = mTree.getInodeById(0);
    // test root path
    Assert.assertEquals(new TachyonURI("/"), mTree.getPath(root));

    // test one level
    InodeTree.CreatePathResult createResult = mTree.createPath(TEST_URI, sDirectoryOptions);
    List<Inode> created = createResult.getCreated();
    Assert.assertEquals(new TachyonURI("/test"), mTree.getPath(created.get(created.size() - 1)));

    // test nesting
    createResult = mTree.createPath(NESTED_URI, sNestedDirectoryOptions);
    created = createResult.getCreated();
    Assert.assertEquals(
        new TachyonURI("/nested/test"), mTree.getPath(created.get(created.size() - 1)));
  }