diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ServiceCapabilitiesReportGenerator.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ServiceCapabilitiesReportGenerator.java index d31ea7f87f..e6b2689683 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ServiceCapabilitiesReportGenerator.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ServiceCapabilitiesReportGenerator.java @@ -36,8 +36,6 @@ import java.util.TreeSet; */ class ServiceCapabilitiesReportGenerator { - private static final String NEW_LINE = System.getProperty("line.separator"); - private final InitializrService initializrService; /** @@ -66,29 +64,29 @@ class ServiceCapabilitiesReportGenerator { private String generateHelp(String url, InitializrServiceMetadata metadata) { String header = "Capabilities of " + url; StringBuilder report = new StringBuilder(); - report.append(repeat("=", header.length()) + NEW_LINE); - report.append(header + NEW_LINE); - report.append(repeat("=", header.length()) + NEW_LINE); - report.append(NEW_LINE); + report.append(repeat("=", header.length()) + System.lineSeparator()); + report.append(header + System.lineSeparator()); + report.append(repeat("=", header.length()) + System.lineSeparator()); + report.append(System.lineSeparator()); reportAvailableDependencies(metadata, report); - report.append(NEW_LINE); + report.append(System.lineSeparator()); reportAvailableProjectTypes(metadata, report); - report.append(NEW_LINE); + report.append(System.lineSeparator()); reportDefaults(report, metadata); return report.toString(); } private void reportAvailableDependencies(InitializrServiceMetadata metadata, StringBuilder report) { - report.append("Available dependencies:" + NEW_LINE); - report.append("-----------------------" + NEW_LINE); + report.append("Available dependencies:" + System.lineSeparator()); + report.append("-----------------------" + System.lineSeparator()); List dependencies = getSortedDependencies(metadata); for (Dependency dependency : dependencies) { report.append(dependency.getId() + " - " + dependency.getName()); if (dependency.getDescription() != null) { report.append(": " + dependency.getDescription()); } - report.append(NEW_LINE); + report.append(System.lineSeparator()); } } @@ -100,8 +98,8 @@ class ServiceCapabilitiesReportGenerator { private void reportAvailableProjectTypes(InitializrServiceMetadata metadata, StringBuilder report) { - report.append("Available project types:" + NEW_LINE); - report.append("------------------------" + NEW_LINE); + report.append("Available project types:" + System.lineSeparator()); + report.append("------------------------" + System.lineSeparator()); SortedSet> entries = new TreeSet<>( Comparator.comparing(Entry::getKey)); entries.addAll(metadata.getProjectTypes().entrySet()); @@ -114,7 +112,7 @@ class ServiceCapabilitiesReportGenerator { if (type.isDefaultType()) { report.append(" (default)"); } - report.append(NEW_LINE); + report.append(System.lineSeparator()); } } @@ -134,13 +132,13 @@ class ServiceCapabilitiesReportGenerator { private void reportDefaults(StringBuilder report, InitializrServiceMetadata metadata) { - report.append("Defaults:" + NEW_LINE); - report.append("---------" + NEW_LINE); + report.append("Defaults:" + System.lineSeparator()); + report.append("---------" + System.lineSeparator()); List defaultsKeys = new ArrayList<>(metadata.getDefaults().keySet()); Collections.sort(defaultsKeys); for (String defaultsKey : defaultsKeys) { String defaultsValue = metadata.getDefaults().get(defaultsKey); - report.append(defaultsKey + ": " + defaultsValue + NEW_LINE); + report.append(defaultsKey + ": " + defaultsValue + System.lineSeparator()); } } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/src/main/java/org/springframework/boot/configurationmetadata/DescriptionExtractor.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/src/main/java/org/springframework/boot/configurationmetadata/DescriptionExtractor.java index a2302ee579..ae5eb4331d 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/src/main/java/org/springframework/boot/configurationmetadata/DescriptionExtractor.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/src/main/java/org/springframework/boot/configurationmetadata/DescriptionExtractor.java @@ -26,8 +26,6 @@ import java.util.Locale; */ class DescriptionExtractor { - private static final String NEW_LINE = System.getProperty("line.separator"); - public String getShortDescription(String description) { if (description == null) { return null; @@ -41,13 +39,13 @@ class DescriptionExtractor { return removeSpaceBetweenLine(text); } else { - String[] lines = description.split(NEW_LINE); + String[] lines = description.split(System.lineSeparator()); return lines[0].trim(); } } private String removeSpaceBetweenLine(String text) { - String[] lines = text.split(NEW_LINE); + String[] lines = text.split(System.lineSeparator()); StringBuilder sb = new StringBuilder(); for (String line : lines) { sb.append(line.trim()).append(" "); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/src/test/java/org/springframework/boot/configurationmetadata/DescriptionExtractorTests.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/src/test/java/org/springframework/boot/configurationmetadata/DescriptionExtractorTests.java index 846ba9b7da..adcdb0a121 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/src/test/java/org/springframework/boot/configurationmetadata/DescriptionExtractorTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/src/test/java/org/springframework/boot/configurationmetadata/DescriptionExtractorTests.java @@ -27,8 +27,6 @@ import static org.assertj.core.api.Assertions.assertThat; */ public class DescriptionExtractorTests { - private static final String NEW_LINE = System.getProperty("line.separator"); - private DescriptionExtractor extractor = new DescriptionExtractor(); @Test @@ -41,14 +39,14 @@ public class DescriptionExtractorTests { @Test public void extractShortDescriptionNewLineBeforeDot() { String description = this.extractor.getShortDescription( - "My short" + NEW_LINE + "description." + NEW_LINE + "More stuff."); + "My short" + System.lineSeparator() + "description." + System.lineSeparator() + "More stuff."); assertThat(description).isEqualTo("My short description."); } @Test public void extractShortDescriptionNewLineBeforeDotWithSpaces() { String description = this.extractor.getShortDescription( - "My short " + NEW_LINE + " description. " + NEW_LINE + "More stuff."); + "My short " + System.lineSeparator() + " description. " + System.lineSeparator() + "More stuff."); assertThat(description).isEqualTo("My short description."); } @@ -61,7 +59,7 @@ public class DescriptionExtractorTests { @Test public void extractShortDescriptionNoDotMultipleLines() { String description = this.extractor - .getShortDescription("My short description " + NEW_LINE + " More stuff"); + .getShortDescription("My short description " + System.lineSeparator() + " More stuff"); assertThat(description).isEqualTo("My short description"); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/ImageBannerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/ImageBannerTests.java index 9231d5095f..ba74b6070b 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/ImageBannerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/ImageBannerTests.java @@ -42,8 +42,6 @@ import static org.assertj.core.api.Assertions.assertThat; */ public class ImageBannerTests { - private static final String NEW_LINE = System.getProperty("line.separator"); - private static final char HIGH_LUMINANCE_CHARACTER = ' '; private static final char LOW_LUMINANCE_CHARACTER = '@'; @@ -149,7 +147,7 @@ public class ImageBannerTests { public void printBannerShouldPrintMargin() { AnsiOutput.setEnabled(AnsiOutput.Enabled.NEVER); String banner = printBanner("large.gif"); - String[] lines = banner.split(NEW_LINE); + String[] lines = banner.split(System.lineSeparator()); for (int i = 2; i < lines.length - 1; i++) { assertThat(lines[i]).startsWith(" @"); } @@ -159,7 +157,7 @@ public class ImageBannerTests { public void printBannerWhenHasMarginPropertyShouldPrintSizedMargin() { AnsiOutput.setEnabled(AnsiOutput.Enabled.NEVER); String banner = printBanner("large.gif", "spring.banner.image.margin=4"); - String[] lines = banner.split(NEW_LINE); + String[] lines = banner.split(System.lineSeparator()); for (int i = 2; i < lines.length - 1; i++) { assertThat(lines[i]).startsWith(" @"); } @@ -169,7 +167,7 @@ public class ImageBannerTests { public void printBannerWhenAnimatesShouldPrintAllFrames() { AnsiOutput.setEnabled(AnsiOutput.Enabled.NEVER); String banner = printBanner("animated.gif"); - String[] lines = banner.split(NEW_LINE); + String[] lines = banner.split(System.lineSeparator()); int frames = 138; int linesPerFrame = 36; assertThat(banner).contains("\r"); @@ -177,12 +175,12 @@ public class ImageBannerTests { } private int getBannerHeight(String banner) { - return banner.split(NEW_LINE).length - 3; + return banner.split(System.lineSeparator()).length - 3; } private int getBannerWidth(String banner) { int width = 0; - for (String line : banner.split(NEW_LINE)) { + for (String line : banner.split(System.lineSeparator())) { width = Math.max(width, line.length()); } return width; diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/ExtendedWhitespaceThrowablePatternConverterTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/ExtendedWhitespaceThrowablePatternConverterTests.java index 01bab8fc36..a4b3cdf22f 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/ExtendedWhitespaceThrowablePatternConverterTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/ExtendedWhitespaceThrowablePatternConverterTests.java @@ -32,8 +32,6 @@ import static org.assertj.core.api.Assertions.assertThat; */ public class ExtendedWhitespaceThrowablePatternConverterTests { - private static final String LINE_SEPARATOR = System.getProperty("line.separator"); - private final ThrowablePatternConverter converter = ExtendedWhitespaceThrowablePatternConverter .newInstance(new DefaultConfiguration(), new String[] {}); @@ -50,7 +48,7 @@ public class ExtendedWhitespaceThrowablePatternConverterTests { LogEvent event = Log4jLogEvent.newBuilder().setThrown(new Exception()).build(); StringBuilder builder = new StringBuilder(); this.converter.format(event, builder); - assertThat(builder).startsWith(LINE_SEPARATOR).endsWith(LINE_SEPARATOR); + assertThat(builder).startsWith(System.lineSeparator()).endsWith(System.lineSeparator()); } } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/WhitespaceThrowablePatternConverterTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/WhitespaceThrowablePatternConverterTests.java index 7076e4a98a..0a0ddb7f6a 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/WhitespaceThrowablePatternConverterTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/WhitespaceThrowablePatternConverterTests.java @@ -31,8 +31,6 @@ import static org.assertj.core.api.Assertions.assertThat; */ public class WhitespaceThrowablePatternConverterTests { - private static final String LINE_SEPARATOR = System.getProperty("line.separator"); - private final ThrowablePatternConverter converter = WhitespaceThrowablePatternConverter .newInstance(new DefaultConfiguration(), new String[] {}); @@ -49,8 +47,8 @@ public class WhitespaceThrowablePatternConverterTests { LogEvent event = Log4jLogEvent.newBuilder().setThrown(new Exception()).build(); StringBuilder builder = new StringBuilder(); this.converter.format(event, builder); - assertThat(builder.toString()).startsWith(LINE_SEPARATOR) - .endsWith(LINE_SEPARATOR); + assertThat(builder.toString()).startsWith(System.lineSeparator()) + .endsWith(System.lineSeparator()); } } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/ExtendedWhitespaceThrowableProxyConverterTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/ExtendedWhitespaceThrowableProxyConverterTests.java index 0faa489eb1..ec58b97b95 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/ExtendedWhitespaceThrowableProxyConverterTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/ExtendedWhitespaceThrowableProxyConverterTests.java @@ -30,8 +30,6 @@ import static org.assertj.core.api.Assertions.assertThat; */ public class ExtendedWhitespaceThrowableProxyConverterTests { - private static final String LINE_SEPARATOR = System.getProperty("line.separator"); - private final ExtendedWhitespaceThrowableProxyConverter converter = new ExtendedWhitespaceThrowableProxyConverter(); private final LoggingEvent event = new LoggingEvent(); @@ -46,7 +44,7 @@ public class ExtendedWhitespaceThrowableProxyConverterTests { public void withStackTrace() { this.event.setThrowableProxy(new ThrowableProxy(new RuntimeException())); String s = this.converter.convert(this.event); - assertThat(s).startsWith(LINE_SEPARATOR).endsWith(LINE_SEPARATOR); + assertThat(s).startsWith(System.lineSeparator()).endsWith(System.lineSeparator()); } } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/WhitespaceThrowableProxyConverterTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/WhitespaceThrowableProxyConverterTests.java index 220c746588..ce04e8a4ab 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/WhitespaceThrowableProxyConverterTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/WhitespaceThrowableProxyConverterTests.java @@ -30,8 +30,6 @@ import static org.assertj.core.api.Assertions.assertThat; */ public class WhitespaceThrowableProxyConverterTests { - private static final String LINE_SEPARATOR = System.getProperty("line.separator"); - private final WhitespaceThrowableProxyConverter converter = new WhitespaceThrowableProxyConverter(); private final LoggingEvent event = new LoggingEvent(); @@ -46,7 +44,7 @@ public class WhitespaceThrowableProxyConverterTests { public void withStackTrace() { this.event.setThrowableProxy(new ThrowableProxy(new RuntimeException())); String s = this.converter.convert(this.event); - assertThat(s).startsWith(LINE_SEPARATOR).endsWith(LINE_SEPARATOR); + assertThat(s).startsWith(System.lineSeparator()).endsWith(System.lineSeparator()); } }