summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDecebal Suiu <decebal.suiu@gmail.com>2019-03-20 22:53:20 +0200
committerDecebal Suiu <decebal.suiu@gmail.com>2019-03-20 22:53:20 +0200
commite1fb3f7bc411cdfc3eee0cacedc8f7b1a238b7cd (patch)
tree95de2ef9c6501467cb078688df9f6bd5eafb90b2
parent9137bff8bd45d84cd22a34b65026bc9de7cf9d4e (diff)
downloadpf4j-e1fb3f7bc411cdfc3eee0cacedc8f7b1a238b7cd.tar.gz
pf4j-e1fb3f7bc411cdfc3eee0cacedc8f7b1a238b7cd.zip
Migrate to JUnit 5
-rw-r--r--pf4j/pom.xml5
-rw-r--r--pf4j/src/test/java/org/pf4j/AbstractExtensionFinderTest.java12
-rw-r--r--pf4j/src/test/java/org/pf4j/CompoundPluginDescriptorFinderTest.java30
-rw-r--r--pf4j/src/test/java/org/pf4j/DefaultExtensionFactoryTest.java7
-rw-r--r--pf4j/src/test/java/org/pf4j/DefaultPluginFactoryTest.java8
-rw-r--r--pf4j/src/test/java/org/pf4j/DefaultPluginManagerTest.java42
-rw-r--r--pf4j/src/test/java/org/pf4j/DefaultPluginRepositoryTest.java42
-rw-r--r--pf4j/src/test/java/org/pf4j/DefaultPluginStatusProviderTest.java30
-rw-r--r--pf4j/src/test/java/org/pf4j/DefaultVersionManagerTest.java18
-rw-r--r--pf4j/src/test/java/org/pf4j/DependencyResolverTest.java10
-rw-r--r--pf4j/src/test/java/org/pf4j/ExtensionAnnotationProcessorTest.java6
-rw-r--r--pf4j/src/test/java/org/pf4j/LegacyExtensionStorageTest.java4
-rw-r--r--pf4j/src/test/java/org/pf4j/LoadPluginsTest.java79
-rw-r--r--pf4j/src/test/java/org/pf4j/ManifestPluginDescriptorFinderTest.java39
-rw-r--r--pf4j/src/test/java/org/pf4j/PluginDependencyTest.java19
-rw-r--r--pf4j/src/test/java/org/pf4j/PropertiesPluginDescriptorFinderTest.java42
-rw-r--r--pf4j/src/test/java/org/pf4j/SingletonExtensionFactoryTest.java5
-rw-r--r--pf4j/src/test/java/org/pf4j/plugin/PluginZip.java19
-rw-r--r--pf4j/src/test/java/org/pf4j/processor/ServiceProviderExtensionStorageTest.java4
-rw-r--r--pf4j/src/test/java/org/pf4j/util/FileUtilsTest.java18
-rw-r--r--pom.xml2
21 files changed, 213 insertions, 228 deletions
diff --git a/pf4j/pom.xml b/pf4j/pom.xml
index 1d07836..0a78ed2 100644
--- a/pf4j/pom.xml
+++ b/pf4j/pom.xml
@@ -100,11 +100,12 @@
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
+
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
diff --git a/pf4j/src/test/java/org/pf4j/AbstractExtensionFinderTest.java b/pf4j/src/test/java/org/pf4j/AbstractExtensionFinderTest.java
index 2acabee..6383756 100644
--- a/pf4j/src/test/java/org/pf4j/AbstractExtensionFinderTest.java
+++ b/pf4j/src/test/java/org/pf4j/AbstractExtensionFinderTest.java
@@ -15,9 +15,9 @@
*/
package org.pf4j;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.pf4j.plugin.FailTestPlugin;
import org.pf4j.plugin.TestExtensionPoint;
@@ -28,7 +28,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -40,7 +40,7 @@ public class AbstractExtensionFinderTest {
private PluginManager pluginManager;
- @Before
+ @BeforeEach
public void setUp() {
PluginWrapper pluginStarted = mock(PluginWrapper.class);
when(pluginStarted.getPluginClassLoader()).thenReturn(getClass().getClassLoader());
@@ -57,7 +57,7 @@ public class AbstractExtensionFinderTest {
when(pluginManager.getExtensionFactory()).thenReturn(new DefaultExtensionFactory());
}
- @After
+ @AfterEach
public void tearDown() {
pluginManager = null;
}
diff --git a/pf4j/src/test/java/org/pf4j/CompoundPluginDescriptorFinderTest.java b/pf4j/src/test/java/org/pf4j/CompoundPluginDescriptorFinderTest.java
index a30a4ff..518ba1e 100644
--- a/pf4j/src/test/java/org/pf4j/CompoundPluginDescriptorFinderTest.java
+++ b/pf4j/src/test/java/org/pf4j/CompoundPluginDescriptorFinderTest.java
@@ -15,28 +15,27 @@
*/
package org.pf4j;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
import org.pf4j.plugin.PluginZip;
-import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* @author Decebal Suiu
*/
public class CompoundPluginDescriptorFinderTest {
- @Rule
- public TemporaryFolder pluginsFolder = new TemporaryFolder();
+ @TempDir
+ Path pluginsPath;
@Test
public void add() {
@@ -49,7 +48,8 @@ public class CompoundPluginDescriptorFinderTest {
@Test
public void find() throws Exception {
- Path pluginPath = pluginsFolder.newFolder("test-plugin-1").toPath();
+ Path pluginPath = pluginsPath.resolve("test-plugin-1");
+ Files.createDirectories(pluginPath);
Files.write(pluginPath.resolve("plugin.properties"), getPlugin1Properties(), StandardCharsets.UTF_8);
PluginDescriptorFinder descriptorFinder = new CompoundPluginDescriptorFinder()
@@ -66,7 +66,7 @@ public class CompoundPluginDescriptorFinderTest {
PluginDescriptorFinder descriptorFinder = new CompoundPluginDescriptorFinder()
.add(new PropertiesPluginDescriptorFinder());
- PluginZip pluginJar = new PluginZip.Builder(pluginsFolder.newFile("my-plugin-1.2.3.jar"), "myPlugin")
+ PluginZip pluginJar = new PluginZip.Builder(pluginsPath.resolve("my-plugin-1.2.3.jar"), "myPlugin")
.pluginVersion("1.2.3")
.build();
@@ -76,19 +76,17 @@ public class CompoundPluginDescriptorFinderTest {
assertEquals("1.2.3", pluginJar.pluginVersion());
}
- @Test(expected = PluginException.class)
- public void testNotFound() throws Exception {
+ @Test
+ public void testNotFound() {
PluginDescriptorFinder descriptorFinder = new CompoundPluginDescriptorFinder();
- Path pluginsPath = pluginsFolder.getRoot().toPath();
- descriptorFinder.find(pluginsPath.resolve("test-plugin-3"));
+ assertThrows(PluginException.class, () -> descriptorFinder.find(pluginsPath.resolve("test-plugin-3")));
}
@Test
public void testSpaceCharacterInFileName() throws Exception {
PluginDescriptorFinder descriptorFinder = new PropertiesPluginDescriptorFinder();
- File jar = pluginsFolder.newFile("my plugin-1.2.3.jar");
- PluginZip pluginJar = new PluginZip.Builder(jar, "myPlugin")
+ PluginZip pluginJar = new PluginZip.Builder(pluginsPath.resolve("my plugin-1.2.3.jar"), "myPlugin")
.pluginVersion("1.2.3")
.build();
diff --git a/pf4j/src/test/java/org/pf4j/DefaultExtensionFactoryTest.java b/pf4j/src/test/java/org/pf4j/DefaultExtensionFactoryTest.java
index 71ffa93..13327cc 100644
--- a/pf4j/src/test/java/org/pf4j/DefaultExtensionFactoryTest.java
+++ b/pf4j/src/test/java/org/pf4j/DefaultExtensionFactoryTest.java
@@ -15,11 +15,12 @@
*/
package org.pf4j;
-import org.junit.Test;
-import org.pf4j.plugin.TestExtension;
+import org.junit.jupiter.api.Test;
import org.pf4j.plugin.FailTestExtension;
+import org.pf4j.plugin.TestExtension;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
*
diff --git a/pf4j/src/test/java/org/pf4j/DefaultPluginFactoryTest.java b/pf4j/src/test/java/org/pf4j/DefaultPluginFactoryTest.java
index f105aa8..eccfca2 100644
--- a/pf4j/src/test/java/org/pf4j/DefaultPluginFactoryTest.java
+++ b/pf4j/src/test/java/org/pf4j/DefaultPluginFactoryTest.java
@@ -15,15 +15,15 @@
*/
package org.pf4j;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.pf4j.plugin.AnotherFailTestPlugin;
import org.pf4j.plugin.FailTestPlugin;
import org.pf4j.plugin.TestPlugin;
import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
diff --git a/pf4j/src/test/java/org/pf4j/DefaultPluginManagerTest.java b/pf4j/src/test/java/org/pf4j/DefaultPluginManagerTest.java
index 3e6fd04..ced9b4e 100644
--- a/pf4j/src/test/java/org/pf4j/DefaultPluginManagerTest.java
+++ b/pf4j/src/test/java/org/pf4j/DefaultPluginManagerTest.java
@@ -15,21 +15,21 @@
*/
package org.pf4j;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+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.PluginZip;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -38,14 +38,12 @@ public class DefaultPluginManagerTest {
private DefaultPluginManager pluginManager;
private DefaultPluginDescriptor pluginDescriptor;
private PluginWrapper pluginWrapper;
- private Path pluginsPath;
- @Rule
- public TemporaryFolder pluginsFolder = new TemporaryFolder();
+ @TempDir
+ Path pluginsPath;
- @Before
+ @BeforeEach
public void setUp() throws IOException {
- pluginsPath = pluginsFolder.getRoot().toPath();
pluginManager = new DefaultPluginManager(pluginsPath);
pluginDescriptor = new DefaultPluginDescriptor();
@@ -59,7 +57,7 @@ public class DefaultPluginManagerTest {
pluginWrapper = new PluginWrapper(pluginManager, pluginDescriptor, Files.createTempDirectory("test"), getClass().getClassLoader());
}
- @After
+ @AfterEach
public void tearDown() {
pluginManager = null;
pluginDescriptor = null;
@@ -71,16 +69,16 @@ public class DefaultPluginManagerTest {
pluginManager.validatePluginDescriptor(pluginDescriptor);
}
- @Test(expected = PluginException.class)
- public void validateFailsOnId() throws PluginException {
+ @Test
+ public void validateFailsOnId() {
pluginDescriptor.setPluginId("");
- pluginManager.validatePluginDescriptor(pluginDescriptor);
+ assertThrows(PluginException.class, () -> pluginManager.validatePluginDescriptor(pluginDescriptor));
}
- @Test(expected = PluginException.class)
- public void validateFailsOnVersion() throws PluginException {
+ @Test
+ public void validateFailsOnVersion() {
pluginDescriptor.setPluginVersion(null);
- pluginManager.validatePluginDescriptor(pluginDescriptor);
+ assertThrows(PluginException.class, () -> pluginManager.validatePluginDescriptor(pluginDescriptor));
}
@Test
@@ -132,7 +130,7 @@ public class DefaultPluginManagerTest {
*/
@Test
public void testPluginDisabledNoStart() throws IOException {
- new PluginZip.Builder(pluginsFolder.newFile("my-plugin-1.2.3.zip"), "myPlugin")
+ new PluginZip.Builder(pluginsPath.resolve("my-plugin-1.2.3.zip"), "myPlugin")
.pluginVersion("1.2.3")
.build();
diff --git a/pf4j/src/test/java/org/pf4j/DefaultPluginRepositoryTest.java b/pf4j/src/test/java/org/pf4j/DefaultPluginRepositoryTest.java
index 4f39f24..91a35f5 100644
--- a/pf4j/src/test/java/org/pf4j/DefaultPluginRepositoryTest.java
+++ b/pf4j/src/test/java/org/pf4j/DefaultPluginRepositoryTest.java
@@ -15,20 +15,18 @@
*/
package org.pf4j;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Mario Franco
@@ -36,25 +34,21 @@ import static org.junit.Assert.assertTrue;
*/
public class DefaultPluginRepositoryTest {
- private Path pluginsPath;
+ @TempDir
+ Path pluginsPath;
- @Rule
- public TemporaryFolder pluginsFolder = new TemporaryFolder();
-
- @Before
+ @BeforeEach
public void setUp() throws IOException {
- pluginsPath = pluginsFolder.getRoot().toPath();
-
- pluginsFolder.newFolder("plugin-1");
+ Path plugin1Path = Files.createDirectories(pluginsPath.resolve("plugin-1"));
// Prove that we can delete a folder with a file inside
- Files.createFile(Paths.get(pluginsFolder.getRoot().getAbsolutePath()).resolve("plugin-1").resolve("myfile"));
+ Files.createFile(plugin1Path.resolve("myfile"));
// Create a zip file for plugin-1 to test that it is deleted when plugin is deleted
- Files.createFile(Paths.get(pluginsFolder.getRoot().getAbsolutePath()).resolve("plugin-1.zip"));
- pluginsFolder.newFolder("plugin-2");
- pluginsFolder.newFolder("plugin-3");
+ Files.createFile(pluginsPath.resolve("plugin-1.zip"));
+ Files.createDirectories(pluginsPath.resolve("plugin-2"));
+ Files.createDirectories(pluginsPath.resolve("plugin-3"));
// standard maven/gradle bin folder - these should be skipped in development mode because the cause errors
- pluginsFolder.newFolder("target");
- pluginsFolder.newFolder("build");
+ Files.createDirectories(pluginsPath.resolve("target"));
+ Files.createDirectories(pluginsPath.resolve("build"));
}
/**
@@ -109,11 +103,11 @@ public class DefaultPluginRepositoryTest {
}
private void assertPathExists(List<Path> paths, Path path) {
- assertTrue("The directory must contain the file " + path, paths.contains(path));
+ assertTrue(paths.contains(path), "The directory must contain the file " + path);
}
private void assertPathDoesNotExists(List<Path> paths, Path path) {
- assertFalse("The directory must not contain the file " + path, paths.contains(path));
+ assertFalse(paths.contains(path), "The directory must not contain the file " + path);
}
}
diff --git a/pf4j/src/test/java/org/pf4j/DefaultPluginStatusProviderTest.java b/pf4j/src/test/java/org/pf4j/DefaultPluginStatusProviderTest.java
index b3f8d2b..635e41c 100644
--- a/pf4j/src/test/java/org/pf4j/DefaultPluginStatusProviderTest.java
+++ b/pf4j/src/test/java/org/pf4j/DefaultPluginStatusProviderTest.java
@@ -15,20 +15,17 @@
*/
package org.pf4j;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
import org.pf4j.util.FileUtils;
-import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Mario Franco
@@ -36,15 +33,8 @@ import static org.junit.Assert.assertTrue;
*/
public class DefaultPluginStatusProviderTest {
- private Path pluginsPath;
-
- @Rule
- public TemporaryFolder pluginsFolder = new TemporaryFolder();
-
- @Before
- public void setUp() {
- pluginsPath = pluginsFolder.getRoot().toPath();
- }
+ @TempDir
+ Path pluginsPath;
@Test
public void testIsPluginDisabled() throws IOException {
@@ -129,8 +119,8 @@ public class DefaultPluginStatusProviderTest {
List<String> disabledPlugins = new ArrayList<>();
disabledPlugins.add("plugin-2");
- File disabledFile = pluginsFolder.newFile("disabled.txt");
- FileUtils.writeLines(disabledPlugins, disabledFile);
+ Path disabledPath = pluginsPath.resolve("disabled.txt");
+ FileUtils.writeLines(disabledPlugins, disabledPath.toFile());
}
private void createEnabledFile() throws IOException {
@@ -138,8 +128,8 @@ public class DefaultPluginStatusProviderTest {
enabledPlugins.add("plugin-1");
enabledPlugins.add("plugin-2");
- File enabledFile = pluginsFolder.newFile("enabled.txt");
- FileUtils.writeLines(enabledPlugins, enabledFile);
+ Path enabledPath = pluginsPath.resolve("enabled.txt");
+ FileUtils.writeLines(enabledPlugins, enabledPath.toFile());
}
}
diff --git a/pf4j/src/test/java/org/pf4j/DefaultVersionManagerTest.java b/pf4j/src/test/java/org/pf4j/DefaultVersionManagerTest.java
index 795d3cf..3a277db 100644
--- a/pf4j/src/test/java/org/pf4j/DefaultVersionManagerTest.java
+++ b/pf4j/src/test/java/org/pf4j/DefaultVersionManagerTest.java
@@ -16,10 +16,12 @@
package org.pf4j;
import com.github.zafarkhaja.semver.ParseException;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Decebal Suiu
@@ -28,7 +30,7 @@ public class DefaultVersionManagerTest {
private VersionManager versionManager;
- @Before
+ @BeforeEach
public void init() {
versionManager = new DefaultVersionManager();
}
@@ -39,14 +41,14 @@ public class DefaultVersionManagerTest {
assertTrue(versionManager.checkVersionConstraint("1.4.3", ">=1.4.0 & <1.6.0")); // range
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void nullOrEmptyVersion() {
- assertFalse(versionManager.checkVersionConstraint(null, ">2.0.0"));
+ assertThrows(IllegalArgumentException.class, () -> versionManager.checkVersionConstraint(null, ">2.0.0"));
}
- @Test(expected = ParseException.class)
+ @Test
public void invalidVersion() {
- assertFalse(versionManager.checkVersionConstraint("1.0", ">2.0.0"));
+ assertThrows(ParseException.class, () -> versionManager.checkVersionConstraint("1.0", ">2.0.0"));
}
@Test
diff --git a/pf4j/src/test/java/org/pf4j/DependencyResolverTest.java b/pf4j/src/test/java/org/pf4j/DependencyResolverTest.java
index f7752d4..6e35780 100644
--- a/pf4j/src/test/java/org/pf4j/DependencyResolverTest.java
+++ b/pf4j/src/test/java/org/pf4j/DependencyResolverTest.java
@@ -15,14 +15,16 @@
*/
package org.pf4j;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Decebal Suiu
@@ -31,7 +33,7 @@ public class DependencyResolverTest {
private DependencyResolver resolver;
- @Before
+ @BeforeEach
public void init() {
VersionManager versionManager = new DefaultVersionManager();
resolver = new DependencyResolver(versionManager);
diff --git a/pf4j/src/test/java/org/pf4j/ExtensionAnnotationProcessorTest.java b/pf4j/src/test/java/org/pf4j/ExtensionAnnotationProcessorTest.java
index 9edd6b9..47efca8 100644
--- a/pf4j/src/test/java/org/pf4j/ExtensionAnnotationProcessorTest.java
+++ b/pf4j/src/test/java/org/pf4j/ExtensionAnnotationProcessorTest.java
@@ -15,13 +15,13 @@
*/
package org.pf4j;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.pf4j.processor.ExtensionAnnotationProcessor;
import java.util.Set;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Mario Franco
diff --git a/pf4j/src/test/java/org/pf4j/LegacyExtensionStorageTest.java b/pf4j/src/test/java/org/pf4j/LegacyExtensionStorageTest.java
index 57125bd..1acc567 100644
--- a/pf4j/src/test/java/org/pf4j/LegacyExtensionStorageTest.java
+++ b/pf4j/src/test/java/org/pf4j/LegacyExtensionStorageTest.java
@@ -15,7 +15,7 @@
*/
package org.pf4j;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.pf4j.processor.LegacyExtensionStorage;
import java.io.IOException;
@@ -24,7 +24,7 @@ import java.io.StringReader;
import java.util.HashSet;
import java.util.Set;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author Decebal Suiu
diff --git a/pf4j/src/test/java/org/pf4j/LoadPluginsTest.java b/pf4j/src/test/java/org/pf4j/LoadPluginsTest.java
index 46980bc..f86cee4 100644
--- a/pf4j/src/test/java/org/pf4j/LoadPluginsTest.java
+++ b/pf4j/src/test/java/org/pf4j/LoadPluginsTest.java
@@ -15,37 +15,37 @@
*/
package org.pf4j;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.startsWith;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.File;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+import org.pf4j.plugin.PluginZip;
+
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.pf4j.plugin.PluginZip;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.startsWith;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
public class LoadPluginsTest {
private DefaultPluginManager pluginManager;
- @Rule
- public TemporaryFolder pluginsFolder = new TemporaryFolder();
+ @TempDir
+ Path pluginsPath;
- @Before
+ @BeforeEach
public void setUp() {
- pluginManager = new DefaultPluginManager(pluginsFolder.getRoot().toPath()) {
+ pluginManager = new DefaultPluginManager(pluginsPath) {
@Override
protected PluginRepository createPluginRepository() {
@@ -62,7 +62,7 @@ public class LoadPluginsTest {
@Test
public void load() throws Exception {
- PluginZip pluginZip = new PluginZip.Builder(pluginsFolder.newFile("my-plugin-1.2.3.zip"), "myPlugin")
+ PluginZip pluginZip = new PluginZip.Builder(pluginsPath.resolve("my-plugin-1.2.3.zip"), "myPlugin")
.pluginVersion("1.2.3")
.build();
@@ -76,31 +76,32 @@ public class LoadPluginsTest {
assertEquals(pluginZip.pluginId(), pluginManager.idForPath(pluginZip.unzippedPath()));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void loadNonExisting() {
- pluginManager.loadPlugin(Paths.get("nonexisting"));
+ assertThrows(IllegalArgumentException.class, () -> pluginManager.loadPlugin(Paths.get("nonexisting")));
}
- @Test(expected = PluginAlreadyLoadedException.class)
+ @Test
public void loadTwiceFails() throws Exception {
- PluginZip pluginZip = new PluginZip.Builder(pluginsFolder.newFile("my-plugin-1.2.3.zip"), "myPlugin")
+ PluginZip pluginZip = new PluginZip.Builder(pluginsPath.resolve("my-plugin-1.2.3.zip"), "myPlugin")
.pluginVersion("1.2.3")
.build();
assertNotNull(pluginManager.loadPluginFromPath(pluginZip.path()));
- assertNull(pluginManager.loadPluginFromPath(pluginZip.path()));
+
+ assertThrows(PluginAlreadyLoadedException.class, () -> pluginManager.loadPluginFromPath(pluginZip.path()));
}
@Test
public void loadPluginWithSameIdDifferentPathFails() throws Exception {
String pluginId = "myPlugin";
String pluginVersion = "1.2.3";
- File plugin1Path = pluginsFolder.newFile("my-plugin-1.2.3.zip");
+ Path plugin1Path = pluginsPath.resolve("my-plugin-1.2.3.zip");
PluginZip plugin1 = new PluginZip.Builder(plugin1Path, pluginId)
.pluginVersion(pluginVersion)
.build();
- File plugin2Path = pluginsFolder.newFile("my-plugin-1.2.3-renamed.zip");
+ Path plugin2Path = pluginsPath.resolve("my-plugin-1.2.3-renamed.zip");
PluginZip plugin2 = new PluginZip.Builder(plugin2Path, pluginId)
.pluginVersion(pluginVersion)
.build();
@@ -134,13 +135,13 @@ public class LoadPluginsTest {
public void loadPluginWithSameIdDifferentVersionsFails() throws Exception {
String pluginId = "myPlugin";
String plugin1Version = "1.2.3";
- File plugin1Path = pluginsFolder.newFile("my-plugin-1.2.3.zip");
+ Path plugin1Path = pluginsPath.resolve("my-plugin-1.2.3.zip");
PluginZip plugin1 = new PluginZip.Builder(plugin1Path, pluginId)
.pluginVersion(plugin1Version)
.build();
String plugin2Version = "2.0.0";
- File plugin2Path = pluginsFolder.newFile("my-plugin-2.0.0.zip");
+ Path plugin2Path = pluginsPath.resolve("my-plugin-2.0.0.zip");
PluginZip plugin2 = new PluginZip.Builder(plugin2Path, pluginId)
.pluginVersion(plugin2Version)
.build();
@@ -162,7 +163,7 @@ public class LoadPluginsTest {
@Test
public void loadUnloadLoad() throws Exception {
- PluginZip pluginZip = new PluginZip.Builder(pluginsFolder.newFile("my-plugin-1.2.3.zip"), "myPlugin")
+ PluginZip pluginZip = new PluginZip.Builder(pluginsPath.resolve("my-plugin-1.2.3.zip"), "myPlugin")
.pluginVersion("1.2.3")
.build();
@@ -181,7 +182,7 @@ public class LoadPluginsTest {
public void upgrade() throws Exception {
String pluginId = "myPlugin";
- new PluginZip.Builder(pluginsFolder.newFile("my-plugin-1.2.3.zip"), pluginId)
+ new PluginZip.Builder(pluginsPath.resolve("my-plugin-1.2.3.zip"), pluginId)
.pluginVersion("1.2.3")
.build();
@@ -191,7 +192,7 @@ public class LoadPluginsTest {
assertEquals(1, pluginManager.getPlugins().size());
assertEquals(1, pluginManager.getStartedPlugins().size());
- PluginZip pluginZip2 = new PluginZip.Builder(pluginsFolder.newFile("my-plugin-2.0.0.ZIP"), pluginId)
+ PluginZip pluginZip2 = new PluginZip.Builder(pluginsPath.resolve("my-plugin-2.0.0.ZIP"), pluginId)
.pluginVersion("2.0.0")
.build();
@@ -208,12 +209,12 @@ public class LoadPluginsTest {
@Test
public void getRoot() {
- assertEquals(pluginsFolder.getRoot().toPath(), pluginManager.getPluginsRoot());
+ assertEquals(pluginsPath, pluginManager.getPluginsRoot());
}
@Test
- public void notAPlugin() throws Exception {
- pluginsFolder.newFile("not-a-zip");
+ public void notAPlugin() {
+ pluginsPath.resolve("not-a-zip");
pluginManager.loadPlugins();
@@ -222,11 +223,11 @@ public class LoadPluginsTest {
@Test
public void deletePlugin() throws Exception {
- PluginZip pluginZip1 = new PluginZip.Builder(pluginsFolder.newFile("my-plugin-1.2.3.zip"), "myPlugin")
+ PluginZip pluginZip1 = new PluginZip.Builder(pluginsPath.resolve("my-plugin-1.2.3.zip"), "myPlugin")
.pluginVersion("1.2.3")
.build();
- PluginZip pluginZip3 = new PluginZip.Builder(pluginsFolder.newFile("other-3.0.0.Zip"), "other")
+ PluginZip pluginZip3 = new PluginZip.Builder(pluginsPath.resolve("other-3.0.0.Zip"), "other")
.pluginVersion("3.0.0")
.build();
diff --git a/pf4j/src/test/java/org/pf4j/ManifestPluginDescriptorFinderTest.java b/pf4j/src/test/java/org/pf4j/ManifestPluginDescriptorFinderTest.java
index bc4eb5f..1d83c9f 100644
--- a/pf4j/src/test/java/org/pf4j/ManifestPluginDescriptorFinderTest.java
+++ b/pf4j/src/test/java/org/pf4j/ManifestPluginDescriptorFinderTest.java
@@ -15,19 +15,21 @@
*/
package org.pf4j;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Mario Franco
@@ -36,40 +38,37 @@ import static org.junit.Assert.*;
public class ManifestPluginDescriptorFinderTest {
private VersionManager versionManager;
- private Path pluginsPath;
- @Rule
- public TemporaryFolder pluginsFolder = new TemporaryFolder();
+ @TempDir
+ Path pluginsPath;
- @Before
+ @BeforeEach
public void setUp() throws IOException {
- pluginsPath = pluginsFolder.getRoot().toPath();
-
Charset charset = Charset.forName("UTF-8");
- Path pluginPath = pluginsFolder.newFolder("test-plugin-1", "classes", "META-INF").toPath();
+ Path pluginPath = Files.createDirectories(pluginsPath.resolve(Paths.get("test-plugin-1", "classes", "META-INF")));
Files.write(pluginPath.resolve("extensions.idx"), "org.pf4j.demo.hello.HelloPlugin$HelloGreeting".getBytes());
Files.write(pluginPath.resolve("MANIFEST.MF"), getPlugin1Manifest(), charset);
- pluginPath = pluginsFolder.newFolder("test-plugin-2", "classes", "META-INF").toPath();
+ pluginPath = Files.createDirectories(pluginsPath.resolve(Paths.get("test-plugin-2", "classes", "META-INF")));
Files.write(pluginPath.resolve("extensions.idx"), "org.pf4j.demo.hello.HelloPlugin$HelloGreeting".getBytes());
Files.write(pluginPath.resolve("MANIFEST.MF"), getPlugin2Manifest(), charset);
// empty plugin
- pluginsFolder.newFolder("test-plugin-3");
+ Files.createDirectories(pluginsPath.resolve("test-plugin-3"));
// no plugin class
- pluginPath = pluginsFolder.newFolder("test-plugin-4", "classes", "META-INF").toPath();
+ pluginPath = Files.createDirectories(pluginsPath.resolve(Paths.get("test-plugin-4", "classes", "META-INF")));
Files.write(pluginPath.resolve("extensions.idx"), "org.pf4j.demo.hello.HelloPlugin$HelloGreeting".getBytes());
Files.write(pluginPath.resolve("MANIFEST.MF"), getPlugin4Manifest(), charset);
// no plugin version
- pluginPath = pluginsFolder.newFolder("test-plugin-5", "classes", "META-INF").toPath();
+ pluginPath = Files.createDirectories(pluginsPath.resolve(Paths.get("test-plugin-5", "classes", "META-INF")));
Files.write(pluginPath.resolve("extensions.idx"), "org.pf4j.demo.hello.HelloPlugin$HelloGreeting".getBytes());
Files.write(pluginPath.resolve("MANIFEST.MF"), getPlugin5Manifest(), charset);
// no plugin id
- pluginPath = pluginsFolder.newFolder("test-plugin-6", "classes", "META-INF").toPath();
+ pluginPath = Files.createDirectories(pluginsPath.resolve(Paths.get("test-plugin-6", "classes", "META-INF")));
Files.write(pluginPath.resolve("extensions.idx"), "org.pf4j.demo.hello.HelloPlugin$HelloGreeting".getBytes());
Files.write(pluginPath.resolve("MANIFEST.MF"), getPlugin6Manifest(), charset);
@@ -110,10 +109,10 @@ public class ManifestPluginDescriptorFinderTest {
/**
* Test of {@link ManifestPluginDescriptorFinder#find(Path)} method.
*/
- @Test(expected = PluginException.class)
- public void testFindNotFound() throws Exception {
+ @Test
+ public void testFindNotFound() {
PluginDescriptorFinder descriptorFinder = new ManifestPluginDescriptorFinder();
- descriptorFinder.find(pluginsPath.resolve("test-plugin-3"));
+ assertThrows(PluginException.class, () -> descriptorFinder.find(pluginsPath.resolve("test-plugin-3")));
}
private List<String> getPlugin1Manifest() {
diff --git a/pf4j/src/test/java/org/pf4j/PluginDependencyTest.java b/pf4j/src/test/java/org/pf4j/PluginDependencyTest.java
index dbd5fd9..a351c4b 100644
--- a/pf4j/src/test/java/org/pf4j/PluginDependencyTest.java
+++ b/pf4j/src/test/java/org/pf4j/PluginDependencyTest.java
@@ -15,9 +15,12 @@
*/
package org.pf4j;
-import org.junit.Test;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Mario Franco
@@ -32,33 +35,33 @@ public class PluginDependencyTest {
PluginDependency instance = new PluginDependency("test");
assertEquals("test", instance.getPluginId());
assertEquals("*", instance.getPluginVersionSupport());
- assertEquals(false, instance.isOptional());
+ assertFalse(instance.isOptional());
instance = new PluginDependency("test@");
assertEquals("test", instance.getPluginId());
assertEquals("*", instance.getPluginVersionSupport());
- assertEquals(false, instance.isOptional());
+ assertFalse(instance.isOptional());
instance = new PluginDependency("test?");
assertEquals("test", instance.getPluginId());
assertEquals("*", instance.getPluginVersionSupport());
- assertEquals(true, instance.isOptional());
+ assertTrue(instance.isOptional());
instance = new PluginDependency("test?@");
assertEquals("test", instance.getPluginId());
assertEquals("*", instance.getPluginVersionSupport());
- assertEquals(true, instance.isOptional());
+ assertTrue(instance.isOptional());
instance = new PluginDependency("test@1.0");
assertEquals("test", instance.getPluginId());
assertEquals("1.0", instance.getPluginVersionSupport());
- assertEquals(false, instance.isOptional());
+ assertFalse(instance.isOptional());
assertEquals("PluginDependency [pluginId=test, pluginVersionSupport=1.0, optional=false]", instance.toString());
instance = new PluginDependency("test?@1.0");
assertEquals("test", instance.getPluginId());
assertEquals("1.0", instance.getPluginVersionSupport());
- assertEquals(true, instance.isOptional());
+ assertTrue(instance.isOptional());
assertEquals("PluginDependency [pluginId=test, pluginVersionSupport=1.0, optional=true]", instance.toString());
}
diff --git a/pf4j/src/test/java/org/pf4j/PropertiesPluginDescriptorFinderTest.java b/pf4j/src/test/java/org/pf4j/PropertiesPluginDescriptorFinderTest.java
index 377d5ca..7845952 100644
--- a/pf4j/src/test/java/org/pf4j/PropertiesPluginDescriptorFinderTest.java
+++ b/pf4j/src/test/java/org/pf4j/PropertiesPluginDescriptorFinderTest.java
@@ -15,10 +15,9 @@
*/
package org.pf4j;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
import org.pf4j.plugin.PluginZip;
import java.io.IOException;
@@ -28,41 +27,42 @@ import java.nio.file.Path;
import java.util.Arrays;
import java.util.List;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class PropertiesPluginDescriptorFinderTest {
private VersionManager versionManager;
- private Path pluginsPath;
- @Rule
- public TemporaryFolder pluginsFolder = new TemporaryFolder();
+ @TempDir
+ Path pluginsPath;
- @Before
+ @BeforeEach
public void setUp() throws IOException {
- pluginsPath = pluginsFolder.getRoot().toPath();
-
Charset charset = Charset.forName("UTF-8");
- Path pluginPath = pluginsFolder.newFolder("test-plugin-1").toPath();
+ Path pluginPath = Files.createDirectories(pluginsPath.resolve("test-plugin-1"));
Files.write(pluginPath.resolve("plugin.properties"), getPlugin1Properties(), charset);
- pluginPath = pluginsFolder.newFolder("test-plugin-2").toPath();
+ pluginPath = Files.createDirectories(pluginsPath.resolve("test-plugin-2"));
Files.write(pluginPath.resolve("plugin.properties"), getPlugin2Properties(), charset);
// empty plugin
- pluginsFolder.newFolder("test-plugin-3");
+ Files.createDirectories(pluginsPath.resolve("test-plugin-3"));
// no plugin class
- pluginPath = pluginsFolder.newFolder("test-plugin-4").toPath();
+ pluginPath = Files.createDirectories(pluginsPath.resolve("test-plugin-4"));
Files.write(pluginPath.resolve("plugin.properties"), getPlugin4Properties(), charset);
// no plugin version
- pluginPath = pluginsFolder.newFolder("test-plugin-5").toPath();
+ pluginPath = Files.createDirectories(pluginsPath.resolve("test-plugin-5"));
Files.write(pluginPath.resolve("plugin.properties"), getPlugin5Properties(), charset);
// no plugin id
- pluginPath = pluginsFolder.newFolder("test-plugin-6").toPath();
+ pluginPath = Files.createDirectories(pluginsPath.resolve("test-plugin-6"));
Files.write(pluginPath.resolve("plugin.properties"), getPlugin6Properties(), charset);
versionManager = new DefaultVersionManager();
@@ -99,15 +99,15 @@ public class PropertiesPluginDescriptorFinderTest {
assertTrue(versionManager.checkVersionConstraint("1.0.0", plugin2.getRequires()));
}
- @Test(expected = PluginException.class)
- public void testNotFound() throws Exception {
+ @Test
+ public void testNotFound() {
PluginDescriptorFinder descriptorFinder = new PropertiesPluginDescriptorFinder();
- descriptorFinder.find(pluginsPath.resolve("test-plugin-3"));
+ assertThrows(PluginException.class, () -> descriptorFinder.find(pluginsPath.resolve("test-plugin-3")));
}
@Test
public void findInJar() throws Exception {
- PluginZip pluginJar = new PluginZip.Builder(pluginsFolder.newFile("my-plugin-1.2.3.jar"), "myPlugin")
+ PluginZip pluginJar = new PluginZip.Builder(pluginsPath.resolve("my-plugin-1.2.3.jar"), "myPlugin")
.pluginVersion("1.2.3")
.build();
diff --git a/pf4j/src/test/java/org/pf4j/SingletonExtensionFactoryTest.java b/pf4j/src/test/java/org/pf4j/SingletonExtensionFactoryTest.java
index 500dd84..80e7ab0 100644
--- a/pf4j/src/test/java/org/pf4j/SingletonExtensionFactoryTest.java
+++ b/pf4j/src/test/java/org/pf4j/SingletonExtensionFactoryTest.java
@@ -15,11 +15,12 @@
*/
package org.pf4j;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.pf4j.plugin.FailTestExtension;
import org.pf4j.plugin.TestExtension;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertSame;
/**
* @author Decebal Suiu
diff --git a/pf4j/src/test/java/org/pf4j/plugin/PluginZip.java b/pf4j/src/test/java/org/pf4j/plugin/PluginZip.java
index f069365..72e3241 100644
--- a/pf4j/src/test/java/org/pf4j/plugin/PluginZip.java
+++ b/pf4j/src/test/java/org/pf4j/plugin/PluginZip.java
@@ -15,7 +15,6 @@
*/
package org.pf4j.plugin;
-import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Path;
@@ -31,22 +30,18 @@ import java.util.zip.ZipOutputStream;
*/
public class PluginZip {
- private final File file;
+ private final Path path;
private final String pluginId;
private final String pluginVersion;
protected PluginZip(Builder builder) {
- this.file = builder.file;
+ this.path = builder.path;
this.pluginId = builder.pluginId;
this.pluginVersion = builder.pluginVersion;
}
- public File file() {
- return file;
- }
-
public Path path() {
- return file.toPath();
+ return path;
}
public String pluginId() {
@@ -66,13 +61,13 @@ public class PluginZip {
public static class Builder {
- private final File file;
+ private final Path path;
private final String pluginId;
private String pluginVersion;
- public Builder(File file, String pluginId) {
- this.file = file;
+ public Builder(Path path, String pluginId) {
+ this.path = path;
this.pluginId = pluginId;
}
@@ -94,7 +89,7 @@ public class PluginZip {
properties.setProperty("plugin.version", pluginVersion);
properties.setProperty("plugin.class", "org.pf4j.plugin.TestPlugin");
- ZipOutputStream outputStream = new ZipOutputStream(new FileOutputStream(file));
+ ZipOutputStream outputStream = new ZipOutputStream(new FileOutputStream(path.toFile()));
ZipEntry propertiesFile = new ZipEntry("plugin.properties");
outputStream.putNextEntry(propertiesFile);
properties.store(outputStream, "");
diff --git a/pf4j/src/test/java/org/pf4j/processor/ServiceProviderExtensionStorageTest.java b/pf4j/src/test/java/org/pf4j/processor/ServiceProviderExtensionStorageTest.java
index d152081..ac16b23 100644
--- a/pf4j/src/test/java/org/pf4j/processor/ServiceProviderExtensionStorageTest.java
+++ b/pf4j/src/test/java/org/pf4j/processor/ServiceProviderExtensionStorageTest.java
@@ -16,7 +16,7 @@
package org.pf4j.processor;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import javax.annotation.processing.Filer;
import javax.tools.FileObject;
@@ -29,8 +29,8 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
diff --git a/pf4j/src/test/java/org/pf4j/util/FileUtilsTest.java b/pf4j/src/test/java/org/pf4j/util/FileUtilsTest.java
index 76d0c2e..5f9a3a7 100644
--- a/pf4j/src/test/java/org/pf4j/util/FileUtilsTest.java
+++ b/pf4j/src/test/java/org/pf4j/util/FileUtilsTest.java
@@ -15,24 +15,24 @@
*/
package org.pf4j.util;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
import org.pf4j.plugin.PluginZip;
import java.nio.file.Files;
import java.nio.file.Path;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class FileUtilsTest {
- @Rule
- public TemporaryFolder testFolder = new TemporaryFolder();
+ @TempDir
+ Path pluginsPath;
@Test
public void expandIfZip() throws Exception {
- PluginZip pluginZip = new PluginZip.Builder(testFolder.newFile("my-plugin-1.2.3.zip"), "myPlugin")
+ PluginZip pluginZip = new PluginZip.Builder(pluginsPath.resolve("my-plugin-1.2.3.zip"), "myPlugin")
.pluginVersion("1.2.3")
.build();
@@ -41,10 +41,10 @@ public class FileUtilsTest {
assertTrue(Files.exists(unzipped.resolve("plugin.properties")));
// File without .suffix
- Path extra = testFolder.newFile("extra").toPath();
+ Path extra = pluginsPath.resolve("extra");
assertEquals(extra, FileUtils.expandIfZip(extra));
// Folder
- Path folder = testFolder.newFile("folder").toPath();
+ Path folder = pluginsPath.resolve("folder");
assertEquals(folder, FileUtils.expandIfZip(folder));
}
diff --git a/pom.xml b/pom.xml
index ddfde0f..46a432d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -48,7 +48,7 @@
<slf4j.version>1.7.25</slf4j.version>
<asm.version>7.1</asm.version>
- <junit.version>4.12</junit.version>
+ <junit.version>5.4.0</junit.version>
<hamcrest.version>2.1</hamcrest.version>
<mockito.version>2.24.0</mockito.version>
<cobertura.version>2.7</cobertura.version>