From 85445db60e417c23237e38715256449839efbb4b Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Tue, 1 Jul 2014 11:12:34 +0200 Subject: Fix some quality flaws --- .../api/utils/command/CommandExecutorTest.java | 49 +++++++++++----------- 1 file changed, 24 insertions(+), 25 deletions(-) (limited to 'sonar-plugin-api/src/test/java/org/sonar/api/utils/command') 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 -- cgit v1.2.3