private void testAdvancePastNextSyncMarkerAt(int position,int size) throws IOException {
  byte sentinel=(byte)0xFF;
  byte[] marker=new byte[]{1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6};
  byte[] haystack=createHaystack(marker,position,size);
  PushbackInputStream stream=new PushbackInputStream(new ByteArrayInputStream(haystack),marker.length);
  if (position + marker.length < size) {
    haystack[position + marker.length]=sentinel;
    assertEquals(position + marker.length,AvroReader.advancePastNextSyncMarker(stream,marker));
    assertEquals(sentinel,(byte)stream.read());
  }
 else {
    assertEquals(size,AvroReader.advancePastNextSyncMarker(stream,marker));
    assertEquals(-1,stream.read());
  }
}

private void testAdvancePastNextSyncMarkerAt ( int position , int size ) throws IOException { byte sentinel = ( byte ) 0xFF ; byte [ ] marker = new byte [ ] { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 , 1 , 2 , 3 , 4 , 5 , 6 } ; byte [ ] haystack = createHaystack ( marker , position , size ) ; PushbackInputStream stream = new PushbackInputStream ( new ByteArrayInputStream ( haystack ) , marker . length ) ; if ( position + marker . length < size ) { haystack [ position + marker . length ] = sentinel ; assertEquals ( position + marker . length , AvroReader . advancePastNextSyncMarker ( stream , marker ) ) ; assertEquals ( sentinel , ( byte ) stream . read ( ) ) ; } else { assertEquals ( size , AvroReader . advancePastNextSyncMarker ( stream , marker ) ) ; assertEquals ( - 1 , stream . read ( ) ) ; } }
asserts that advancepastnextsyncmarker advances an input stream past a sync marker and correctly returns the number of bytes consumed from the stream . creates a haystack of size bytes and places a 16 - byte sync marker at the position specified .
