summaryrefslogtreecommitdiffstats
path: root/sonar-batch/src/test
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2015-11-19 15:29:03 +0100
committerJulien HENRY <julien.henry@sonarsource.com>2015-11-19 17:14:45 +0100
commitad5d5937a83af9377dbf1044f900e967c122c041 (patch)
tree49ecf915c81e68fc0c3dfa701a6d0954bb62bacc /sonar-batch/src/test
parentacc1f7b6c754afd765cedd4cd19400ac1c495cea (diff)
downloadsonarqube-ad5d5937a83af9377dbf1044f900e967c122c041.tar.gz
sonarqube-ad5d5937a83af9377dbf1044f900e967c122c041.zip
Improve stability of unit test coverage
Diffstat (limited to 'sonar-batch/src/test')
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/util/ProgressReportTest.java25
1 files changed, 21 insertions, 4 deletions
diff --git a/sonar-batch/src/test/java/org/sonar/batch/util/ProgressReportTest.java b/sonar-batch/src/test/java/org/sonar/batch/util/ProgressReportTest.java
index dd2d131bf0e..cec84572543 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/util/ProgressReportTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/util/ProgressReportTest.java
@@ -20,19 +20,23 @@
package org.sonar.batch.util;
import java.util.Set;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.api.utils.log.LogTester;
import static org.assertj.core.api.Assertions.assertThat;
-import org.junit.Test;
-import org.junit.Before;
-
public class ProgressReportTest {
private static final String THREAD_NAME = "progress";
private ProgressReport progressReport;
+ @Rule
+ public LogTester logTester = new LogTester();
+
@Before
public void setUp() {
- progressReport = new ProgressReport(THREAD_NAME, 1000);
+ progressReport = new ProgressReport(THREAD_NAME, 100);
}
@Test
@@ -50,6 +54,19 @@ public class ProgressReportTest {
progressReport.stop("stop");
}
+ @Test
+ public void do_log() {
+ progressReport.start("start");
+ progressReport.message("Some message");
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ // Ignore
+ }
+ progressReport.stop("stop");
+ assertThat(logTester.logs()).contains("Some message");
+ }
+
private static boolean isDaemon(String name) {
Thread t = getThread(name);
return (t != null) && t.isDaemon();