jetty-9 write on ssl connection test harness
This commit is contained in:
parent
16b404754e
commit
97ff08b3be
|
@ -38,6 +38,8 @@ public class SslConnectionTest
|
|||
private static ByteBufferPool __byteBufferPool = new StandardByteBufferPool();
|
||||
|
||||
protected volatile EndPoint _lastEndp;
|
||||
private volatile boolean _testFill=true;
|
||||
private volatile FutureCallback<Void> _writeCallback;
|
||||
protected ServerSocketChannel _connector;
|
||||
protected QueuedThreadPool _threadPool = new QueuedThreadPool();
|
||||
protected ScheduledExecutorService _scheduler = Executors.newSingleThreadScheduledExecutor();
|
||||
|
@ -88,6 +90,8 @@ public class SslConnectionTest
|
|||
@Before
|
||||
public void startManager() throws Exception
|
||||
{
|
||||
_testFill=true;
|
||||
_writeCallback=null;
|
||||
_lastEndp=null;
|
||||
_connector = ServerSocketChannel.open();
|
||||
_connector.socket().bind(null);
|
||||
|
@ -118,7 +122,10 @@ public class SslConnectionTest
|
|||
public void onOpen()
|
||||
{
|
||||
super.onOpen();
|
||||
fillInterested();
|
||||
if (_testFill)
|
||||
fillInterested();
|
||||
else
|
||||
getEndPoint().write(null,_writeCallback,BufferUtil.toBuffer("Hello Client"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -204,6 +211,29 @@ public class SslConnectionTest
|
|||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testWriteOnConnect() throws Exception
|
||||
{
|
||||
_testFill=false;
|
||||
|
||||
for (int i=0;i<10;i++)
|
||||
{
|
||||
_writeCallback = new FutureCallback<>();
|
||||
Socket client = newClient();
|
||||
client.setSoTimeout(60000);
|
||||
|
||||
SocketChannel server = _connector.accept();
|
||||
server.configureBlocking(false);
|
||||
_manager.accept(server);
|
||||
|
||||
byte[] buffer = new byte[1024];
|
||||
int len=client.getInputStream().read(buffer);
|
||||
Assert.assertEquals("Hello Client",new String(buffer,0,len,StringUtil.__UTF8_CHARSET));
|
||||
Assert.assertEquals(null,_writeCallback.get(100,TimeUnit.MILLISECONDS));
|
||||
client.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testManyLines() throws Exception
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue