Package org.sonar.api.resources

Examples of org.sonar.api.resources.Languages


  @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.
    LanguagesReferential languages = new DefaultLanguagesReferential(new Languages(new MockLanguage("java", "java"), new MockLanguage("abap")));

    // No side-effect on non-ABAP projects
    LanguageDetection detection = new LanguageDetection(new Settings(), languages);
    assertThat(detection.language(newInputFile("abc"))).isNull();
    assertThat(detection.language(newInputFile("abc.abap"))).isNull();
View Full Code Here


    assertThat(detection.language(newInputFile("abc.java"))).isEqualTo("abap");
  }

  @Test
  public void force_language_using_deprecated_property() throws Exception {
    LanguagesReferential languages = new DefaultLanguagesReferential(new Languages(new MockLanguage("java", "java"), new MockLanguage("php", "php")));

    Settings settings = new Settings();
    settings.setProperty(CoreProperties.PROJECT_LANGUAGE_PROPERTY, "java");
    LanguageDetection detection = new LanguageDetection(settings, languages);
    assertThat(detection.language(newInputFile("abc"))).isNull();
View Full Code Here

  @Test
  public void fail_if_invalid_language() throws Exception {
    thrown.expect(MessageException.class);
    thrown.expectMessage("No language is installed with key 'unknown'. Please update property 'sonar.language'");

    LanguagesReferential languages = new DefaultLanguagesReferential(new Languages(new MockLanguage("java", "java"), new MockLanguage("php", "php")));
    Settings settings = new Settings();
    settings.setProperty(CoreProperties.PROJECT_LANGUAGE_PROPERTY, "unknown");
    new LanguageDetection(settings, languages);
  }
View Full Code Here

    new LanguageDetection(settings, languages);
  }

  @Test
  public void fail_if_conflicting_language_suffix() throws Exception {
    LanguagesReferential languages = new DefaultLanguagesReferential(new Languages(new MockLanguage("xml", "xhtml"), new MockLanguage("web", "xhtml")));
    LanguageDetection detection = new LanguageDetection(new Settings(), languages);
    try {
      detection.language(newInputFile("abc.xhtml"));
      fail();
    } catch (MessageException e) {
View Full Code Here

    }
  }

  @Test
  public void solve_conflict_using_filepattern() throws Exception {
    LanguagesReferential languages = new DefaultLanguagesReferential(new Languages(new MockLanguage("xml", "xhtml"), new MockLanguage("web", "xhtml")));

    Settings settings = new Settings();
    settings.setProperty("sonar.lang.patterns.xml", "xml/**");
    settings.setProperty("sonar.lang.patterns.web", "web/**");
    LanguageDetection detection = new LanguageDetection(settings, languages);
View Full Code Here

    assertThat(detection.language(newInputFile("web/abc.xhtml"))).isEqualTo("web");
  }

  @Test
  public void fail_if_conflicting_filepattern() throws Exception {
    LanguagesReferential languages = new DefaultLanguagesReferential(new Languages(new MockLanguage("abap", "abap"), new MockLanguage("cobol", "cobol")));
    Settings settings = new Settings();
    settings.setProperty("sonar.lang.patterns.abap", "*.abap,*.txt");
    settings.setProperty("sonar.lang.patterns.cobol", "*.cobol,*.txt");

    LanguageDetection detection = new LanguageDetection(settings, languages);
View Full Code Here

TOP

Related Classes of org.sonar.api.resources.Languages

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.