Skip to content

Commit 01d7ec2

Browse files
committed
Check that newFolder fails for read only parent
1 parent 67d424b commit 01d7ec2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/test/java/org/junit/rules/TemporaryFolderUsageTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,17 @@ public void newFolderWithGivenFolderThrowsIOExceptionIfFileExists() throws IOExc
9393
thrown.expectMessage("could not create a folder with the path 'level1'");
9494
tempFolder.newFolder("level1");
9595
}
96+
97+
@Test
98+
public void newFolderWithGivenFolderThrowsIOExceptionWhenFolderCannotBeCreated() throws IOException {
99+
tempFolder.create();
100+
assertTrue("Could not make folder " + tempFolder.getRoot() + " read only.",
101+
tempFolder.getRoot().setReadOnly());
102+
103+
thrown.expect(IOException.class);
104+
thrown.expectMessage("could not create a folder with the path 'level1'");
105+
tempFolder.newFolder("level1");
106+
}
96107

97108
@Test
98109
public void newFolderWithPathStartingWithFileSeparatorThrowsIOException()

0 commit comments

Comments
 (0)