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;
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<FcpKeyPair> 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<FcpKeyPair> keyPairFuture = fcpClient.generateKeypair().execute();