????@TransactionConfiguration ?? @Rollback

??????????£?Spring ????????????????е???? transactionManager ?? bean ??????????????????????????????????????? transactionManager ?????????????????? defaultRollback ???????? true???????е?????? rollback???????????? false???????????Щ??? rollback ??????????????? @Rollback??true?????ɡ?

?????? Junit4 ??????????

???????????? Spring ?????????????????????????Щ????????? Junit4 ????????? Spring ????????е???÷?????

????@Test(expected=…)

???????????????????????????????????????????????????????? xxx.class ????????磬??????? AccountService.Java ?? insertIfNotExist ????????????????????????????? IllegalArgumentException?????£?

    public void insertIfNotExist(Account account) { 
        if(account==null) 
            throw new IllegalArgumentException("account is null"); 
        Account acct = accountDao.getAccountById(account.getId()); 
        if(acct==null) { 
            log.debug("No "+account+" found??would insert it."); 
            accountDao.saveAccount(account); 
        } 
        acct = null; 
    }

???????????????????????????????????????£?

    @Test(expected=IllegalArgumentException.class) 
    public void testInsertException() { 
        service.insertIfNotExist(null); 
    }

???????н???? green bar??

????@Test(timeout=…)

???????????????????????????????????????????????????????????????

?????????? AccountService ?????????·?????

    public void doSomeHugeJob() { 
        try { 
            Thread.sleep(2*1000); 
        } catch (InterruptedException e) { 
        } 
    }

????????????????????????? 2 ?????????????£?

    @Test(timeout=3000) 
    public void testHugeJob() { 
        service.doSomeHugeJob(); 
    }

?????????????????? service.doSomeHugeJob ???????? 3 ???????????в??????? green bar??

????@Repeat

??????? @Repeat?????????????????в??????????????????д for ???????÷?????

    @Repeat(3) 
    @Test(expected=IllegalArgumentException.class) 
    public void testInsertException() { 
        service.insertIfNotExist(null); 
    }

??????????testInsertException ?????? 3 ?Ρ?