diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2013-10-21 15:17:01 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2013-10-21 15:17:01 +0200 |
commit | 0d8f6d214dbada7cb8f8be037c26d6a411a11572 (patch) | |
tree | d528feadf9b654e768c4a2a194a9012f92cf9ca4 /sonar-plugin-api/src | |
parent | 8842c50c19054ced2809a8ebdde854a83312a8d2 (diff) | |
download | sonarqube-0d8f6d214dbada7cb8f8be037c26d6a411a11572.tar.gz sonarqube-0d8f6d214dbada7cb8f8be037c26d6a411a11572.zip |
Improve code coverage
Diffstat (limited to 'sonar-plugin-api/src')
-rw-r--r-- | sonar-plugin-api/src/main/java/org/sonar/api/utils/internal/DefaultTempFolder.java | 2 | ||||
-rw-r--r-- | sonar-plugin-api/src/test/java/org/sonar/api/utils/internal/DefaultTempFolderTest.java | 26 |
2 files changed, 27 insertions, 1 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/internal/DefaultTempFolder.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/internal/DefaultTempFolder.java index a1862ede487..80665d76374 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/internal/DefaultTempFolder.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/internal/DefaultTempFolder.java @@ -67,7 +67,7 @@ public class DefaultTempFolder implements TempFolder { try { FileUtils.forceMkdir(dir); } catch (IOException e) { - throw new IllegalStateException("Unable to create temp directory in " + dir, e); + throw new IllegalStateException("Failed to create temp directory in " + dir, e); } return dir; } diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/internal/DefaultTempFolderTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/internal/DefaultTempFolderTest.java index 07f6d7545c6..4c4ae168e04 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/internal/DefaultTempFolderTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/internal/DefaultTempFolderTest.java @@ -60,4 +60,30 @@ public class DefaultTempFolderTest { new TempFolderCleaner(tempFolder).stop(); assertThat(rootTempFolder).doesNotExist(); } + + @Test + public void createTempFolderWithInvalidName() throws Exception { + File rootTempFolder = temp.newFolder(); + DefaultTempFolder tempFolder = new DefaultTempFolder(rootTempFolder); + String tooLong = "tooooolong"; + for (int i = 0; i < 50; i++) { + tooLong += "tooooolong"; + } + throwable.expect(IllegalStateException.class); + throwable.expectMessage("Failed to create temp directory"); + tempFolder.newDir(tooLong); + } + + @Test + public void createNewFileWithInvalidName() throws Exception { + File rootTempFolder = temp.newFolder(); + DefaultTempFolder tempFolder = new DefaultTempFolder(rootTempFolder); + String tooLong = "tooooolong"; + for (int i = 0; i < 50; i++) { + tooLong += "tooooolong"; + } + throwable.expect(IllegalStateException.class); + throwable.expectMessage("Failed to create temp file"); + tempFolder.newFile(tooLong, ".txt"); + } } |