]> source.dussan.org Git - sonarqube.git/commitdiff
Use INFO level by default in unit tests
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 1 Feb 2016 22:09:09 +0000 (23:09 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 2 Feb 2016 08:27:11 +0000 (09:27 +0100)
server/sonar-process/src/test/resources/logback-test.xml
server/sonar-search/src/test/resources/logback-test.xml
sonar-application/src/test/resources/logback-test.xml
sonar-batch/src/test/resources/logback-test.xml
sonar-plugin-api/src/main/java/org/sonar/api/utils/log/LogTester.java
sonar-plugin-api/src/test/java/org/sonar/api/utils/log/ConsoleLoggersTest.java
sonar-plugin-api/src/test/java/org/sonar/api/utils/log/LogTesterTest.java

index f2d5a6a466fb5b412f58b8c82564a23501c858e3..9c9ff1aab017be0aac4976882b55a95a180767c5 100644 (file)
@@ -7,7 +7,7 @@
     </encoder>
   </appender>
 
-  <root level="debug">
+  <root level="INFO">
     <appender-ref ref="STDOUT"/>
   </root>
 </configuration>
index ff2270cc122edabd0f127b1b50ef6dd01ea2f678..df0bb26d4072be51c9af7496b6ab9251f185aae1 100644 (file)
@@ -31,7 +31,7 @@
   </appender>
 
   <root>
-    <level value="DEBUG"/>
+    <level value="INFO"/>
     <appender-ref ref="CONSOLE"/>
   </root>
 
index f62e5c2b41d4dda0931a5c79af25d7113d17aff4..4c62d576dee82f0496ce0df3af4315968afc5d90 100644 (file)
@@ -11,7 +11,7 @@
   </appender>
 
   <root>
-    <level value="DEBUG"/>
+    <level value="INFO"/>
     <appender-ref ref="CONSOLE"/>
   </root>
 
index 304e617b1c30895c2d4390fa51e7eb09217b831b..da6be3344a29d417201d5ec2ee8522c9890222c8 100644 (file)
@@ -35,7 +35,7 @@
   </logger>
 
   <root>
-    <level value="DEBUG"/>
+    <level value="INFO"/>
     <appender-ref ref="STDOUT"/>
   </root>
 
index 4290cc6d16bee8a390b9b18dc2d0648faf2f3b13..25bd90bc6695880e5621b36f0a2eeba143dacf74 100644 (file)
@@ -19,9 +19,8 @@
  */
 package org.sonar.api.utils.log;
 
-import org.junit.rules.ExternalResource;
-
 import java.util.List;
+import org.junit.rules.ExternalResource;
 
 /**
  * <b>For tests only</b>
@@ -58,12 +57,8 @@ import java.util.List;
  */
 public class LogTester extends ExternalResource {
 
-  private LoggerLevel initialLevel;
-
   @Override
   protected void before() throws Throwable {
-    initialLevel = Loggers.getFactory().getLevel();
-
     // this shared instance breaks compatibility with parallel execution of tests
     LogInterceptors.set(new ListInterceptor());
     setLevel(LoggerLevel.INFO);
@@ -72,7 +67,7 @@ public class LogTester extends ExternalResource {
   @Override
   protected void after() {
     LogInterceptors.set(NullInterceptor.NULL_INSTANCE);
-    setLevel(initialLevel);
+    setLevel(LoggerLevel.INFO);
   }
 
   LoggerLevel getLevel() {
@@ -81,7 +76,7 @@ public class LogTester extends ExternalResource {
 
   /**
    * Enable/disable debug logs. Info, warn and error logs are always enabled.
-   * By default debug logs are enabled when LogTester is started.
+   * By default INFO logs are enabled when LogTester is started.
    */
   public LogTester setLevel(LoggerLevel level) {
     Loggers.getFactory().setLevel(level);
index 4c0dd961e2a814f5112a8d773b576d721fc8e62a..fa8b2db317dd143f32e2ff0c9c92bd7f4c5bf5b2 100644 (file)
@@ -40,5 +40,7 @@ public class ConsoleLoggersTest {
 
     underTest.setLevel(LoggerLevel.DEBUG);
     assertThat(underTest.getLevel()).isEqualTo(LoggerLevel.DEBUG);
+
+    underTest.setLevel(LoggerLevel.INFO);
   }
 }
index f396b2f5d6b3df4b56762a58f92768ee380e1571..0521837bc3b5630c4588717796ce25d670920ac3 100644 (file)
@@ -29,8 +29,6 @@ public class LogTesterTest {
 
   @Test
   public void info_level_by_default() throws Throwable {
-    LoggerLevel initial = underTest.getLevel();
-
     // when LogTester is used, then info logs are enabled by default
     underTest.before();
     assertThat(underTest.getLevel()).isEqualTo(LoggerLevel.INFO);
@@ -43,8 +41,8 @@ public class LogTesterTest {
 
     // reset to initial level after execution of test
     underTest.after();
-    assertThat(underTest.getLevel()).isEqualTo(initial);
-    assertThat(Loggers.getFactory().getLevel()).isEqualTo(initial);
+    assertThat(underTest.getLevel()).isEqualTo(LoggerLevel.INFO);
+    assertThat(Loggers.getFactory().getLevel()).isEqualTo(LoggerLevel.INFO);
   }
 
   @Test