aboutsummaryrefslogtreecommitdiffstats
path: root/pf4j/src/test/java
diff options
context:
space:
mode:
authorSebastian Lövdahl <slovdahl@hibox.fi>2020-01-13 13:39:40 +0200
committerDecebal Suiu <decebal.suiu@gmail.com>2020-01-13 13:39:40 +0200
commite524ac2ca5c18e469c9855da2d2c36ef8a32d1a5 (patch)
treeafb1185b2113882878a1509e62414b79016d07eb /pf4j/src/test/java
parent77fb6914b47a93b805baae8a6ff819f686367144 (diff)
downloadpf4j-e524ac2ca5c18e469c9855da2d2c36ef8a32d1a5.tar.gz
pf4j-e524ac2ca5c18e469c9855da2d2c36ef8a32d1a5.zip
Throw IOException if `mkdirs()` fails while unpacking ZIP file (#359) (#362)
Diffstat (limited to 'pf4j/src/test/java')
-rw-r--r--pf4j/src/test/java/org/pf4j/util/FileUtilsTest.java23
1 files changed, 20 insertions, 3 deletions
diff --git a/pf4j/src/test/java/org/pf4j/util/FileUtilsTest.java b/pf4j/src/test/java/org/pf4j/util/FileUtilsTest.java
index 5f9a3a7..7bf06c6 100644
--- a/pf4j/src/test/java/org/pf4j/util/FileUtilsTest.java
+++ b/pf4j/src/test/java/org/pf4j/util/FileUtilsTest.java
@@ -21,6 +21,7 @@ import org.pf4j.plugin.PluginZip;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.nio.file.Paths;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -31,18 +32,34 @@ public class FileUtilsTest {
Path pluginsPath;
@Test
- public void expandIfZip() throws Exception {
+ public void expandIfZipForZipWithOnlyModuleDescriptor() throws Exception {
PluginZip pluginZip = new PluginZip.Builder(pluginsPath.resolve("my-plugin-1.2.3.zip"), "myPlugin")
- .pluginVersion("1.2.3")
- .build();
+ .pluginVersion("1.2.3")
+ .build();
Path unzipped = FileUtils.expandIfZip(pluginZip.path());
assertEquals(pluginZip.unzippedPath(), unzipped);
assertTrue(Files.exists(unzipped.resolve("plugin.properties")));
+ }
+
+ @Test
+ public void expandIfZipForZipWithResourceFile() throws Exception {
+ PluginZip pluginZip = new PluginZip.Builder(pluginsPath.resolve("my-second-plugin-1.2.3.zip"), "myPlugin")
+ .pluginVersion("1.2.3")
+ .addFile(Paths.get("classes/META-INF/plugin-file"), "plugin")
+ .build();
+ Path unzipped = FileUtils.expandIfZip(pluginZip.path());
+ assertEquals(pluginZip.unzippedPath(), unzipped);
+ assertTrue(Files.exists(unzipped.resolve("classes/META-INF/plugin-file")));
+ }
+
+ @Test
+ public void expandIfZipNonZipFiles() throws Exception {
// File without .suffix
Path extra = pluginsPath.resolve("extra");
assertEquals(extra, FileUtils.expandIfZip(extra));
+
// Folder
Path folder = pluginsPath.resolve("folder");
assertEquals(folder, FileUtils.expandIfZip(folder));