From: David ‘Bombe’ Roden Date: Fri, 21 Aug 2015 22:05:19 +0000 (+0200) Subject: Add method to wait for removal of a plugin X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=47bca39b9aa221c26541b544309b279e2d08119d;p=jFCPlib.git Add method to wait for removal of a plugin --- diff --git a/src/main/java/net/pterodactylus/fcp/quelaton/RemovePluginCommand.java b/src/main/java/net/pterodactylus/fcp/quelaton/RemovePluginCommand.java index c221592..56fafa1 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/RemovePluginCommand.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/RemovePluginCommand.java @@ -7,6 +7,7 @@ package net.pterodactylus.fcp.quelaton; */ public interface RemovePluginCommand { + RemovePluginCommand waitFor(int milliseconds); Executable plugin(String pluginClass); } diff --git a/src/main/java/net/pterodactylus/fcp/quelaton/RemovePluginCommandImpl.java b/src/main/java/net/pterodactylus/fcp/quelaton/RemovePluginCommandImpl.java index b4a6b79..4bc0781 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/RemovePluginCommandImpl.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/RemovePluginCommandImpl.java @@ -31,6 +31,12 @@ public class RemovePluginCommandImpl implements RemovePluginCommand { } @Override + public RemovePluginCommand waitFor(int milliseconds) { + removePlugin.setMaxWaitTime(milliseconds); + return this; + } + + @Override public Executable plugin(String pluginClass) { removePlugin.setPluginName(pluginClass); return this::execute; diff --git a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java index fafee42..3495588 100644 --- a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java +++ b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java @@ -2202,6 +2202,15 @@ public class DefaultFcpClientTest { assertThat(pluginRemoved.get(), is(true)); } + @Test + public void removingPluginWithMaxWaitTimeWorks() + throws InterruptedException, ExecutionException, IOException { + Future 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",