aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api/src/test/java/org/sonar/api/utils/command
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2014-07-01 11:12:34 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2014-07-01 12:10:47 +0200
commit85445db60e417c23237e38715256449839efbb4b (patch)
tree45e2892b635892409d82c1a2a7938fb2322ecbc5 /sonar-plugin-api/src/test/java/org/sonar/api/utils/command
parentd74be88c29c5b967278aab5202f0aff1184143a0 (diff)
downloadsonarqube-85445db60e417c23237e38715256449839efbb4b.tar.gz
sonarqube-85445db60e417c23237e38715256449839efbb4b.zip
Fix some quality flaws
Diffstat (limited to 'sonar-plugin-api/src/test/java/org/sonar/api/utils/command')
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/utils/command/CommandExecutorTest.java49
1 files changed, 24 insertions, 25 deletions
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/command/CommandExecutorTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/command/CommandExecutorTest.java
index f06adc75dd8..b8d4de67865 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/command/CommandExecutorTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/command/CommandExecutorTest.java
@@ -34,7 +34,6 @@ import java.io.IOException;
import static org.fest.assertions.Assertions.assertThat;
import static org.junit.Assert.fail;
-import static org.junit.Assume.assumeFalse;
public class CommandExecutorTest {
@@ -57,30 +56,30 @@ public class CommandExecutorTest {
@Test
public void should_consume_StdOut_and_StdErr() throws Exception {
// too many false-positives on MS windows
- assumeFalse(SystemUtils.IS_OS_WINDOWS);
-
- final StringBuilder stdOutBuilder = new StringBuilder();
- StreamConsumer stdOutConsumer = new StreamConsumer() {
- public void consumeLine(String line) {
- stdOutBuilder.append(line).append(SystemUtils.LINE_SEPARATOR);
- }
- };
- final StringBuilder stdErrBuilder = new StringBuilder();
- StreamConsumer stdErrConsumer = new StreamConsumer() {
- public void consumeLine(String line) {
- stdErrBuilder.append(line).append(SystemUtils.LINE_SEPARATOR);
- }
- };
- Command command = Command.create(getScript("output")).setDirectory(workDir);
- int exitCode = CommandExecutor.create().execute(command, stdOutConsumer, stdErrConsumer, 1000L);
- assertThat(exitCode).isEqualTo(0);
-
- String stdOut = stdOutBuilder.toString();
- String stdErr = stdErrBuilder.toString();
- assertThat(stdOut).contains("stdOut: first line");
- assertThat(stdOut).contains("stdOut: second line");
- assertThat(stdErr).contains("stdErr: first line");
- assertThat(stdErr).contains("stdErr: second line");
+ if (!SystemUtils.IS_OS_WINDOWS) {
+ final StringBuilder stdOutBuilder = new StringBuilder();
+ StreamConsumer stdOutConsumer = new StreamConsumer() {
+ public void consumeLine(String line) {
+ stdOutBuilder.append(line).append(SystemUtils.LINE_SEPARATOR);
+ }
+ };
+ final StringBuilder stdErrBuilder = new StringBuilder();
+ StreamConsumer stdErrConsumer = new StreamConsumer() {
+ public void consumeLine(String line) {
+ stdErrBuilder.append(line).append(SystemUtils.LINE_SEPARATOR);
+ }
+ };
+ Command command = Command.create(getScript("output")).setDirectory(workDir);
+ int exitCode = CommandExecutor.create().execute(command, stdOutConsumer, stdErrConsumer, 1000L);
+ assertThat(exitCode).isEqualTo(0);
+
+ String stdOut = stdOutBuilder.toString();
+ String stdErr = stdErrBuilder.toString();
+ assertThat(stdOut).contains("stdOut: first line");
+ assertThat(stdOut).contains("stdOut: second line");
+ assertThat(stdErr).contains("stdErr: first line");
+ assertThat(stdErr).contains("stdErr: second line");
+ }
}
@Test