From 97ff08b3be3cdce8c23c77e96f2f6c7359a7b781 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Fri, 10 Aug 2012 13:30:56 +1000 Subject: [PATCH] jetty-9 write on ssl connection test harness --- .../eclipse/jetty/io/SslConnectionTest.java | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/jetty-io/src/test/java/org/eclipse/jetty/io/SslConnectionTest.java b/jetty-io/src/test/java/org/eclipse/jetty/io/SslConnectionTest.java index 596253c43a8..98b150016dc 100644 --- a/jetty-io/src/test/java/org/eclipse/jetty/io/SslConnectionTest.java +++ b/jetty-io/src/test/java/org/eclipse/jetty/io/SslConnectionTest.java @@ -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 _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 {