/* * To change this template, choose Tools | Templates * and open the template in the editor. */ import com.ibatis.common.resources.Resources; import com.ibatis.dao.client.DaoManager; import com.ibatis.dao.client.DaoManagerBuilder; import ibatis.Account; import ibatis.dao.AccountDAO; import java.io.Reader; import java.util.List; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; /** * * @author lane */ public class ReadUsingDAOJUnitTest { private String resource = "dao.xml"; private Reader reader; private DaoManager daoManager; public ReadUsingDAOJUnitTest() { } @BeforeClass public static void setUpClass() throws Exception { } @AfterClass public static void tearDownClass() throws Exception { } @Before public void setUp() { try { reader = Resources.getResourceAsReader (resource); daoManager = DaoManagerBuilder.buildDaoManager(reader); daoManager.startTransaction(); }catch(Exception e) { e.printStackTrace(); throw new RuntimeException ("Error initializing DaoManager. Cause: "+e); } } @After public void tearDown() { reader = null; daoManager = null; } // TODO add test methods here. // The methods must be annotated with annotation @Test. For example: // // @Test // public void hello() {} @Test public void testGetAll() { try { System.out.println("function getAll() test:"); AccountDAO adao = (AccountDAO) daoManager.getDao(AccountDAO.class); List li = adao.getAll(); for (int i=0;i