public void testReadAndWrite() throws Exception { SortedOplogConfiguration config = new SortedOplogConfiguration("lex") .setComparator(new LexicographicalComparator()); hfile = new HFileSortedOplog(new File("lexi.soplog"), config); SortedOplogWriter wtr = hfile.createWriter(); for (int i = -100; i < 100; i++) { wtr.append(ComparisonTestCase.convert(i), ComparisonTestCase.convert(i)); } wtr.close(null); SortedReader<ByteBuffer> rdr = hfile.createReader(); for (int i = -100; i < 100; i++) { byte[] key = ComparisonTestCase.convert(i); assertTrue(rdr.mightContain(key)); ByteBuffer val = rdr.read(key); assertEquals(i, ComparisonTestCase.recover(val.array(), val.arrayOffset(), val.remaining())); } rdr.close(); }