Package org.sonar.api.config

Examples of org.sonar.api.config.Settings


  }

  @Test
  public void number_of_threads_should_not_be_negative() throws Exception {
    try {
      Settings settings = new Settings();
      settings.setProperty(ViolationConverters.THREADS_PROPERTY, -2);
      new ViolationConverters(settings).numberOfThreads();
      fail();
    } catch (IllegalArgumentException e) {
      assertThat(e.getMessage()).isEqualTo("Bad value of " + ViolationConverters.THREADS_PROPERTY + ": -2");
    }
View Full Code Here


    Callable<Object> callable = mock(Callable.class);
    when(callable.call()).thenThrow(new IllegalStateException("Need to cry"));

    List<Callable<Object>> callables = Lists.newArrayList(callable);
    try {
      new ViolationConverters(new Settings()).doExecute(new FakeTimerTask(), callables);
      fail();
    } catch (Exception e) {
      assertThat(ExceptionUtils.getRootCause(e).getMessage()).isEqualTo("Need to cry");
    }
View Full Code Here

    this.sut = new ProjectPurgeTask(dao, periodCleaner, profiler);
  }

  @Test
  public void no_profiling_when_property_is_false() throws Exception {
    Settings settings = mock(Settings.class);
    when(settings.getBoolean(CoreProperties.PROFILING_LOG_PROPERTY)).thenReturn(false);

    sut.purge(mock(DbSession.class), mock(PurgeConfiguration.class), settings);

    verify(profiler, never()).dump(anyLong(), any(Logger.class));
  }
View Full Code Here

    verify(profiler, never()).dump(anyLong(), any(Logger.class));
  }

  @Test
  public void profiling_when_property_is_true() throws Exception {
    Settings settings = mock(Settings.class);
    when(settings.getBoolean(CoreProperties.PROFILING_LOG_PROPERTY)).thenReturn(true);

    sut.purge(mock(DbSession.class), mock(PurgeConfiguration.class), settings);

    verify(profiler, times(1)).dump(anyLong(), any(Logger.class));
  }
View Full Code Here

  }

  @Test
  public void shouldNotDeleteHistoricalDataOfDirectories() {
    PurgeDao purgeDao = mock(PurgeDao.class);
    Settings settings = new Settings(new PropertyDefinitions(DbCleanerProperties.all()));
    settings.setProperty(DbCleanerConstants.PROPERTY_CLEAN_DIRECTORY, "false");
    DefaultPurgeTask task = new DefaultPurgeTask(purgeDao, resourceDao, settings, mock(DefaultPeriodCleaner.class), mock(PurgeProfiler.class));

    task.purge(1L);

    verify(purgeDao).purge(argThat(new ArgumentMatcher<PurgeConfiguration>() {
View Full Code Here

  }

  @Test
  public void shouldDeleteHistoricalDataOfDirectoriesByDefault() {
    PurgeDao purgeDao = mock(PurgeDao.class);
    Settings settings = new Settings(new PropertyDefinitions(DbCleanerProperties.all()));
    DefaultPurgeTask task = new DefaultPurgeTask(purgeDao, resourceDao, settings, mock(DefaultPeriodCleaner.class), mock(PurgeProfiler.class));

    task.purge(1L);

    verify(purgeDao).purge(argThat(new ArgumentMatcher<PurgeConfiguration>() {
View Full Code Here

  @Test
  public void shouldNotFailOnErrors() {
    PurgeDao purgeDao = mock(PurgeDao.class);
    when(purgeDao.purge(any(PurgeConfiguration.class))).thenThrow(new RuntimeException());
    DefaultPurgeTask task = new DefaultPurgeTask(purgeDao, resourceDao, new Settings(), mock(DefaultPeriodCleaner.class), mock(PurgeProfiler.class));

    task.purge(1L);

    verify(purgeDao, times(1)).purge(any(PurgeConfiguration.class));
  }
View Full Code Here

  @Test
  public void shouldDumpProfiling() {
    PurgeConfiguration conf = new PurgeConfiguration(1L, new String[0], 30);
    PurgeDao purgeDao = mock(PurgeDao.class);
    when(purgeDao.purge(conf)).thenThrow(new RuntimeException());
    Settings settings = new Settings(new PropertyDefinitions(DbCleanerProperties.all()));
    settings.setProperty(CoreProperties.PROFILING_LOG_PROPERTY, true);
    PurgeProfiler profiler = mock(PurgeProfiler.class);

    DefaultPurgeTask task = new DefaultPurgeTask(purgeDao, resourceDao, settings, mock(DefaultPeriodCleaner.class), profiler);
    task.purge(1L);
View Full Code Here

public class DefaultDatabaseTest {

  @Test
  public void shouldLoadDefaultValues() {
    DefaultDatabase db = new DefaultDatabase(new Settings());
    db.initSettings();

    Properties props = db.getProperties();
    assertThat(props.getProperty("sonar.jdbc.username")).isEqualTo("sonar");
    assertThat(props.getProperty("sonar.jdbc.password")).isEqualTo("sonar");
View Full Code Here

    assertThat(db.toString()).isEqualTo("Database[jdbc:h2:tcp://localhost/sonar]");
  }

  @Test
  public void shouldSupportDeprecatedUserProperty() {
    Settings settings = new Settings();
    settings.setProperty("sonar.jdbc.user", "me");

    DefaultDatabase db = new DefaultDatabase(settings);
    db.initSettings();
    Properties props = db.getProperties();
View Full Code Here

TOP

Related Classes of org.sonar.api.config.Settings

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.