[
https://issues.apache.org/jira/browse/LANG-727?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13071496#comment-13071496
]
Henri Yandell commented on LANG-727:
------------------------------------
Looking at the code:
{code:java}
assertEquals(baseStr +
"[elementData={<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>},size=0,modCount=0]",
ToStringBuilder.reflectionToString(base, null, true));
assertEquals(baseStr + "[size=0]",
ToStringBuilder.reflectionToString(base, null, false));
{code}
I think the 2nd test should pass as there's only one item. So just the first
one to fix. I think we can use StringUtils.contains, ie:
{code:java}
String result = ToStringBuilder.reflectionToString(base, null, true);
assertTrue( StringUtils.startsWith(result, baseStr + "[") );
assertTrue( StringUtils.contains(result,
"[elementData={<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>}"
) );
assertTrue( StringUtils.contains(result, "size=0") );
assertTrue( StringUtils.contains(result, "modCount=0") );
assertTrue( StringUtils.endsWith(result, "]") );
assertEquals(baseStr + "[size=0]",
ToStringBuilder.reflectionToString(base, null, false));
{code}
Is that something you could easily test in JDK 6 and commit?
I also suspect that we should hard code the elementData size by doing
ArrayList(10).
> ToStringBuilderTest.testReflectionHierarchyArrayList fails with IBM JDK 6
> -------------------------------------------------------------------------
>
> Key: LANG-727
> URL: https://issues.apache.org/jira/browse/LANG-727
> Project: Commons Lang
> Issue Type: Bug
> Components: lang.builder.*
> Affects Versions: 3.0
> Reporter: Joerg Schaible
> Priority: Trivial
> Fix For: 3.0.1
>
>
> The unit test fails when running with IBM JDK 6:
> {noformat}
> Failed tests:
> testReflectionHierarchyArrayList(org.apache.commons.lang3.builder.ToStringBuilderTest): null
> expected:<....ArrayList@115b115b[[elementData={<null>,<null>,<null>,<null>,<null>,<null>,<null>,null>,null>,null>},size=0],modCount=0]>
> but
> was:<....ArrayList@115b115b[[firstIndex=0,lastIndex=0,array={<null>,<null>,<null>,<null>,<null>,<null>,<null>,null>,null>,null>}],modCount=0]>
> {noformat}
> Actually the test is wrong, because it makes wrong assumptions about the
> implementation of ArrayList in the runtime.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira