/**
* Tests file creation
*/
public void testFileCreate() throws Exception
{
FileObject scratchFolder = createScratchFolder();
// Create direct child of the test folder
FileObject file = scratchFolder.resolveFile("file1.txt");
assertTrue(!file.exists());
file.createFile();
assertTrue(file.exists());
assertSame(FileType.FILE, file.getType());
assertEquals(0, file.getContent().getSize());
assertFalse(file.isHidden());
assertTrue(file.isReadable());
assertTrue(file.isWriteable());
// Create direct child of the test folder - special name
file = scratchFolder.resolveFile("file1%25.txt");
assertTrue(!file.exists());
file.createFile();
assertTrue(file.exists());
assertSame(FileType.FILE, file.getType());
assertEquals(0, file.getContent().getSize());
assertFalse(file.isHidden());
assertTrue(file.isReadable());
assertTrue(file.isWriteable());
// Create a descendant, where the intermediate folders don't exist
file = scratchFolder.resolveFile("dir1/dir1/file1.txt");
assertTrue(!file.exists());
assertTrue(!file.getParent().exists());
assertTrue(!file.getParent().getParent().exists());
file.createFile();
assertTrue(file.exists());
assertSame(FileType.FILE, file.getType());
assertEquals(0, file.getContent().getSize());
assertTrue(file.getParent().exists());
assertTrue(file.getParent().getParent().exists());
assertFalse(file.getParent().isHidden());
assertFalse(file.getParent().getParent().isHidden());
// Test creating a file that already exists
assertTrue(file.exists());
file.createFile();
assertTrue(file.exists());
assertTrue(file.isReadable());
assertTrue(file.isWriteable());
}