use of org.sonar.process.Props in project sonarqube by SonarSource.
the class LogbackHelperTest method apply_does_not_set_level_if_sonar_global_level_is_TRACE.
@Test
public void apply_does_not_set_level_if_sonar_global_level_is_TRACE() {
Properties properties = new Properties();
properties.setProperty("sonar.log.level", Level.TRACE.toString());
assertThat(underTest.getRootContext().getLogger("fii").getLevel()).isNull();
LoggerContext context = underTest.apply(newLogLevelConfig().offUnlessTrace("fii").build(), new Props(properties));
assertThat(context.getLogger("fii").getLevel()).isNull();
}
use of org.sonar.process.Props in project sonarqube by SonarSource.
the class LogbackHelperTest method apply_set_level_to_OFF_if_sonar_global_level_is_not_set.
@Test
public void apply_set_level_to_OFF_if_sonar_global_level_is_not_set() {
LoggerContext context = underTest.apply(newLogLevelConfig().offUnlessTrace("fii").build(), new Props(new Properties()));
assertThat(context.getLogger("fii").getLevel()).isEqualTo(Level.OFF);
}
use of org.sonar.process.Props in project sonarqube by SonarSource.
the class LogbackHelperTest method log_to_console_setting_disabled.
@Test
public void log_to_console_setting_disabled() {
Properties properties = new Properties();
properties.setProperty("sonar.log.console", "false");
assertThat(underTest.isAllLogsToConsoleEnabled(new Props(properties))).isFalse();
}
use of org.sonar.process.Props in project sonarqube by SonarSource.
the class EsSettingsTest method configureAuthentication_givenClusterSearchPasswordProvidedButKeystorePathMissing_throwException.
@Test
public void configureAuthentication_givenClusterSearchPasswordProvidedButKeystorePathMissing_throwException() throws Exception {
Props props = minProps(true);
props.set(CLUSTER_SEARCH_PASSWORD.getKey(), "qwerty");
EsSettings settings = new EsSettings(props, new EsInstallation(props), system);
assertThatThrownBy(settings::build).isInstanceOf(MessageException.class).hasMessage("CLUSTER_ES_KEYSTORE property need to be set when using elastic search authentication");
}
use of org.sonar.process.Props in project sonarqube by SonarSource.
the class EsSettingsTest method minProps.
private Props minProps(boolean cluster, @Nullable String host, @Nullable String port) throws IOException {
File homeDir = temp.newFolder();
Props props = new Props(new Properties());
ServiceLoaderWrapper serviceLoaderWrapper = mock(ServiceLoaderWrapper.class);
when(serviceLoaderWrapper.load()).thenReturn(ImmutableSet.of());
new ProcessProperties(serviceLoaderWrapper).completeDefaults(props);
props.set(PATH_HOME.getKey(), homeDir.getAbsolutePath());
props.set(Property.CLUSTER_ENABLED.getKey(), Boolean.toString(cluster));
if (cluster) {
ofNullable(host).ifPresent(h -> props.set(CLUSTER_NODE_ES_HOST.getKey(), h));
ofNullable(port).ifPresent(p -> props.set(CLUSTER_NODE_ES_PORT.getKey(), p));
ofNullable(host).ifPresent(h -> props.set(CLUSTER_NODE_SEARCH_HOST.getKey(), h));
ofNullable(port).ifPresent(p -> props.set(CLUSTER_NODE_SEARCH_PORT.getKey(), p));
ofNullable(port).ifPresent(h -> props.set(CLUSTER_ES_HOSTS.getKey(), h));
} else {
ofNullable(host).ifPresent(h -> props.set(SEARCH_HOST.getKey(), h));
ofNullable(port).ifPresent(p -> props.set(SEARCH_PORT.getKey(), p));
}
return props;
}
Aggregations