Posts Tagged ‘junit’
About two years ago I blogged about using HSQLDB to unit test JPA entities. This year, Apache released a Derby version allowing you to use an in memory backend. As I use Derby in software I write, being able to run unit tests on the very same SGBD but in memory is a real gift.
For reference, here is a link to my previous post titled Unit test JPA Entities with in-memory database. What follows is just the very same method applied to Derby.
Still about Hibernate, I have several JPA Entities grouped in a Persistence Unit that I need to test. So here is another quick and dirty howto titled “Unit test JPA Entities with in-memory database”.
Here I assume you already have written your entities java classes with correct annotations.
As I’m working with embedded Derby for a year, I first tried with it but procton (thank you procton) pointed me to another lightweight RDBMS.
So, in this how-to we will set up a unit-tests dedicated persistence unit and use HSQLDB as in-memory database for unit tests.
UPDATE: now that Apache Derby provide an in memory backend, I implemented the very same thing with it in a new post : Unit test JPA Entities with in-memory Derby/JavaDB