Improve test (#10480)

This commit is contained in:
Atul Mohan 2020-10-07 08:40:02 -05:00 committed by GitHub
parent e9e7d82714
commit 0ab8b6e0a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

View File

@ -103,12 +103,14 @@ public class FileUtilsTest
@Test
public void testCreateTempDirNonexistentBase()
{
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage("java.io.tmpdir (/nonexistent) does not exist");
final String oldJavaTmpDir = System.getProperty("java.io.tmpdir");
final String nonExistentDir = oldJavaTmpDir + "/nonexistent";
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage(StringUtils.format("java.io.tmpdir (%s) does not exist", nonExistentDir));
try {
System.setProperty("java.io.tmpdir", "/nonexistent");
System.setProperty("java.io.tmpdir", nonExistentDir);
FileUtils.createTempDir();
}
finally {