Browse Source

Improve testing of #335

pull/337/head
Decebal Suiu 5 years ago
parent
commit
d7344b8d3c
  1. 16
      pf4j/src/test/java/org/pf4j/DefaultPluginStatusProviderTest.java

16
pf4j/src/test/java/org/pf4j/DefaultPluginStatusProviderTest.java

@ -82,6 +82,9 @@ public class DefaultPluginStatusProviderTest {
assertTrue(statusProvider.isPluginDisabled("plugin-1")); assertTrue(statusProvider.isPluginDisabled("plugin-1"));
assertTrue(statusProvider.isPluginDisabled("plugin-2")); assertTrue(statusProvider.isPluginDisabled("plugin-2"));
assertFalse(statusProvider.isPluginDisabled("plugin-3")); assertFalse(statusProvider.isPluginDisabled("plugin-3"));
List<String> disabledPlugins = FileUtils.readLines(pluginsPath.resolve("disabled.txt"), true);
assertTrue(disabledPlugins.contains("plugin-1"));
} }
@Test @Test
@ -94,10 +97,13 @@ public class DefaultPluginStatusProviderTest {
assertFalse(statusProvider.isPluginDisabled("plugin-1")); assertFalse(statusProvider.isPluginDisabled("plugin-1"));
assertFalse(statusProvider.isPluginDisabled("plugin-2")); assertFalse(statusProvider.isPluginDisabled("plugin-2"));
assertTrue(statusProvider.isPluginDisabled("plugin-3")); assertTrue(statusProvider.isPluginDisabled("plugin-3"));
List<String> disabledPlugins = FileUtils.readLines(pluginsPath.resolve("disabled.txt"), true);
assertFalse(disabledPlugins.contains("plugin-2"));
} }
@Test @Test
public void testEnablePluginWithEnableEmpty() throws Exception{ public void testEnablePluginWithEnableEmpty() {
PluginStatusProvider statusProvider = new DefaultPluginStatusProvider(pluginsPath); PluginStatusProvider statusProvider = new DefaultPluginStatusProvider(pluginsPath);
statusProvider.enablePlugin("plugin-2"); statusProvider.enablePlugin("plugin-2");
@ -107,7 +113,7 @@ public class DefaultPluginStatusProviderTest {
} }
@Test @Test
public void testDisablePluginWithoutDisabledFile() throws Exception { public void testDisablePluginWithoutDisabledFile() {
PluginStatusProvider statusProvider = new DefaultPluginStatusProvider(pluginsPath); PluginStatusProvider statusProvider = new DefaultPluginStatusProvider(pluginsPath);
assertFalse(statusProvider.isPluginDisabled("plugin-1")); assertFalse(statusProvider.isPluginDisabled("plugin-1"));
@ -120,8 +126,7 @@ public class DefaultPluginStatusProviderTest {
List<String> disabledPlugins = new ArrayList<>(); List<String> disabledPlugins = new ArrayList<>();
disabledPlugins.add("plugin-2"); disabledPlugins.add("plugin-2");
Path disabledPath = pluginsPath.resolve("disabled.txt"); FileUtils.writeLines(disabledPlugins, pluginsPath.resolve("disabled.txt").toFile());
FileUtils.writeLines(disabledPlugins, disabledPath.toFile());
} }
private void createEnabledFile() throws IOException { private void createEnabledFile() throws IOException {
@ -129,8 +134,7 @@ public class DefaultPluginStatusProviderTest {
enabledPlugins.add("plugin-1"); enabledPlugins.add("plugin-1");
enabledPlugins.add("plugin-2"); enabledPlugins.add("plugin-2");
Path enabledPath = pluginsPath.resolve("enabled.txt"); FileUtils.writeLines(enabledPlugins, pluginsPath.resolve("enabled.txt").toFile());
FileUtils.writeLines(enabledPlugins, enabledPath.toFile());
} }
} }

Loading…
Cancel
Save