|
1 | 1 | /* |
2 | | - * Copyright 2002-2017 the original author or authors. |
| 2 | + * Copyright 2002-2018 the original author or authors. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
|
60 | 60 |
|
61 | 61 | /** |
62 | 62 | * @author Gary Russell |
| 63 | + * @author Artem Bilan |
| 64 | + * |
63 | 65 | * @since 2.2 |
64 | 66 | */ |
65 | 67 | public class SocketSupportTests { |
@@ -354,15 +356,18 @@ public void postProcessServerSocket(ServerSocket serverSocket) { |
354 | 356 | DefaultTcpNetSSLSocketFactorySupport clientTcpSocketFactorySupport = |
355 | 357 | new DefaultTcpNetSSLSocketFactorySupport(clientSslContextSupport); |
356 | 358 | client.setTcpSocketFactorySupport(clientTcpSocketFactorySupport); |
357 | | - client.start(); |
358 | | - |
359 | | - TcpConnection connection = client.getConnection(); |
360 | | - connection.send(new GenericMessage<String>("Hello, world!")); |
361 | | - assertTrue(latch.await(10, TimeUnit.SECONDS)); |
362 | | - assertEquals("Hello, world!", new String((byte[]) messages.get(0).getPayload())); |
363 | 359 |
|
364 | | - client.stop(); |
365 | | - server.stop(); |
| 360 | + try { |
| 361 | + client.start(); |
| 362 | + TcpConnection connection = client.getConnection(); |
| 363 | + connection.send(new GenericMessage<String>("Hello, world!")); |
| 364 | + assertTrue(latch.await(10, TimeUnit.SECONDS)); |
| 365 | + assertEquals("Hello, world!", new String((byte[]) messages.get(0).getPayload())); |
| 366 | + } |
| 367 | + finally { |
| 368 | + client.stop(); |
| 369 | + server.stop(); |
| 370 | + } |
366 | 371 | } |
367 | 372 |
|
368 | 373 | @Test |
@@ -428,7 +433,8 @@ public void testNioClientAndServerSSLDifferentContexts() throws Exception { |
428 | 433 | assertThat(e.getMessage(), |
429 | 434 | anyOf( |
430 | 435 | containsString("Socket closed during SSL Handshake"), |
431 | | - containsString("Broken pipe"))); |
| 436 | + containsString("Broken pipe"), |
| 437 | + containsString("Connection reset by peer"))); |
432 | 438 | } |
433 | 439 | } |
434 | 440 | } |
@@ -465,15 +471,18 @@ protected void postProcessSSLEngine(SSLEngine sslEngine) { |
465 | 471 | DefaultTcpNioSSLConnectionSupport clientTcpNioConnectionSupport = |
466 | 472 | new DefaultTcpNioSSLConnectionSupport(clientSslContextSupport); |
467 | 473 | client.setTcpNioConnectionSupport(clientTcpNioConnectionSupport); |
468 | | - client.start(); |
469 | | - |
470 | | - TcpConnection connection = client.getConnection(); |
471 | | - connection.send(new GenericMessage<String>("Hello, world!")); |
472 | | - assertTrue(latch.await(10, TimeUnit.SECONDS)); |
473 | | - assertEquals("Hello, world!", new String((byte[]) messages.get(0).getPayload())); |
474 | 474 |
|
475 | | - client.stop(); |
476 | | - server.stop(); |
| 475 | + try { |
| 476 | + client.start(); |
| 477 | + TcpConnection connection = client.getConnection(); |
| 478 | + connection.send(new GenericMessage<String>("Hello, world!")); |
| 479 | + assertTrue(latch.await(10, TimeUnit.SECONDS)); |
| 480 | + assertEquals("Hello, world!", new String((byte[]) messages.get(0).getPayload())); |
| 481 | + } |
| 482 | + finally { |
| 483 | + client.stop(); |
| 484 | + server.stop(); |
| 485 | + } |
477 | 486 | } |
478 | 487 |
|
479 | 488 | @Test |
|
0 commit comments