@Test
public void testBasicDecodingFile() throws Exception {

    final ReadableByteChannel channel = new ReadableByteChannelMock(
            new String[] {"stuff; ", "more stuff; ", "a lot more stuff!"}, StandardCharsets.US_ASCII);
    final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, 0, StandardCharsets.US_ASCII);
    final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
    final IdentityDecoder decoder = new IdentityDecoder(
            channel, inbuf, metrics);
    createTempFile();
    final RandomAccessFile testfile = new RandomAccessFile(this.tmpfile, "rw");
    try {
        final FileChannel fchannel = testfile.getChannel();
        long pos = 0;
        while (!decoder.isCompleted()) {
            final long bytesRead = decoder.transfer(fchannel, pos, 10);
            if (bytesRead > 0) {
                pos += bytesRead;
            }
        }
        Assert.assertEquals(testfile.length(), metrics.getBytesTransferred());
    } finally {
        testfile.close();
    }
    Assert.assertEquals("stuff; more stuff; a lot more stuff!",
        CodecTestUtils.readFromFile(this.tmpfile));
}