commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael A. Smith" <...@apache.org>
Subject Re: [collections] One test failed
Date Wed, 13 Mar 2002 13:37:04 GMT
On Wed, 13 Mar 2002, Lev Assinovsky wrote:
> Hi Michael!
> May be  it's interesting for you?
> I made cvs update (for collections) and
> run ant (jdk 1.4).

Yup.  I mentioned this yesterday afternoon, just didn't have a chance last 
night to get to them.  

"I've seen this as well, and is actually a bad test.  The test is
iterating over the results and expecting a certain order, however "hash"
based collections usually do not guaruntee a particular ordering.  In this
case, the hashing behavior between JDK 1.3 and JDK 1.4 is different so the
iterator is returning the elements in a different order (thus the test
fails)."

In other words, the test is assuming that the Bag.iterator() method
returns the elements in some particular order.  For the HashBag, this
ordering is based on a hashtable, which does not guaruntee any particular
order.  The hashing behavior changed between jdk 1.3 and 1.4, so the order
changed for 1.4 (and broke the test under 1.4). 

The Bag interface does not specify that iterator() should return its
elements in any particular order.  Since the test assumes an order, this
is is a bug in the test, not in the code itself.

regards,
michael

> Here are the results:
> 
> test:
>      [java] .........................................
>      [java] .........................................
>      [java] .........................................
>      [java] .........................................
>      [java] .........................................
>      [java] .........................................
>      [java] .........................................
>      [java] .........................................
>      [java] .........................................
>      [java] .........................................
>      [java] .........................................
>      [java] .........................................
>      [java] .........................................
>      [java] .............F........F....................
>      [java] .........................................
>      [java] .........................................
>      [java] .........................................
>      [java] .........................................
>      [java] ...........
>      [java] Time: 13.029
>      [java] There were 2 failures:
>      [java] 1)
> testIterator(org.apache.commons.collections.TestHashBag)junit.framework.AssertionFailedError:
> 
> First should be 'A' expected:<A> but was:<B>
>      [java]     at
> org.apache.commons.collections.TestBag.testIterator(Unknown Source)
>      [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
>      [java]     at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:42)
> 
>      [java]     at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:28)
> 
>      [java] 2)
> testIteratorFail(org.apache.commons.collections.TestHashBag)junit.framework.AssertionFailedErr
> 
> or: First should be 'A' expected:<A> but was:<B>
>      [java]     at
> org.apache.commons.collections.TestBag.testIteratorFail(Unknown Source)
>      [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
>      [java]     at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:42)
> 
>      [java]     at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:28)
> 
>      [java]
>      [java] FAILURES!!!
>      [java] Tests run: 749,  Failures: 2,  Errors: 0
>      [java]
> 
> 
> Regards,
> 
> --
> Lev Assinovsky                Peterlink Web
> Programmer                    St. Petersburg, Russia
> Tel/Fax: +7 812 3275343       197022 ul.Chapigina 7Á
> E-mail: lev@peterlink.ru
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>
> 


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message