aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2017-04-13 15:45:32 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2017-04-13 18:54:32 +0200
commit4b95f2fc707bf92eaaf8081042c20544db06e028 (patch)
tree54c80ed6ff3b8df03d70cb000e33a8bc1afd94f7 /sonar-scanner-engine
parent92b758dffffb4e917bbb76e64eab75eea4647df6 (diff)
downloadsonarqube-4b95f2fc707bf92eaaf8081042c20544db06e028.tar.gz
sonarqube-4b95f2fc707bf92eaaf8081042c20544db06e028.zip
Remove false-positive in ProgressReportTest
Diffstat (limited to 'sonar-scanner-engine')
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/util/ProgressReportTest.java37
1 files changed, 17 insertions, 20 deletions
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/util/ProgressReportTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/util/ProgressReportTest.java
index 9358db7370f..d2283d0212c 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/util/ProgressReportTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/util/ProgressReportTest.java
@@ -20,52 +20,49 @@
package org.sonar.scanner.util;
import java.util.Set;
-import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.DisableOnDebug;
+import org.junit.rules.TestRule;
+import org.junit.rules.Timeout;
import org.sonar.api.utils.log.LogTester;
-import org.sonar.scanner.util.ProgressReport;
import static org.assertj.core.api.Assertions.assertThat;
public class ProgressReportTest {
private static final String THREAD_NAME = "progress";
- private ProgressReport progressReport;
@Rule
+ public TestRule timeoutSafeguard = new DisableOnDebug(Timeout.seconds(10));
+ @Rule
public LogTester logTester = new LogTester();
- @Before
- public void setUp() {
- progressReport = new ProgressReport(THREAD_NAME, 100);
- }
+ private ProgressReport underTest = new ProgressReport(THREAD_NAME, 1);
@Test
- public void die_on_stop() {
- progressReport.start("start");
+ public void stop_thread_on_stop() {
+ underTest.start("start");
assertThat(isThreadAlive(THREAD_NAME)).isTrue();
- progressReport.stop("stop");
+ underTest.stop("stop");
assertThat(isThreadAlive(THREAD_NAME)).isFalse();
}
@Test
public void do_not_block_app() {
- progressReport.start("start");
+ underTest.start("start");
assertThat(isDaemon(THREAD_NAME)).isTrue();
- progressReport.stop("stop");
+ underTest.stop("stop");
}
@Test
public void do_log() {
- progressReport.start("start");
- progressReport.message("Some message");
- try {
- Thread.sleep(200);
- } catch (InterruptedException e) {
- // Ignore
+ underTest.start("start");
+ underTest.message("Some message");
+ boolean logged = false;
+ while (!logged) {
+ logged = logTester.logs().contains("Some message");
}
- progressReport.stop("stop");
- assertThat(logTester.logs()).contains("Some message");
+ underTest.stop("stop");
}
private static boolean isDaemon(String name) {