@Test public void test40Buffer() throws Exception { ByteBufferCache cache = new ByteBufferCache(40, 80, true); ByteBufferDirectory dir = new ByteBufferDirectory(cache); insertData(dir, 40); verifyData(dir); dir.close(); cache.close(); }
@Test public void testSimpleLocking() throws Exception { ByteBufferCache cache = new ByteBufferCache(40, 80, true); ByteBufferDirectory dir = new ByteBufferDirectory(cache); Lock lock = dir.makeLock("testlock"); assertThat(lock.isLocked(), equalTo(false)); assertThat(lock.obtain(200), equalTo(true)); assertThat(lock.isLocked(), equalTo(true)); try { assertThat(lock.obtain(200), equalTo(false)); assertThat("lock should be thrown", false, equalTo(true)); } catch (LockObtainFailedException e) { // all is well } lock.release(); assertThat(lock.isLocked(), equalTo(false)); dir.close(); cache.close(); }