public void test_reallocate(){
  final Journal store=(Journal)getStore();
  try {
    final byte[] buf=new byte[1024];
    r.nextBytes(buf);
    final ByteBuffer bb=ByteBuffer.wrap(buf);
    final RWStrategy bs=(RWStrategy)store.getBufferStrategy();
    final RWStore rw=bs.getStore();
    long faddr1=bs.write(bb);
    bb.position(0);
    long faddr2=bs.write(bb);
    bb.position(0);
    ByteBuffer inbb1=bs.read(faddr1);
    ByteBuffer inbb2=bs.read(faddr2);
    assertEquals(bb,inbb1);
    assertEquals(bb,inbb2);
    store.commit();
    inbb1=bs.read(faddr1);
    inbb2=bs.read(faddr2);
    assertEquals(bb,inbb1);
    assertEquals(bb,inbb2);
    rw.reset();
    inbb1=bs.read(faddr1);
    inbb2=bs.read(faddr2);
    assertEquals(bb,inbb1);
    assertEquals(bb,inbb2);
    inbb1=bs.read(faddr1);
    inbb2=bs.read(faddr2);
    assertEquals(bb,inbb1);
    assertEquals(bb,inbb2);
  }
  finally {
    store.destroy();
  }
}

public void test_reallocate ( ) { final Journal store = ( Journal ) getStore ( ) ; try { final byte [ ] buf = new byte [ 1024 ] ; r . nextBytes ( buf ) ; final ByteBuffer bb = ByteBuffer . wrap ( buf ) ; final RWStrategy bs = ( RWStrategy ) store . getBufferStrategy ( ) ; final RWStore rw = bs . getStore ( ) ; long faddr1 = bs . write ( bb ) ; bb . position ( 0 ) ; long faddr2 = bs . write ( bb ) ; bb . position ( 0 ) ; ByteBuffer inbb1 = bs . read ( faddr1 ) ; ByteBuffer inbb2 = bs . read ( faddr2 ) ; assertEquals ( bb , inbb1 ) ; assertEquals ( bb , inbb2 ) ; store . commit ( ) ; inbb1 = bs . read ( faddr1 ) ; inbb2 = bs . read ( faddr2 ) ; assertEquals ( bb , inbb1 ) ; assertEquals ( bb , inbb2 ) ; rw . reset ( ) ; inbb1 = bs . read ( faddr1 ) ; inbb2 = bs . read ( faddr2 ) ; assertEquals ( bb , inbb1 ) ; assertEquals ( bb , inbb2 ) ; inbb1 = bs . read ( faddr1 ) ; inbb2 = bs . read ( faddr2 ) ; assertEquals ( bb , inbb1 ) ; assertEquals ( bb , inbb2 ) ; } finally { store . destroy ( ) ; } }
reallocates the same object several times , then commits and tests read back . has been amended to exercise different cache read paths .
