From 91de0a638af50527fc314ed97a095d1beaf36866 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 15 Oct 2015 07:17:57 +0200 Subject: [PATCH 1/1] Add test that protocol error ends AddPeer command --- .../fcp/quelaton/DefaultFcpClientTest.java | 24 ++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) 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 -- 2.7.4