public void testCopyFile() throws Exception { File fromDir = createTempDirectory(); File toDir = createTempDirectory(); VirtualFile fromVDir = LocalFileSystem.getInstance() .findFileByPath(fromDir.getPath().replace(File.separatorChar, '/')); VirtualFile toVDir = LocalFileSystem.getInstance() .findFileByPath(toDir.getPath().replace(File.separatorChar, '/')); assertNotNull(fromVDir); assertNotNull(toVDir); final VirtualFile fileToCopy = fromVDir.createChildData(this, "temp_file"); final byte[] byteContent = {0, 1, 2, 3}; fileToCopy.setBinaryContent(byteContent); final String newName = "new_temp_file"; final VirtualFile copy = fileToCopy.copy(this, toVDir, newName); assertEquals(newName, copy.getName()); assertTrue(Arrays.equals(byteContent, copy.contentsToByteArray())); }