Registry r = f.getRegistry();
assertNotNull(r);
ThreadEventNotifier t = (ThreadEventNotifier) r.getService(
HiveMind.THREAD_EVENT_NOTIFIER_SERVICE,
ThreadEventNotifier.class);
ThreadListenerFixture l = new ThreadListenerFixture();
t.addThreadCleanupListener(l);
MockControl requestControl = newControl(HttpServletRequest.class);
HttpServletRequest request = (HttpServletRequest) requestControl.getMock();
HttpServletResponse response = (HttpServletResponse) newMock(HttpServletResponse.class);
FilterChain chain = (FilterChain) newMock(FilterChain.class);
request.setAttribute(AutoloadingHiveMindFilter.REQUEST_KEY, r);
chain.doFilter(request, response);
request.getAttribute(AutoloadingHiveMindFilter.REBUILD_REQUEST_KEY);
requestControl.setReturnValue(null);
request.getAttribute(AutoloadingHiveMindFilter.REQUEST_KEY);
requestControl.setReturnValue(r);
replayControls();
f.doFilter(request, response, chain);
assertSame(r, AutoloadingHiveMindFilter.getRegistry(request));
assertEquals(true, l.getCleanup());
f.destroy();
try
{
t.addThreadCleanupListener(null);
unreachable();
}
catch (ApplicationRuntimeException ex)
{
assertExceptionSubstring(ex, "The HiveMind Registry has been shutdown.");