chipmunk
chipmunk

Reputation: 565

Testing my REST interface

I'm new to testing and this is case:

  1. 1 have a REST service, so a REST.class
  2. I have a backend which connects to the DB and persists all the GET/POST method (say 10-15 tables are modified)
  3. I have a class in between both, which does the manipulation of the input/output

What I have done so far: 1. Mocked the classes and the input/output objects of the manip class. This has worked well. 2. Tested the REST using Jersey Test with my h2 db as test db.

My Q: How can I test the individual parts of the application without any dependency on the DB? As in, I want to eliminated the actual writing/reading to the test DB and mock that too. Is that possible? these are the basic cases I would like to test:

  1. Test if the DB is up i.e. if I can connect to it in the first place.
  2. If yes, then check if the tables are properly written into. Right now, i'm checking manually against the DB. I want to eliminate the DB part by mocking.

please let me know if I haven't been clear. Thanks.

Upvotes: 0

Views: 367

Answers (1)

Teixi
Teixi

Reputation: 1097

You could use a test database such as: Apache Derby (JavaDB), Hypersonic, H2, HSQLDB...

Here you can find more details on integration testing with file or in-memory persiste: http://www.oracle.com/technetwork/articles/java/integrationtesting-487452.html

Upvotes: 1

Related Questions