コード例 #1
0
  @Test(timeout = 2000)
  public void should_check_url() {
    when(conf.getThreadCount()).thenReturn(1);
    when(conf.getUrl()).thenReturn("scm:url");

    scmActivitySensor.analyse(project, context);

    verify(urlChecker).check("scm:url");
  }
コード例 #2
0
  @Test
  public void shouldOverrideMavenUrl() {
    when(mavenConf.getUrl()).thenReturn("scm:svn:http:readonly");
    settings.setProperty(ScmActivityPlugin.URL, "scm:svn:http:override");

    assertThat(scmConfiguration.getUrl()).isEqualTo("scm:svn:http:override");
  }
コード例 #3
0
  @Test
  public void shouldNotGetMavenDeveloperUrlIfNoCredentials() {
    when(mavenConf.getDeveloperUrl()).thenReturn("scm:svn:https:writable");
    when(mavenConf.getUrl()).thenReturn("scm:svn:https:readonly");

    assertThat(scmConfiguration.getUrl()).isEqualTo("scm:svn:https:readonly");
  }
コード例 #4
0
  @Test
  public void should_guess_by_default() {
    when(scmUrlGuess.guess()).thenReturn("scm:svn:guessed");
    when(mavenConf.getUrl()).thenReturn("scm:svn:http:readonly");

    assertThat(scmConfiguration.getUrl()).isEqualTo("scm:svn:guessed");
  }
コード例 #5
0
  @Test
  public void should_disable_guess_with_hidden_configuration() {
    settings.setProperty("sonar.scm.hidden.guess", false);
    when(scmUrlGuess.guess()).thenReturn("scm:svn:guessed");
    when(mavenConf.getUrl()).thenReturn("scm:svn:http:readonly");

    assertThat(scmConfiguration.getUrl()).isEqualTo("scm:svn:http:readonly");
  }
コード例 #6
0
  @Test
  public void should_guess_url_only_once() {
    when(scmUrlGuess.guess()).thenReturn("scm:svn:guessed");

    assertThat(scmConfiguration.getUrl()).isEqualTo("scm:svn:guessed");
    assertThat(scmConfiguration.getUrl()).isEqualTo("scm:svn:guessed");
    verify(scmUrlGuess, times(1)).guess();
  }
コード例 #7
0
  @Test
  public void should_execute() {
    when(conf.isEnabled()).thenReturn(true);

    boolean shouldExecute = scmActivitySensor.shouldExecuteOnProject(project);

    assertThat(shouldExecute).isTrue();
  }
コード例 #8
0
  @Test
  public void should_not_execute_if_disabled() {
    when(conf.isEnabled()).thenReturn(false);

    boolean shouldExecute = scmActivitySensor.shouldExecuteOnProject(project);

    assertThat(shouldExecute).isFalse();
  }
コード例 #9
0
  @Test
  public void shouldGetMavenDeveloperUrlIfCredentials() {
    when(mavenConf.getDeveloperUrl()).thenReturn("scm:svn:https:writable");
    settings.setProperty(ScmActivityPlugin.USER, "godin");
    settings.setProperty(ScmActivityPlugin.PASSWORD, "pass");

    assertThat(scmConfiguration.getUrl()).isEqualTo("scm:svn:https:writable");
  }
コード例 #10
0
  @Test
  public void should_fail_on_invalid_thread_count() {
    settings.setProperty(ScmActivityPlugin.THREAD_COUNT, 0);

    exception.expect(SonarException.class);
    exception.expectMessage(
        "SCM Activity Plugin is configured to use [0] thread(s). The minimum is 1.");

    scmConfiguration.getThreadCount();
  }
コード例 #11
0
  @Test
  public void should_carry_on_after_error() {
    InputFile first = file("source.java");
    InputFile second = file("UNKNOWN.java");
    when(conf.getThreadCount()).thenReturn(1);
    fs.add(first);
    fs.add(second);
    when(context.getResource(any(org.sonar.api.resources.File.class))).thenReturn(file);
    when(blameVersionSelector.detect(file, first, context)).thenThrow(new RuntimeException("BUG"));
    when(blameVersionSelector.detect(file, second, context)).thenReturn(measureUpdate);

    scmActivitySensor.analyse(project, context);

    verify(measureUpdate).execute(timeMachine, context);
  }
