File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Testing and the fly likes EasyMock 3.0 Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "EasyMock 3.0 Question" Watch "EasyMock 3.0 Question" New topic

EasyMock 3.0 Question

Jeff Palmer

Joined: Feb 14, 2011
Posts: 1
I'm trying to use EasyMock 3.0 to test a MessageListener class that I wrote. When I run my test, I'm consistently getting a NPE for a class that I'm mocking.

The code for the method I'm trying to test is as follows (the NPE is happening at line 07 in the following code):

My test code is as follows:

I'm fairly new to EasyMock so any help would be greatly appreciated. Thanks!
Krisztian Milesz

Joined: Mar 02, 2008
Posts: 5
It seems like that you've just created a mock MessageUtility but you didn't inject that into the listener object. You have to tell the listener to use your mocked MessageUtility.

I agree. Here's the link:
subject: EasyMock 3.0 Question
It's not a secret anymore!