I have a simple MongoDB DAO class for implementing basic CRUD operations (e.g. connection to the running instance and database, etc), but I am struggling to understand how to test it. Are mocks (Mockito) recommended? Can you provide an example of how they can be used?
Mock objects are used as "stand-ins" for the real things so that you can test something that interacts with them. The mocks are merely there to simulate the behavior of the more unwieldy things they stand in for. In the case of DAOs, the thing you are testing is usually the class that uses the DAO. A DAO is normally an interface, which makes it easier to mock out.
Those are just examples of how you might define classes based on a DAO interface.
This is an example of how you might unit test a class that uses TwitterFeedDao:
If you are going to unit test a MongoDBDao, then you'd have to mock out the connection and anything else that represents MongoDB functionality. I wouldn't bother with that though. My approach with DAOs is to use integration tests with them. Spring has many wonderful features to help write integration tests. Google for "integration testing with Spring and MongoDB".