deprecate SystemUtils#LINE_SEPARATOR in favor of java.lang.System#lineSeparator

This commit is contained in:
pascalschumacher 2017-01-20 17:40:38 +01:00
parent aab4018d8f
commit d0e2bfc466
11 changed files with 58 additions and 66 deletions

View File

@ -664,8 +664,10 @@ public class SystemUtils {
* sync with that System property. * sync with that System property.
* </p> * </p>
* *
* @deprecated Use {@link System#lineSeparator} instead, since it does not require a privilege check.
* @since Java 1.1 * @since Java 1.1
*/ */
@Deprecated
public static final String LINE_SEPARATOR = getSystemProperty("line.separator"); public static final String LINE_SEPARATOR = getSystemProperty("line.separator");
/** /**

View File

@ -18,7 +18,6 @@
package org.apache.commons.lang3.builder; package org.apache.commons.lang3.builder;
import org.apache.commons.lang3.ClassUtils; import org.apache.commons.lang3.ClassUtils;
import org.apache.commons.lang3.SystemUtils;
/** /**
* <p>Works with {@link ToStringBuilder} to create a "deep" <code>toString</code>. * <p>Works with {@link ToStringBuilder} to create a "deep" <code>toString</code>.
@ -89,13 +88,13 @@ public MultilineRecursiveToStringStyle() {
* Must be invoked after changing the {@link #spaces} value. * Must be invoked after changing the {@link #spaces} value.
*/ */
private void resetIndent() { private void resetIndent() {
setArrayStart("{" + SystemUtils.LINE_SEPARATOR + spacer(spaces)); setArrayStart("{" + System.lineSeparator() + spacer(spaces));
setArraySeparator("," + SystemUtils.LINE_SEPARATOR + spacer(spaces)); setArraySeparator("," + System.lineSeparator() + spacer(spaces));
setArrayEnd(SystemUtils.LINE_SEPARATOR + spacer(spaces - indent) + "}"); setArrayEnd(System.lineSeparator() + spacer(spaces - indent) + "}");
setContentStart("[" + SystemUtils.LINE_SEPARATOR + spacer(spaces)); setContentStart("[" + System.lineSeparator() + spacer(spaces));
setFieldSeparator("," + SystemUtils.LINE_SEPARATOR + spacer(spaces)); setFieldSeparator("," + System.lineSeparator() + spacer(spaces));
setContentEnd(SystemUtils.LINE_SEPARATOR + spacer(spaces - indent) + "]"); setContentEnd(System.lineSeparator() + spacer(spaces - indent) + "]");
} }
/** /**

View File

@ -25,7 +25,6 @@
import org.apache.commons.lang3.ClassUtils; import org.apache.commons.lang3.ClassUtils;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils;
/** /**
* <p>Controls <code>String</code> formatting for {@link ToStringBuilder}. * <p>Controls <code>String</code> formatting for {@link ToStringBuilder}.
@ -2294,9 +2293,9 @@ private static final class MultiLineToStringStyle extends ToStringStyle {
MultiLineToStringStyle() { MultiLineToStringStyle() {
super(); super();
this.setContentStart("["); this.setContentStart("[");
this.setFieldSeparator(SystemUtils.LINE_SEPARATOR + " "); this.setFieldSeparator(System.lineSeparator() + " ");
this.setFieldSeparatorAtStart(true); this.setFieldSeparatorAtStart(true);
this.setContentEnd(SystemUtils.LINE_SEPARATOR + "]"); this.setContentEnd(System.lineSeparator() + "]");
} }
/** /**

View File

@ -615,7 +615,7 @@ public static String[] getStackFrames(final Throwable throwable) {
* @return an array where each element is a line from the argument * @return an array where each element is a line from the argument
*/ */
static String[] getStackFrames(final String stackTrace) { static String[] getStackFrames(final String stackTrace) {
final String linebreak = SystemUtils.LINE_SEPARATOR; final String linebreak = System.lineSeparator();
final StringTokenizer frames = new StringTokenizer(stackTrace, linebreak); final StringTokenizer frames = new StringTokenizer(stackTrace, linebreak);
final List<String> list = new ArrayList<>(); final List<String> list = new ArrayList<>();
while (frames.hasMoreTokens()) { while (frames.hasMoreTokens()) {
@ -638,7 +638,7 @@ static String[] getStackFrames(final String stackTrace) {
*/ */
static List<String> getStackFrameList(final Throwable t) { static List<String> getStackFrameList(final Throwable t) {
final String stackTrace = getStackTrace(t); final String stackTrace = getStackTrace(t);
final String linebreak = SystemUtils.LINE_SEPARATOR; final String linebreak = System.lineSeparator();
final StringTokenizer frames = new StringTokenizer(stackTrace, linebreak); final StringTokenizer frames = new StringTokenizer(stackTrace, linebreak);
final List<String> list = new ArrayList<>(); final List<String> list = new ArrayList<>();
boolean traceStarted = false; boolean traceStarted = false;

View File

@ -27,7 +27,6 @@
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils;
import org.apache.commons.lang3.builder.Builder; import org.apache.commons.lang3.builder.Builder;
/** /**
@ -477,7 +476,7 @@ public int readFrom(final Readable readable) throws IOException {
*/ */
public StrBuilder appendNewLine() { public StrBuilder appendNewLine() {
if (newLine == null) { if (newLine == null) {
append(SystemUtils.LINE_SEPARATOR); append(System.lineSeparator());
return this; return this;
} }
return append(newLine); return append(newLine);

View File

@ -21,7 +21,6 @@
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils;
/** /**
* <p>Operations on Strings that contain words.</p> * <p>Operations on Strings that contain words.</p>
@ -270,7 +269,7 @@ public static String wrap(final String str, int wrapLength, String newLineStr, f
return null; return null;
} }
if (newLineStr == null) { if (newLineStr == null) {
newLineStr = SystemUtils.LINE_SEPARATOR; newLineStr = System.lineSeparator();
} }
if (wrapLength < 1) { if (wrapLength < 1) {
wrapLength = 1; wrapLength = 1;

View File

@ -23,7 +23,6 @@
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import org.apache.commons.lang3.SystemUtils;
import org.apache.commons.lang3.builder.ToStringStyleTest.Person; import org.apache.commons.lang3.builder.ToStringStyleTest.Person;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
@ -63,25 +62,25 @@ public void testAppendSuper() {
assertEquals( assertEquals(
"{}", "{}",
new ToStringBuilder(base).appendSuper( new ToStringBuilder(base).appendSuper(
"Integer@8888[" + SystemUtils.LINE_SEPARATOR + "]") "Integer@8888[" + System.lineSeparator() + "]")
.toString()); .toString());
assertEquals( assertEquals(
"{}", "{}",
new ToStringBuilder(base).appendSuper( new ToStringBuilder(base).appendSuper(
"Integer@8888[" + SystemUtils.LINE_SEPARATOR + " null" "Integer@8888[" + System.lineSeparator() + " null"
+ SystemUtils.LINE_SEPARATOR + "]").toString()); + System.lineSeparator() + "]").toString());
assertEquals( assertEquals(
"{\"a\":\"hello\"}", "{\"a\":\"hello\"}",
new ToStringBuilder(base) new ToStringBuilder(base)
.appendSuper( .appendSuper(
"Integer@8888[" + SystemUtils.LINE_SEPARATOR "Integer@8888[" + System.lineSeparator()
+ "]").append("a", "hello").toString()); + "]").append("a", "hello").toString());
assertEquals( assertEquals(
"{\"a\":\"hello\"}", "{\"a\":\"hello\"}",
new ToStringBuilder(base) new ToStringBuilder(base)
.appendSuper( .appendSuper(
"Integer@8888[" + SystemUtils.LINE_SEPARATOR "Integer@8888[" + System.lineSeparator()
+ " null" + SystemUtils.LINE_SEPARATOR + " null" + System.lineSeparator()
+ "]").append("a", "hello").toString()); + "]").append("a", "hello").toString());
assertEquals("{\"a\":\"hello\"}", new ToStringBuilder(base) assertEquals("{\"a\":\"hello\"}", new ToStringBuilder(base)
.appendSuper(null).append("a", "hello").toString()); .appendSuper(null).append("a", "hello").toString());

View File

@ -21,7 +21,6 @@
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import org.apache.commons.lang3.SystemUtils;
import org.apache.commons.lang3.builder.ToStringStyleTest.Person; import org.apache.commons.lang3.builder.ToStringStyleTest.Person;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
@ -49,35 +48,35 @@ public void tearDown() throws Exception {
@Test @Test
public void testBlank() { public void testBlank() {
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).toString()); assertEquals(baseStr + "[" + System.lineSeparator() + "]", new ToStringBuilder(base).toString());
} }
@Test @Test
public void testAppendSuper() { public void testAppendSuper() {
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).appendSuper("Integer@8888[" + SystemUtils.LINE_SEPARATOR + "]").toString()); assertEquals(baseStr + "[" + System.lineSeparator() + "]", new ToStringBuilder(base).appendSuper("Integer@8888[" + System.lineSeparator() + "]").toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " <null>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).appendSuper("Integer@8888[" + SystemUtils.LINE_SEPARATOR + " <null>" + SystemUtils.LINE_SEPARATOR + "]").toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " <null>" + System.lineSeparator() + "]", new ToStringBuilder(base).appendSuper("Integer@8888[" + System.lineSeparator() + " <null>" + System.lineSeparator() + "]").toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a=hello" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).appendSuper("Integer@8888[" + SystemUtils.LINE_SEPARATOR + "]").append("a", "hello").toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " a=hello" + System.lineSeparator() + "]", new ToStringBuilder(base).appendSuper("Integer@8888[" + System.lineSeparator() + "]").append("a", "hello").toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " <null>" + SystemUtils.LINE_SEPARATOR + " a=hello" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).appendSuper("Integer@8888[" + SystemUtils.LINE_SEPARATOR + " <null>" + SystemUtils.LINE_SEPARATOR + "]").append("a", "hello").toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " <null>" + System.lineSeparator() + " a=hello" + System.lineSeparator() + "]", new ToStringBuilder(base).appendSuper("Integer@8888[" + System.lineSeparator() + " <null>" + System.lineSeparator() + "]").append("a", "hello").toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a=hello" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).appendSuper(null).append("a", "hello").toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " a=hello" + System.lineSeparator() + "]", new ToStringBuilder(base).appendSuper(null).append("a", "hello").toString());
} }
@Test @Test
public void testObject() { public void testObject() {
final Integer i3 = Integer.valueOf(3); final Integer i3 = Integer.valueOf(3);
final Integer i4 = Integer.valueOf(4); final Integer i4 = Integer.valueOf(4);
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " <null>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append((Object) null).toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " <null>" + System.lineSeparator() + "]", new ToStringBuilder(base).append((Object) null).toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " 3" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append(i3).toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " 3" + System.lineSeparator() + "]", new ToStringBuilder(base).append(i3).toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a=<null>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", (Object) null).toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " a=<null>" + System.lineSeparator() + "]", new ToStringBuilder(base).append("a", (Object) null).toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a=3" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", i3).toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " a=3" + System.lineSeparator() + "]", new ToStringBuilder(base).append("a", i3).toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a=3" + SystemUtils.LINE_SEPARATOR + " b=4" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", i3).append("b", i4).toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " a=3" + System.lineSeparator() + " b=4" + System.lineSeparator() + "]", new ToStringBuilder(base).append("a", i3).append("b", i4).toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a=<Integer>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", i3, false).toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " a=<Integer>" + System.lineSeparator() + "]", new ToStringBuilder(base).append("a", i3, false).toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a=<size=0>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", new ArrayList<>(), false).toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " a=<size=0>" + System.lineSeparator() + "]", new ToStringBuilder(base).append("a", new ArrayList<>(), false).toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a=[]" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", new ArrayList<>(), true).toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " a=[]" + System.lineSeparator() + "]", new ToStringBuilder(base).append("a", new ArrayList<>(), true).toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a=<size=0>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", new HashMap<>(), false).toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " a=<size=0>" + System.lineSeparator() + "]", new ToStringBuilder(base).append("a", new HashMap<>(), false).toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a={}" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", new HashMap<>(), true).toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " a={}" + System.lineSeparator() + "]", new ToStringBuilder(base).append("a", new HashMap<>(), true).toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a=<size=0>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", (Object) new String[0], false).toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " a=<size=0>" + System.lineSeparator() + "]", new ToStringBuilder(base).append("a", (Object) new String[0], false).toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a={}" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", (Object) new String[0], true).toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " a={}" + System.lineSeparator() + "]", new ToStringBuilder(base).append("a", (Object) new String[0], true).toString());
} }
@Test @Test
@ -87,44 +86,44 @@ public void testPerson() {
p.age = 25; p.age = 25;
p.smoker = true; p.smoker = true;
final String pBaseStr = p.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(p)); final String pBaseStr = p.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(p));
assertEquals(pBaseStr + "[" + SystemUtils.LINE_SEPARATOR + " name=Jane Doe" + SystemUtils.LINE_SEPARATOR + " age=25" + SystemUtils.LINE_SEPARATOR + " smoker=true" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(p).append("name", p.name).append("age", p.age).append("smoker", p.smoker).toString()); assertEquals(pBaseStr + "[" + System.lineSeparator() + " name=Jane Doe" + System.lineSeparator() + " age=25" + System.lineSeparator() + " smoker=true" + System.lineSeparator() + "]", new ToStringBuilder(p).append("name", p.name).append("age", p.age).append("smoker", p.smoker).toString());
} }
@Test @Test
public void testLong() { public void testLong() {
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " 3" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append(3L).toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " 3" + System.lineSeparator() + "]", new ToStringBuilder(base).append(3L).toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a=3" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", 3L).toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " a=3" + System.lineSeparator() + "]", new ToStringBuilder(base).append("a", 3L).toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a=3" + SystemUtils.LINE_SEPARATOR + " b=4" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", 3L).append("b", 4L).toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " a=3" + System.lineSeparator() + " b=4" + System.lineSeparator() + "]", new ToStringBuilder(base).append("a", 3L).append("b", 4L).toString());
} }
@Test @Test
public void testObjectArray() { public void testObjectArray() {
Object[] array = new Object[] {null, base, new int[] {3, 6}}; Object[] array = new Object[] {null, base, new int[] {3, 6}};
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " {<null>,5,{3,6}}" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append(array).toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " {<null>,5,{3,6}}" + System.lineSeparator() + "]", new ToStringBuilder(base).append(array).toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " {<null>,5,{3,6}}" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append((Object) array).toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " {<null>,5,{3,6}}" + System.lineSeparator() + "]", new ToStringBuilder(base).append((Object) array).toString());
array = null; array = null;
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " <null>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append(array).toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " <null>" + System.lineSeparator() + "]", new ToStringBuilder(base).append(array).toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " <null>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append((Object) array).toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " <null>" + System.lineSeparator() + "]", new ToStringBuilder(base).append((Object) array).toString());
} }
@Test @Test
public void testLongArray() { public void testLongArray() {
long[] array = new long[] {1, 2, -3, 4}; long[] array = new long[] {1, 2, -3, 4};
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " {1,2,-3,4}" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append(array).toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " {1,2,-3,4}" + System.lineSeparator() + "]", new ToStringBuilder(base).append(array).toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " {1,2,-3,4}" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append((Object) array).toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " {1,2,-3,4}" + System.lineSeparator() + "]", new ToStringBuilder(base).append((Object) array).toString());
array = null; array = null;
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " <null>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append(array).toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " <null>" + System.lineSeparator() + "]", new ToStringBuilder(base).append(array).toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " <null>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append((Object) array).toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " <null>" + System.lineSeparator() + "]", new ToStringBuilder(base).append((Object) array).toString());
} }
@Test @Test
public void testLongArrayArray() { public void testLongArrayArray() {
long[][] array = new long[][] {{1, 2}, null, {5}}; long[][] array = new long[][] {{1, 2}, null, {5}};
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " {{1,2},<null>,{5}}" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append(array).toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " {{1,2},<null>,{5}}" + System.lineSeparator() + "]", new ToStringBuilder(base).append(array).toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " {{1,2},<null>,{5}}" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append((Object) array).toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " {{1,2},<null>,{5}}" + System.lineSeparator() + "]", new ToStringBuilder(base).append((Object) array).toString());
array = null; array = null;
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " <null>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append(array).toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " <null>" + System.lineSeparator() + "]", new ToStringBuilder(base).append(array).toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " <null>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append((Object) array).toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " <null>" + System.lineSeparator() + "]", new ToStringBuilder(base).append((Object) array).toString());
} }
} }

View File

@ -22,14 +22,13 @@
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.lang3.SystemUtils;
import org.junit.Test; import org.junit.Test;
/** /**
*/ */
public class MultilineRecursiveToStringStyleTest { public class MultilineRecursiveToStringStyleTest {
private final String BR = SystemUtils.LINE_SEPARATOR; private final String BR = System.lineSeparator();
@Test @Test
public void simpleObject() { public void simpleObject() {

View File

@ -26,15 +26,13 @@
import java.util.Collections; import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import org.apache.commons.lang3.SystemUtils;
/** /**
* Unit tests for {@link org.apache.commons.lang3.text.StrBuilder}. * Unit tests for {@link org.apache.commons.lang3.text.StrBuilder}.
*/ */
public class StrBuilderAppendInsertTest { public class StrBuilderAppendInsertTest {
/** The system line separator. */ /** The system line separator. */
private static final String SEP = SystemUtils.LINE_SEPARATOR; private static final String SEP = System.lineSeparator();
/** Test subclass of Object, with a toString method. */ /** Test subclass of Object, with a toString method. */
private static final Object FOO = new Object() { private static final Object FOO = new Object() {

View File

@ -21,7 +21,6 @@
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import org.apache.commons.lang3.SystemUtils;
import org.junit.Test; import org.junit.Test;
/** /**
@ -50,7 +49,7 @@ public void testWrap_StringInt() {
assertEquals("", WordUtils.wrap("", -1)); assertEquals("", WordUtils.wrap("", -1));
// normal // normal
final String systemNewLine = SystemUtils.LINE_SEPARATOR; final String systemNewLine = System.lineSeparator();
String input = "Here is one line of text that is going to be wrapped after 20 columns."; String input = "Here is one line of text that is going to be wrapped after 20 columns.";
String expected = "Here is one line of" + systemNewLine + "text that is going" String expected = "Here is one line of" + systemNewLine + "text that is going"
+ systemNewLine + "to be wrapped after" + systemNewLine + "20 columns."; + systemNewLine + "to be wrapped after" + systemNewLine + "20 columns.";
@ -112,7 +111,7 @@ public void testWrap_StringIntStringBoolean() {
assertEquals(expected, WordUtils.wrap(input, -1, "\n", false)); assertEquals(expected, WordUtils.wrap(input, -1, "\n", false));
// system newline char // system newline char
final String systemNewLine = SystemUtils.LINE_SEPARATOR; final String systemNewLine = System.lineSeparator();
input = "Here is one line of text that is going to be wrapped after 20 columns."; input = "Here is one line of text that is going to be wrapped after 20 columns.";
expected = "Here is one line of" + systemNewLine + "text that is going" + systemNewLine expected = "Here is one line of" + systemNewLine + "text that is going" + systemNewLine
+ "to be wrapped after" + systemNewLine + "20 columns."; + "to be wrapped after" + systemNewLine + "20 columns.";