@Test
public void testRenameFileWithNoAccess() throws IOException {

	final FileSystem fs = FileSystem.getLocalFileSystem();
	final File srcFile = temporaryFolder.newFile("someFile.txt");
	final File destFile = new File(temporaryFolder.newFolder(), "target");
	// we need to make the file non-modifiable so that the rename fails
	Assume.assumeTrue(srcFile.getParentFile().setWritable(false, false));
	Assume.assumeTrue(srcFile.setWritable(false, false));
	try {
		final Path srcFilePath = new Path(srcFile.toURI());
		final Path destFilePath = new Path(destFile.toURI());
		// this cannot succeed because the source folder has no permission to remove the file
		assertFalse(fs.rename(srcFilePath, destFilePath));
	}
	finally {
		// make sure we give permission back to ensure proper cleanup
		//noinspection ResultOfMethodCallIgnored
		srcFile.getParentFile().setWritable(true, false);
		//noinspection ResultOfMethodCallIgnored
		srcFile.setWritable(true, false);
	}
}