diff --git a/test/framework/src/main/java/org/elasticsearch/common/cli/CliToolTestCase.java b/test/framework/src/main/java/org/elasticsearch/common/cli/CliToolTestCase.java index 9debf4b8f33..06c197a05da 100644 --- a/test/framework/src/main/java/org/elasticsearch/common/cli/CliToolTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/common/cli/CliToolTestCase.java @@ -28,6 +28,10 @@ import org.elasticsearch.test.StreamsUtils; import org.junit.After; import org.junit.Before; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.isEmptyString; +import static org.hamcrest.Matchers.not; + public abstract class CliToolTestCase extends ESTestCase { @Before @@ -51,8 +55,10 @@ public abstract class CliToolTestCase extends ESTestCase { public static void assertTerminalOutputContainsHelpFile(MockTerminal terminal, String classPath) throws IOException { String output = terminal.getOutput(); - assertFalse(output, output.isEmpty()); + assertThat(output, not(isEmptyString())); String expectedDocs = StreamsUtils.copyToStringFromClasspath(classPath); - assertTrue(output, output.contains(expectedDocs)); + // convert to *nix newlines as MockTerminal used for tests also uses *nix newlines + expectedDocs = expectedDocs.replace("\r\n", "\n"); + assertThat(output, containsString(expectedDocs)); } }