jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Korver, Aaron" <Aaron.Kor...@Fiserv.com>
Subject RE: Errors that don't make sense...
Date Wed, 01 Dec 2004 16:17:05 GMT
assertSame doesn't test for equality.  It tests to see if the objects are
pointing to the same reference.  Hence if you have two Long objects (Long A
= new Long(), Long B = new Long()) and they have the same VALUES then....
assertSame(A,B) is false as they are different objects
assertEquals(A,B) is true as the VALUES are the same.

Instead, lets assume it was coded like this...
Long A = new Long();
Long B = A;

In this case
assertSame(A,B) is true as A and B both point to the same object reference.
assertEquals(A,B) is true as the values of A and B are the same.

Hope this helps.

> -----Original Message-----
> From: Andrew Swan [mailto:andrews@bisinfo.com.au]
> Sent: Tuesday, November 30, 2004 6:09 PM
> To: 'Cactus Users List'
> Subject: RE: Errors that don't make sense...
> 
> 
> If you're using assertSame(Object, Object), then the 
> assertion will fail if
> the two objects are different objects on the heap, even if 
> they are both
> Longs that have the same longValue(), or more generally, the 
> same toString()
> output, which is what JUnit shows you between the angle brackets <>.
> 
> Hope this helps?
> 
> Andrew
> 
> -----Original Message-----
> From: Mick.Knutson@wellsfargo.com [mailto:Mick.Knutson@wellsfargo.com]
> Sent: Wednesday, 1 December 2004 10:53 AM
> To: cactus-user@jakarta.apache.org
> Subject: Errors that don't make sense...
> 
> 
> I keep running my tests, and keep getting failures like this:
> 
> expected:<987654321> but was:<987654321>
> 
> junit.framework.AssertionFailedError: expected:<987654321> but
> was:<987654321> at
> com.wf.bd.ice.business.BusinessValidatorFormTest.testSetGetBan
> kAccount_1(Bus
> inessValidatorFormTest.java:670) at
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccess
> orImpl.java:39
> ) at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMeth
> odAccessorImpl
> .java:25)
> 
> This does not make sense as the 2 values are 
> java.lang.Long()'s and match as
> stated above....
> 
> 
> 
> 
> --------------------
> Mick Knutson
> Wells Fargo Business Direct Information Systems
> (415) 222-1020
> 
> "This message may contain confidential and/or privileged 
> information. If you
> are not the addressee or authorized to receive this for the 
> addressee, you
> must not use, copy, disclose, or take any action based on 
> this message or
> any information herein. If you have received this message in 
> error, please
> advise the sender immediately by reply e-mail and delete this 
> message. Thank
> you for your cooperation."
> --------------------
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: cactus-user-help@jakarta.apache.org
> 
> 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message