aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Becker2012-02-28 04:41:49 (EST)
committerThomas Becker2012-03-01 09:14:56 (EST)
commit3a94e4505050457a01431f9b4e77bd7a3e0e4a81 (patch)
treee88edfa9aa7565f11ea6ae53b7b398eb64c26781
parent5c0c8c7e73c86dd334e856cc28d1cefae3a8f462 (diff)
downloadorg.eclipse.jetty.project-3a94e4505050457a01431f9b4e77bd7a3e0e4a81.zip
org.eclipse.jetty.project-3a94e4505050457a01431f9b4e77bd7a3e0e4a81.tar.gz
org.eclipse.jetty.project-3a94e4505050457a01431f9b4e77bd7a3e0e4a81.tar.bz2
372115: Cleanup of AsyncContextTest.javarefs/changes/02/5202/1
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/AsyncContinuation.java7
-rw-r--r--jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncContextTest.java59
2 files changed, 24 insertions, 42 deletions
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncContinuation.java b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncContinuation.java
index ca6a1a7..7c68dfa 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncContinuation.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncContinuation.java
@@ -24,7 +24,6 @@ import javax.servlet.http.HttpServletRequest;
import org.eclipse.jetty.continuation.Continuation;
import org.eclipse.jetty.continuation.ContinuationListener;
import org.eclipse.jetty.continuation.ContinuationThrowable;
-import org.eclipse.jetty.http.PathMap;
import org.eclipse.jetty.io.AsyncEndPoint;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.server.handler.ContextHandler;
@@ -821,8 +820,10 @@ public class AsyncContinuation implements AsyncContext, Continuation
synchronized (this)
{
doSuspend(context,request,response);
- if ( request instanceof HttpServletRequest)
- _event._pathInContext=URIUtil.addPaths(((HttpServletRequest)request).getServletPath(),((HttpServletRequest)request).getPathInfo());
+ if (request instanceof HttpServletRequest)
+ {
+ _event._pathInContext = URIUtil.addPaths(((HttpServletRequest)request).getServletPath(),((HttpServletRequest)request).getPathInfo());
+ }
}
}
diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncContextTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncContextTest.java
index a0af395..9311d67 100644
--- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncContextTest.java
+++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncContextTest.java
@@ -42,7 +42,7 @@ public class AsyncContextTest
@Before
public void setUp() throws Exception
{
- _connector.setMaxIdleTime(3000000);
+ _connector.setMaxIdleTime(30000);
_server.setConnectors(new Connector[]
{ _connector });
@@ -65,15 +65,10 @@ public class AsyncContextTest
{
String request = "GET /servletPath HTTP/1.1\r\n" + "Host: localhost\r\n" + "Content-Type: application/x-www-form-urlencoded\r\n"
+ "Connection: close\r\n" + "\r\n";
+
String responseString = _connector.getResponses(request);
- BufferedReader br = new BufferedReader(new StringReader(responseString));
-
- Assert.assertEquals("HTTP/1.1 200 OK",br.readLine());
-
- br.readLine();// connection close
- br.readLine();// server
- br.readLine();// empty
+ BufferedReader br = parseHeader(responseString);
Assert.assertEquals("servlet gets right path","doGet:getServletPath:/servletPath", br.readLine());
Assert.assertEquals("async context gets right path in get","doGet:async:getServletPath:/servletPath", br.readLine());
@@ -87,13 +82,7 @@ public class AsyncContextTest
+ "Connection: close\r\n" + "\r\n";
String responseString = _connector.getResponses(request);
- BufferedReader br = new BufferedReader(new StringReader(responseString));
-
- Assert.assertEquals("HTTP/1.1 200 OK",br.readLine());
-
- br.readLine();// connection close
- br.readLine();// server
- br.readLine();// empty
+ BufferedReader br = parseHeader(responseString);
Assert.assertEquals("servlet gets right path","doGet:getServletPath:/servletPath2", br.readLine());
Assert.assertEquals("async context gets right path in get","doGet:async:getServletPath:/servletPath2", br.readLine());
@@ -111,15 +100,10 @@ public class AsyncContextTest
String request = "GET /foo/servletPath HTTP/1.1\r\n" + "Host: localhost\r\n" + "Content-Type: application/x-www-form-urlencoded\r\n"
+ "Connection: close\r\n" + "\r\n";
+
String responseString = _connector.getResponses(request);
- BufferedReader br = new BufferedReader(new StringReader(responseString));
-
- Assert.assertEquals("HTTP/1.1 200 OK",br.readLine());
-
- br.readLine();// connection close
- br.readLine();// server
- br.readLine();// empty
+ BufferedReader br = parseHeader(responseString);
Assert.assertEquals("servlet gets right path","doGet:getServletPath:/servletPath", br.readLine());
Assert.assertEquals("async context gets right path in get","doGet:async:getServletPath:/servletPath", br.readLine());
@@ -133,17 +117,10 @@ public class AsyncContextTest
String request = "GET /foo/servletPath?dispatch=true HTTP/1.1\r\n" + "Host: localhost\r\n" + "Content-Type: application/x-www-form-urlencoded\r\n"
+ "Connection: close\r\n" + "\r\n";
- String responseString = _connector.getResponses(request);
-
- System.out.println(responseString);
- BufferedReader br = new BufferedReader(new StringReader(responseString));
-
- Assert.assertEquals("HTTP/1.1 200 OK",br.readLine());
+ String responseString = _connector.getResponses(request);
- br.readLine();// connection close
- br.readLine();// server
- br.readLine();// empty
+ BufferedReader br = parseHeader(responseString);
Assert.assertEquals("servlet gets right path","doGet:getServletPath:/servletPath2", br.readLine());
Assert.assertEquals("async context gets right path in get","doGet:async:getServletPath:/servletPath2", br.readLine());
@@ -159,14 +136,10 @@ public class AsyncContextTest
{
String request = "GET /forward HTTP/1.1\r\n" + "Host: localhost\r\n" + "Content-Type: application/x-www-form-urlencoded\r\n" + "Connection: close\r\n"
+ "\r\n";
- String responseString = _connector.getResponses(request);
- BufferedReader br = new BufferedReader(new StringReader(responseString));
- assertEquals("HTTP/1.1 200 OK",br.readLine());
+ String responseString = _connector.getResponses(request);
- br.readLine();// connection close
- br.readLine();// server
- br.readLine();// empty
+ BufferedReader br = parseHeader(responseString);
assertThat("!ForwardingServlet",br.readLine(),equalTo("Dispatched back to ForwardingServlet"));
}
@@ -176,16 +149,24 @@ public class AsyncContextTest
{
String request = "GET /forward?dispatchRequestResponse=true HTTP/1.1\r\n" + "Host: localhost\r\n"
+ "Content-Type: application/x-www-form-urlencoded\r\n" + "Connection: close\r\n" + "\r\n";
+
String responseString = _connector.getResponses(request);
+ BufferedReader br = parseHeader(responseString);
+
+ assertThat("!AsyncDispatchingServlet",br.readLine(),equalTo("Dispatched back to AsyncDispatchingServlet"));
+ }
+
+ private BufferedReader parseHeader(String responseString) throws IOException
+ {
BufferedReader br = new BufferedReader(new StringReader(responseString));
+
assertEquals("HTTP/1.1 200 OK",br.readLine());
br.readLine();// connection close
br.readLine();// server
br.readLine();// empty
-
- assertThat("!AsyncDispatchingServlet",br.readLine(),equalTo("Dispatched back to AsyncDispatchingServlet"));
+ return br;
}
private class ForwardingServlet extends HttpServlet