vendredi 27 mars 2015

test transaction propagation with service and DAO

I have a service method of the service class, which is a Spring bean, that looks like



@Transactional
public void doThis() {
dao.d1();
dao.d2();
}


and in my DAO class, which extends Spring's NamedParameterJdbcDaoSupport. I have it set up as



@Transactional(propagation = Propagation.MANDATORY)
public void d1(){...}

@Transactional(propagation = Propagation.MANDATORY)
public void d2(){...}


and the configuration looks like



<tx:annotation-driven proxy-target-class="true" transaction-manager="transactionManager" />


Now my question is, how can I integration test it in Spring context? I have tested my DAO with AbstractTransactionalJUnit4SpringContextTests and an embedded database. how will I test the chain of service and DAO now so if dao throws a RuntimeException, I can see the whole transaction is rolled back?


Hope I explain it well. Any hints/suggestions are welcome


Aucun commentaire:

Enregistrer un commentaire