From ef346b48b21ef133e7217b1c36babb6d941ad4f4 Mon Sep 17 00:00:00 2001 From: Joerg Schaible Date: Sat, 6 Aug 2011 15:43:07 +0000 Subject: [PATCH] Ignore assertions for IBM JDK 1.6.0 in ToStringBuilderTest.testReflectionHierarchyArrayList because the test makes assumptions on the internal representation of an ArrayList (LANG-727). git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1154530 13f79535-47bb-0310-9956-ffa450edef68 --- .../lang3/builder/ToStringBuilderTest.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java index 633cef92c..7c1fbfac0 100644 --- a/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java @@ -24,6 +24,8 @@ import java.util.List; import org.junit.Test; +import org.apache.commons.lang3.SystemUtils; + /** * Unit tests for {@link org.apache.commons.lang3.builder.ToStringBuilder}. * @@ -320,13 +322,27 @@ public class ToStringBuilderTest { } // Reflection hierarchy tests - @Test public void testReflectionHierarchyArrayList() { List base = new ArrayList(); String baseStr = this.toBaseString(base); - assertEquals(baseStr + "[elementData={,,,,,,,,,},size=0,modCount=0]", ToStringBuilder.reflectionToString(base, null, true)); - assertEquals(baseStr + "[size=0]", ToStringBuilder.reflectionToString(base, null, false)); + // note, the test data depends on the internal representation of the ArrayList, which may differ between JDK versions and vendors + String expectedWithTransients = baseStr + "[elementData={,,,,,,,,,},size=0,modCount=0]"; + String toStringWithTransients = ToStringBuilder.reflectionToString(base, null, true); + if (!expectedWithTransients.equals(toStringWithTransients)) { + // representation different for IBM JDK 1.6.0, LANG-727 + if (!("IBM Corporation".equals(SystemUtils.JAVA_VENDOR) && "1.6".equals(SystemUtils.JAVA_SPECIFICATION_VERSION))) { + assertEquals(expectedWithTransients, toStringWithTransients); + } + } + String expectedWithoutTransients = baseStr + "[size=0]"; + String toStringWithoutTransients = ToStringBuilder.reflectionToString(base, null, false); + if (!expectedWithoutTransients.equals(toStringWithoutTransients)) { + // representation different for IBM JDK 1.6.0, LANG-727 + if (!("IBM Corporation".equals(SystemUtils.JAVA_VENDOR) && "1.6".equals(SystemUtils.JAVA_SPECIFICATION_VERSION))) { + assertEquals(expectedWithoutTransients, toStringWithoutTransients); + } + } this.validateNullToStringStyleRegistry(); }