From: David ‘Bombe’ Roden Date: Thu, 9 Jul 2015 05:10:04 +0000 (+0200) Subject: Add test for different protocol error than 25 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=c60508a35e188f72fd6165711c1cb4e32190a4f4;p=jFCPlib.git Add test for different protocol error than 25 --- 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)); + } + + }