@Test
@EnabledOnOs(WINDOWS)
public void shouldUnlockFileAfterReadingExtensionsFromPlugin() throws Exception {

    PluginJar pluginJar = new PluginJar.Builder(pluginsPath.resolve("test-plugin.jar"), "test-plugin")
            .pluginClass(TestPlugin.class.getName())
            .pluginVersion("1.2.3")
            .extension(TestExtension.class.getName())
            .build();
    assertTrue(pluginJar.file().exists());
    PluginManager pluginManager = new JarPluginManager(pluginsPath);
    pluginManager.loadPlugins();
    assertEquals(1, pluginManager.getPlugins().size());
    LegacyExtensionFinder extensionFinder = new LegacyExtensionFinder(pluginManager);
    Map<String, Set<String>> pluginsStorages = extensionFinder.readPluginsStorages();
    assertNotNull(pluginsStorages);
    pluginManager.unloadPlugin(pluginJar.pluginId());
    boolean fileDeleted = pluginJar.file().delete();
    Set<String> pluginStorages = pluginsStorages.get(pluginJar.pluginId());
    assertNotNull(pluginStorages);
    assertEquals(1, pluginStorages.size());
    assertThat(pluginStorages, contains(TestExtension.class.getName()));
    assertTrue(fileDeleted);
    assertFalse(pluginJar.file().exists());
}