use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.
the class CoverageExclusionsTest method prepare.
@Before
public void prepare() {
settings = new MapSettings(new PropertyDefinitions(ExclusionProperties.all()));
coverageExclusions = new CoverageExclusions(settings);
}
use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.
the class LanguageDetectionTest method solve_conflict_using_filepattern.
@Test
public void solve_conflict_using_filepattern() throws Exception {
LanguagesRepository languages = new DefaultLanguagesRepository(new Languages(new MockLanguage("xml", "xhtml"), new MockLanguage("web", "xhtml")));
Settings settings = new MapSettings();
settings.setProperty("sonar.lang.patterns.xml", "xml/**");
settings.setProperty("sonar.lang.patterns.web", "web/**");
LanguageDetection detection = new LanguageDetection(settings, languages);
assertThat(detection.language(newIndexedFile("xml/abc.xhtml"))).isEqualTo("xml");
assertThat(detection.language(newIndexedFile("web/abc.xhtml"))).isEqualTo("web");
}
use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.
the class LanguageDetectionTest method fail_if_conflicting_language_suffix.
@Test
public void fail_if_conflicting_language_suffix() throws Exception {
LanguagesRepository languages = new DefaultLanguagesRepository(new Languages(new MockLanguage("xml", "xhtml"), new MockLanguage("web", "xhtml")));
LanguageDetection detection = new LanguageDetection(new MapSettings(), languages);
try {
detection.language(newIndexedFile("abc.xhtml"));
fail();
} catch (MessageException e) {
assertThat(e.getMessage()).contains("Language of file 'abc.xhtml' can not be decided as the file matches patterns of both ").contains("sonar.lang.patterns.web : **/*.xhtml").contains("sonar.lang.patterns.xml : **/*.xhtml");
}
}
use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.
the class LanguageDetectionTest method fail_if_invalid_language.
@Test
public void fail_if_invalid_language() {
thrown.expect(MessageException.class);
thrown.expectMessage("You must install a plugin that supports the language 'unknown'");
LanguagesRepository languages = new DefaultLanguagesRepository(new Languages(new MockLanguage("java", "java"), new MockLanguage("php", "php")));
Settings settings = new MapSettings();
settings.setProperty(CoreProperties.PROJECT_LANGUAGE_PROPERTY, "unknown");
new LanguageDetection(settings, languages);
}
use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.
the class LanguageDetectionTest method search_by_file_extension.
@Test
public void search_by_file_extension() throws Exception {
LanguagesRepository languages = new DefaultLanguagesRepository(new Languages(new MockLanguage("java", "java", "jav"), new MockLanguage("cobol", "cbl", "cob")));
LanguageDetection detection = new LanguageDetection(new MapSettings(), languages);
assertThat(detection.language(newIndexedFile("Foo.java"))).isEqualTo("java");
assertThat(detection.language(newIndexedFile("src/Foo.java"))).isEqualTo("java");
assertThat(detection.language(newIndexedFile("Foo.JAVA"))).isEqualTo("java");
assertThat(detection.language(newIndexedFile("Foo.jav"))).isEqualTo("java");
assertThat(detection.language(newIndexedFile("Foo.Jav"))).isEqualTo("java");
assertThat(detection.language(newIndexedFile("abc.cbl"))).isEqualTo("cobol");
assertThat(detection.language(newIndexedFile("abc.CBL"))).isEqualTo("cobol");
assertThat(detection.language(newIndexedFile("abc.php"))).isNull();
assertThat(detection.language(newIndexedFile("abc"))).isNull();
}
Aggregations