Skip to content

Commit 0c7f708

Browse files
author
eugenp
committed
IO work
1 parent a48a53a commit 0c7f708

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

File renamed without changes.

core-java/src/test/java/org/baeldung/java/io/JavaFileIntegrationTest.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,26 @@ public class JavaFileIntegrationTest {
1515
// create a file
1616

1717
@Test
18-
public void givenUsingJDK6_whenCreatingFile_thenCorrect() throws IOException {
18+
public final void givenUsingJDK6_whenCreatingFile_thenCorrect() throws IOException {
1919
final File newFile = new File("src/test/resources/newFile_jdk6.txt");
2020
newFile.createNewFile();
2121
}
2222

2323
@Test
24-
public void givenUsingJDK7nio2_whenCreatingFile_thenCorrect() throws IOException {
24+
public final void givenUsingJDK7nio2_whenCreatingFile_thenCorrect() throws IOException {
2525
final Path newFilePath = Paths.get("src/test/resources/newFile_jdk7.txt");
2626
Files.createFile(newFilePath);
2727
}
2828

2929
@Test
30-
public void givenUsingApache_whenCreatingFile_thenCorrect() throws IOException {
30+
public final void givenUsingApache_whenCreatingFile_thenCorrect() throws IOException {
3131
FileUtils.touch(new File("src/test/resources/newFile_commonsio.txt"));
3232
}
3333

3434
// move a file
3535

3636
@Test
37-
public void givenUsingJDK6_whenMovingFile_thenCorrect() throws IOException {
37+
public final void givenUsingJDK6_whenMovingFile_thenCorrect() throws IOException {
3838
final File fileToMove = new File("src/test/resources/toMoveFile_jdk6.txt");
3939
fileToMove.exists();
4040
final File destDir = new File("src/test/resources/");
@@ -47,7 +47,7 @@ public void givenUsingJDK6_whenMovingFile_thenCorrect() throws IOException {
4747
}
4848

4949
@Test
50-
public void givenUsingJDK7Nio2_whenMovingFile_thenCorrect() throws IOException {
50+
public final void givenUsingJDK7Nio2_whenMovingFile_thenCorrect() throws IOException {
5151
final Path fileToMovePath = Files.createFile(Paths.get("src/test/resources/fileToMove.txt"));
5252
final Path dirPath = Paths.get("src/test/resources/");
5353
final Path targetPath = Files.createDirectory(dirPath);
@@ -56,7 +56,7 @@ public void givenUsingJDK7Nio2_whenMovingFile_thenCorrect() throws IOException {
5656
}
5757

5858
@Test
59-
public void givenUsingGuava_whenMovingFile_thenCorrect() throws IOException {
59+
public final void givenUsingGuava_whenMovingFile_thenCorrect() throws IOException {
6060
final File fileToMove = new File("src/test/resources/fileToMove.txt");
6161
fileToMove.createNewFile();
6262
final File destDir = new File("src/test/resources/");
@@ -66,10 +66,16 @@ public void givenUsingGuava_whenMovingFile_thenCorrect() throws IOException {
6666
}
6767

6868
@Test
69-
public void givenUsingApache_whenMovingFile_thenCorrect() throws IOException {
69+
public final void givenUsingApache_whenMovingFile_thenCorrect() throws IOException {
7070
FileUtils.moveFile(FileUtils.getFile("src/test/resources/fileToMove.txt"), FileUtils.getFile("src/test/resources/fileMoved.txt"));
7171
}
7272

73+
@Test
74+
public final void givenUsingApache_whenMovingFileApproach2_thenCorrect() throws IOException {
75+
FileUtils.touch(new File("src/test/resources/fileToMove.txt"));
76+
FileUtils.moveFileToDirectory(FileUtils.getFile("src/test/resources/fileToMove.txt"), FileUtils.getFile("src/main/resources/"), true);
77+
}
78+
7379
// rename a file
7480

7581
}

0 commit comments

Comments
 (0)