public void sendAndFlush(ByteBuffer packet) throws IOException {
        sendOnePacket(packet);
        flush();
    }
@Test(expected = IOException.class)
    public void testSendFail() throws IOException {
        // mock
        new Expectations() {
            {
                channel.write((ByteBuffer) any);
                minTimes = 0;
                result = new Delegate() {
                    int fakeWrite(ByteBuffer buffer) {
                        int writeLen = 0;
                        writeLen += buffer.remaining();
                        buffer.position(buffer.limit());
                        return writeLen - 1;
                    }
                };
            }
        };
        MysqlChannel channel1 = new MysqlChannel(channel);
        ByteBuffer buf = ByteBuffer.allocate(1000);
        channel1.sendAndFlush(buf);
        Assert.fail("No Exception throws.");
    }