### Question:
BrotliLoader { LibEntry extractLibrary() throws IOException { String libName = System.mapLibraryName(BASE_LIB_NAME); String libPath = findLibraryPath(libName); URL libUrl = BrotliLoader.class.getResource(libPath); if (libUrl == null) { throw new FileNotFoundException("couldn't find brotli jni library: " + libPath); } cleanStaleEntries(libName); return createLibEntry(libName, libUrl); } BrotliLoader(Path tempDir);   BrotliLoader(Path tempDir, String dictionaryPath);  static final int BROTLI_DICT_SIZE; }### Answer:
@Test void entryCreation(@TempDir Path tempDir) throws IOException { new BrotliLoader(tempDir).extractLibrary(); var libName = System.mapLibraryName(BASE_LIB_NAME); var createdEntries = listFiles(tempDir); assertEquals(1, createdEntries.size(), createdEntries.toString()); var entry = createdEntries.get(0); var createdFiles = listFiles(entry); assertEquals(2, createdFiles.size(), createdFiles.toString()); var expected = Set.of(entry.resolve(libName), entry.resolve(libName + ".lock")); assertEquals(expected, Set.copyOf(createdFiles)); }
@Test void cleanupRoutine(@TempDir Path tempDir) throws IOException { var libName = System.mapLibraryName(BASE_LIB_NAME); var staleEntry = Files.createDirectory(tempDir.resolve(ENTRY_DIR_PREFIX + "stale")); Files.createFile(staleEntry.resolve(libName)); var activeEntry = Files.createDirectories(tempDir.resolve(ENTRY_DIR_PREFIX + "active")); Files.createFile(activeEntry.resolve(libName)); Files.createFile(activeEntry.resolve(libName + ".lock")); var entryUnderCreation = Files.createDirectory(tempDir.resolve(ENTRY_DIR_PREFIX + "underCreation")); new BrotliLoader(tempDir).extractLibrary(); var entries = listFiles(tempDir); assertEquals(3, entries.size(), entries.toString()); assertFalse(entries.contains(staleEntry), entries.toString()); assertTrue(entries.containsAll(Set.of(activeEntry, entryUnderCreation)), entries.toString()); }