Refactor FileTest

This commit is contained in:
Grzegorz Piwowarek 2016-11-01 12:03:22 +00:00
parent f7525b82fb
commit 0532349b4e
1 changed files with 8 additions and 19 deletions

View File

@ -1,20 +1,14 @@
package com.baeldung.java.nio2;
import org.junit.Test;
import java.io.IOException;
import java.nio.file.*;
import java.util.UUID;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.nio.file.DirectoryNotEmptyException;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.UUID;
import org.junit.Test;
public class FileTest {
private static final String HOME = System.getProperty("user.home");
@ -158,16 +152,11 @@ public class FileTest {
}
@Test
@Test(expected = NoSuchFileException.class)
public void givenInexistentFile_whenDeleteFails_thenCorrect() throws IOException {
Path p = Paths.get(HOME + "/inexistentFile.txt");
assertFalse(Files.exists(p));
try {
Files.delete(p);
} catch (IOException e) {
assertTrue(e instanceof NoSuchFileException);
}
Files.delete(p);
}
@Test