• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

easymock question: semantics of EasyMock.same()

 
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

i am using EasyMock.same() to pass a kind of criteria object to record a test double.

mockedInstance.callSomething(EasyMock.same(new CriteriaObject("bla"));

what semantics does same() use? i did an override of equals() and hashCode() because i expected that easy mocks is calling indirectly equals() for deciding if something is same or not. this seems not to be the case.

what else is same() using?

thanks
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Remember that EasyMock is open source, so you can look it up for yourself.

In EasyMock, the semantics of "same" are the same (pun not intended) as in JUnit - object identity.

Object equality is the default behavior of mocks - just remove the call to same to get that behavior:

mockedInstance.callSomething(new CriteriaObject("bla"));
 
reply
    Bookmark Topic Watch Topic
  • New Topic