From: David ‘Bombe’ Roden Date: Fri, 10 Jul 2015 12:20:53 +0000 (+0200) Subject: Add test for CloseConnectionDuplicateClientName handling X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=a9e24cccfca7217fcfee9e8115ce7ef40cc7a4d8;p=jFCPlib.git Add test for CloseConnectionDuplicateClientName handling --- diff --git a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java index 575c188..6632d59 100644 --- a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java +++ b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java @@ -16,6 +16,8 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; +import java.util.logging.Level; +import java.util.logging.Logger; import java.util.stream.Collectors; import net.pterodactylus.fcp.FcpKeyPair; @@ -61,6 +63,21 @@ public class DefaultFcpClientTest { fcpServer.close(); } + @Test(expected = ExecutionException.class) + public void defaultFcpClientThrowsExceptionIfItCanNotConnect() + throws IOException, ExecutionException, InterruptedException { + Logger.getAnonymousLogger().getParent().setLevel(Level.FINEST); + Logger.getAnonymousLogger().getParent().getHandlers()[0].setLevel(Level.FINEST); + Future keyPairFuture = fcpClient.generateKeypair().execute(); + fcpServer.connect().get(); + fcpServer.collectUntil(is("EndMessage")); + fcpServer.writeLine( + "CloseConnectionDuplicateClientName", + "EndMessage" + ); + keyPairFuture.get(); + } + @Test public void defaultFcpClientCanGenerateKeypair() throws ExecutionException, InterruptedException, IOException { Future keyPairFuture = fcpClient.generateKeypair().execute();