From: David ‘Bombe’ Roden Date: Fri, 21 Aug 2015 20:43:34 +0000 (+0200) Subject: Add method to add wait time for reloading plugins X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=d21f485b5918b4281c349d8c04893d27a979ae76;p=jFCPlib.git Add method to add wait time for reloading plugins --- diff --git a/src/main/java/net/pterodactylus/fcp/quelaton/ReloadPluginCommand.java b/src/main/java/net/pterodactylus/fcp/quelaton/ReloadPluginCommand.java index ef25380..65febba 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/ReloadPluginCommand.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/ReloadPluginCommand.java @@ -11,6 +11,7 @@ import net.pterodactylus.fcp.PluginInfo; */ public interface ReloadPluginCommand { + ReloadPluginCommand waitFor(int milliseconds); Executable> plugin(String pluginClassName); } diff --git a/src/main/java/net/pterodactylus/fcp/quelaton/ReloadPluginCommandImpl.java b/src/main/java/net/pterodactylus/fcp/quelaton/ReloadPluginCommandImpl.java index c1a33fe..f7c11a9 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/ReloadPluginCommandImpl.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/ReloadPluginCommandImpl.java @@ -33,6 +33,12 @@ public class ReloadPluginCommandImpl implements ReloadPluginCommand { } @Override + public ReloadPluginCommand waitFor(int milliseconds) { + reloadPlugin.setMaxWaitTime(milliseconds); + return this; + } + + @Override public Executable> plugin(String pluginClassName) { reloadPlugin.setPluginName(pluginClassName); 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 7ba009c..d4d67c5 100644 --- a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java +++ b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java @@ -1,6 +1,7 @@ package net.pterodactylus.fcp.quelaton; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.hasItem; @@ -2145,14 +2146,28 @@ public class DefaultFcpClientTest { @Test public void reloadingPluginWorks() throws InterruptedException, ExecutionException, IOException { Future> pluginInfo = fcpClient.reloadPlugin().plugin(CLASS_NAME).execute(); - connectAndAssert(() -> matchesFcpMessage( + connectAndAssert(() -> matchReloadPluginMessage()); + replyWithPluginInfo(); + verifyPluginInfo(pluginInfo); + } + + @Test + public void reloadingPluginWithMaxWaitTimeWorks() + throws InterruptedException, ExecutionException, IOException { + Future> pluginInfo = + fcpClient.reloadPlugin().waitFor(1234).plugin(CLASS_NAME).execute(); + connectAndAssert(() -> allOf(matchReloadPluginMessage(), hasItem("MaxWaitTime=1234"))); + replyWithPluginInfo(); + verifyPluginInfo(pluginInfo); + } + + private Matcher> matchReloadPluginMessage() { + return matchesFcpMessage( "ReloadPlugin", "Identifier=" + identifier, "PluginName=" + CLASS_NAME, "EndMessage" - )); - replyWithPluginInfo(); - verifyPluginInfo(pluginInfo); + ); } }