diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2013-01-07 18:27:30 +0100 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2013-01-07 18:27:30 +0100 |
commit | 5aeb92cac38f2f71e810b2405b08c1c2c8b62e4c (patch) | |
tree | f19ec30fd67afc3f060e966d53f051d18dc558bc /src/test/java | |
parent | f6b9f918c292a88c8069effd198061c042197b56 (diff) | |
download | sonar-scanner-cli-5aeb92cac38f2f71e810b2405b08c1c2c8b62e4c.tar.gz sonar-scanner-cli-5aeb92cac38f2f71e810b2405b08c1c2c8b62e4c.zip |
SONARPLUGINS-2285 Improve validation of (tests/binaries/libraries) folders
Diffstat (limited to 'src/test/java')
-rw-r--r-- | src/test/java/org/sonar/runner/internal/batch/SonarProjectBuilderTest.java | 53 |
1 files changed, 42 insertions, 11 deletions
diff --git a/src/test/java/org/sonar/runner/internal/batch/SonarProjectBuilderTest.java b/src/test/java/org/sonar/runner/internal/batch/SonarProjectBuilderTest.java index 8f2143e..4cb65ab 100644 --- a/src/test/java/org/sonar/runner/internal/batch/SonarProjectBuilderTest.java +++ b/src/test/java/org/sonar/runner/internal/batch/SonarProjectBuilderTest.java @@ -69,7 +69,7 @@ public class SonarProjectBuilderTest { @Test public void shouldFailIfUnexistingSourceDirectory() throws IOException { thrown.expect(RunnerException.class); - thrown.expectMessage("The folder 'unexisting-source-dir' does not exist for 'com.foo.project' project (base directory = " + thrown.expectMessage("The folder 'unexisting-source-dir' does not exist for 'com.foo.project' (base directory = " + TestUtils.getResource(this.getClass(), "simple-project-with-unexisting-source-dir") + ")"); loadProjectDefinition("simple-project-with-unexisting-source-dir"); @@ -324,6 +324,47 @@ public class SonarProjectBuilderTest { } @Test + public void shouldFailIfUnexistingSourceFolderInheritedInMultimodule() throws IOException { + thrown.expect(RunnerException.class); + thrown.expectMessage("The folder 'unexisting-source-dir' does not exist for 'com.foo.project:module1' (base directory = " + + TestUtils.getResource(this.getClass(), "multi-module-with-unexisting-source-dir").getAbsolutePath() + File.separator + "module1)"); + + loadProjectDefinition("multi-module-with-unexisting-source-dir"); + } + + @Test + public void shouldNotFailIfUnexistingTestBinLibFolderInheritedInMultimodule() throws IOException { + loadProjectDefinition("multi-module-with-unexisting-test-bin-lib-dir"); + } + + @Test + public void shouldFailIfExplicitUnexistingTestFolder() throws IOException { + thrown.expect(RunnerException.class); + thrown.expectMessage("The folder 'tests' does not exist for 'module1' (base directory = " + + TestUtils.getResource(this.getClass(), "multi-module-with-explicit-unexisting-test-dir").getAbsolutePath() + File.separator + "module1)"); + + loadProjectDefinition("multi-module-with-explicit-unexisting-test-dir"); + } + + @Test + public void shouldFailIfExplicitUnexistingBinaryFolder() throws IOException { + thrown.expect(RunnerException.class); + thrown.expectMessage("The folder 'bin' does not exist for 'module1' (base directory = " + + TestUtils.getResource(this.getClass(), "multi-module-with-explicit-unexisting-binary-dir").getAbsolutePath() + File.separator + "module1)"); + + loadProjectDefinition("multi-module-with-explicit-unexisting-binary-dir"); + } + + @Test + public void shouldFailIfExplicitUnmatchingLibFolder() throws IOException { + thrown.expect(RunnerException.class); + thrown.expectMessage("No files matching pattern \"lib/*.jar\" in directory \"" + + TestUtils.getResource(this.getClass(), "multi-module-with-explicit-unexisting-lib").getAbsolutePath() + File.separator + "module1\""); + + loadProjectDefinition("multi-module-with-explicit-unexisting-lib"); + } + + @Test public void shouldExtractModuleProperties() { Properties props = new Properties(); props.setProperty("sources", "src/main/java"); @@ -397,16 +438,6 @@ public class SonarProjectBuilderTest { } @Test - public void shouldThrowExceptionWhenNoFilesMatchingPattern() throws Exception { - File baseDir = TestUtils.getResource(this.getClass(), "shouldFilterFiles"); - - thrown.expect(RunnerException.class); - thrown.expectMessage("No files matching pattern \"*.jar\" in directory"); - - SonarProjectBuilder.getLibraries(baseDir, "*.jar"); - } - - @Test public void shouldGetRelativeFile() { assertThat(SonarProjectBuilder.getFileFromPath("shouldGetFile/foo.properties", TestUtils.getResource(this.getClass(), "/"))) .isEqualTo(TestUtils.getResource(this.getClass(), "shouldGetFile/foo.properties")); |