File tree Expand file tree Collapse file tree
core-java/src/test/java/com/baeldung/java/nio2 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package com .baeldung .java .nio2 ;
22
3- import static org .junit .Assert .assertFalse ;
4- import static org .junit .Assert .assertTrue ;
3+ import org .junit .Test ;
54
65import java .io .IOException ;
7- import java .nio .file .DirectoryNotEmptyException ;
8- import java .nio .file .FileAlreadyExistsException ;
9- import java .nio .file .Files ;
10- import java .nio .file .NoSuchFileException ;
11- import java .nio .file .Path ;
12- import java .nio .file .Paths ;
13- import java .nio .file .StandardCopyOption ;
6+ import java .nio .file .*;
147import java .util .UUID ;
158
16- import org .junit .Test ;
9+ import static org .junit .Assert .assertFalse ;
10+ import static org .junit .Assert .assertTrue ;
1711
1812public class FileTest {
1913 private static final String HOME = System .getProperty ("user.home" );
@@ -158,16 +152,11 @@ public void givenPath_whenFailsToDeleteNonEmptyDir_thenCorrect() throws IOExcept
158152
159153 }
160154
161- @ Test
155+ @ Test ( expected = NoSuchFileException . class )
162156 public void givenInexistentFile_whenDeleteFails_thenCorrect () throws IOException {
163157 Path p = Paths .get (HOME + "/inexistentFile.txt" );
164158 assertFalse (Files .exists (p ));
165- try {
166- Files .delete (p );
167- } catch (IOException e ) {
168- assertTrue (e instanceof NoSuchFileException );
169- }
170-
159+ Files .delete (p );
171160 }
172161
173162 @ Test
You can’t perform that action at this time.
0 commit comments