I want to write integration tests for an ejb that does some basic CRUD operations.
here is how my test looks like now:
@Test
public void testAdd() {
EJBContainer container = javax.ejb.embeddable.EJBContainer.createEJBContainer();
MyEJBLocal myEjb= (MyEJBLocal)container.getContext().lookup("java:global/classes/MyEJB");
// assuming I empty the database in the setup
myEjb.add();
int numOfEntities= myEjb.getAll().size();
Assert.assertTrue("Unexpected number of entities", (numOfEntities==1));
container.close();
}
obviously, this is not a good test but how to properly integrate DBUnit or any similar framework to control the state of the database before and after the add()
method?
Iam using EJB, Hibernate and embedded Glassfish