public void test_write_flush_update(){
  final Journal store=(Journal)getStore();
  try {
    RWStrategy bufferStrategy=(RWStrategy)store.getBufferStrategy();
    final int nbytes=60;
    byte[] a=new byte[nbytes];
    r.nextBytes(a);
    final long addr=bufferStrategy.write(ByteBuffer.wrap(a));
    assertEquals(nbytes,store.getByteCount(addr));
    store.commit();
{
      final ByteBuffer b=bufferStrategy.read(addr);
      assertNotNull(b);
      for (int i=20; i < 40; i++) {
        assertEquals("data differs at offset=" + i,a[i],b.get(i));
      }
    }
  }
  finally {
    store.destroy();
  }
}

public void test_write_flush_update ( ) { final Journal store = ( Journal ) getStore ( ) ; try { RWStrategy bufferStrategy = ( RWStrategy ) store . getBufferStrategy ( ) ; final int nbytes = 60 ; byte [ ] a = new byte [ nbytes ] ; r . nextBytes ( a ) ; final long addr = bufferStrategy . write ( ByteBuffer . wrap ( a ) ) ; assertEquals ( nbytes , store . getByteCount ( addr ) ) ; store . commit ( ) ; { final ByteBuffer b = bufferStrategy . read ( addr ) ; assertNotNull ( b ) ; for ( int i = 20 ; i < 40 ; i ++ ) { assertEquals ( "data differs at offset=" + i , a [ i ] , b . get ( i ) ) ; } } } finally { store . destroy ( ) ; } }
ttest write ( ) + flush ( ) + update ( ) - for this case the data have been flushed from the write cache so the update will be a random write on the file rather than being buffered by the write cache .
