diff options
author | Decebal Suiu <decebal.suiu@gmail.com> | 2024-04-06 23:29:37 +0300 |
---|---|---|
committer | Decebal Suiu <decebal.suiu@gmail.com> | 2024-04-06 23:29:37 +0300 |
commit | 74aa987ca9a23234efbd58766d648135af7bdcc7 (patch) | |
tree | cbf969b42cc52ff512145c525b71b4dcac13aaaf /pf4j | |
parent | f563b9168b4beaca95b28541c1031b0dd7bed913 (diff) | |
download | pf4j-74aa987ca9a23234efbd58766d648135af7bdcc7.tar.gz pf4j-74aa987ca9a23234efbd58766d648135af7bdcc7.zip |
Add stopPluginWithDeletedDependency (see #576)
Diffstat (limited to 'pf4j')
-rw-r--r-- | pf4j/src/test/java/org/pf4j/DefaultPluginManagerTest.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/pf4j/src/test/java/org/pf4j/DefaultPluginManagerTest.java b/pf4j/src/test/java/org/pf4j/DefaultPluginManagerTest.java index bc23630..d10689f 100644 --- a/pf4j/src/test/java/org/pf4j/DefaultPluginManagerTest.java +++ b/pf4j/src/test/java/org/pf4j/DefaultPluginManagerTest.java @@ -366,4 +366,34 @@ public class DefaultPluginManagerTest { assertTrue(unloadedEvent.isPresent()); } + + @Test + void stopPluginWithDeletedDependency() throws IOException { + PluginZip pluginZip1 = new PluginZip.Builder(pluginsPath.resolve("my-first-plugin-1.1.1.zip"), "myPlugin1") + .pluginVersion("1.1.1") + .build(); + + PluginZip pluginZip2 = new PluginZip.Builder(pluginsPath.resolve("my-second-plugin-2.2.2.zip"), "myPlugin2") + .pluginVersion("2.2.2") + .pluginDependencies("myPlugin1") + .build(); + + pluginManager.loadPlugins(); + pluginManager.startPlugins(); + + assertEquals(PluginState.STARTED, pluginManager.getPlugin(pluginZip1.pluginId()).getPluginState()); + assertEquals(PluginState.STARTED, pluginManager.getPlugin(pluginZip2.pluginId()).getPluginState()); + + System.out.println("Stopping " + pluginZip1.pluginId()); + pluginManager.stopPlugin(pluginZip1.pluginId()); + assertEquals(PluginState.STOPPED, pluginManager.getPlugin(pluginZip1.pluginId()).getPluginState()); + + boolean deleted = pluginManager.deletePlugin(pluginZip1.pluginId()); + assertTrue(deleted); + + assertEquals(0, pluginManager.getPlugins().size()); + + assertThrows(PluginNotFoundException.class, () -> pluginManager.stopPlugin(pluginZip2.pluginId())); + } + } |