From: David ‘Bombe’ Roden Date: Fri, 21 Aug 2015 22:50:47 +0000 (+0200) Subject: Add test for protocol error on GetPluginInfo X-Git-Url: https://git.pterodactylus.net/?p=jFCPlib.git;a=commitdiff_plain;h=be6c1651ce3c53daa254fb2dbce9221450d381e8 Add test for protocol error on GetPluginInfo --- diff --git a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java index 78aa52a..557350b 100644 --- a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java +++ b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java @@ -2126,14 +2126,8 @@ public class DefaultFcpClientTest { public void failedLoad() throws ExecutionException, InterruptedException, IOException { Future> pluginInfo = fcpClient.loadPlugin().officialFromFreenet("superPlugin").execute(); - connectNode(); - List lines = fcpServer.collectUntil(is("EndMessage")); - String identifier = extractIdentifier(lines); - fcpServer.writeLine( - "ProtocolError", - "Identifier=" + identifier, - "EndMessage" - ); + connectAndAssert(() -> matchesFcpMessage("LoadPlugin", "EndMessage")); + replyWithProtocolError(); assertThat(pluginInfo.get().isPresent(), is(false)); } @@ -2141,6 +2135,14 @@ public class DefaultFcpClientTest { } + private void replyWithProtocolError() throws IOException { + fcpServer.writeLine( + "ProtocolError", + "Identifier=" + identifier, + "EndMessage" + ); + } + public class ReloadPlugin { @Test @@ -2260,6 +2262,16 @@ public class DefaultFcpClientTest { verifyPluginInfo(pluginInfo); } + @Test + public void protocolErrorIsRecognizedAsFailure() + throws InterruptedException, ExecutionException, IOException { + Future> pluginInfo = + fcpClient.getPluginInfo().detailed().plugin(CLASS_NAME).execute(); + connectAndAssert(() -> allOf(matchGetPluginInfoMessage(), hasItem("Detailed=true"))); + replyWithProtocolError(); + assertThat(pluginInfo.get(), is(Optional.empty())); + } + private Matcher> matchGetPluginInfoMessage() { return matchesFcpMessage( "GetPluginInfo",