core/src/test/java/org/apache/commons/vfs2/test/ProviderRenameTests.java
/**
     * Tests create-delete-create-a-file sequence on the same file system.
     */
Tests create-delete-create-a-file sequence on the same file system.
Tests create - delete - create - a - file sequence on the same file system .
public void testRenameFile() throws Exception
    {
        final FileObject scratchFolder = createScratchFolder();
        final FileObject file = scratchFolder.resolveFile("file1.txt");
        assertTrue(!file.exists());
        final String content = "Here is some sample content for the file.  Blah Blah Blah.";
        final OutputStream os = file.getContent().getOutputStream();
        try
        {
            os.write(content.getBytes("utf-8"));
        }
        finally
        {
            os.close();
        }
        assertSameContent(content, file);
        FileObject fileMove = scratchFolder.resolveFile("file1move.txt");
        assertTrue(!fileMove.exists());
        file.moveTo(fileMove);
        assertTrue(!file.exists());
        assertTrue(fileMove.exists());
        assertSameContent(content, fileMove);
        assertTrue(fileMove.exists());
        assertTrue(fileMove.delete());
    }
public void testRenameFile ( ) throws Exception { final FileObject scratchFolder = createScratchFolder ( ) ; final FileObject file = scratchFolder . resolveFile ( "file1.txt" ) ; assertTrue ( ! file . exists ( ) ) ; final String content = "Here is some sample content for the file.  Blah Blah Blah." ; final OutputStream os = file . getContent ( ) . getOutputStream ( ) ; try { os . write ( content . getBytes ( "utf-8" ) ) ; } finally { os . close ( ) ; } assertSameContent ( content , file ) ; FileObject fileMove = scratchFolder . resolveFile ( "file1move.txt" ) ; assertTrue ( ! fileMove . exists ( ) ) ; file . moveTo ( fileMove ) ; assertTrue ( ! file . exists ( ) ) ; assertTrue ( fileMove . exists ( ) ) ; assertSameContent ( content , fileMove ) ; assertTrue ( fileMove . exists ( ) ) ; assertTrue ( fileMove . delete ( ) ) ; }
Tests create-delete-create-a-file sequence on the same file system.
Tests create - delete - create - a - file sequence on the same file system .
// Create direct child of the test folder // Create the source file // Make sure we can move the new file to another file on the same filesystem // Delete the file.