use of org.sonar.scanner.repository.language.DefaultLanguagesRepository in project sonarqube by SonarSource.
the class LanguageDetectionTest method force_language_using_deprecated_property.
@Test
public void force_language_using_deprecated_property() throws Exception {
LanguagesRepository languages = new DefaultLanguagesRepository(new Languages(new MockLanguage("java", "java"), new MockLanguage("php", "php")));
Settings settings = new MapSettings();
settings.setProperty(CoreProperties.PROJECT_LANGUAGE_PROPERTY, "java");
LanguageDetection detection = new LanguageDetection(settings, languages);
assertThat(detection.language(newIndexedFile("abc"))).isNull();
assertThat(detection.language(newIndexedFile("abc.php"))).isNull();
assertThat(detection.language(newIndexedFile("abc.java"))).isEqualTo("java");
assertThat(detection.language(newIndexedFile("src/abc.java"))).isEqualTo("java");
}
use of org.sonar.scanner.repository.language.DefaultLanguagesRepository in project sonarqube by SonarSource.
the class LanguageDetectionTest method language_with_no_extension.
@Test
public void language_with_no_extension() throws Exception {
// abap does not declare any file extensions.
// When analyzing an ABAP project, then all source files must be parsed.
LanguagesRepository languages = new DefaultLanguagesRepository(new Languages(new MockLanguage("java", "java"), new MockLanguage("abap")));
// No side-effect on non-ABAP projects
LanguageDetection detection = new LanguageDetection(new MapSettings(), languages);
assertThat(detection.language(newIndexedFile("abc"))).isNull();
assertThat(detection.language(newIndexedFile("abc.abap"))).isNull();
assertThat(detection.language(newIndexedFile("abc.java"))).isEqualTo("java");
Settings settings = new MapSettings();
settings.setProperty(CoreProperties.PROJECT_LANGUAGE_PROPERTY, "abap");
detection = new LanguageDetection(settings, languages);
assertThat(detection.language(newIndexedFile("abc"))).isEqualTo("abap");
assertThat(detection.language(newIndexedFile("abc.txt"))).isEqualTo("abap");
assertThat(detection.language(newIndexedFile("abc.java"))).isEqualTo("abap");
}
use of org.sonar.scanner.repository.language.DefaultLanguagesRepository in project sonarqube by SonarSource.
the class LanguageDetectionTest method plugin_can_declare_a_file_extension_twice_for_case_sensitivity.
@Test
public void plugin_can_declare_a_file_extension_twice_for_case_sensitivity() {
LanguagesRepository languages = new DefaultLanguagesRepository(new Languages(new MockLanguage("abap", "abap", "ABAP")));
LanguageDetection detection = new LanguageDetection(settings.asConfig(), languages);
assertThat(detectLanguageKey(detection, "abc.abap")).isEqualTo("abap");
}
use of org.sonar.scanner.repository.language.DefaultLanguagesRepository 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.scanner.repository.language.DefaultLanguagesRepository in project sonarqube by SonarSource.
the class LanguageDetectionTest method should_not_fail_if_no_language.
@Test
public void should_not_fail_if_no_language() {
LanguageDetection detection = spy(new LanguageDetection(settings.asConfig(), new DefaultLanguagesRepository(new Languages())));
assertThat(detectLanguageKey(detection, "Foo.java")).isNull();
}
Aggregations