aboutsummaryrefslogtreecommitdiffstats
path: root/pf4j/src/test
diff options
context:
space:
mode:
authordecebals <decebal.suiu@gmail.com>2019-05-30 22:03:51 +0300
committerdecebals <decebal.suiu@gmail.com>2019-05-30 22:03:51 +0300
commit733fb970b4523f61832f0f92f8b4c90daf949487 (patch)
tree998bedc2535fbd9b21c40c36971503e2bb23c67f /pf4j/src/test
parent0ad926448eae71ff720174dd940468eac942161d (diff)
downloadpf4j-733fb970b4523f61832f0f92f8b4c90daf949487.tar.gz
pf4j-733fb970b4523f61832f0f92f8b4c90daf949487.zip
Add JarPluginManagerTest
Diffstat (limited to 'pf4j/src/test')
-rw-r--r--pf4j/src/test/java/org/pf4j/JarPluginManagerTest.java80
1 files changed, 80 insertions, 0 deletions
diff --git a/pf4j/src/test/java/org/pf4j/JarPluginManagerTest.java b/pf4j/src/test/java/org/pf4j/JarPluginManagerTest.java
new file mode 100644
index 0000000..45c3999
--- /dev/null
+++ b/pf4j/src/test/java/org/pf4j/JarPluginManagerTest.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2012-present the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.pf4j;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+import org.pf4j.plugin.PluginJar;
+import org.pf4j.plugin.TestPlugin;
+
+import java.io.IOException;
+import java.nio.file.Path;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class JarPluginManagerTest {
+
+ private PluginJar pluginJar;
+ private JarPluginManager pluginManager;
+
+ @TempDir
+ Path pluginsPath;
+
+ @BeforeEach
+ public void setUp() throws IOException {
+ pluginJar = new PluginJar.Builder(pluginsPath.resolve("test-plugin.jar"), "test-plugin")
+ .pluginClass(TestPlugin.class.getName())
+ .pluginVersion("1.2.3")
+ .build();
+
+ pluginManager = new JarPluginManager(pluginsPath);
+ }
+
+ @AfterEach
+ public void tearDown() {
+ pluginJar = null;
+ pluginManager = null;
+ }
+
+ @Test
+ public void unloadPlugin() throws Exception {
+ pluginManager.loadPlugins();
+
+ assertEquals(1, pluginManager.getPlugins().size());
+
+ boolean unloaded = pluginManager.unloadPlugin(pluginJar.pluginId());
+ assertTrue(unloaded);
+
+ assertTrue(pluginJar.file().exists());
+ }
+
+ @Test
+ public void deletePlugin() throws Exception {
+ pluginManager.loadPlugins();
+
+ assertEquals(1, pluginManager.getPlugins().size());
+
+ boolean deleted = pluginManager.deletePlugin(pluginJar.pluginId());
+ assertTrue(deleted);
+
+ assertFalse(pluginJar.file().exists());
+ }
+
+}