### Question:
PackedDatabase extends Database { public void dispose() { if (!isCached && dbDir != null && dbDir.exists()) { File tmpDbDir = new File(dbDir.getParentFile(), dbDir.getName() + ".delete"); if (!dbDir.renameTo(tmpDbDir)) { Msg.error(this, "Failed to dispose PackedDatabase - it may still be in use!\n" + packedDbFile, new Exception()); return; } deleteDir(tmpDbDir); } if (dbHandle != null) { dbHandle = null; if (updateLock != null && updateLock.haveLock(true)) { updateLock.removeLock(); } } if (packedDbLock != null && packedDbLock.haveLock(true)) { packedDbLock.removeLock(); } removeInstance(this); } private  PackedDatabase(ResourceFile packedDbFile);   PackedDatabase(ResourceFile packedDbFile, LockFile packedDbLock, CachedDB cachedDb,
			TaskMonitor monitor);   PackedDatabase(PackedDBHandle dbHandle, ResourceFile packedDbFile, String itemName,
			Long newDatabaseId, TaskMonitor monitor); boolean isReadOnly(); static PackedDatabase getPackedDatabase(File packedDbFile, TaskMonitor monitor); static PackedDatabase getPackedDatabase(File packedDbFile, boolean neverCache,
			TaskMonitor monitor); static PackedDatabase getPackedDatabase(ResourceFile packedDbFile, boolean neverCache,
			TaskMonitor monitor); static boolean isReadOnlyPDBDirectory(ResourceFile directory); void dispose(); String getContentType(); ResourceFile getPackedFile(); void delete(); static void delete(File packedDbFile); static void unpackDatabase(BufferFileManager bfMgr, long checkinId, File packedFile,
			TaskMonitor monitor); static void packDatabase(DBHandle dbh, String itemName, String contentType,
			File outputFile, TaskMonitor monitor); @Override synchronized DBHandle open(TaskMonitor monitor); @Override synchronized DBHandle openForUpdate(TaskMonitor monitor); static void cleanupOldTempDatabases(); static final String READ_ONLY_DIRECTORY_LOCK_FILE; }### Answer:
@Test public void testDispose() throws Exception { createPackedDatabase(); assertTrue(packedDbFile.exists()); db = PackedDatabase.getPackedDatabase(packedDbFile, true, TaskMonitorAdapter.DUMMY_MONITOR); File dbDir = (File) getInstanceField("dbDir", db); File tmpDbDir = new File(dbDir.getParentFile(), dbDir.getName() + ".delete"); assertTrue(dbDir.isDirectory()); assertTrue(!tmpDbDir.exists()); assertTrue(dbDir.isDirectory()); assertTrue(!tmpDbDir.exists()); db.dispose(); assertTrue(!dbDir.exists()); assertTrue(!tmpDbDir.exists()); }