Test: use System.lineSeperator instead of `\n`

This changes the native realm migrate tool tests to use the System.lineSeperator instead of `\n`
so that the tests will pass on Windows.

Original commit: elastic/x-pack-elasticsearch@d3f9a71ac4
This commit is contained in:
jaymode 2017-06-19 10:34:30 -06:00
parent cbceae4a33
commit 0532c9069b
1 changed files with 3 additions and 4 deletions

View File

@ -16,7 +16,6 @@ import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment; import org.elasticsearch.env.Environment;
import org.elasticsearch.xpack.security.authz.RoleDescriptor; import org.elasticsearch.xpack.security.authz.RoleDescriptor;
import org.elasticsearch.xpack.security.authz.permission.FieldPermissions;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.nio.file.Files; import java.nio.file.Files;
@ -76,12 +75,12 @@ public class ESNativeRealmMigrateToolTests extends CommandTestCase {
} }
terminalLogger.log(Level.ERROR, "logging an error"); terminalLogger.log(Level.ERROR, "logging an error");
assertEquals("logging an error\n", terminal.getOutput()); assertEquals("logging an error" + System.lineSeparator(), terminal.getOutput());
terminal.reset(); terminal.reset();
assertThat(terminal.getOutput(), isEmptyString()); assertThat(terminal.getOutput(), isEmptyString());
terminalLogger.log(Level.FATAL, "logging a fatal message"); terminalLogger.log(Level.FATAL, "logging a fatal message");
assertEquals("logging a fatal message\n", terminal.getOutput()); assertEquals("logging a fatal message" + System.lineSeparator(), terminal.getOutput());
terminal.reset(); terminal.reset();
assertThat(terminal.getOutput(), isEmptyString()); assertThat(terminal.getOutput(), isEmptyString());
@ -91,7 +90,7 @@ public class ESNativeRealmMigrateToolTests extends CommandTestCase {
loggingLevels.remove(Level.OFF); loggingLevels.remove(Level.OFF);
for (Level level : loggingLevels) { for (Level level : loggingLevels) {
terminalLogger.log(level, "this level should log " + level.name()); terminalLogger.log(level, "this level should log " + level.name());
assertEquals("this level should log " + level.name() + "\n", terminal.getOutput()); assertEquals("this level should log " + level.name() + System.lineSeparator(), terminal.getOutput());
terminal.reset(); terminal.reset();
assertThat(terminal.getOutput(), isEmptyString()); assertThat(terminal.getOutput(), isEmptyString());
} }