use of org.sonar.api.config.Settings in project sonarqube by SonarSource.
the class FileCacheProviderTest method keep_singleton_instance.
@Test
public void keep_singleton_instance() {
FileCacheProvider provider = new FileCacheProvider();
Settings settings = new MapSettings();
FileCache cache1 = provider.provide(settings);
FileCache cache2 = provider.provide(settings);
assertThat(cache1).isSameAs(cache2);
}
use of org.sonar.api.config.Settings in project sonarqube by SonarSource.
the class DefaultServerTest method invalid_startup_date_throws_exception.
@Test(expected = RuntimeException.class)
public void invalid_startup_date_throws_exception() {
Settings settings = new MapSettings();
settings.setProperty(CoreProperties.SERVER_STARTTIME, "invalid");
ScannerWsClient client = mock(ScannerWsClient.class);
DefaultServer metadata = new DefaultServer(settings, client, null);
metadata.getStartedAt();
}
use of org.sonar.api.config.Settings in project sonarqube by SonarSource.
the class DefaultServerTest method shouldLoadServerProperties.
@Test
public void shouldLoadServerProperties() {
Settings settings = new MapSettings();
settings.setProperty(CoreProperties.SERVER_ID, "123");
settings.setProperty(CoreProperties.SERVER_STARTTIME, "2010-05-18T17:59:00+0000");
settings.setProperty(CoreProperties.PERMANENT_SERVER_ID, "abcde");
ScannerWsClient client = mock(ScannerWsClient.class);
when(client.baseUrl()).thenReturn("http://foo.com");
DefaultServer metadata = new DefaultServer(settings, client, SonarRuntimeImpl.forSonarQube(Version.parse("2.2"), SonarQubeSide.SCANNER));
assertThat(metadata.getId()).isEqualTo("123");
assertThat(metadata.getVersion()).isEqualTo("2.2");
assertThat(metadata.getStartedAt()).isNotNull();
assertThat(metadata.getURL()).isEqualTo("http://foo.com");
assertThat(metadata.getPermanentServerId()).isEqualTo("abcde");
assertThat(metadata.getRootDir()).isNull();
assertThat(metadata.getDeployDir()).isNull();
assertThat(metadata.getContextPath()).isNull();
assertThat(metadata.isDev()).isFalse();
assertThat(metadata.isSecured()).isFalse();
}
use of org.sonar.api.config.Settings in project sonarqube by SonarSource.
the class ExclusionFiltersTest method match_at_least_one_inclusion.
@Test
public void match_at_least_one_inclusion() throws IOException {
Settings settings = new MapSettings();
settings.setProperty(CoreProperties.PROJECT_INCLUSIONS_PROPERTY, "**/*Dao.java,**/*Dto.java");
ExclusionFilters filter = new ExclusionFilters(new FileExclusions(settings));
filter.prepare();
IndexedFile indexedFile = new DefaultIndexedFile("foo", moduleBaseDir, "src/main/java/com/mycompany/Foo.java");
assertThat(filter.accept(indexedFile, InputFile.Type.MAIN)).isFalse();
indexedFile = new DefaultIndexedFile("foo", moduleBaseDir, "src/main/java/com/mycompany/FooDto.java");
assertThat(filter.accept(indexedFile, InputFile.Type.MAIN)).isTrue();
}
use of org.sonar.api.config.Settings in project sonarqube by SonarSource.
the class ExclusionFiltersTest method match_exclusions.
@Test
public void match_exclusions() throws IOException {
Settings settings = new MapSettings();
settings.setProperty(CoreProperties.PROJECT_INCLUSIONS_PROPERTY, "src/main/java/**/*");
settings.setProperty(CoreProperties.PROJECT_TEST_INCLUSIONS_PROPERTY, "src/test/java/**/*");
settings.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, "**/*Dao.java");
ExclusionFilters filter = new ExclusionFilters(new FileExclusions(settings));
filter.prepare();
IndexedFile indexedFile = new DefaultIndexedFile("foo", moduleBaseDir, "src/main/java/com/mycompany/FooDao.java");
assertThat(filter.accept(indexedFile, InputFile.Type.MAIN)).isFalse();
indexedFile = new DefaultIndexedFile("foo", moduleBaseDir, "src/main/java/com/mycompany/Foo.java");
assertThat(filter.accept(indexedFile, InputFile.Type.MAIN)).isTrue();
// source exclusions do not apply to tests
indexedFile = new DefaultIndexedFile("foo", moduleBaseDir, "src/test/java/com/mycompany/FooDao.java");
assertThat(filter.accept(indexedFile, InputFile.Type.TEST)).isTrue();
}
Aggregations