Add method to purge plugin while reloading
authorDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Fri, 21 Aug 2015 21:00:08 +0000 (23:00 +0200)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Fri, 21 Aug 2015 21:00:08 +0000 (23:00 +0200)
src/main/java/net/pterodactylus/fcp/quelaton/ReloadPluginCommand.java
src/main/java/net/pterodactylus/fcp/quelaton/ReloadPluginCommandImpl.java
src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java

index 65febba..8495ad2 100644 (file)
@@ -12,6 +12,7 @@ import net.pterodactylus.fcp.PluginInfo;
 public interface ReloadPluginCommand {
 
        ReloadPluginCommand waitFor(int milliseconds);
+       ReloadPluginCommand purge();
        Executable<Optional<PluginInfo>> plugin(String pluginClassName);
 
 }
index f7c11a9..2c2e6c4 100644 (file)
@@ -39,6 +39,12 @@ public class ReloadPluginCommandImpl implements ReloadPluginCommand {
        }
 
        @Override
+       public ReloadPluginCommand purge() {
+               reloadPlugin.setPurge(true);
+               return this;
+       }
+
+       @Override
        public Executable<Optional<PluginInfo>> plugin(String pluginClassName) {
                reloadPlugin.setPluginName(pluginClassName);
                return this::execute;
index d4d67c5..0974d40 100644 (file)
@@ -2161,6 +2161,16 @@ public class DefaultFcpClientTest {
                                verifyPluginInfo(pluginInfo);
                        }
 
+                       @Test
+                       public void reloadingPluginWithPurgeWorks()
+                       throws InterruptedException, ExecutionException, IOException {
+                               Future<Optional<PluginInfo>> pluginInfo =
+                                       fcpClient.reloadPlugin().purge().plugin(CLASS_NAME).execute();
+                               connectAndAssert(() -> allOf(matchReloadPluginMessage(), hasItem("Purge=true")));
+                               replyWithPluginInfo();
+                               verifyPluginInfo(pluginInfo);
+                       }
+
                        private Matcher<List<String>> matchReloadPluginMessage() {
                                return matchesFcpMessage(
                                        "ReloadPlugin",