BAEL-3227 fixed tests
This commit is contained in:
parent
ed459a5786
commit
ed7b67f19c
@ -4,6 +4,8 @@ import org.junit.Test;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class CreateFilesUnitTest {
|
public class CreateFilesUnitTest {
|
||||||
@Test(expected = IOException.class)
|
@Test(expected = IOException.class)
|
||||||
public void whenCreatingAFileWithAbsolutePath_thenExceptionIsThrown() throws IOException {
|
public void whenCreatingAFileWithAbsolutePath_thenExceptionIsThrown() throws IOException {
|
||||||
@ -12,18 +14,24 @@ public class CreateFilesUnitTest {
|
|||||||
Files.touch(fileWithAbsolutePath);
|
Files.touch(fileWithAbsolutePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test
|
||||||
public void givenAnExistingDirectory_whenCreatingANewDirectoryAndFile_thenExceptionIsThrown() throws IOException {
|
public void givenAnExistingDirectory_whenCreatingANewDirectoryAndFile_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");
|
||||||
|
|
||||||
|
fileWithRelativePath.mkdirs();
|
||||||
Files.touch(fileWithRelativePath);
|
Files.touch(fileWithRelativePath);
|
||||||
|
|
||||||
|
assertTrue(fileWithRelativePath.exists());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IOException.class)
|
@Test
|
||||||
public void whenCreatingAFileWithFileSeparator_thenPathIsCreated() throws IOException {
|
public void whenCreatingAFileWithFileSeparator_thenFileIsCreated() throws IOException {
|
||||||
File newFile = new File("src" + File.separator + "test" + File.separator + "resources" + File.separator + "newFile.txt");
|
File newFile = new File("src" + File.separator + "test" + File.separator + "resources" + File.separator + "newFile.txt");
|
||||||
|
|
||||||
|
newFile.mkdirs();
|
||||||
Files.touch(newFile);
|
Files.touch(newFile);
|
||||||
|
|
||||||
|
assertTrue(newFile.exists());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user