From: David ‘Bombe’ Roden Date: Thu, 15 Oct 2015 05:17:57 +0000 (+0200) Subject: Add test that protocol error ends AddPeer command X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=91de0a638af50527fc314ed97a095d1beaf36866;p=jFCPlib.git Add test that protocol error ends AddPeer command --- diff --git a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java index f7823d6..8adf900 100644 --- a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java +++ b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java @@ -215,6 +215,14 @@ public class DefaultFcpClientTest { assertThat(lines, requestMatcher.get()); } + private void replyWithProtocolError() throws IOException { + fcpServer.writeLine( + "ProtocolError", + "Identifier=" + identifier, + "EndMessage" + ); + } + public class ConnectionsAndKeyPairs { public class Connections { @@ -438,6 +446,14 @@ public class DefaultFcpClientTest { assertThat(peer.get().get().getIdentity(), is("id1")); } + @Test + public void protocolErrorEndsCommand() throws InterruptedException, ExecutionException, IOException { + Future> peer = fcpClient.addPeer().fromFile(new File("/tmp/ref.txt")).execute(); + connectAndAssert(() -> allOf(matchesAddPeer(), hasItem("File=/tmp/ref.txt"))); + replyWithProtocolError(); + assertThat(peer.get().isPresent(), is(false)); + } + private NodeRef createNodeRef() { NodeRef nodeRef = new NodeRef(); nodeRef.setIdentity("id1"); @@ -974,14 +990,6 @@ public class DefaultFcpClientTest { } - private void replyWithProtocolError() throws IOException { - fcpServer.writeLine( - "ProtocolError", - "Identifier=" + identifier, - "EndMessage" - ); - } - public class ReloadPlugin { @Test