Add method to store plugin in config after reloading
authorDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Fri, 21 Aug 2015 21:03:44 +0000 (23:03 +0200)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Fri, 21 Aug 2015 21:03:44 +0000 (23:03 +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 8495ad2..5024267 100644 (file)
@@ -13,6 +13,7 @@ public interface ReloadPluginCommand {
 
        ReloadPluginCommand waitFor(int milliseconds);
        ReloadPluginCommand purge();
+       ReloadPluginCommand addToConfig();
        Executable<Optional<PluginInfo>> plugin(String pluginClassName);
 
 }
index 2c2e6c4..e544ec6 100644 (file)
@@ -45,6 +45,12 @@ public class ReloadPluginCommandImpl implements ReloadPluginCommand {
        }
 
        @Override
+       public ReloadPluginCommand addToConfig() {
+               reloadPlugin.setStore(true);
+               return this;
+       }
+
+       @Override
        public Executable<Optional<PluginInfo>> plugin(String pluginClassName) {
                reloadPlugin.setPluginName(pluginClassName);
                return this::execute;
index 0974d40..6cc61d6 100644 (file)
@@ -2171,6 +2171,16 @@ public class DefaultFcpClientTest {
                                verifyPluginInfo(pluginInfo);
                        }
 
+                       @Test
+                       public void reloadingPluginWithStoreWorks()
+                       throws InterruptedException, ExecutionException, IOException {
+                               Future<Optional<PluginInfo>> pluginInfo =
+                                       fcpClient.reloadPlugin().addToConfig().plugin(CLASS_NAME).execute();
+                               connectAndAssert(() -> allOf(matchReloadPluginMessage(), hasItem("Store=true")));
+                               replyWithPluginInfo();
+                               verifyPluginInfo(pluginInfo);
+                       }
+
                        private Matcher<List<String>> matchReloadPluginMessage() {
                                return matchesFcpMessage(
                                        "ReloadPlugin",