From 41874b5fbeff7db4b85ad0fbd3ca4a321092fe61 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Mon, 12 Mar 2012 15:30:26 +0100 Subject: [PATCH] Made the test portable between Jetty7 and Jetty8. --- .../jetty/spdy/http/ServerHTTPSPDYTest.java | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ServerHTTPSPDYTest.java b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ServerHTTPSPDYTest.java index 2fea3ea340d..59370e5ce8e 100644 --- a/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ServerHTTPSPDYTest.java +++ b/jetty-spdy/spdy-jetty-http/src/test/java/org/eclipse/jetty/spdy/http/ServerHTTPSPDYTest.java @@ -31,8 +31,9 @@ import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.eclipse.jetty.continuation.Continuation; +import org.eclipse.jetty.continuation.ContinuationSupport; import org.eclipse.jetty.io.ByteArrayBuffer; -import org.eclipse.jetty.server.AsyncContext; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.spdy.api.BytesDataInfo; @@ -975,7 +976,10 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest throws IOException, ServletException { request.setHandled(true); - final AsyncContext async = request.startAsync(); + + final Continuation continuation = ContinuationSupport.getContinuation(request); + continuation.suspend(); + new Thread() { @Override @@ -988,7 +992,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest int read = 0; while (read < data.length) read += input.read(buffer); - async.complete(); + continuation.complete(); latch.countDown(); } catch (IOException x) @@ -1034,7 +1038,10 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest throws IOException, ServletException { request.setHandled(true); - final AsyncContext async = request.startAsync(); + + final Continuation continuation = ContinuationSupport.getContinuation(request); + continuation.suspend(); + new Thread() { @Override @@ -1047,7 +1054,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest int read = 0; while (read < 2 * data.length) read += input.read(buffer); - async.complete(); + continuation.complete(); latch.countDown(); } catch (IOException x) @@ -1094,14 +1101,17 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest throws IOException, ServletException { request.setHandled(true); - if (request.getAsyncContinuation().isInitial()) + + final Continuation continuation = ContinuationSupport.getContinuation(request); + + if (continuation.isInitial()) { InputStream input = request.getInputStream(); byte[] buffer = new byte[256]; int read = 0; while (read < data.length) read += input.read(buffer); - final AsyncContext async = request.startAsync(); + continuation.suspend(); new Thread() { @Override @@ -1110,7 +1120,7 @@ public class ServerHTTPSPDYTest extends AbstractHTTPSPDYTest try { TimeUnit.SECONDS.sleep(1); - async.dispatch(); + continuation.resume(); latch.countDown(); } catch (InterruptedException x)