From c60508a35e188f72fd6165711c1cb4e32190a4f4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 9 Jul 2015 07:10:04 +0200 Subject: [PATCH] Add test for different protocol error than 25 --- .../fcp/quelaton/ClientPutCommandImpl.java | 8 ++++++-- .../fcp/quelaton/DefaultFcpClientTest.java | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/pterodactylus/fcp/quelaton/ClientPutCommandImpl.java b/src/main/java/net/pterodactylus/fcp/quelaton/ClientPutCommandImpl.java index f0a6706..2796156 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/ClientPutCommandImpl.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/ClientPutCommandImpl.java @@ -166,8 +166,12 @@ class ClientPutCommandImpl implements ClientPutCommand { @Override protected void consumeProtocolError(ProtocolError protocolError) { - if (protocolError.getIdentifier().equals(identifier.get()) && (protocolError.getCode() == 25)) { - sendMessage(new TestDDARequest(directory.get(), true, false)); + if (protocolError.getIdentifier().equals(identifier.get())) { + if (protocolError.getCode() == 25) { + sendMessage(new TestDDARequest(directory.get(), true, false)); + } else { + putFinished.set(true); + } } } diff --git a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java index 0fbb7b8..47aff70 100644 --- a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java +++ b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java @@ -457,4 +457,21 @@ public class DefaultFcpClientTest { assertThat(key.get().get().getKey(), is("KSK@foo.txt")); } + @Test + public void clientPutAbortsOnProtocolErrorOtherThan25() + throws InterruptedException, ExecutionException, IOException { + Future> key = fcpClient.clientPut().from(new File("/tmp/data.txt")).key(new Key("KSK@foo.txt")); + connectNode(); + List lines = fcpServer.collectUntil(is("EndMessage")); + String identifier = extractIdentifier(lines); + fcpServer.writeLine( + "ProtocolError", + "Identifier=" + identifier, + "Code=1", + "EndMessage" + ); + assertThat(key.get().isPresent(), is(false)); + } + + } -- 2.7.4