コード例 #12
0
  @Test
  public void should_execute_measure_update_for_known_files() {
    InputFile source = file("source.java");
    InputFile test = file("UNKNOWN.java");
    when(conf.getThreadCount()).thenReturn(1);
    fs.add(source);
    fs.add(test);
    when(blameVersionSelector.detect(
            any(org.sonar.api.resources.File.class), eq(source), eq(context)))
        .thenReturn(measureUpdate);
    when(context.getResource(any(org.sonar.api.resources.File.class)))
        .thenReturn(file)
        .thenReturn(null);
    scmActivitySensor.analyse(project, context);

    verify(measureUpdate, only()).execute(timeMachine, context);
  }
コード例 #13
0
  @Test
  public void shouldReturnPerforceClientSpec() {
    settings.setProperty(ScmActivityPlugin.PERFORCE_CLIENTSPEC_NAME, "myclientspec");

    assertThat(scmConfiguration.getPerforceClientspecName()).isEqualTo("myclientspec");
  }
コード例 #14
0
  @Test
  public void shouldGetMavenUrlIfNoDeveloperUrl() {
    when(mavenConf.getUrl()).thenReturn("scm:svn:http:readonly");

    assertThat(scmConfiguration.getUrl()).isEqualTo("scm:svn:http:readonly");
  }
コード例 #15
0
  @Test
  public void should_guess_url_if_nothing_configured() {
    when(scmUrlGuess.guess()).thenReturn("scm:svn:guessed");

    assertThat(scmConfiguration.getUrl()).isEqualTo("scm:svn:guessed");
  }
コード例 #16
0
 @Test
 public void should_get_default_thread_count() {
   assertThat(scmConfiguration.getThreadCount()).isEqualTo(4);
 }
コード例 #17
0
  @Test
  public void should_use_single_thread() {
    settings.setProperty(ScmActivityPlugin.THREAD_COUNT, 1);

    assertThat(scmConfiguration.getThreadCount()).isEqualTo(1);
  }
コード例 #18
0
 @Test
 public void should_be_enabled_by_default() {
   assertThat(scmConfiguration.isEnabled()).isTrue();
 }
コード例 #19
0
  @Test
  public void should_disable() {
    settings.setProperty(ScmActivityPlugin.ENABLED, false);

    assertThat(scmConfiguration.isEnabled()).isFalse();
  }
コード例 #20
0
  @Test
  public void shouldReturnPassword() {
    settings.setProperty(ScmActivityPlugin.PASSWORD, "pass");

    assertThat(scmConfiguration.getPassword()).isEqualTo("pass");
  }
コード例 #21
0
  @Test
  public void shouldReturnUrlFromConfiguration() {
    settings.setProperty(ScmActivityPlugin.URL, "http://test");

    assertThat(scmConfiguration.getUrl()).isEqualTo("http://test");
  }
コード例 #22
0
  @Test
  public void shouldReturnUsername() {
    settings.setProperty(ScmActivityPlugin.USER, "godin");

    assertThat(scmConfiguration.getUser()).isEqualTo("godin");
  }
コード例 #23
0
  @Test
  public void should_accept_thread_count_too_high() {
    settings.setProperty(ScmActivityPlugin.THREAD_COUNT, 1000);

    assertThat(scmConfiguration.getThreadCount()).isEqualTo(1000);
  }
コード例 #24
0
  @Test
  public void should_get_maven_url_in_non_maven_environment() {
    scmConfiguration = new ScmConfiguration(settings, scmUrlGuess);

    assertThat(scmConfiguration.getUrl()).isNull();
  }
コード例 #25
0
  @Test
  public void should_get_empty_scm_provider() {
    when(mavenConf.getUrl()).thenReturn(" ");

    assertThat(scmConfiguration.getScmProvider()).isNull();
  }
コード例 #26
0
  @Test
  public void shouldGetScmProvider() {
    when(mavenConf.getUrl()).thenReturn("scm:svn:http:foo");

    assertThat(scmConfiguration.getScmProvider()).isEqualTo("svn");
  }