@Test
public void testWriteBeyondFileSize() throws Exception {

    final ReadableByteChannel channel = new ReadableByteChannelMock(
            new String[] {"a"}, StandardCharsets.US_ASCII);
    final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, 0, StandardCharsets.US_ASCII);
    final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
    final LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
            channel, inbuf, metrics, 1);
    createTempFile();
    final RandomAccessFile testfile = new RandomAccessFile(this.tmpfile, "rw");
    try {
        final FileChannel fchannel = testfile.getChannel();
        Assert.assertEquals(0, testfile.length());
        try {
            decoder.transfer(fchannel, 5, 10);
            Assert.fail("IOException should have been thrown");
        } catch(final IOException expected) {
        }
    } finally {
        testfile.close();
    }
}