* Tests parent identity
*/
public void testParent() throws FileSystemException
{
// Test when both exist
FileObject folder = getReadFolder().resolveFile("dir1");
FileObject child = folder.resolveFile("file3.txt");
assertTrue("folder exists", folder.exists());
assertTrue("child exists", child.exists());
assertSame(folder, child.getParent());
// Test when file does not exist
child = folder.resolveFile("unknown-file");
assertTrue("folder exists", folder.exists());
assertTrue("child does not exist", !child.exists());
assertSame(folder, child.getParent());
// Test when neither exists
folder = getReadFolder().resolveFile("unknown-folder");
child = folder.resolveFile("unknown-file");
assertTrue("folder does not exist", !folder.exists());
assertTrue("child does not exist", !child.exists());
assertSame(folder, child.getParent());
// Test the parent of the root of the file system
// TODO - refactor out test cases for layered vs originating fs
final FileSystem fileSystem = getReadFolder().getFileSystem();
FileObject root = fileSystem.getRoot();
if (fileSystem.getParentLayer() == null)
{
// No parent layer, so parent should be null
assertNull("root has null parent", root.getParent());
}
else
{
// Parent should be parent of parent layer.
assertSame(fileSystem.getParentLayer().getParent(), root.getParent());
}
}