improving absolute path test
This commit is contained in:
parent
0eac69ca79
commit
2a7f9f6ede
@ -9,15 +9,19 @@ import java.io.IOException;
|
|||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class CreateFilesUnitTest {
|
public class CreateFilesUnitTest {
|
||||||
@Test(expected = IOException.class)
|
@Test
|
||||||
public void whenCreatingAFileWithAbsolutePath_thenExceptionIsThrown() throws IOException {
|
public void givenAnExistingDirectory_whenCreatingAFileWithAbsolutePath_thenFileIsCreated() throws IOException {
|
||||||
File fileWithAbsolutePath = new File("/myDirectory/testFile.txt");
|
File tempDirectory = new File(System.getProperty("java.io.tmpdir"));
|
||||||
|
File fileWithAbsolutePath = new File(tempDirectory.getAbsolutePath() + "/myDirectory/testFile.txt");
|
||||||
|
|
||||||
|
fileWithAbsolutePath.mkdirs();
|
||||||
Files.touch(fileWithAbsolutePath);
|
Files.touch(fileWithAbsolutePath);
|
||||||
|
|
||||||
|
assertTrue(fileWithAbsolutePath.exists());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenAnExistingDirectory_whenCreatingANewDirectoryAndFile_thenFileIsCreated() throws IOException {
|
public void givenAnExistingDirectory_whenCreatingANewDirectoryAndFileWithRelativePath_thenFileIsCreated() throws IOException {
|
||||||
File tempDirectory = new File(System.getProperty("java.io.tmpdir"));
|
File tempDirectory = new File(System.getProperty("java.io.tmpdir"));
|
||||||
File fileWithRelativePath = new File(tempDirectory, "myDirectory/newFile.txt");
|
File fileWithRelativePath = new File(tempDirectory, "myDirectory/newFile.txt");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user