testNG test transaction rollback

/**
* Transactions are automatically rolled back
*/
@ContextConfiguration("classpath:/config/applicationContext.xml")
public class CollegeMapperTest extends AbstractTransactionalTestNGSpringContextTests{

    @Resource
    private CollegeMapper collegeMapper;
    @Test
    public void testInsertReject() throws Exception {
        Reject reject = new Reject(1,null,"XXX");
        collegeMapper.insertReject(reject);
    }
}

/**
* Select the rollback of the transaction
*/
@ContextConfiguration("classpath:/config/applicationContext.xml")
@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = false)
public class CollegeMapperTest extends AbstractTestNGSpringContextTests{

    @Resource
    private CollegeMapper collegeMapper;

    @Rollback(true)
    @Test
    public void testInsertReject() throws Exception {
        Reject reject = new Reject(1,null,"XXXX");
        collegeMapper.insertReject(reject);
    }
}

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326517379&siteId=291194637