diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2014-07-04 10:54:28 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2014-07-04 10:57:49 +0200 |
commit | 87dbec69eeca5f8a94ed08e9cc9df588dc89a770 (patch) | |
tree | 15d70ff9b820031b2b7ca473c407e5a88c2b548f /sonar-batch/src/test/java/org/sonar/batch | |
parent | e7e0038abbd71c6a2df8c4721a6295588ee3176a (diff) | |
download | sonarqube-87dbec69eeca5f8a94ed08e9cc9df588dc89a770.tar.gz sonarqube-87dbec69eeca5f8a94ed08e9cc9df588dc89a770.zip |
SONAR-5433 Do not loose exception when indexing FS
Diffstat (limited to 'sonar-batch/src/test/java/org/sonar/batch')
-rw-r--r-- | sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/FileSystemMediumTest.java | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/FileSystemMediumTest.java b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/FileSystemMediumTest.java index aafeada87cf..10fbfd2263f 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/FileSystemMediumTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/FileSystemMediumTest.java @@ -23,10 +23,13 @@ import com.google.common.collect.ImmutableMap; import org.apache.commons.io.FileUtils; import org.junit.After; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; import org.sonar.api.batch.fs.InputFile; import org.sonar.api.rule.RuleKey; +import org.sonar.api.utils.MessageException; import org.sonar.batch.mediumtest.AnalyzerMediumTester; import org.sonar.batch.mediumtest.AnalyzerMediumTester.TaskResult; import org.sonar.batch.mediumtest.xoo.plugin.XooPlugin; @@ -39,9 +42,12 @@ import static org.fest.assertions.Assertions.assertThat; public class FileSystemMediumTest { - @org.junit.Rule + @Rule public TemporaryFolder temp = new TemporaryFolder(); + @Rule + public ExpectedException thrown = ExpectedException.none(); + public AnalyzerMediumTester tester = AnalyzerMediumTester.builder() .registerPlugin("xoo", new XooPlugin()) .registerLanguage(new Xoo()) @@ -141,4 +147,22 @@ public class FileSystemMediumTest { assertThat(result.inputFiles()).hasSize(4); } + @Test + public void failForDuplicateInputFile() throws IOException { + File srcDir = new File(baseDir, "src"); + srcDir.mkdir(); + + File xooFile = new File(srcDir, "sample.xoo"); + FileUtils.write(xooFile, "Sample xoo\ncontent"); + + thrown.expect(MessageException.class); + thrown.expectMessage("can't be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test files"); + tester.newTask() + .properties(builder + .put("sonar.sources", "src,src/sample.xoo") + .build()) + .start(); + + } + } |