]> source.dussan.org Git - pf4j.git/commitdiff
Add stopPluginWithDeletedDependency (see #576)
authorDecebal Suiu <decebal.suiu@gmail.com>
Sat, 6 Apr 2024 20:29:37 +0000 (23:29 +0300)
committerDecebal Suiu <decebal.suiu@gmail.com>
Sat, 6 Apr 2024 20:29:37 +0000 (23:29 +0300)
pf4j/src/test/java/org/pf4j/DefaultPluginManagerTest.java

index bc2363077a95b7afef83e61e5400816af7e1c795..d10689f1f755b079c2d3eb9c2df8b08caf583f58 100644 (file)
@@ -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()));
+    }
+
 }