diff options
author | Greg Wilkins | 2015-08-13 06:55:45 +0000 |
---|---|---|
committer | Greg Wilkins | 2015-08-13 06:55:45 +0000 |
commit | 0f6a83f7109f9a3bf4e69760cbca3a6f5a038335 (patch) | |
tree | 84962acfcc07a662498197e2d8df24a791bf07d7 | |
parent | d1aa9ce993029b752e8c85d64aef18835f519305 (diff) | |
download | org.eclipse.jetty.project-0f6a83f7109f9a3bf4e69760cbca3a6f5a038335.tar.gz org.eclipse.jetty.project-0f6a83f7109f9a3bf4e69760cbca3a6f5a038335.tar.xz org.eclipse.jetty.project-0f6a83f7109f9a3bf4e69760cbca3a6f5a038335.zip |
474634 - AsyncListener.onError() handling.
Fixed async blocking read test
-rw-r--r-- | jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncServletTest.java | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncServletTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncServletTest.java index 3c05f51808..c36c093bbd 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncServletTest.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncServletTest.java @@ -26,6 +26,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Timer; import java.util.TimerTask; +import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -80,7 +81,17 @@ public class AsyncServletTest protected List<String> _log; protected int _expectedLogs; protected String _expectedCode; - protected static List<String> __history=new ArrayList<>(); + protected static List<String> __history=new CopyOnWriteArrayList() + { + + @Override + public boolean add(Object e) + { + System.err.println("H: "+e); + return super.add(e); + } + + }; protected static CountDownLatch __latch; @Before @@ -150,6 +161,18 @@ public class AsyncServletTest } @Test + public void testNonAsync() throws Exception + { + String response=process("",null); + Assert.assertThat(response,Matchers.startsWith("HTTP/1.1 200 OK")); + assertThat(__history,contains( + "REQUEST /ctx/path/info", + "initial")); + + assertContains("NORMAL",response); + } + + @Test public void testStart() throws Exception { _expectedCode="500 "; @@ -573,28 +596,23 @@ public class AsyncServletTest @Test public void testAsyncRead() throws Exception { - _expectedLogs=2; String header="GET /ctx/path/info?start=2000&dispatch=1500 HTTP/1.1\r\n"+ "Host: localhost\r\n"+ "Content-Length: 10\r\n"+ - "\r\n"; - String body="12345678\r\n"; - String close="GET /ctx/path/info HTTP/1.1\r\n"+ - "Host: localhost\r\n"+ "Connection: close\r\n"+ "\r\n"; + String body="12345678\r\n"; try (Socket socket = new Socket("localhost",_port)) { socket.setSoTimeout(10000); socket.getOutputStream().write(header.getBytes(StandardCharsets.ISO_8859_1)); - Thread.sleep(500); socket.getOutputStream().write(body.getBytes(StandardCharsets.ISO_8859_1),0,2); Thread.sleep(500); socket.getOutputStream().write(body.getBytes(StandardCharsets.ISO_8859_1),2,8); - socket.getOutputStream().write(close.getBytes(StandardCharsets.ISO_8859_1)); String response = IO.toString(socket.getInputStream()); + __latch.await(1,TimeUnit.SECONDS); assertThat(response,startsWith("HTTP/1.1 200 OK")); assertThat(__history,contains( "REQUEST /ctx/path/info", |