From 47bca39b9aa221c26541b544309b279e2d08119d Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 22 Aug 2015 00:05:19 +0200 Subject: [PATCH] Add method to wait for removal of a plugin --- .../java/net/pterodactylus/fcp/quelaton/RemovePluginCommand.java | 1 + .../net/pterodactylus/fcp/quelaton/RemovePluginCommandImpl.java | 6 ++++++ .../net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java | 9 +++++++++ 3 files changed, 16 insertions(+) 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", -- 2.7.4