### Question:
BufferMgr { public void deleteBuffer(int id) throws IOException { synchronized (snapshotLock) { synchronized (this) { if (corruptedState) { throw new IOException("Corrupted BufferMgr state"); } try { DataBuffer buf = getBuffer(id); buf.setEmpty(true); buf.setDirty(true); releaseBuffer(buf); } catch (Exception e) { handleCorruptionException(e, "BufferMgr buffer delete failed"); } } } } BufferMgr();  BufferMgr(int requestedBufferSize, long approxCacheSize, int maxUndos);  BufferMgr(BufferFile sourceFile);  BufferMgr(BufferFile sourceFile, long approxCacheSize, int maxUndos); private  BufferMgr(BufferFile sourceFile, int requestedbufferSize, long approxCacheSize,
			int maxUndos); void enablePreCache(); void setCorruptedState(); boolean isCorrupted(); synchronized int getLockCount(); int getBufferSize(); BufferFile getSourceFile(); void dispose(); void dispose(boolean keepRecoveryData); void setMaxUndos(int maxUndos); void clearCheckpoints(); int getMaxUndos(); synchronized DataBuffer getBuffer(int id); DataBuffer createBuffer(); void releaseBuffer(DataBuffer buf); void deleteBuffer(int id); boolean atCheckpoint(); boolean checkpoint(); synchronized boolean isChanged(); boolean hasUndoCheckpoints(); boolean hasRedoCheckpoints(); int getAvailableUndoCount(); int getAvailableRedoCount(); boolean undo(boolean redoable); boolean redo(); boolean canSave(); synchronized boolean modifiedSinceSnapshot(); boolean takeRecoverySnapshot(DBChangeSet changeSet, TaskMonitor monitor); LocalBufferFile getRecoveryChangeSetFile(); void clearRecoveryFiles(); boolean recover(TaskMonitor monitor); static boolean canRecover(BufferFileManager bfMgr); void save(String comment, DBChangeSet changeSet, TaskMonitor monitor); void saveAs(BufferFile outFile, boolean associateWithNewFile, TaskMonitor monitor); long getCacheHits(); long getCacheMisses(); int getLowBufferCount(); void resetCacheStatistics(); String getStatusInfo(); int getAllocatedBufferCount(); int getFreeBufferCount(); static void cleanupOldCacheFiles(); static final String ALWAYS_PRECACHE_PROPERTY; static final int DEFAULT_BUFFER_SIZE; static final int DEFAULT_CHECKPOINT_COUNT; static final int DEFAULT_CACHE_SIZE; }### Answer:
@Test public void testDeleteBuffer() throws IOException { initNewFile(); DataBuffer buf = mgr.createBuffer(); assertEquals(1, mgr.getLockCount()); int id = buf.getId(); buf.put(0, fillPattern1); mgr.releaseBuffer(buf); assertEquals(0, mgr.getLockCount()); buf = mgr.getBuffer(id); assertEquals(1, mgr.getLockCount()); mgr.releaseBuffer(buf); assertEquals(0, mgr.getLockCount()); mgr.deleteBuffer(id); assertEquals(0, mgr.getLockCount()); try { buf = mgr.getBuffer(id); Assert.fail("Deleted buffer still exists"); } catch (IOException e) { } assertEquals(0, mgr.getLockCount()); }