### Question:
SQLUserDAO implements UserDAO { @Override public List<IUser> getAll() { try { List<IUser> result = new LinkedList<IUser>(); PreparedStatement ps = connection.prepareStatement(GET_ALL_SQL); ResultSet r = ps.executeQuery(); while (r.next()) { result.add(readUser(r)); } r.close(); ps.close(); return result; } catch (SQLException e) { throw new RuntimeException(e); } } SQLUserDAO(Connection c); @Override void delete(IUser user); @Override List<IUser> getAll(); @Override IUser getById(int id); @Override List<IUser> getByName(String name); @Override void saveOrUpdate(IUser user);  }### Answer:
@Test(expected = RuntimeException.class) public void testGetAll() throws DatabaseUnitException, SQLException, Exception { UserDAO dao = new SQLUserDAO(connection); List<IUser> userlist = dao.getAll(); ITable actualTable = (ITable) userlist; InputStream stream = this.getClass().getResourceAsStream("UserDaoTestData.xml"); IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(stream); ITable expectedTable = expectedDataSet.getTable("CLIENTS"); assertEquals(expectedTable, actualTable); stream = this.getClass().getResourceAsStream("UserDaoSingleRowTest.xml"); IDataSet dataSet = new FlatXmlDataSetBuilder().build(stream); DatabaseOperation.CLEAN_INSERT.execute(tester.getConnection(), dataSet); dao = new SQLUserDAO(tester.getConnection().getConnection()); userlist = dao.getAll(); assertEquals(1, userlist.size()); assertEquals("Bond", userlist.get(0).getName()); stream = this.getClass().getResourceAsStream("UserDaoEmpty.xml"); dataSet = new XmlDataSet(stream); DatabaseOperation.CLEAN_INSERT.execute(tester.getConnection(), dataSet); Connection conn = tester.getConnection().getConnection(); dao = new SQLUserDAO(conn); userlist = dao.getAll(); assertNotNull(userlist); assertEquals(0, userlist.size()); conn.close(); dao.getAll(); }