0

How to mock third party API via EasyMock ?

Ex: 2 classes - Employee - our class, NPECustomer - Third Party class

Assume Employee has createCustomer method with the following code

createCustomer(Employee emp) {
NPECustomer customer = new NPECustomer();
customer.add
customer.finalize
more customer. method and it goes on...
  1. Now the question is how to mock third party API via easy Mock
  2. What are the alternate ways to solve the above problem if Mocking the third party API is not feasible or tedious
asgoth
  • 35,552
  • 12
  • 89
  • 98
Kathir
  • 2,733
  • 12
  • 39
  • 67
  • I may be misunderstanding the question, but I think you can simply do EasyMock.createMock(NPECustomer.class); Then you can add expectations like normal. If this isn't what you're asking, please add some more clarifications. – Joe Jan 12 '13 at 15:51
  • This can be used for creating mock objects for normal java classes. In which are the cases the third party API causes an issue. I have not used EasyMock to create mock for third party APIs so far and would like to know if there are any limitations or issues may occur upfront. – Kathir Jan 14 '13 at 13:38
  • As long as the class you're trying to mock isn't final, it should work about the same as if it was one of your classes. Is there something that makes the 3rd party api different than a normal java class (other than it coming from a non-local source)? – Joe Jan 14 '13 at 16:42

1 Answers1

0

Mocking can be done for any object. for third party ad servers we can start mock servers. This resolves the problem.

Kathir
  • 2,733
  • 12
  • 39
  • 67