I was assigned the old web applicator (JSF 1.2 + Eclipselink), there is no middleware such as EJB or Spring, and the application service level consists of POJO, which calls EntityManager directly. The code structure looks like this: SomeBean (bean support) → SomeServices (there is a combination of business logic and a data access code), without a separate DAO layer. The code in service classes usually looks like this (very simplified here):
public void someMethod(SomeEntity someEntity, ....) throws SomeServiceExeption {
try{
entitiyManager.getTransaction.begin();
entitiyManager.getTransaction.commit();
}catch(Exception e){
log.error("");
if(entitiyManager.getTransaction..isActive()){
entitiyManager.getTransaction.rollback();
}
throw new SomeServiceExeption(e);
}
}
, , ( , , ). , unit test . :
- . DAO
entityManager.
.
- Mock EntityManager. EasyMock,
, , ,
, , , ,
api, . EntityManager .
- hsqldb h2
. , , ,
.
, .