    @Test
    public void testUpdateMessageAttachment3() throws Exception {

        String channelId = "testchannel";
        long messageId = 1;
        Attachment attachment = new Attachment("testattachment", StringUtils.repeat("testtest", "", 10 * 1024 * 1024 / 8).getBytes(), "text/plain");

        ResultSet segmentCountResult = mock(ResultSet.class);
        PreparedStatement segmentCountStatement = mock(PreparedStatement.class);
        PreparedStatement updateStatement = mock(PreparedStatement.class);
        PreparedStatement insertStatement = mock(PreparedStatement.class);
        PreparedStatement deleteStatement = mock(PreparedStatement.class);
        JdbcDao dao = getDao(channelId, segmentCountResult, segmentCountStatement, updateStatement, insertStatement, deleteStatement);

        when(segmentCountResult.getInt(1)).thenReturn(1);

        dao.updateMessageAttachment(channelId, messageId, attachment);

        verify(segmentCountStatement, times(1)).setString(1, attachment.getId());
        verify(segmentCountStatement, times(1)).setLong(2, messageId);
        verify(segmentCountStatement, times(1)).executeQuery();

        verify(updateStatement, times(1)).setString(1, attachment.getType());
        verify(updateStatement, times(1)).setString(4, attachment.getId());
        verify(updateStatement, times(1)).setLong(5, messageId);

        verify(insertStatement, times(1)).setString(1, attachment.getId());
        verify(insertStatement, times(1)).setLong(2, messageId);
        verify(insertStatement, times(1)).setString(3, attachment.getType());

        verify(updateStatement, times(1)).setInt(6, 1);
        verify(updateStatement, times(1)).setInt(2, 10000000);
        verify(updateStatement, times(1)).setBytes(3, Arrays.copyOfRange(attachment.getContent(), 0, 10000000));
        verify(updateStatement, times(1)).executeUpdate();

        verify(insertStatement, times(1)).setInt(4, 2);
        verify(insertStatement, times(1)).setInt(5, attachment.getContent().length - 10000000);
        verify(insertStatement, times(1)).setBytes(6, Arrays.copyOfRange(attachment.getContent(), 10000000, attachment.getContent().length));
        verify(insertStatement, times(1)).executeUpdate();

        verify(updateStatement, times(1)).clearParameters();
        verify(insertStatement, times(1)).clearParameters();

        verify(deleteStatement, times(0)).setString(1, attachment.getId());
        verify(deleteStatement, times(0)).setLong(2, messageId);
        verify(deleteStatement, times(0)).setInt(eq(3), anyInt());
        verify(deleteStatement, times(0)).executeUpdate();
    }