Add test for different protocol error than 25
authorDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Thu, 9 Jul 2015 05:10:04 +0000 (07:10 +0200)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Thu, 9 Jul 2015 05:10:04 +0000 (07:10 +0200)
src/main/java/net/pterodactylus/fcp/quelaton/ClientPutCommandImpl.java
src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java

index f0a6706..2796156 100644 (file)
@@ -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);
+                               }
                        }
                }
 
index 0fbb7b8..47aff70 100644 (file)
@@ -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<Optional<Key>> key = fcpClient.clientPut().from(new File("/tmp/data.txt")).key(new Key("KSK@foo.txt"));
+               connectNode();
+               List<String> lines = fcpServer.collectUntil(is("EndMessage"));
+               String identifier = extractIdentifier(lines);
+               fcpServer.writeLine(
+                       "ProtocolError",
+                       "Identifier=" + identifier,
+                       "Code=1",
+                       "EndMessage"
+               );
+               assertThat(key.get().isPresent(), is(false));
+       }
+
+
 }