aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch/src/test/java/org/sonar/batch/bootstrapper/LoggingConfigurationTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-batch/src/test/java/org/sonar/batch/bootstrapper/LoggingConfigurationTest.java')
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/bootstrapper/LoggingConfigurationTest.java47
1 files changed, 19 insertions, 28 deletions
diff --git a/sonar-batch/src/test/java/org/sonar/batch/bootstrapper/LoggingConfigurationTest.java b/sonar-batch/src/test/java/org/sonar/batch/bootstrapper/LoggingConfigurationTest.java
index 9b773b220e9..948fbc8177e 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/bootstrapper/LoggingConfigurationTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/bootstrapper/LoggingConfigurationTest.java
@@ -19,67 +19,58 @@
*/
package org.sonar.batch.bootstrapper;
-import org.sonar.home.log.LogListener;
-
import com.google.common.collect.Maps;
import org.junit.Test;
import java.util.Map;
-import static org.mockito.Mockito.mock;
import static org.assertj.core.api.Assertions.assertThat;
public class LoggingConfigurationTest {
@Test
public void testSetVerbose() {
- assertThat(new LoggingConfiguration(null).setVerbose(true)
+ assertThat(LoggingConfiguration.create(null).setVerbose(true)
.getSubstitutionVariable(LoggingConfiguration.PROPERTY_ROOT_LOGGER_LEVEL)).isEqualTo(LoggingConfiguration.LEVEL_ROOT_VERBOSE);
- assertThat(new LoggingConfiguration(null).setVerbose(false)
+ assertThat(LoggingConfiguration.create(null).setVerbose(false)
.getSubstitutionVariable(LoggingConfiguration.PROPERTY_ROOT_LOGGER_LEVEL)).isEqualTo(LoggingConfiguration.LEVEL_ROOT_DEFAULT);
- assertThat(new LoggingConfiguration(null).setRootLevel("ERROR")
+ assertThat(LoggingConfiguration.create(null).setRootLevel("ERROR")
.getSubstitutionVariable(LoggingConfiguration.PROPERTY_ROOT_LOGGER_LEVEL)).isEqualTo("ERROR");
}
@Test
public void shouldNotBeVerboseByDefault() {
- assertThat(new LoggingConfiguration(null)
+ assertThat(LoggingConfiguration.create(null)
.getSubstitutionVariable(LoggingConfiguration.PROPERTY_ROOT_LOGGER_LEVEL)).isEqualTo(LoggingConfiguration.LEVEL_ROOT_DEFAULT);
}
@Test
- public void test_log_listener_setter() {
- LogListener listener = mock(LogListener.class);
- assertThat(new LoggingConfiguration(null).setListener(listener).listener).isEqualTo(listener);
- }
-
- @Test
public void test_deprecated_log_properties() {
Map<String, String> properties = Maps.newHashMap();
- assertThat(new LoggingConfiguration(null).setProperties(properties)
+ assertThat(LoggingConfiguration.create(null).setProperties(properties)
.getSubstitutionVariable(LoggingConfiguration.PROPERTY_ROOT_LOGGER_LEVEL)).isEqualTo(LoggingConfiguration.LEVEL_ROOT_DEFAULT);
properties.put("sonar.verbose", "true");
- LoggingConfiguration conf = new LoggingConfiguration(null).setProperties(properties);
+ LoggingConfiguration conf = LoggingConfiguration.create(null).setProperties(properties);
assertThat(conf.getSubstitutionVariable(LoggingConfiguration.PROPERTY_ROOT_LOGGER_LEVEL)).isEqualTo(LoggingConfiguration.LEVEL_ROOT_VERBOSE);
assertThat(conf.getSubstitutionVariable(LoggingConfiguration.PROPERTY_SQL_LOGGER_LEVEL)).isEqualTo("WARN");
properties.put("sonar.verbose", "false");
- conf = new LoggingConfiguration(null).setProperties(properties);
+ conf = LoggingConfiguration.create(null).setProperties(properties);
assertThat(conf.getSubstitutionVariable(LoggingConfiguration.PROPERTY_ROOT_LOGGER_LEVEL)).isEqualTo(LoggingConfiguration.LEVEL_ROOT_DEFAULT);
assertThat(conf.getSubstitutionVariable(LoggingConfiguration.PROPERTY_SQL_LOGGER_LEVEL)).isEqualTo("WARN");
properties.put("sonar.verbose", "false");
properties.put("sonar.log.profilingLevel", "FULL");
- conf = new LoggingConfiguration(null).setProperties(properties);
+ conf = LoggingConfiguration.create(null).setProperties(properties);
assertThat(conf.getSubstitutionVariable(LoggingConfiguration.PROPERTY_ROOT_LOGGER_LEVEL)).isEqualTo("DEBUG");
assertThat(conf.getSubstitutionVariable(LoggingConfiguration.PROPERTY_SQL_LOGGER_LEVEL)).isEqualTo("TRACE");
properties.put("sonar.verbose", "false");
properties.put("sonar.log.profilingLevel", "BASIC");
- conf = new LoggingConfiguration(null).setProperties(properties);
+ conf = LoggingConfiguration.create(null).setProperties(properties);
assertThat(conf.getSubstitutionVariable(LoggingConfiguration.PROPERTY_ROOT_LOGGER_LEVEL)).isEqualTo("DEBUG");
assertThat(conf.getSubstitutionVariable(LoggingConfiguration.PROPERTY_SQL_LOGGER_LEVEL)).isEqualTo("WARN");
}
@@ -87,53 +78,53 @@ public class LoggingConfigurationTest {
@Test
public void test_log_level_property() {
Map<String, String> properties = Maps.newHashMap();
- LoggingConfiguration conf = new LoggingConfiguration(null).setProperties(properties);
+ LoggingConfiguration conf = LoggingConfiguration.create(null).setProperties(properties);
assertThat(conf.getSubstitutionVariable(LoggingConfiguration.PROPERTY_ROOT_LOGGER_LEVEL)).isEqualTo("INFO");
assertThat(conf.getSubstitutionVariable(LoggingConfiguration.PROPERTY_SQL_LOGGER_LEVEL)).isEqualTo("WARN");
properties.put("sonar.log.level", "INFO");
- conf = new LoggingConfiguration(null).setProperties(properties);
+ conf = LoggingConfiguration.create(null).setProperties(properties);
assertThat(conf.getSubstitutionVariable(LoggingConfiguration.PROPERTY_ROOT_LOGGER_LEVEL)).isEqualTo("INFO");
assertThat(conf.getSubstitutionVariable(LoggingConfiguration.PROPERTY_SQL_LOGGER_LEVEL)).isEqualTo("WARN");
properties.put("sonar.log.level", "DEBUG");
- conf = new LoggingConfiguration(null).setProperties(properties);
+ conf = LoggingConfiguration.create(null).setProperties(properties);
assertThat(conf.getSubstitutionVariable(LoggingConfiguration.PROPERTY_ROOT_LOGGER_LEVEL)).isEqualTo("DEBUG");
assertThat(conf.getSubstitutionVariable(LoggingConfiguration.PROPERTY_SQL_LOGGER_LEVEL)).isEqualTo("WARN");
properties.put("sonar.log.level", "TRACE");
- conf = new LoggingConfiguration(null).setProperties(properties);
+ conf = LoggingConfiguration.create(null).setProperties(properties);
assertThat(conf.getSubstitutionVariable(LoggingConfiguration.PROPERTY_ROOT_LOGGER_LEVEL)).isEqualTo("DEBUG");
assertThat(conf.getSubstitutionVariable(LoggingConfiguration.PROPERTY_SQL_LOGGER_LEVEL)).isEqualTo("TRACE");
}
@Test
public void testDefaultFormat() {
- assertThat(new LoggingConfiguration(null)
+ assertThat(LoggingConfiguration.create(null)
.getSubstitutionVariable(LoggingConfiguration.PROPERTY_FORMAT)).isEqualTo(LoggingConfiguration.FORMAT_DEFAULT);
}
@Test
public void testMavenFormat() {
- assertThat(new LoggingConfiguration(new EnvironmentInformation("maven", "1.0"))
+ assertThat(LoggingConfiguration.create(new EnvironmentInformation("maven", "1.0"))
.getSubstitutionVariable(LoggingConfiguration.PROPERTY_FORMAT)).isEqualTo(LoggingConfiguration.FORMAT_MAVEN);
}
@Test
public void testSetFormat() {
- assertThat(new LoggingConfiguration(null).setFormat("%d %level")
+ assertThat(LoggingConfiguration.create(null).setFormat("%d %level")
.getSubstitutionVariable(LoggingConfiguration.PROPERTY_FORMAT)).isEqualTo("%d %level");
}
@Test
public void shouldNotSetBlankFormat() {
- assertThat(new LoggingConfiguration(null).setFormat(null)
+ assertThat(LoggingConfiguration.create(null).setFormat(null)
.getSubstitutionVariable(LoggingConfiguration.PROPERTY_FORMAT)).isEqualTo(LoggingConfiguration.FORMAT_DEFAULT);
- assertThat(new LoggingConfiguration(null).setFormat("")
+ assertThat(LoggingConfiguration.create(null).setFormat("")
.getSubstitutionVariable(LoggingConfiguration.PROPERTY_FORMAT)).isEqualTo(LoggingConfiguration.FORMAT_DEFAULT);
- assertThat(new LoggingConfiguration(null).setFormat(" ")
+ assertThat(LoggingConfiguration.create(null).setFormat(" ")
.getSubstitutionVariable(LoggingConfiguration.PROPERTY_FORMAT)).isEqualTo(LoggingConfiguration.FORMAT_DEFAULT);
}
}