Add method to wait for removal of a plugin
authorDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Fri, 21 Aug 2015 22:05:19 +0000 (00:05 +0200)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Fri, 21 Aug 2015 22:05:19 +0000 (00:05 +0200)
src/main/java/net/pterodactylus/fcp/quelaton/RemovePluginCommand.java
src/main/java/net/pterodactylus/fcp/quelaton/RemovePluginCommandImpl.java
src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java

index c221592..56fafa1 100644 (file)
@@ -7,6 +7,7 @@ package net.pterodactylus.fcp.quelaton;
  */
 public interface RemovePluginCommand {
 
+       RemovePluginCommand waitFor(int milliseconds);
        Executable<Boolean> plugin(String pluginClass);
 
 }
index b4a6b79..4bc0781 100644 (file)
@@ -31,6 +31,12 @@ public class RemovePluginCommandImpl implements RemovePluginCommand {
        }
 
        @Override
+       public RemovePluginCommand waitFor(int milliseconds) {
+               removePlugin.setMaxWaitTime(milliseconds);
+               return this;
+       }
+
+       @Override
        public Executable<Boolean> plugin(String pluginClass) {
                removePlugin.setPluginName(pluginClass);
                return this::execute;
index fafee42..3495588 100644 (file)
@@ -2202,6 +2202,15 @@ public class DefaultFcpClientTest {
                                assertThat(pluginRemoved.get(), is(true));
                        }
 
+                       @Test
+                       public void removingPluginWithMaxWaitTimeWorks()
+                       throws InterruptedException, ExecutionException, IOException {
+                               Future<Boolean> pluginRemoved = fcpClient.removePlugin().waitFor(1234).plugin(CLASS_NAME).execute();
+                               connectAndAssert(() -> allOf(matchPluginRemovedMessage(), hasItem("MaxWaitTime=1234")));
+                               replyWithPluginRemoved();
+                               assertThat(pluginRemoved.get(), is(true));
+                       }
+
                        private void replyWithPluginRemoved() throws IOException {
                                fcpServer.writeLine(
                                        "PluginRemoved",