• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Integration Testing with Spring and Mocks  RSS feed

Ranch Hand
Posts: 123
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know this post doesnt have much to do with the Spring framework but wanted to get some feedback from fellow developers as this must be a common problem.

Furthermore I using Spring for integration testing purposes where Im testing business methods expose by a service layer. More so the problem I have is that part of the integration testing is to create/mock domain models/objects used by the services ie.:

Two problems im facing:
1. If I use EasyMock as above ALL my domain models that I want to mock have to be interfaces of which currently no domain models are as to me this is an extreme case of too many interfaces especially as all my models are hibernate specific. Find below an outline of the Client model:

2. Im trying to replicate an invocation to the "getPrimaryId()" method of which is causing an issue when I mock the Client.class using either Mockito and EasyMock as the getPrimaryId() method is used in the "equals()" method in the domain model. This is causing a StackOverflow as both mocking frameworks use the equals method to determine which mock object to evaluation and test against. The equals method is as follow:

Any feedback will be awesome, thanks.

Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EasyMock is providing its own implementation of equals. This method cannot be mocked. However, yours is final which prevents EasyMock to work correctly.

You have two choices:
- Remove the final
- Use weaving to remove it at classloading during your tests
I'm THIS CLOSE to ruling the world! Right after reading this tiny ad:
how do I do my own kindle-like thing - without amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!