?????????????????????
<?xml version="1.0" encoding="UTF-8"?>
<dataset>
<branch id="1" name="????1" sub_id="1"/>
<branch id="2" name="????2" sub_id="1"/>
<branch id="3" name="????3" sub_id="1"/>
<branch id="4" name="????4" sub_id="1"/>
<branch id="5" name="????5" sub_id="1"/>
<branch id="6" name="????6" sub_id="1"/>
</dataset>
?????????????:BranchDaoTest
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("/beans.xml")
public class BranchDaoTest extends AbstractDbUnitTestCase {
@Inject
private SessionFactory sessionFactory;
@Inject
private IBranchDao branchDao;
@Inject
private ISubjectDao subjectDao;
@Before
public void setUp() throws SQLException?? IOException?? DatabaseUnitException {
//????ò?????Spring??Transactional??????????dbunit?????jdbc??????connection???????spring???Щ???????л????????shisu
Session s = sessionFactory.openSession();
TransactionSynchronizationManager.bindResource(sessionFactory?? new SessionHolder(s));
this.backupAllTable();
IDataSet ds = createDateSet("t_beans");
DatabaseOperation.CLEAN_INSERT.execute(dbunitCon??ds);
}
@After
public void tearDown() throws DatabaseUnitException?? SQLException?? IOException {
SessionHolder holder = (SessionHolder) TransactionSynchronizationManager.getResource(sessionFactory);
Session s = holder.getSession();
s.flush();
TransactionSynchronizationManager.unbindResource(sessionFactory);
this.resumeTable();
}
@Test
public void testLoadByName(){
Branch branch=branchDao.loadByName("?????");
assertEquals(branch.getId()?? 1);
}
}
??????????