Package org.springframework.dao

Examples of org.springframework.dao.DataAccessException


        readerService.findReaderById(null);
    }
   
    @Test(expected=DataAccessException.class)
    public void testFindReaderWithWrongId() {
        when(readerDAO.findReaderById(new Long(-1))).thenThrow(new DataAccessException("illegal reader id") {});
        readerService.findReaderById(new Long(-1));
    }
View Full Code Here


        assertEquals(readerTO, readerService.findReaderById(1l));
    }
   
    @Test
    public void testDeleteReaderWithNullID() {
       doThrow(new DataAccessException("null reader id") {}).when(readerDAO).deleteReader(reader);
       readerService.deleteReader(null);
    }
View Full Code Here

       readerService.deleteReader(null);
    }
   
    @Test
    public void testUpdateReaderWithNullID() {
       doThrow(new DataAccessException("null reader id") {}).when(readerDAO).updateReader(reader);
       readerService.updateReader(null);
    }
View Full Code Here

    public void tearDown() {
    }

    @Test(expected=DataAccessException.class)
    public void testCreateBorrowWithNullArgument() {
        when(mockBorrowDao.createBorrow(null)).thenThrow(new DataAccessException("null argument") {});
       
        borrowService.createBorrow(null);
    }
View Full Code Here

    }
   
    @Test(expected=DataAccessException.class)
    public void testCreateBorrowWithNullDate() {
        when(borrow1.getBorrowDate()).thenReturn(null);
        when(mockBorrowDao.createBorrow(borrow1)).thenThrow(new DataAccessException("null date") {});
       
        borrowService.createBorrow(borrow1TO);
    }
View Full Code Here

    }
   
    @Test(expected=DataAccessException.class)
    public void testCreateBorrowWithNullBorrowList() {
        when(borrow1TO.getTitlesTO()).thenReturn(null);
        when(mockBorrowDao.createBorrow(borrow1)).thenThrow(new DataAccessException("null borrow list") {});
       
        borrowService.createBorrow(borrow1TO);
    }
View Full Code Here

    }
   
    @Test(expected=DataAccessException.class)
    public void testCreateBorrowWithEmptyBorrowList() {
        when(borrow1TO.getTitlesTO()).thenReturn(new ArrayList<BookTO>());
        when(mockBorrowDao.createBorrow(borrow1)).thenThrow(new DataAccessException("empty borrow list") {});
       
        borrowService.createBorrow(borrow1TO);
    }
View Full Code Here

        borrowService.createBorrow(borrow1TO);
    }
   
    @Test(expected=DataAccessException.class)
    public void testCreateBorrowWithNullReader() {
        when(mockBorrowDao.createBorrow(borrow1)).thenThrow(new DataAccessException("null reader") {});
       
        borrowService.createBorrow(borrow1TO);
    }
View Full Code Here

   
    @Test(expected=DataAccessException.class)
    public void testCreateBorrowWithAlreadyBorrowedBook() {
        when(iterator.hasNext()).thenReturn(true, true, true, false);
        when(iterator.next()).thenReturn(book1, book2, book3);
        when(mockBorrowDao.createBorrow(borrow1)).thenThrow(new DataAccessException("borrow already borrowed book") {});
       
        borrowService.createBorrow(borrow1TO);
    }
View Full Code Here

        borrowService.createBorrow(borrow1TO);
    }
   
    @Test(expected=DataAccessException.class)
    public void testCreateBorrowWithIllegalReaderID() {
        when(mockBorrowDao.createBorrow(borrow1)).thenThrow(new DataAccessException("illegal reader id") {});

        borrowService.createBorrow(borrow1TO);
    }
View Full Code Here

TOP

Related Classes of org.springframework.dao.DataAccessException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.