ASF Bugzilla – Attachment 33796 Details for
Bug 59219
AsyncListener#onError not called on exception during async processing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Unit test of bug 59219
unit-test-bug59219.patch (text/plain), 3.36 KB, created by
Abdessamed MANSOURI
on 2016-04-23 01:39:40 UTC
(
hide
)
Description:
Unit test of bug 59219
Filename:
MIME Type:
Creator:
Abdessamed MANSOURI
Created:
2016-04-23 01:39:40 UTC
Size:
3.36 KB
patch
obsolete
>Index: test/org/apache/catalina/core/TestAsyncContextImpl.java >=================================================================== >--- test/org/apache/catalina/core/TestAsyncContextImpl.java (revision 1740624) >+++ test/org/apache/catalina/core/TestAsyncContextImpl.java (working copy) >@@ -1821,7 +1821,104 @@ > } > } > >+ //Point 2. > @Test >+ public void testBug59219a() throws Exception{ >+ resetTracker(); >+ Tomcat tomcat = getTomcatInstance(); >+ >+ Context ctx = tomcat.addContext("", null); >+ Wrapper wrapper = tomcat.addServlet("", "async", new Bug59219ServletA()); >+ wrapper.setAsyncSupported(true); >+ >+ ctx.addServletMapping("/async", "async"); >+ >+ tomcat.start(); >+ >+ getUrl("http://localhost:" + getPort() + "/async"); >+ String expected = "onError-onComplete-"; >+ >+ //Just let's give it 5 seconds :) >+ int count = 0; >+ while(!expected.equals(getTrack()) && count < 100) { >+ Thread.sleep(50); >+ count++; >+ } >+ >+ Assert.assertEquals(expected, getTrack()); >+ } >+ >+ private static class Bug59219ServletA extends HttpServlet { >+ >+ @Override >+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) >+ throws ServletException, IOException { >+ >+ AsyncContext ctx = req.startAsync(); >+ ctx.addListener(new TrackingListener(true, false, "/async")); >+ >+ throw new ServletException("container be nice and process onError."); >+ } >+ } >+ >+ >+ // Point 3. >+ @Test >+ public void testBug59219b() throws Exception { >+ resetTracker(); >+ Tomcat tomcat = getTomcatInstance(); >+ >+ Context ctx = tomcat.addContext("", null); >+ Wrapper wrapper = tomcat.addServlet("", "async", new Bug59219ServletB()); >+ wrapper.setAsyncSupported(true); >+ >+ ctx.addServletMapping("/async", "async"); >+ >+ tomcat.start(); >+ >+ getUrl("http://localhost:" + getPort() + "/async?loop=2"); >+ String expected = "onStartAsync-onStartAsync-onError-onComplete-"; >+ >+ //Just let's give it 5 seconds :) >+ int count = 0; >+ while(!expected.equals(getTrack()) && count < 100) { >+ Thread.sleep(50); >+ count++; >+ } >+ >+ Assert.assertEquals(expected, getTrack()); >+ } >+ >+ private static class Bug59219ServletB extends HttpServlet { >+ >+ @Override >+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) >+ throws ServletException, IOException { >+ >+ AsyncContext ctx = req.startAsync(); >+ ctx.addListener(new TrackingListener(true, false, "/async")); >+ >+ String loop = req.getParameter("loop"); >+ Integer iloop = (Integer) req.getAttribute("iloop"); >+ >+ if (iloop == null) { >+ iloop = 0; >+ if (loop != null) { >+ iloop = Integer.parseInt(loop); >+ } >+ } >+ >+ if (iloop > 0) { >+ iloop--; >+ req.setAttribute("iloop", iloop); >+ ctx.dispatch(); >+ } else >+ throw new ServletException("container be nice and process onError."); >+ } >+ } >+ >+ >+ @Test > public void testForbiddenDispatching() throws Exception { > resetTracker(); > // Setup Tomcat instance
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 59219
:
33782
|
33783
|
33784
|
33796
|
33802