JdbcMessageDAO extends NamedParameterJdbcDaoSupport implements
        MessageDAO { public int saveMessageContent(byte[] messageContent) throws DataAccessException { MapSqlParameterSource params = new MapSqlParameterSource(); params.addValue(CONTENT, messageContent, Types.LONGVARBINARY); params.addValue(SIZE, messageContent.length, Types.INTEGER); KeyHolder key = new GeneratedKeyHolder(); getNamedParameterJdbcTemplate().update(INSERT_CONTENT, params, key); return key.getKey().intValue(); }  void createTables(); int saveConversation(int requestId, int responseId); boolean deleteConversation(int id); Collection<Integer> listConversations(); Collection<Integer> listConversationsSince(int id); int getMessageContentId(int headerId); int getMessageContentSize(int id); Conversation getConversation(int id); ConversationSummary getConversationSummary(int id); byte[] loadMessageContent(int id); BufferedRequest loadRequest(int id); RequestHeader loadRequestHeader(int id); MutableBufferedResponse loadResponse(int id); MutableResponseHeader loadResponseHeader(int id); int saveMessageContent(byte[] messageContent); int saveMessageContent(InputStream messageContent); void saveRequest(MutableBufferedRequest request); void saveRequestHeader(MutableRequestHeader requestHeader,
            int contentId); void saveResponse(MutableBufferedResponse response); void saveResponseHeader(MutableResponseHeader responseHeader,
            int contentId);  }
@Test public void testSaveMessageContent() { MutableBufferedRequest request = new MutableBufferedRequest.Impl(); request.setTarget(InetSocketAddress.createUnresolved("localhost", 80)); request.setSsl(false); request.setHeader(AsciiString .getBytes("GET / HTTP/1.0\r\nHost: localhost\r\n\r\n")); request.setTime(1); MutableBufferedResponse response = new MutableBufferedResponse.Impl(); response.setHeader(AsciiString .getBytes("HTTP/1.0 200 Ok\r\nContent-Type: text\r\n\r\n")); byte[] cont = AsciiString.getBytes("Some content"); response.setContent(cont); response.setHeaderTime(2); response.setContentTime(4); dao.saveRequest(request); dao.saveResponse(response); int id = dao.saveConversation(request.getId(), response.getId()); logger.fine("ADDED conversation"); dump(); logger.fine("##############################################"); Conversation c = dao.getConversation(id); RequestHeader reqh = dao.loadRequestHeader(c.getRequestId()); ResponseHeader resph = dao.loadResponseHeader(c.getResponseId()); assertTrue(Arrays.equals(request.getHeader(), reqh.getHeader())); assertEquals(request.getTarget(), reqh.getTarget()); assertEquals(request.isSsl(), reqh.isSsl()); assertEquals(request.getTime(), reqh.getTime()); assertTrue(Arrays.equals(response .getHeader(), resph.getHeader()),"Response headers differ"); assertEquals(response.getHeaderTime(), resph.getHeaderTime()); assertEquals(response.getContentTime(), resph.getContentTime()); byte[] content = dao.loadMessageContent(dao.getMessageContentId(c .getRequestId())); assertNull(content); content = dao.loadMessageContent(dao.getMessageContentId(c .getResponseId())); assertTrue(Arrays.equals(cont, content)); assertTrue(dao.deleteConversation(id),"Delete failed"); dump(); }