diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2015-04-23 01:11:58 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2015-08-17 23:25:20 +0200 |
commit | 548ba66a377e74e4dce35545798738509fea129b (patch) | |
tree | 442b28a565935ef58af766f0bf98b124c6089949 /org.eclipse.jgit.test | |
parent | 2e5c7c5db476a00ee89e610824f070471693ab6a (diff) | |
download | jgit-548ba66a377e74e4dce35545798738509fea129b.tar.gz jgit-548ba66a377e74e4dce35545798738509fea129b.zip |
Use NIO2 to implement FileUtils.rename() and expose options
- use NIO2's Files.move() to reimplement rename()
- provide a second method accepting CopyOptions which can be used to
request atomic move.
Change-Id: Ibcf722978e65745218a1ccda45344ca295911659
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FileUtils7Test.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FileUtils7Test.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FileUtils7Test.java index 9dc5fac5d8..4625f30683 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FileUtils7Test.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FileUtils7Test.java @@ -48,6 +48,8 @@ import static org.junit.Assert.assertTrue; import java.io.File; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.StandardCopyOption; import org.junit.After; import org.junit.Before; @@ -83,4 +85,14 @@ public class FileUtils7Test { assertTrue(dir.exists()); assertTrue(file.exists()); } + + @Test + public void testAtomicMove() throws IOException { + File src = new File(trash, "src"); + Files.createFile(src.toPath()); + File dst = new File(trash, "dst"); + FileUtils.rename(src, dst, StandardCopyOption.ATOMIC_MOVE); + assertFalse(Files.exists(src.toPath())); + assertTrue(Files.exists(dst.toPath())); + } } |