LockReleasingSanskrit implements Sanskrit { @Override @SuppressWarnings("try") public void close() throws SanskritException { try ( Owner<DirectoryLock, IOException> lockOwner = own(lock, IOException.class); Owner<Sanskrit, SanskritException> sanskritOwner = own(underlying, SanskritException.class) ) { } catch (IOException e) { throw new SanskritException(e); } } LockReleasingSanskrit(Sanskrit underlying, DirectoryLock lock); @Override @SuppressWarnings("try") void close(); @Override String getString(String key); @Override Long getLong(String key); @Override SanskritObject getObject(String key); @Override void applyChange(SanskritChange change); @Override MutableSanskritObject newMutableSanskritObject(); @Override void reset();  }
@Test public void releasesLocks() throws Exception { LockReleasingSanskrit sanskrit = new LockReleasingSanskrit(underlying, lock); sanskrit.close(); InOrder inOrder = inOrder(underlying, lock); inOrder.verify(underlying).close(); inOrder.verify(lock).close(); }