Jmock mock DAO object

Posted by Gandalf StormCrow on Stack Overflow See other posts from Stack Overflow or by Gandalf StormCrow
Published on 2010-03-30T14:44:59Z Indexed on 2010/03/30 15:13 UTC
Read the original article Hit count: 624

Filed under:
|
|

Hi all, I wrote a method that retrieves certain list of strings, given a correct string key. Now when I create a list(the one to be retrieved by method descibed in previous sentence) and create test I can easily get results and test passes successfully.

Now on the other hand if I save the content of this list to database in 2 columns, key and value I wrote a class which retrieves this items with method inside it. And when I print it out to console the expected results are correct, now I initialize my DAO from application context where inside its bean it gets session and because of DAO works.

Now I'm trying to write a test which will mock the DAO, because I'm running test localy not on the server .. so I told jmock to mock it :

private MyDAO myDAO;

in the setup()

myDAO = context.mock(MyDAO.class);

I think I'm mocking it correctly or not, how can I mock this data from database? what is the best way?

Is there somewhere good Jmock documentation? on their official site its not very good and clear, you have to know what you seek in order to find it, can't discover something cool in the mean time.

© Stack Overflow or respective owner

Related posts about java

Related posts about dao