@Test(expected=ConnectionClosedException.class)
public void testTruncatedContentWithFile() throws Exception {

    final ReadableByteChannel channel = new ReadableByteChannelMock(
            new String[] {"1234567890"}, 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, 20);
    createTempFile();
    final RandomAccessFile testfile  = new RandomAccessFile(this.tmpfile, "rw");
    try {
        final FileChannel fchannel = testfile.getChannel();
        final long bytesRead = decoder.transfer(fchannel, 0, Integer.MAX_VALUE);
        Assert.assertEquals(10, bytesRead);
        decoder.transfer(fchannel, 0, Integer.MAX_VALUE);
    } finally {
        testfile.close();
    }
}