public void testReadAndSkipWithMultipleBlocks(final List<BCF2TypedValue> block1, final List<BCF2TypedValue> block2) throws IOException { final byte[] record1 = encodeRecord(block1); final byte[] record2 = encodeRecord(block2); // each record is individually good decodeRecord(block1, record1); decodeRecord(block2, record2); BCF2Decoder decoder = new BCF2Decoder(); // test setting decoder.setRecordBytes(record1); decodeRecord(block1, decoder); decoder.setRecordBytes(record2); decodeRecord(block2, decoder); // test combining the streams final byte[] combined = combineRecords(record1, record2); final List<BCF2TypedValue> combinedObjects = new ArrayList<BCF2TypedValue>(block1); combinedObjects.addAll(block2); // the combined bytes is the same as the combined objects InputStream stream = new ByteArrayInputStream(combined); decoder.readNextBlock(record1.length, stream); decodeRecord(block1, decoder); decoder.readNextBlock(record2.length, stream); decodeRecord(block2, decoder); // skipping the first block allows us to read the second block directly stream = new ByteArrayInputStream(combined); decoder.skipNextBlock(record1.length, stream); decoder.readNextBlock(record2.length, stream); decodeRecord(block2, decoder); }