Merge "372115: codeformat of AsyncContextTest.java"
This commit is contained in:
commit
d5443ded0e
|
@ -9,7 +9,7 @@ import javax.servlet.http.HttpServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
import static org.hamcrest.Matchers.*;
|
import static org.hamcrest.Matchers.*;
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
|
|
||||||
import org.eclipse.jetty.continuation.ContinuationSupport;
|
import org.eclipse.jetty.continuation.ContinuationSupport;
|
||||||
|
@ -70,9 +70,9 @@ public class AsyncContextTest
|
||||||
|
|
||||||
BufferedReader br = parseHeader(responseString);
|
BufferedReader br = parseHeader(responseString);
|
||||||
|
|
||||||
Assert.assertEquals("servlet gets right path","doGet:getServletPath:/servletPath", br.readLine());
|
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());
|
Assert.assertEquals("async context gets right path in get","doGet:async:getServletPath:/servletPath",br.readLine());
|
||||||
Assert.assertEquals("async context gets right path in async","async:run:attr:servletPath:/servletPath", br.readLine());
|
Assert.assertEquals("async context gets right path in async","async:run:attr:servletPath:/servletPath",br.readLine());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -84,13 +84,13 @@ public class AsyncContextTest
|
||||||
|
|
||||||
BufferedReader br = parseHeader(responseString);
|
BufferedReader br = parseHeader(responseString);
|
||||||
|
|
||||||
Assert.assertEquals("servlet gets right path","doGet:getServletPath:/servletPath2", br.readLine());
|
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());
|
Assert.assertEquals("async context gets right path in get","doGet:async:getServletPath:/servletPath2",br.readLine());
|
||||||
Assert.assertEquals("servlet path attr is original","async:run:attr:servletPath:/servletPath", br.readLine());
|
Assert.assertEquals("servlet path attr is original","async:run:attr:servletPath:/servletPath",br.readLine());
|
||||||
Assert.assertEquals("path info attr is correct","async:run:attr:pathInfo:null", br.readLine());
|
Assert.assertEquals("path info attr is correct","async:run:attr:pathInfo:null",br.readLine());
|
||||||
Assert.assertEquals("query string attr is correct","async:run:attr:queryString:dispatch=true", br.readLine());
|
Assert.assertEquals("query string attr is correct","async:run:attr:queryString:dispatch=true",br.readLine());
|
||||||
Assert.assertEquals("context path attr is correct","async:run:attr:contextPath:", br.readLine());
|
Assert.assertEquals("context path attr is correct","async:run:attr:contextPath:",br.readLine());
|
||||||
Assert.assertEquals("request uri attr is correct","async:run:attr:requestURI:/servletPath", br.readLine());
|
Assert.assertEquals("request uri attr is correct","async:run:attr:requestURI:/servletPath",br.readLine());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -105,9 +105,9 @@ public class AsyncContextTest
|
||||||
|
|
||||||
BufferedReader br = parseHeader(responseString);
|
BufferedReader br = parseHeader(responseString);
|
||||||
|
|
||||||
Assert.assertEquals("servlet gets right path","doGet:getServletPath:/servletPath", br.readLine());
|
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());
|
Assert.assertEquals("async context gets right path in get","doGet:async:getServletPath:/servletPath",br.readLine());
|
||||||
Assert.assertEquals("async context gets right path in async","async:run:attr:servletPath:/servletPath", br.readLine());
|
Assert.assertEquals("async context gets right path in async","async:run:attr:servletPath:/servletPath",br.readLine());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -122,13 +122,13 @@ public class AsyncContextTest
|
||||||
|
|
||||||
BufferedReader br = parseHeader(responseString);
|
BufferedReader br = parseHeader(responseString);
|
||||||
|
|
||||||
Assert.assertEquals("servlet gets right path","doGet:getServletPath:/servletPath2", br.readLine());
|
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());
|
Assert.assertEquals("async context gets right path in get","doGet:async:getServletPath:/servletPath2",br.readLine());
|
||||||
Assert.assertEquals("servlet path attr is original","async:run:attr:servletPath:/servletPath", br.readLine());
|
Assert.assertEquals("servlet path attr is original","async:run:attr:servletPath:/servletPath",br.readLine());
|
||||||
Assert.assertEquals("path info attr is correct","async:run:attr:pathInfo:null", br.readLine());
|
Assert.assertEquals("path info attr is correct","async:run:attr:pathInfo:null",br.readLine());
|
||||||
Assert.assertEquals("query string attr is correct","async:run:attr:queryString:dispatch=true", br.readLine());
|
Assert.assertEquals("query string attr is correct","async:run:attr:queryString:dispatch=true",br.readLine());
|
||||||
Assert.assertEquals("context path attr is correct","async:run:attr:contextPath:/foo", br.readLine());
|
Assert.assertEquals("context path attr is correct","async:run:attr:contextPath:/foo",br.readLine());
|
||||||
Assert.assertEquals("request uri attr is correct","async:run:attr:requestURI:/foo/servletPath", br.readLine());
|
Assert.assertEquals("request uri attr is correct","async:run:attr:requestURI:/foo/servletPath",br.readLine());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -187,28 +187,28 @@ public class AsyncContextTest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class AsyncDispatchingServlet extends HttpServlet
|
private class AsyncDispatchingServlet extends HttpServlet
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doGet(HttpServletRequest req, final HttpServletResponse response) throws ServletException, IOException
|
protected void doGet(HttpServletRequest req, final HttpServletResponse response) throws ServletException, IOException
|
||||||
{
|
{
|
||||||
Request request = (Request)req;
|
Request request = (Request)req;
|
||||||
if (request.getDispatcherType() == DispatcherType.ASYNC)
|
if (request.getDispatcherType() == DispatcherType.ASYNC)
|
||||||
{
|
{
|
||||||
response.getOutputStream().print("Dispatched back to AsyncDispatchingServlet");
|
response.getOutputStream().print("Dispatched back to AsyncDispatchingServlet");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final AsyncContext asyncContext;
|
final AsyncContext asyncContext;
|
||||||
if (request.getParameter("dispatchRequestResponse") != null)
|
if (request.getParameter("dispatchRequestResponse") != null)
|
||||||
asyncContext = request.startAsync(request,response);
|
asyncContext = request.startAsync(request,response);
|
||||||
else
|
else
|
||||||
asyncContext = request.startAsync();
|
asyncContext = request.startAsync();
|
||||||
|
|
||||||
new Thread(new DispatchingRunnable(asyncContext)).start();
|
new Thread(new DispatchingRunnable(asyncContext)).start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue