*
* @throws Exception
*/
public void testRequest1_jetty_https() throws Exception
{
Server server=new Server();
SslSelectChannelConnector connector=new SslSelectChannelConnector();
String keystore = System.getProperty("user.dir")+File.separator+"src"+File.separator+"test"+File.separator+"resources"+File.separator+"keystore";
connector.setPort(0);
connector.setKeystore(keystore);
connector.setPassword("storepwd");
connector.setKeyPassword("keypwd");
server.setConnectors(new Connector[]
{ connector });
server.setHandler(new HelloWorldHandler());
server.start();
final int numConns=200;
Socket[] client=new Socket[numConns];
SSLContext ctx=SSLContext.getInstance("SSLv3");
ctx.init(null,s_dummyTrustManagers,new java.security.SecureRandom());
int port=connector.getLocalPort();
try
{
for (int i=0; i<numConns; ++i)
{
// System.err.println("write:"+i);
client[i]=ctx.getSocketFactory().createSocket("localhost",port);
OutputStream os=client[i].getOutputStream();
os.write(REQUEST0.getBytes());
os.write(REQUEST0.getBytes());
os.flush();
}
for (int i=0; i<numConns; ++i)
{
// System.err.println("flush:"+i);
OutputStream os=client[i].getOutputStream();
os.write(REQUEST1.getBytes());
os.flush();
}
for (int i=0; i<numConns; ++i)
{
// System.err.println("read:"+i);
// Read the response.
String responses=readResponse(client[i]);
// Check the response
assertEquals(String.format("responses %d",i),RESPONSE0+RESPONSE0+RESPONSE1,responses);
}
}
finally
{
for (int i=0; i<numConns; ++i)
{
if (client[i]!=null)
{
client[i].close();
}
}
server.stop();
}
}