encoder.write(kv3);
encoder.flush();
dos.close();
long offset = cos.getCount();
assertEquals(length * 3, offset);
CountingInputStream cis =
new CountingInputStream(new ByteArrayInputStream(baos.toByteArray()));
DataInputStream dis = new DataInputStream(cis);
Codec.Decoder decoder = kvc.getDecoder(dis);
assertTrue(decoder.advance());
KeyValue kv = (KeyValue)decoder.current();
assertTrue(kv1.equals(kv));
assertTrue(decoder.advance());
kv = (KeyValue)decoder.current();
assertTrue(kv2.equals(kv));
assertTrue(decoder.advance());
kv = (KeyValue)decoder.current();
assertTrue(kv3.equals(kv));
assertFalse(decoder.advance());
dis.close();
assertEquals((length * 3), cis.getCount());
}