| 12 | import static org.junit.Assert.*; |
| 13 | |
| 14 | @RunWith(SpringJUnit4ClassRunner.class) |
| 15 | @ContextConfiguration(locations = {"file:src/main/webapp/WEB-INF/spring/root-context.xml"}) |
| 16 | public class BoardDaoImplTest { |
| 17 | @Autowired |
| 18 | private BoardDao boardDao; |
| 19 | |
| 20 | @Test |
| 21 | public void countTest() throws Exception { |
| 22 | boardDao.deleteAll(); |
| 23 | assertTrue(boardDao.count()==0); |
| 24 | |
| 25 | BoardDto boardDto = new BoardDto("no title", "no content", "asdf"); |
| 26 | assertTrue(boardDao.insert(boardDto)==1); |
| 27 | assertTrue(boardDao.count()==1); |
| 28 | |
| 29 | assertTrue(boardDao.insert(boardDto)==1); |
| 30 | assertTrue(boardDao.count()==2); |
| 31 | } |
| 32 | |
| 33 | @Test |
| 34 | public void deleteAllTest() throws Exception { |
| 35 | boardDao.deleteAll(); |
| 36 | assertTrue(boardDao.count()==0); |
| 37 | |
| 38 | BoardDto boardDto = new BoardDto("no title", "no content", "asdf"); |
| 39 | assertTrue(boardDao.insert(boardDto)==1); |
| 40 | assertTrue(boardDao.deleteAll()==1); |
| 41 | assertTrue(boardDao.count()==0); |
| 42 | |
| 43 | boardDto = new BoardDto("no title", "no content", "asdf"); |
| 44 | assertTrue(boardDao.insert(boardDto)==1); |
| 45 | assertTrue(boardDao.insert(boardDto)==1); |
| 46 | assertTrue(boardDao.deleteAll()==2); |
| 47 | assertTrue(boardDao.count()==0); |
| 48 | } |
| 49 | |
| 50 | @Test |
| 51 | public void deleteTest() throws Exception { |
| 52 | boardDao.deleteAll(); |
| 53 | assertTrue(boardDao.count()==0); |
| 54 | |
| 55 | BoardDto boardDto = new BoardDto("no title", "no content", "asdf"); |
| 56 | assertTrue(boardDao.insert(boardDto)==1); |
| 57 | Integer bno = boardDao.selectAll().get(0).getBno(); |
| 58 | assertTrue(boardDao.delete(bno, boardDto.getWriter())==1); |
| 59 | assertTrue(boardDao.count()==0); |
| 60 | |
| 61 | assertTrue(boardDao.insert(boardDto)==1); |
| 62 | bno = boardDao.selectAll().get(0).getBno(); |
| 63 | assertTrue(boardDao.delete(bno, boardDto.getWriter()+"222")==0); |
| 64 | assertTrue(boardDao.count()==1); |
| 65 | |
| 66 | assertTrue(boardDao.delete(bno, boardDto.getWriter())==1); |
| 67 | assertTrue(boardDao.count()==0); |
| 68 | |
| 69 | assertTrue(boardDao.insert(boardDto)==1); |
| 70 | bno = boardDao.selectAll().get(0).getBno(); |
| 71 | assertTrue(boardDao.delete(bno+1, boardDto.getWriter())==0); |
nothing calls this directly
no outgoing calls
no test coverage detected