diff --git a/src/test/java/org/apache/commons/lang3/builder/RecursiveToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/RecursiveToStringStyleTest.java index bbe7d2bc0..dbf36c1b0 100644 --- a/src/test/java/org/apache/commons/lang3/builder/RecursiveToStringStyleTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/RecursiveToStringStyleTest.java @@ -35,7 +35,7 @@ public class RecursiveToStringStyleTest { @Before public void setUp() throws Exception { - ToStringBuilder.setDefaultStyle(ToStringStyle.DEFAULT_STYLE); + ToStringBuilder.setDefaultStyle(new RecursiveToStringStyle()); } @After @@ -64,14 +64,17 @@ public class RecursiveToStringStyleTest { public void testObject() { final Integer i3 = Integer.valueOf(3); final Integer i4 = Integer.valueOf(4); + final ArrayList emptyList = new ArrayList<>(); + assertEquals(baseStr + "[]", new ToStringBuilder(base).append((Object) null).toString()); assertEquals(baseStr + "[3]", new ToStringBuilder(base).append(i3).toString()); assertEquals(baseStr + "[a=]", new ToStringBuilder(base).append("a", (Object) null).toString()); assertEquals(baseStr + "[a=3]", new ToStringBuilder(base).append("a", i3).toString()); assertEquals(baseStr + "[a=3,b=4]", new ToStringBuilder(base).append("a", i3).append("b", i4).toString()); assertEquals(baseStr + "[a=]", new ToStringBuilder(base).append("a", i3, false).toString()); - assertEquals(baseStr + "[a=]", new ToStringBuilder(base).append("a", new ArrayList<>(), false).toString()); - assertEquals(baseStr + "[a=[]]", new ToStringBuilder(base).append("a", new ArrayList<>(), true).toString()); + assertEquals(baseStr + "[a=]", new ToStringBuilder(base).append("a", emptyList, false).toString()); + assertEquals(baseStr + "[a=java.util.ArrayList@" + Integer.toHexString(System.identityHashCode(emptyList)) + "{}]", + new ToStringBuilder(base).append("a", emptyList, true).toString()); assertEquals(baseStr + "[a=]", new ToStringBuilder(base).append("a", new HashMap<>(), false).toString()); assertEquals(baseStr + "[a={}]", new ToStringBuilder(base).append("a", new HashMap<>(), true).toString()); assertEquals(baseStr + "[a=]", new ToStringBuilder(base).append("a", (Object) new String[0], false).toString());