Made SslBytesClientTest more robust by avoiding a race in establishing connection with the proxy.

This commit is contained in:
Simone Bordet 2011-11-24 23:08:57 +01:00
parent ccfbb3e623
commit cfef7c631b
2 changed files with 5 additions and 3 deletions

View File

@ -35,6 +35,7 @@ public class SslBytesClientTest extends SslBytesTest
threadPool = Executors.newCachedThreadPool();
client = new HttpClient();
client.setMaxConnectionsPerAddress(1);
client.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
File keyStore = MavenTestingUtils.getTestResourceFile("keystore");
SslContextFactory cf = client.getSslContextFactory();
@ -44,7 +45,7 @@ public class SslBytesClientTest extends SslBytesTest
client.start();
SSLContext sslContext = cf.getSslContext();
acceptor = (SSLServerSocket)sslContext.getServerSocketFactory().createServerSocket(5870);
acceptor = (SSLServerSocket)sslContext.getServerSocketFactory().createServerSocket(0);
int serverPort = acceptor.getLocalPort();
@ -74,6 +75,7 @@ public class SslBytesClientTest extends SslBytesTest
String method = HttpMethods.GET;
exchange.setMethod(method);
client.send(exchange);
Assert.assertTrue(proxy.awaitClient(5, TimeUnit.SECONDS));
final SSLSocket server = (SSLSocket)acceptor.accept();
server.setUseClientMode(false);

View File

@ -97,8 +97,8 @@ public abstract class SslBytesTest
public void start() throws Exception
{
serverSocket = new ServerSocket(5871);
// serverSocket = new ServerSocket(0);
// serverSocket = new ServerSocket(5871);
serverSocket = new ServerSocket(0);
Thread acceptor = new Thread(this);
acceptor.start();
server = new Socket(serverHost, serverPort);