Search in sources :

Example 51 with MapSettings

use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.

the class DefaultDatabaseTest method shouldLoadDefaultValues.

@Test
public void shouldLoadDefaultValues() {
    DefaultDatabase db = new DefaultDatabase(logbackHelper, new MapSettings());
    db.initSettings();
    Properties props = db.getProperties();
    assertThat(props.getProperty("sonar.jdbc.url")).isEqualTo("jdbc:h2:tcp://localhost/sonar");
    assertThat(props.getProperty("sonar.jdbc.driverClassName")).isEqualTo("org.h2.Driver");
    assertThat(db.toString()).isEqualTo("Database[jdbc:h2:tcp://localhost/sonar]");
}
Also used : MapSettings(org.sonar.api.config.MapSettings) Properties(java.util.Properties) Test(org.junit.Test)

Example 52 with MapSettings

use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.

the class DefaultDatabaseTest method shouldStart.

@Test
public void shouldStart() {
    Settings settings = new MapSettings();
    settings.setProperty("sonar.jdbc.url", "jdbc:h2:mem:sonar");
    settings.setProperty("sonar.jdbc.driverClassName", "org.h2.Driver");
    settings.setProperty("sonar.jdbc.username", "sonar");
    settings.setProperty("sonar.jdbc.password", "sonar");
    settings.setProperty("sonar.jdbc.maxActive", "1");
    DefaultDatabase db = new DefaultDatabase(logbackHelper, settings);
    db.start();
    db.stop();
    assertThat(db.getDialect().getId()).isEqualTo("h2");
    assertThat(((BasicDataSource) db.getDataSource()).getMaxActive()).isEqualTo(1);
}
Also used : MapSettings(org.sonar.api.config.MapSettings) BasicDataSource(org.apache.commons.dbcp.BasicDataSource) Settings(org.sonar.api.config.Settings) MapSettings(org.sonar.api.config.MapSettings) Test(org.junit.Test)

Example 53 with MapSettings

use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.

the class DefaultDatabaseTest method shouldGuessDialectFromUrl.

@Test
public void shouldGuessDialectFromUrl() {
    Settings settings = new MapSettings();
    settings.setProperty("sonar.jdbc.url", "jdbc:postgresql://localhost/sonar");
    DefaultDatabase database = new DefaultDatabase(logbackHelper, settings);
    database.initSettings();
    assertThat(database.getDialect().getId()).isEqualTo(PostgreSql.ID);
}
Also used : MapSettings(org.sonar.api.config.MapSettings) Settings(org.sonar.api.config.Settings) MapSettings(org.sonar.api.config.MapSettings) Test(org.junit.Test)

Example 54 with MapSettings

use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.

the class PurgeConfigurationTest method do_not_delete_directory_by_default.

@Test
public void do_not_delete_directory_by_default() {
    Settings settings = new MapSettings();
    settings.setProperty(PurgeConstants.PROPERTY_CLEAN_DIRECTORY, false);
    settings.setProperty(PurgeConstants.DAYS_BEFORE_DELETING_CLOSED_ISSUES, 5);
    Date now = new Date();
    PurgeConfiguration underTest = PurgeConfiguration.newDefaultPurgeConfiguration(settings, new IdUuidPair(42L, "any-uuid"), Collections.emptyList());
    assertThat(underTest.scopesWithoutHistoricalData()).contains(Scopes.FILE).doesNotContain(Scopes.DIRECTORY);
    assertThat(underTest.maxLiveDateOfClosedIssues(now)).isEqualTo(DateUtils.addDays(now, -5));
}
Also used : MapSettings(org.sonar.api.config.MapSettings) Settings(org.sonar.api.config.Settings) MapSettings(org.sonar.api.config.MapSettings) Date(java.util.Date) Test(org.junit.Test)

Example 55 with MapSettings

use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.

the class PurgeConfigurationTest method delete_directory_if_in_settings.

@Test
public void delete_directory_if_in_settings() {
    Settings settings = new MapSettings();
    settings.setProperty(PurgeConstants.PROPERTY_CLEAN_DIRECTORY, true);
    PurgeConfiguration underTest = PurgeConfiguration.newDefaultPurgeConfiguration(settings, new IdUuidPair(42L, "any-uuid"), Collections.emptyList());
    assertThat(underTest.scopesWithoutHistoricalData()).contains(Scopes.DIRECTORY, Scopes.FILE);
}
Also used : MapSettings(org.sonar.api.config.MapSettings) Settings(org.sonar.api.config.Settings) MapSettings(org.sonar.api.config.MapSettings) Test(org.junit.Test)

Aggregations

MapSettings (org.sonar.api.config.MapSettings)98 Test (org.junit.Test)75 Settings (org.sonar.api.config.Settings)36 Before (org.junit.Before)20 URI (java.net.URI)13 Languages (org.sonar.api.resources.Languages)9 DefaultLanguagesRepository (org.sonar.scanner.repository.language.DefaultLanguagesRepository)9 LanguagesRepository (org.sonar.scanner.repository.language.LanguagesRepository)8 File (java.io.File)7 SensorStorage (org.sonar.api.batch.sensor.internal.SensorStorage)7 FileExclusions (org.sonar.api.scan.filesystem.FileExclusions)6 Properties (java.util.Properties)5 IndexedFile (org.sonar.api.batch.fs.IndexedFile)5 DefaultFileSystem (org.sonar.api.batch.fs.internal.DefaultFileSystem)5 DefaultIndexedFile (org.sonar.api.batch.fs.internal.DefaultIndexedFile)5 PropertyDefinitions (org.sonar.api.config.PropertyDefinitions)5 InputFile (org.sonar.api.batch.fs.InputFile)4 InputStream (java.io.InputStream)3 Description (org.hamcrest.Description)3 CoreProperties (org.sonar.api.CoreProperties)3